From 543bd9598bc895b89def0798a7e292c1ea94c935 Mon Sep 17 00:00:00 2001 From: Danielle Hutzley Date: Sun, 10 Jul 2022 17:05:49 -0700 Subject: [PATCH 1/7] Initial authentication implementation --- Cargo.lock | 834 +++++++++++++------------ flake.nix | 3 +- theseus/Cargo.toml | 39 +- theseus/src/api/auth.rs | 36 ++ theseus/src/api/mod.rs | 11 +- theseus/src/api/profile.rs | 2 +- theseus/src/error.rs | 12 + theseus/src/launcher/auth.rs | 158 ++++- theseus/src/launcher/download.rs | 5 - theseus/src/launcher/mod.rs | 3 +- theseus/src/lib.rs | 4 +- theseus/src/util/mod.rs | 11 + theseus_cli/Cargo.toml | 2 + theseus_cli/src/subcommands/profile.rs | 27 +- 14 files changed, 699 insertions(+), 448 deletions(-) create mode 100644 theseus/src/api/auth.rs diff --git a/Cargo.lock b/Cargo.lock index 3c54e629e..b6ae6f69d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,9 +55,9 @@ checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" [[package]] name = "argh" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb41d85d92dfab96cb95ab023c265c5e4261bb956c0fb49ca06d90c570f1958" +checksum = "f023c76cd7975f9969f8e29f0e461decbdc7f51048ce43427107a3d192f1c9bf" dependencies = [ "argh_derive", "argh_shared", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "argh_derive" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be69f70ef5497dd6ab331a50bd95c6ac6b8f7f17a7967838332743fbd58dc3b5" +checksum = "48ad219abc0c06ca788aface2e3a1970587e3413ab70acd20e54b6ec524c1f8f" dependencies = [ "argh_shared", "heck 0.3.3", @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "argh_shared" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f8c380fa28aa1b36107cd97f0196474bb7241bb95a453c5c01a15ac74b2eac" +checksum = "38de00daab4eac7d753e97697066238d67ce9d7e2d823ab4f72fe14af29f3f33" [[package]] name = "async-trait" @@ -93,6 +93,22 @@ dependencies = [ "syn", ] +[[package]] +name = "async-tungstenite" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1b71b31561643aa8e7df3effe284fa83ab1a840e52294c5f4bd7bfd8b2becbb" +dependencies = [ + "futures-io", + "futures-util", + "log", + "native-tls", + "pin-project-lite", + "tokio", + "tokio-native-tls", + "tungstenite", +] + [[package]] name = "atk" version = "0.15.1" @@ -148,9 +164,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "base64" @@ -158,6 +174,15 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bincode" version = "2.0.0-rc.1" @@ -251,9 +276,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.10.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" +checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" [[package]] name = "byte-tools" @@ -261,12 +286,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" -[[package]] -name = "bytemuck" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc" - [[package]] name = "byteorder" version = "1.4.3" @@ -337,9 +356,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.73" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" dependencies = [ "jobserver", ] @@ -371,9 +390,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.10.3" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +checksum = "295b6eb918a60a25fec0b23a5e633e74fddbaf7bb04411e65a10c366aca4b5cd" dependencies = [ "smallvec", ] @@ -394,7 +413,7 @@ dependencies = [ "num-integer", "num-traits", "serde", - "time 0.1.44", + "time 0.1.43", "winapi", ] @@ -429,12 +448,6 @@ dependencies = [ "objc", ] -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - [[package]] name = "combine" version = "4.6.4" @@ -462,9 +475,9 @@ dependencies = [ [[package]] name = "const_format" -version = "0.2.25" +version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2906f2480cdc015e998deac388331a0f1c1cd88744948c749513020c83c370bc" +checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" dependencies = [ "const_format_proc_macros", ] @@ -488,9 +501,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" dependencies = [ "core-foundation-sys", "libc", @@ -538,9 +551,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" dependencies = [ "cfg-if", ] @@ -581,9 +594,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +checksum = "2ccfd8c0ee4cce11e45b3fd6f9d5e69e0cc62912aa6a0cb1bf4617b0eba5a12f" dependencies = [ "generic-array 0.14.5", "typenum", @@ -638,7 +651,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1949fc56475cb37470a1abb5a113e6f70d48fbcc0c2c315a11b24040f81062" dependencies = [ - "bincode", + "bincode 2.0.0-rc.1", "bytes", "chrono", "reqwest", @@ -686,9 +699,9 @@ dependencies = [ [[package]] name = "dbus" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0a745c25b32caa56b82a3950f5fec7893a960f4c10ca3b02060b0c38d8c2ce" +checksum = "6f8bcdd56d2e5c4ed26a529c5a9029f5db8290d433497506f958eae3be148eb6" dependencies = [ "libc", "libdbus-sys", @@ -740,9 +753,9 @@ dependencies = [ [[package]] name = "diff" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" [[package]] name = "digest" @@ -825,19 +838,6 @@ dependencies = [ "dtoa", ] -[[package]] -name = "embed-resource" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc24ff8d764818e9ab17963b0593c535f077a513f565e75e4352d758bc4d8c0" -dependencies = [ - "cc", - "rustc_version 0.4.0", - "toml", - "vswhom", - "winreg", -] - [[package]] name = "embed_plist" version = "1.2.2" @@ -852,9 +852,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.31" +version = "0.8.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" dependencies = [ "cfg-if", ] @@ -909,24 +909,26 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0408e2626025178a6a7f7ffc05a25bc47103229f19c113755de7bf63816290c" +checksum = "e94a7bbaa59354bc20dd75b67f23e2797b4490e9d6928203fb105c79e448c86c" dependencies = [ "cfg-if", "libc", "redox_syscall", - "winapi", + "windows-sys", ] [[package]] name = "flate2" -version = "1.0.24" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" dependencies = [ + "cfg-if", "crc32fast", - "miniz_oxide", + "libc", + "miniz_oxide 0.4.4", ] [[package]] @@ -988,9 +990,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.21" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" dependencies = [ "futures-channel", "futures-core", @@ -1003,9 +1005,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.21" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" dependencies = [ "futures-core", "futures-sink", @@ -1013,15 +1015,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" [[package]] name = "futures-executor" -version = "0.3.21" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" dependencies = [ "futures-core", "futures-task", @@ -1030,9 +1032,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" [[package]] name = "futures-lite" @@ -1051,10 +1053,12 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.21" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" dependencies = [ + "autocfg", + "proc-macro-hack", "proc-macro2", "quote", "syn", @@ -1062,22 +1066,23 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" dependencies = [ + "autocfg", "futures-channel", "futures-core", "futures-io", @@ -1087,6 +1092,8 @@ dependencies = [ "memchr", "pin-project-lite", "pin-utils", + "proc-macro-hack", + "proc-macro-nested", "slab", ] @@ -1216,13 +1223,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -1387,9 +1394,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.13" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" +checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" dependencies = [ "bytes", "fnv", @@ -1406,9 +1413,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" [[package]] name = "heck" @@ -1461,9 +1468,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" dependencies = [ "bytes", "http", @@ -1478,9 +1485,9 @@ checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" [[package]] name = "httparse" -version = "1.7.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" +checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" [[package]] name = "httpdate" @@ -1499,9 +1506,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.19" +version = "0.14.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42dc3c131584288d375f2d07f822b0cb012d8c6fb899a5b9fdb3cb7eb9b6004f" +checksum = "436ec0091e4f20e655156a30a0df3770fe2900aa301e548e08446ec794b6953c" dependencies = [ "bytes", "futures-channel", @@ -1512,7 +1519,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.2", + "itoa 0.4.8", "pin-project-lite", "socket2", "tokio", @@ -1579,20 +1586,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "image" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28edd9d7bc256be2502e325ac0628bde30b7001b9b52e0abe31a1a9dc2701212" -dependencies = [ - "bytemuck", - "byteorder", - "color_quant", - "num-iter", - "num-rational", - "num-traits", -] - [[package]] name = "indenter" version = "0.3.3" @@ -1601,9 +1594,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "1.9.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" dependencies = [ "autocfg", "hashbrown", @@ -1638,9 +1631,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.5.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" [[package]] name = "itoa" @@ -1722,9 +1715,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.58" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" dependencies = [ "wasm-bindgen", ] @@ -1771,9 +1764,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" [[package]] name = "libdbus-sys" @@ -1784,21 +1777,29 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "line-wrap" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +dependencies = [ + "safemem", +] + [[package]] name = "lock_api" -version = "0.4.7" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" dependencies = [ - "autocfg", "scopeguard", ] [[package]] name = "log" -version = "0.4.17" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ "cfg-if", ] @@ -1826,9 +1827,9 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "mac-notification-sys" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "042f74a606175d72ca483e14e0873fe0f6c003f7af45865b17b16fdaface7203" +checksum = "47a4acb83c904844ca12aafeac6fff6f781cf9e220a985c1db94fd94123993aa" dependencies = [ "cc", "dirs-next", @@ -1883,9 +1884,9 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "memchr" -version = "2.5.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" @@ -1902,6 +1903,16 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "miniz_oxide" version = "0.5.3" @@ -1913,21 +1924,31 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.4" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", ] [[package]] name = "native-tls" -version = "0.2.10" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" dependencies = [ "lazy_static", "libc", @@ -1960,6 +1981,34 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" +[[package]] +name = "ndk-glue" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d0c4a7b83860226e6b4183edac21851f05d5a51756e97a1144b7f5a6b63e65f" +dependencies = [ + "lazy_static", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-macro", + "ndk-sys", +] + +[[package]] +name = "ndk-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" +dependencies = [ + "darling", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "ndk-sys" version = "0.3.0" @@ -1993,31 +2042,29 @@ dependencies = [ ] [[package]] -name = "num-integer" -version = "0.1.45" +name = "ntapi" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" dependencies = [ - "autocfg", - "num-traits", + "winapi", ] [[package]] -name = "num-iter" -version = "0.1.43" +name = "num-integer" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ "autocfg", - "num-integer", "num-traits", ] [[package]] -name = "num-rational" -version = "0.4.1" +name = "num-iter" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" dependencies = [ "autocfg", "num-integer", @@ -2026,18 +2073,18 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ "hermit-abi", "libc", @@ -2114,9 +2161,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "opaque-debug" @@ -2126,9 +2173,9 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "open" -version = "3.0.1" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360bcc8316bf6363aa3954c3ccc4de8add167b087e0259190a043c9514f910fe" +checksum = "f2423ffbf445b82e58c3b1543655968923dd06f85432f10be2bb4f1b7122f98c" dependencies = [ "pathdiff", "windows-sys", @@ -2136,41 +2183,29 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.40" +version = "0.10.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" +checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" dependencies = [ "bitflags", "cfg-if", "foreign-types", "libc", "once_cell", - "openssl-macros", "openssl-sys", ] -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "openssl-probe" -version = "0.1.5" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" [[package]] name = "openssl-sys" -version = "0.9.74" +version = "0.9.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1" +checksum = "7df13d165e607909b363a4757a6f133f8a818a74e9d3a98d09c6128e15fa4c73" dependencies = [ "autocfg", "cc", @@ -2263,17 +2298,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core 0.8.5", -] - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core 0.9.3", + "parking_lot_core", ] [[package]] @@ -2290,19 +2315,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "parking_lot_core" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - [[package]] name = "paste" version = "1.0.7" @@ -2367,7 +2379,7 @@ checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" dependencies = [ "maplit", "pest", - "sha-1", + "sha-1 0.8.2", ] [[package]] @@ -2419,7 +2431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ "phf_shared 0.10.0", - "rand 0.8.5", + "rand 0.8.4", ] [[package]] @@ -2470,9 +2482,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pin-utils" @@ -2482,9 +2494,23 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" + +[[package]] +name = "plist" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "bd39bc6cdc9355ad1dc5eeedefee696bb35c34caf21768741e81826c0bbd7225" +dependencies = [ + "base64", + "indexmap", + "line-wrap", + "serde", + "time 0.3.11", + "xml-rs", +] [[package]] name = "png" @@ -2507,14 +2533,14 @@ dependencies = [ "bitflags", "crc32fast", "deflate 1.0.0", - "miniz_oxide", + "miniz_oxide 0.5.3", ] [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "precomputed-hash" @@ -2584,6 +2610,12 @@ version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + [[package]] name = "proc-macro2" version = "1.0.40" @@ -2601,9 +2633,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.20" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" dependencies = [ "proc-macro2", ] @@ -2618,19 +2650,20 @@ dependencies = [ "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc", + "rand_hc 0.2.0", "rand_pcg", ] [[package]] name = "rand" -version = "0.8.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" dependencies = [ "libc", "rand_chacha 0.3.1", "rand_core 0.6.3", + "rand_hc 0.3.1", ] [[package]] @@ -2668,7 +2701,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.3", ] [[package]] @@ -2680,6 +2713,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_hc" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core 0.6.3", +] + [[package]] name = "rand_pcg" version = "0.2.1" @@ -2713,16 +2755,16 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.3", "redox_syscall", "thiserror", ] [[package]] name = "regex" -version = "1.5.6" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", @@ -2740,9 +2782,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "remove_dir_all" @@ -2755,16 +2797,15 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.11" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92" +checksum = "66d2927ca2f685faf0fc620ac4834690d29e7abb153add10f5812eef20b5e280" dependencies = [ "base64", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2", "http", "http-body", "hyper", @@ -2782,7 +2823,6 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", - "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -2792,13 +2832,12 @@ dependencies = [ [[package]] name = "rfd" -version = "0.9.1" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f121348fd3b9035ed11be1f028e8944263c30641f8c5deacf57a4320782fb402" +checksum = "1f756b55bff8f256a1a8c24dbabb1430ac8110628e418a02e4a1c5ff67179f56" dependencies = [ "block", "dispatch", - "embed-resource", "glib-sys", "gobject-sys", "gtk-sys", @@ -2830,7 +2869,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.10", + "semver 1.0.12", ] [[package]] @@ -2841,9 +2880,15 @@ checksum = "a0a5f7c728f5d284929a1cccb5bc19884422bfe6ef4d6c409da2c41838983fcf" [[package]] name = "ryu" -version = "1.0.10" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" [[package]] name = "same-file" @@ -2856,12 +2901,12 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.20" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ "lazy_static", - "windows-sys", + "winapi", ] [[package]] @@ -2878,9 +2923,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "security-framework" -version = "2.6.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" +checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" dependencies = [ "bitflags", "core-foundation", @@ -2891,9 +2936,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.6.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" dependencies = [ "core-foundation-sys", "libc", @@ -2930,9 +2975,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c" +checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" dependencies = [ "serde", ] @@ -2948,18 +2993,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.137" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c" dependencies = [ "proc-macro2", "quote", @@ -2968,11 +3013,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "063bf466a64011ac24040a49009724ee60a57da1b437617ceb32e53ad61bfb19" dependencies = [ - "itoa 1.0.2", + "itoa 0.4.8", "ryu", "serde", ] @@ -2990,12 +3035,12 @@ dependencies = [ [[package]] name = "serde_urlencoded" -version = "0.7.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" dependencies = [ "form_urlencoded", - "itoa 1.0.2", + "itoa 0.4.8", "ryu", "serde", ] @@ -3067,19 +3112,21 @@ dependencies = [ ] [[package]] -name = "sha1" -version = "0.6.1" +name = "sha-1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" dependencies = [ - "sha1_smol", + "cfg-if", + "cpufeatures", + "digest 0.10.3", ] [[package]] -name = "sha1_smol" -version = "1.0.0" +name = "sha1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" [[package]] name = "sha2" @@ -3128,9 +3175,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.6" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "sled" @@ -3145,21 +3192,21 @@ dependencies = [ "fxhash", "libc", "log", - "parking_lot 0.11.2", + "parking_lot", "zstd", ] [[package]] name = "smallvec" -version = "1.8.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc88c725d61fc6c3132893370cac4a0200e3fedf5da8331c570664b1987f5ca2" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" dependencies = [ "libc", "winapi", @@ -3210,13 +3257,13 @@ dependencies = [ [[package]] name = "string_cache" -version = "0.8.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" +checksum = "33994d0838dc2d152d17a62adf608a869b5e846b65b389af7f3dbc1de45c5b26" dependencies = [ + "lazy_static", "new_debug_unreachable", - "once_cell", - "parking_lot 0.12.1", + "parking_lot", "phf_shared 0.10.0", "precomputed-hash", "serde", @@ -3301,7 +3348,7 @@ version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a45a1c4c9015217e12347f2a411b57ce2c4fc543913b14b6fe40483328e709" dependencies = [ - "cfg-expr 0.10.3", + "cfg-expr 0.10.1", "heck 0.4.0", "pkg-config", "toml", @@ -3331,9 +3378,9 @@ dependencies = [ [[package]] name = "tao" -version = "0.11.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfe4c782f0543f667ee3b732d026b2f1c64af39cd52e726dec1ea1f2d8f6b80" +checksum = "53da5dd98a3c605a3ca8fe967d7c50eba8a36072ff13e04e24402b2c492ac55a" dependencies = [ "bitflags", "cairo-rs", @@ -3351,7 +3398,6 @@ dependencies = [ "glib", "glib-sys", "gtk", - "image", "instant", "jni 0.19.0", "lazy_static", @@ -3362,15 +3408,13 @@ dependencies = [ "ndk-sys", "objc", "once_cell", - "parking_lot 0.11.2", + "parking_lot", "paste", - "png 0.17.5", "raw-window-handle", "scopeguard", "serde", "tao-core-video-sys", "unicode-segmentation", - "uuid 0.8.2", "windows 0.37.0", "windows-implement", "x11-dl", @@ -3401,12 +3445,13 @@ dependencies = [ [[package]] name = "tauri" -version = "1.0.0" +version = "1.0.0-rc.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1ebb60bb8f246d5351ff9b7728fdfa7a6eba72baa722ab6021d553981caba1" +checksum = "81af088a87f908dab3a268f92e3c331e911bed6b1756bbfaeadedfe9dd40fe4f" dependencies = [ "anyhow", "attohttpc", + "bincode 1.3.3", "cocoa", "dirs-next", "embed_plist", @@ -3426,11 +3471,11 @@ dependencies = [ "os_info", "os_pipe", "percent-encoding", - "rand 0.8.5", + "rand 0.8.4", "raw-window-handle", "regex", "rfd", - "semver 1.0.10", + "semver 1.0.12", "serde", "serde_json", "serde_repr", @@ -3454,14 +3499,15 @@ dependencies = [ [[package]] name = "tauri-build" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7b26eb3523e962b90012fedbfb744ca153d9be85e7981e00737e106d5323941" +checksum = "2f2b32e551ec810ba4ab2ad735de5e3576e54bf0322ab0f4b7ce41244bc65ecf" dependencies = [ "anyhow", "cargo_toml", "heck 0.4.0", - "semver 1.0.10", + "json-patch", + "semver 1.0.12", "serde_json", "tauri-utils", "winres", @@ -3469,32 +3515,35 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9468c5189188c820ef605dfe4937c768cb2918e9460c8093dc4ee2cbd717b262" +checksum = "f6f1f7928dd040fc03c94207adfad506c0cf5b152982fd1dc0a621f7fd777e22" dependencies = [ "base64", "brotli", "ico", + "json-patch", + "plist", "png 0.17.5", "proc-macro2", "quote", "regex", - "semver 1.0.10", + "semver 1.0.12", "serde", "serde_json", "sha2", "tauri-utils", "thiserror", + "time 0.3.11", "uuid 1.1.2", "walkdir", ] [[package]] name = "tauri-macros" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40e3ffddd7a274fc7baaa260888c971a0d95d2ef403aa16600c878b8b1c00ffe" +checksum = "e50b9f52871c088857360319a37472d59f4644f1ed004489599d62831a1b6996" dependencies = [ "heck 0.4.0", "proc-macro2", @@ -3506,9 +3555,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "0.9.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb7dc4db360bb40584187b6cb7834da736ce4ef2ab0914e2be98014444fa9920" +checksum = "dc343e974f76c0f5471da85f87510bb54dfc9a7664f3e649af58f49887965e43" dependencies = [ "gtk", "http", @@ -3525,14 +3574,14 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" -version = "0.9.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c876fb3a6e7c6fe2ac466b2a6ecd83658528844b4df0914558a9bc1501b31cf3" +checksum = "0cd6fe3f8dc12a9c409ee6da19379636525e0ff8da12897c04dc1e76b8c8ff62" dependencies = [ "cocoa", "gtk", "percent-encoding", - "rand 0.8.5", + "rand 0.8.4", "tauri-runtime", "tauri-utils", "uuid 1.1.2", @@ -3544,9 +3593,9 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727145cb55b8897fa9f2bcea4fad31dc39394703d037c9669b40f2d1c0c2d7f3" +checksum = "12ff4b68d9faeb57c9c727bf58c9c9768d2b67d8e84e62ce6146e7859a2e9c6b" dependencies = [ "brotli", "ctor", @@ -3559,24 +3608,25 @@ dependencies = [ "phf 0.10.1", "proc-macro2", "quote", - "semver 1.0.10", + "semver 1.0.12", "serde", "serde_json", "serde_with", "thiserror", "url", "walkdir", + "windows 0.37.0", ] [[package]] name = "tempfile" -version = "3.3.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ "cfg-if", - "fastrand", "libc", + "rand 0.8.4", "redox_syscall", "remove_dir_all", "winapi", @@ -3618,7 +3668,8 @@ version = "0.1.0" dependencies = [ "argh", "async-trait", - "bincode", + "async-tungstenite", + "bincode 2.0.0-rc.1", "bytes", "chrono", "const_format", @@ -3640,6 +3691,7 @@ dependencies = [ "sys-info", "thiserror", "tokio", + "url", "uuid 0.8.2", "zip", "zip-extensions", @@ -3662,7 +3714,9 @@ dependencies = [ "theseus", "tokio", "tokio-stream", + "url", "uuid 0.8.2", + "webbrowser", ] [[package]] @@ -3683,18 +3737,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" [[package]] name = "thiserror" -version = "1.0.31" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", @@ -3712,12 +3766,11 @@ dependencies = [ [[package]] name = "time" -version = "0.1.44" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "wasi 0.10.0+wasi-snapshot-preview1", "winapi", ] @@ -3727,15 +3780,16 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72c91f41dcb2f096c05f0873d667dceec1087ce5bcf984ec8ffb19acddbb3217" dependencies = [ + "itoa 1.0.2", "libc", "num_threads", ] [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" dependencies = [ "tinyvec_macros", ] @@ -3748,9 +3802,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.19.2" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" +checksum = "0c27a64b625de6d309e8c57716ba93021dccf1b3b5c97edd6d3dd2d2135afc0a" dependencies = [ "bytes", "libc", @@ -3758,10 +3812,9 @@ dependencies = [ "mio", "num_cpus", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2", "tokio-macros", "winapi", ] @@ -3800,16 +3853,16 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.3" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" +checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" dependencies = [ "bytes", "futures-core", "futures-sink", + "log", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -3823,15 +3876,15 @@ dependencies = [ [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.35" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ "cfg-if", "pin-project-lite", @@ -3841,9 +3894,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c" +checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" dependencies = [ "proc-macro2", "quote", @@ -3852,12 +3905,11 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.28" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" +checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" dependencies = [ - "once_cell", - "valuable", + "lazy_static", ] [[package]] @@ -3873,9 +3925,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.11" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596" +checksum = "5312f325fe3588e277415f5a6cca1f4ccad0f248c4cd5a4bd33032d7286abc22" dependencies = [ "ansi_term", "lazy_static", @@ -3904,6 +3956,26 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +[[package]] +name = "tungstenite" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96a2dea40e7570482f28eb57afbe42d97551905da6a9400acc5c328d24004f5" +dependencies = [ + "base64", + "byteorder", + "bytes", + "http", + "httparse", + "log", + "native-tls", + "rand 0.8.4", + "sha-1 0.10.0", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "typenum" version = "1.15.0" @@ -3912,15 +3984,15 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" [[package]] name = "unicode-ident" @@ -3930,18 +4002,18 @@ checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" [[package]] name = "unicode-normalization" -version = "0.1.20" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dee68f85cab8cf68dec42158baf3a79a1cdc065a8b103025965d6ccb7f6cbd" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.9.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" [[package]] name = "unicode-width" @@ -3951,9 +4023,9 @@ checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "url" @@ -3980,7 +4052,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.3", "serde", ] @@ -3990,15 +4062,9 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.3", ] -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "vcpkg" version = "0.2.15" @@ -4029,26 +4095,6 @@ version = "0.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "757cfbfe0d17ee6f22fe97e536d463047d451b47cf9d11e2b7d1398b0ef274dd" -[[package]] -name = "vswhom" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" -dependencies = [ - "libc", - "vswhom-sys", -] - -[[package]] -name = "vswhom-sys" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22025f6d8eb903ebf920ea6933b70b1e495be37e2cb4099e62c80454aaf57c39" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "waker-fn" version = "1.1.0" @@ -4084,21 +4130,15 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.81" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -4106,9 +4146,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.81" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" dependencies = [ "bumpalo", "lazy_static", @@ -4121,9 +4161,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.31" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f" +checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" dependencies = [ "cfg-if", "js-sys", @@ -4133,9 +4173,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.81" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4143,9 +4183,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.81" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", "quote", @@ -4156,20 +4196,34 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.81" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "web-sys" -version = "0.3.58" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" dependencies = [ "js-sys", "wasm-bindgen", ] +[[package]] +name = "webbrowser" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a3cffdb686fbb24d9fb8f03a213803277ed2300f11026a3afe1f108dc021b" +dependencies = [ + "jni 0.19.0", + "ndk-glue", + "url", + "web-sys", + "widestring", + "winapi", +] + [[package]] name = "webkit2gtk" version = "0.18.0" @@ -4254,11 +4308,17 @@ dependencies = [ "windows-bindgen", ] +[[package]] +name = "widestring" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" + [[package]] name = "wildmatch" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c48bd20df7e4ced539c12f570f937c6b4884928a87fee70a479d72f031d4e0" +checksum = "ee583bdc5ff1cf9db20e9db5bb3ff4c3089a8f6b8b31aff265c9aba85812db86" [[package]] name = "winapi" @@ -4448,9 +4508,9 @@ checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d" [[package]] name = "winreg" -version = "0.10.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ "winapi", ] @@ -4477,9 +4537,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.18.3" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b1ba327c7dd4292f46bf8e6ba8e6ec2db4443b2973c9d304a359d95e0aa856" +checksum = "38425583b1f8c16c074fa4f962f7f0ddd5cb2f6b241a494a26db5eca3ccd4fd7" dependencies = [ "block", "cocoa", @@ -4545,9 +4605,9 @@ checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" [[package]] name = "zeroize" -version = "1.5.5" +version = "1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" +checksum = "20b578acffd8516a6c3f2a1bdefc1ec37e547bb4e0fb8b6b01a4cafc886b4442" [[package]] name = "zip" @@ -4560,7 +4620,7 @@ dependencies = [ "crc32fast", "flate2", "thiserror", - "time 0.1.44", + "time 0.1.43", ] [[package]] diff --git a/flake.nix b/flake.nix index 43c6ba5dc..3bc06f971 100644 --- a/flake.nix +++ b/flake.nix @@ -38,8 +38,7 @@ gtk4 gdk-pixbuf atk webkitgtk dbus ]; shell = [ - toolchain - (with fenix; combine [toolchain default.clippy rust-analyzer]) + (with fenix; combine [toolchain default.clippy complete.rust-src rust-analyzer]) git jdk17 jdk8 ]; diff --git a/theseus/Cargo.toml b/theseus/Cargo.toml index 619f96572..98dd3d279 100644 --- a/theseus/Cargo.toml +++ b/theseus/Cargo.toml @@ -7,38 +7,35 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -thiserror = "1.0" -async-trait = "0.1.51" - -daedalus = { version = "0.1.16", features = ["bincode"] } - +bytes = "1" bincode = { version = "2.0.0-rc.1", features = ["serde"] } -sled = { version = "0.34.7", features = ["compression"] } - -reqwest = { version = "0.11", features = ["json"] } +const_format = "0.2.22" +fs_extra = "1.2.0" +json5 = "0.4.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -json5 = "0.4.1" -chrono = { version = "0.4", features = ["serde"] } +sha1 = { version = "0.6.0", features = ["std"]} +sled = { version = "0.34.7", features = ["compression"] } +url = "2.2" uuid = { version = "0.8", features = ["serde", "v4"] } -bytes = "1" zip = "0.5" zip-extensions = "0.6" -sha1 = { version = "0.6.0", features = ["std"]} -path-clean = "0.1.0" -fs_extra = "1.2.0" -dirs = "4.0" +chrono = { version = "0.4.19", features = ["serde"] } +daedalus = { version = "0.1.16", features = ["bincode"] } +dirs = "4.0" +log = "0.4.14" +path-clean = "0.1.0" regex = "1.5" - -tokio = { version = "1", features = ["full"] } -futures = "0.3" - sys-info = "0.9.0" +thiserror = "1.0" -log = "0.4.14" -const_format = "0.2.22" +async-trait = "0.1.51" +async-tungstenite = { version = "0.17", features = ["tokio-runtime", "tokio-native-tls"] } +futures = "0.3" once_cell = "1.9.0" +reqwest = { version = "0.11", features = ["json"] } +tokio = { version = "1", features = ["full"] } [dev-dependencies] argh = "0.1.6" diff --git a/theseus/src/api/auth.rs b/theseus/src/api/auth.rs new file mode 100644 index 000000000..ea5aa081a --- /dev/null +++ b/theseus/src/api/auth.rs @@ -0,0 +1,36 @@ +//! Authentication flow interface +use crate::launcher::auth as inner; +use tokio::sync::oneshot; + +pub use inner::Credentials; + +/// Authenticate a user with Hydra +/// To run this, you need to first spawn this function as a task, then +/// open a browser to the given URL and finally wait on the spawned future +/// with the ability to cancel in case the browser is closed before finishing +pub async fn authenticate( + browser_url: oneshot::Sender, +) -> crate::Result { + let mut flow = inner::HydraAuthFlow::new().await?; + let url = flow.prepare_login_url().await?; + browser_url.send(url).map_err(|url| { + crate::Error::OtherError(format!( + "Error sending browser url to parent: {url}" + )) + })?; + flow.extract_credentials().await +} + +/// Refresh some credentials using Hydra, if needed +pub async fn refresh( + credentials: &mut Credentials, + update_name: bool, +) -> crate::Result<()> { + if chrono::offset::Utc::now() > credentials.expires { + inner::refresh_credentials(credentials).await?; + if update_name { + inner::refresh_username(credentials).await?; + } + } + Ok(()) +} diff --git a/theseus/src/api/mod.rs b/theseus/src/api/mod.rs index cdddd67b5..7ce80205d 100644 --- a/theseus/src/api/mod.rs +++ b/theseus/src/api/mod.rs @@ -1,18 +1,17 @@ //! API for interacting with Theseus +pub mod auth; pub mod profile; pub mod data { - pub use crate::{ - launcher::Credentials, - state::{ - DirectoryInfo, Hooks, JavaSettings, MemorySettings, ModLoader, - ProfileMetadata, Settings, WindowSize, - }, + pub use crate::state::{ + DirectoryInfo, Hooks, JavaSettings, MemorySettings, ModLoader, + ProfileMetadata, Settings, WindowSize, }; } pub mod prelude { pub use crate::{ + auth::{authenticate, Credentials}, data::*, profile::{self, Profile}, State, diff --git a/theseus/src/api/profile.rs b/theseus/src/api/profile.rs index 6b91592ca..273f346d1 100644 --- a/theseus/src/api/profile.rs +++ b/theseus/src/api/profile.rs @@ -92,7 +92,7 @@ where /// Run Minecraft using a profile pub async fn run( path: &Path, - credentials: &crate::launcher::Credentials, + credentials: &crate::auth::Credentials, ) -> crate::Result { let state = State::get().await.unwrap(); let settings = state.settings.read().await; diff --git a/theseus/src/error.rs b/theseus/src/error.rs index 2ba5ccc82..348ed1d7d 100644 --- a/theseus/src/error.rs +++ b/theseus/src/error.rs @@ -13,6 +13,9 @@ pub enum Error { #[error("Deserialization error (Bincode): {0}")] DecodeError(#[from] bincode::error::EncodeError), + #[error("Error parsing URL: {0}")] + URLError(#[from] url::ParseError), + #[error("Database error: {0}")] DBError(#[from] sled::Error), @@ -22,6 +25,9 @@ pub enum Error { #[error("Metadata error: {0}")] MetadataError(#[from] daedalus::Error), + #[error("Minecraft authentication error: {0}")] + HydraError(String), + #[error("I/O error: {0}")] IOError(#[from] std::io::Error), @@ -31,6 +37,12 @@ pub enum Error { #[error("Error fetching URL: {0}")] FetchError(#[from] reqwest::Error), + #[error("Websocket error: {0}")] + WSError(#[from] async_tungstenite::tungstenite::Error), + + #[error("Websocket closed before {0} could be received!")] + WSClosedError(String), + #[error("Incorrect Sha1 hash for download: {0} != {1}")] HashError(String, String), diff --git a/theseus/src/launcher/auth.rs b/theseus/src/launcher/auth.rs index d05595754..794752e63 100644 --- a/theseus/src/launcher/auth.rs +++ b/theseus/src/launcher/auth.rs @@ -1,8 +1,160 @@ -//! Authentication flow -// TODO: Implement authentication -#[derive(Debug)] +//! Authentication flow based on Hydra +use async_tungstenite as ws; +use bincode::{Decode, Encode}; +use chrono::{prelude::*, Duration}; +use futures::prelude::*; +use once_cell::sync::*; +use serde::Deserialize; +use url::Url; + +pub const HYDRA_URL: Lazy = + Lazy::new(|| Url::parse("https://hydra.modrinth.com").unwrap()); + +// Socket messages +#[derive(Deserialize)] +struct ErrorJSON { + error: String, +} + +impl ErrorJSON { + pub fn unwrap<'a, T: Deserialize<'a>>(data: &'a [u8]) -> crate::Result { + if let Ok(err) = serde_json::from_slice::(data) { + Err(crate::Error::HydraError(err.error)) + } else { + Ok(serde_json::from_slice::(data)?) + } + } +} + +#[derive(Deserialize)] +struct LoginCodeJSON { + login_code: String, +} + +#[derive(Deserialize)] +struct TokenJSON { + token: String, + refresh_token: String, + expires_after: u32, +} + +#[derive(Deserialize)] +struct ProfileInfoJSON { + id: uuid::Uuid, + name: String, +} + +// Login information +#[derive(Debug, Encode, Decode)] pub struct Credentials { + #[bincode(with_serde)] pub id: uuid::Uuid, pub username: String, pub access_token: String, + pub refresh_token: String, + #[bincode(with_serde)] + pub expires: DateTime, +} + +// Implementation +pub struct HydraAuthFlow { + socket: ws::WebSocketStream, +} + +impl HydraAuthFlow { + pub async fn new() -> crate::Result { + let sock_url = wrap_ref_builder!( + it < HYDRA_URL => + { it.set_scheme("wss").ok() } + ); + let (socket, _) = ws::tokio::connect_async(sock_url.clone()).await?; + Ok(Self { socket }) + } + + pub async fn prepare_login_url(&mut self) -> crate::Result { + let code_resp = self + .socket + .try_next() + .await? + .ok_or(crate::Error::WSClosedError(String::from( + "login socket ID", + )))? + .into_data(); + let code = ErrorJSON::unwrap::(&code_resp)?; + Ok(wrap_ref_builder!( + it < HYDRA_URL.join("login")? => + { it.query_pairs_mut().append_pair("id", &code.login_code); } + )) + } + + pub async fn extract_credentials(&mut self) -> crate::Result { + // Minecraft bearer token + let token_resp = self + .socket + .try_next() + .await? + .ok_or(crate::Error::WSClosedError(String::from( + "login socket ID", + )))? + .into_data(); + let token = ErrorJSON::unwrap::(&token_resp)?; + let expires = + Utc::now() + Duration::seconds(token.expires_after.into()); + + // Get account credentials + let info = fetch_info(&token.token).await?; + + // Return structure from response + Ok(Credentials { + username: info.name, + id: info.id, + refresh_token: token.refresh_token, + access_token: token.token, + expires, + }) + } +} + +pub async fn refresh_credentials( + credentials: &mut Credentials, +) -> crate::Result<()> { + let resp = crate::config::REQWEST_CLIENT + .post(HYDRA_URL.join("/refresh")?) + .json( + &serde_json::json!({ "refresh_token": credentials.refresh_token }), + ) + .send() + .await? + .error_for_status()? + .json::() + .await?; + + credentials.access_token = resp.token; + credentials.refresh_token = resp.refresh_token; + credentials.expires = + Utc::now() + Duration::seconds(resp.expires_after.into()); + + Ok(()) +} + +pub async fn refresh_username( + credentials: &mut Credentials, +) -> crate::Result<()> { + let info = fetch_info(&credentials.access_token).await?; + credentials.username = info.name; + Ok(()) +} + +// Helpers +async fn fetch_info(token: &str) -> crate::Result { + let url = + Url::parse("https://api.minecraftservices.com/minecraft/profile")?; + Ok(crate::config::REQWEST_CLIENT + .get(url) + .header(reqwest::header::AUTHORIZATION, format!("Bearer {token}")) + .send() + .await? + .error_for_status()? + .json::() + .await?) } diff --git a/theseus/src/launcher/download.rs b/theseus/src/launcher/download.rs index 224594757..6cb0ff2f8 100644 --- a/theseus/src/launcher/download.rs +++ b/theseus/src/launcher/download.rs @@ -13,7 +13,6 @@ use daedalus::{ modded::LoaderVersion, }; use futures::prelude::*; -use std::sync::Arc; use tokio::{fs, sync::OnceCell}; pub async fn download_minecraft( @@ -186,10 +185,6 @@ pub async fn download_libraries( version: &str, ) -> crate::Result<()> { log::debug!("Loading libraries"); - let (libraries_dir, natives_dir) = ( - Arc::new(st.directories.libraries_dir()), - Arc::new(st.directories.version_natives_dir(version)), - ); tokio::try_join! { fs::create_dir_all(st.directories.libraries_dir()), diff --git a/theseus/src/launcher/mod.rs b/theseus/src/launcher/mod.rs index 93da54c32..f84c73dfe 100644 --- a/theseus/src/launcher/mod.rs +++ b/theseus/src/launcher/mod.rs @@ -6,8 +6,7 @@ use tokio::process::{Child, Command}; mod args; -mod auth; -pub use auth::Credentials; +pub mod auth; mod download; diff --git a/theseus/src/lib.rs b/theseus/src/lib.rs index 80baede2d..61ca15e23 100644 --- a/theseus/src/lib.rs +++ b/theseus/src/lib.rs @@ -7,12 +7,14 @@ and launching Modrinth mod packs #![warn(unused_import_braces, missing_debug_implementations)] #![deny(unused_must_use)] +#[macro_use] +mod util; + mod api; mod config; mod error; mod launcher; mod state; -mod util; pub use api::*; pub use error::*; diff --git a/theseus/src/util/mod.rs b/theseus/src/util/mod.rs index c664986d5..8c6fab4ea 100644 --- a/theseus/src/util/mod.rs +++ b/theseus/src/util/mod.rs @@ -1,3 +1,14 @@ //! Theseus utility functions pub mod fetch; pub mod platform; + +macro_rules! wrap_ref_builder { + ($id:ident < $init:expr => $transform:block) => {{ + let mut it = $init; + { + let $id = &mut it; + $transform; + } + it + }}; +} diff --git a/theseus_cli/Cargo.toml b/theseus_cli/Cargo.toml index d51a57214..fc95382e4 100644 --- a/theseus_cli/Cargo.toml +++ b/theseus_cli/Cargo.toml @@ -19,6 +19,8 @@ eyre = "0.6" tabled = "0.5" dirs = "4.0" uuid = {version = "0.8", features = ["v4", "serde"]} +url = "2.2" # TODO: merge logging with paris logging pretty_env_logger = "0.4" log = "0.4.14" +webbrowser = "0.7" \ No newline at end of file diff --git a/theseus_cli/src/subcommands/profile.rs b/theseus_cli/src/subcommands/profile.rs index c39e67bef..56f8d68d1 100644 --- a/theseus_cli/src/subcommands/profile.rs +++ b/theseus_cli/src/subcommands/profile.rs @@ -9,9 +9,8 @@ use paris::*; use std::path::{Path, PathBuf}; use tabled::{Table, Tabled}; use theseus::prelude::*; -use tokio::fs; +use tokio::{fs, sync::oneshot}; use tokio_stream::wrappers::ReadDirStream; -use uuid::Uuid; #[derive(argh::FromArgs)] #[argh(subcommand, name = "profile")] @@ -371,19 +370,6 @@ pub struct ProfileRun { #[argh(positional, default = "std::env::current_dir().unwrap()")] /// the profile to run profile: PathBuf, - - // TODO: auth - #[argh(option, short = 't')] - /// the Minecraft token to use for player login. Should be replaced by auth when that is a thing. - token: String, - - #[argh(option, short = 'n')] - /// the uername to use for running the game - name: String, - - #[argh(option, short = 'i')] - /// the account id to use for running the game - id: Uuid, } impl ProfileRun { @@ -400,11 +386,12 @@ impl ProfileRun { "Profile not managed by Theseus (if it exists, try using `profile add` first!)", ); - let credentials = Credentials { - id: self.id.clone(), - username: self.name.clone(), - access_token: self.token.clone(), - }; + // TODO: credential storage and refresh + let (tx, rx) = oneshot::channel::(); + let auth_flow = tokio::spawn(authenticate(tx)); + let url = rx.await?; + webbrowser::open(url.as_str())?; + let credentials = auth_flow.await??; let mut proc = profile::run(&path, &credentials).await?; profile::wait_for(&mut proc).await?; From 23027ebef53b30255c3afe1a92c088787b3ee3db Mon Sep 17 00:00:00 2001 From: Danielle Hutzley Date: Mon, 11 Jul 2022 12:39:46 -0700 Subject: [PATCH 2/7] Store user info in the database, improve encapsulation in profiles --- theseus/src/api/auth.rs | 67 +++++++++++++++++++++++--- theseus/src/api/mod.rs | 2 +- theseus/src/api/profile.rs | 16 ++++-- theseus/src/error.rs | 3 ++ theseus/src/launcher/auth.rs | 6 ++- theseus/src/state/metadata.rs | 1 + theseus/src/state/mod.rs | 38 +++++++++------ theseus/src/state/profiles.rs | 2 +- theseus/src/state/settings.rs | 2 + theseus/src/state/users.rs | 67 ++++++++++++++++++++++++++ theseus/src/util/mod.rs | 11 ++++- theseus_cli/src/subcommands/mod.rs | 3 ++ theseus_cli/src/subcommands/profile.rs | 29 +++++++---- theseus_cli/src/subcommands/user.rs | 60 +++++++++++++++++++++++ 14 files changed, 265 insertions(+), 42 deletions(-) create mode 100644 theseus/src/state/users.rs create mode 100644 theseus_cli/src/subcommands/user.rs diff --git a/theseus/src/api/auth.rs b/theseus/src/api/auth.rs index ea5aa081a..1001b13bb 100644 --- a/theseus/src/api/auth.rs +++ b/theseus/src/api/auth.rs @@ -1,5 +1,6 @@ //! Authentication flow interface -use crate::launcher::auth as inner; +use crate::{launcher::auth as inner, State}; +use futures::prelude::*; use tokio::sync::oneshot; pub use inner::Credentials; @@ -12,25 +13,75 @@ pub async fn authenticate( browser_url: oneshot::Sender, ) -> crate::Result { let mut flow = inner::HydraAuthFlow::new().await?; + let state = State::get().await?; + let mut users = state.users.write().await; + let url = flow.prepare_login_url().await?; browser_url.send(url).map_err(|url| { crate::Error::OtherError(format!( "Error sending browser url to parent: {url}" )) })?; - flow.extract_credentials().await + + let credentials = flow.extract_credentials().await?; + users.insert(&credentials)?; + + if state.settings.read().await.default_user.is_none() { + let mut settings = state.settings.write().await; + settings.default_user = Some(credentials.id); + } + + State::sync().await?; + Ok(credentials) } /// Refresh some credentials using Hydra, if needed pub async fn refresh( - credentials: &mut Credentials, + user: uuid::Uuid, update_name: bool, -) -> crate::Result<()> { - if chrono::offset::Utc::now() > credentials.expires { - inner::refresh_credentials(credentials).await?; - if update_name { - inner::refresh_username(credentials).await?; +) -> crate::Result { + let state = State::get().await?; + let mut users = state.users.write().await; + + futures::future::ready(users.get(user)?.ok_or_else(|| { + crate::Error::OtherError(format!( + "Tried to refresh nonexistent user with ID {user}" + )) + })) + .and_then(|mut credentials| async move { + if chrono::offset::Utc::now() > credentials.expires { + inner::refresh_credentials(&mut credentials).await?; + if update_name { + inner::refresh_username(&mut credentials).await?; + } } + users.insert(&credentials)?; + Ok(credentials) + }) + .await +} + +/// Remove a user account from the database +pub async fn remove(user: uuid::Uuid) -> crate::Result<()> { + let state = State::get().await?; + let mut users = state.users.write().await; + + if state.settings.read().await.default_user == Some(user) { + let mut settings = state.settings.write().await; + settings.default_user = users + .0 + .first()? + .map(|it| uuid::Uuid::from_slice(&it.0)) + .transpose()?; } + + users.remove(user)?; Ok(()) } + +/// Get a copy of the list of all user credentials +pub async fn users() -> crate::Result> { + let state = State::get().await?; + let users = state.users.read().await; + users.iter().collect() +} diff --git a/theseus/src/api/mod.rs b/theseus/src/api/mod.rs index 7ce80205d..0d572b3b5 100644 --- a/theseus/src/api/mod.rs +++ b/theseus/src/api/mod.rs @@ -11,7 +11,7 @@ pub mod data { pub mod prelude { pub use crate::{ - auth::{authenticate, Credentials}, + auth::{self, Credentials}, data::*, profile::{self, Profile}, State, diff --git a/theseus/src/api/profile.rs b/theseus/src/api/profile.rs index 273f346d1..a9acd3264 100644 --- a/theseus/src/api/profile.rs +++ b/theseus/src/api/profile.rs @@ -1,11 +1,13 @@ //! Theseus profile management interface - pub use crate::{ state::{JavaSettings, Profile}, State, }; use daedalus as d; -use std::{future::Future, path::Path}; +use std::{ + future::Future, + path::{Path, PathBuf}, +}; use tokio::process::{Child, Command}; /// Add a profile to the in-memory state @@ -75,7 +77,7 @@ pub async fn edit( where Fut: Future>, { - let state = State::get().await.unwrap(); + let state = State::get().await?; let mut profiles = state.profiles.write().await; match profiles.0.get_mut(path) { @@ -89,6 +91,14 @@ where } } +/// Get a copy of the profile set +pub async fn list( +) -> crate::Result>> { + let state = State::get().await?; + let profiles = state.profiles.read().await; + Ok(profiles.0.clone()) +} + /// Run Minecraft using a profile pub async fn run( path: &Path, diff --git a/theseus/src/error.rs b/theseus/src/error.rs index 348ed1d7d..d93aba5a3 100644 --- a/theseus/src/error.rs +++ b/theseus/src/error.rs @@ -7,6 +7,9 @@ pub enum Error { #[error("Serialization error (JSON): {0}")] JSONError(#[from] serde_json::Error), + #[error("Error parsing UUID: {0}")] + UUIDError(#[from] uuid::Error), + #[error("Serialization error (Bincode): {0}")] EncodeError(#[from] bincode::error::DecodeError), diff --git a/theseus/src/launcher/auth.rs b/theseus/src/launcher/auth.rs index 794752e63..8b0de5c51 100644 --- a/theseus/src/launcher/auth.rs +++ b/theseus/src/launcher/auth.rs @@ -54,6 +54,7 @@ pub struct Credentials { pub refresh_token: String, #[bincode(with_serde)] pub expires: DateTime, + _ctor_scope: (), } // Implementation @@ -64,7 +65,7 @@ pub struct HydraAuthFlow { impl HydraAuthFlow { pub async fn new() -> crate::Result { let sock_url = wrap_ref_builder!( - it < HYDRA_URL => + it = HYDRA_URL => { it.set_scheme("wss").ok() } ); let (socket, _) = ws::tokio::connect_async(sock_url.clone()).await?; @@ -82,7 +83,7 @@ impl HydraAuthFlow { .into_data(); let code = ErrorJSON::unwrap::(&code_resp)?; Ok(wrap_ref_builder!( - it < HYDRA_URL.join("login")? => + it = HYDRA_URL.join("login")? => { it.query_pairs_mut().append_pair("id", &code.login_code); } )) } @@ -111,6 +112,7 @@ impl HydraAuthFlow { refresh_token: token.refresh_token, access_token: token.token, expires, + _ctor_scope: (), }) } } diff --git a/theseus/src/state/metadata.rs b/theseus/src/state/metadata.rs index eacf59de8..e666c0d51 100644 --- a/theseus/src/state/metadata.rs +++ b/theseus/src/state/metadata.rs @@ -13,6 +13,7 @@ use std::collections::LinkedList; const METADATA_URL: &str = "https://meta.modrinth.com/gamedata"; const METADATA_DB_FIELD: &[u8] = b"metadata"; +// TODO: store as subtree in database #[derive(Encode, Decode, Debug)] pub struct Metadata { pub minecraft: MinecraftManifest, diff --git a/theseus/src/state/mod.rs b/theseus/src/state/mod.rs index 645c8708a..a89b1b925 100644 --- a/theseus/src/state/mod.rs +++ b/theseus/src/state/mod.rs @@ -4,17 +4,18 @@ use std::sync::Arc; use tokio::sync::{Mutex, OnceCell, RwLock, Semaphore}; // Submodules -mod dirs; -pub use self::dirs::*; - -mod metadata; -pub use metadata::*; - -mod settings; -pub use settings::*; +macro_rules! submodule { + ($name:ident) => { + mod $name; + pub use self::$name::*; + }; +} -mod profiles; -pub use profiles::*; +submodule!(dirs); +submodule!(metadata); +submodule!(profiles); +submodule!(settings); +submodule!(users); // Global state static LAUNCHER_STATE: OnceCell> = OnceCell::const_new(); @@ -28,10 +29,13 @@ pub struct State { pub io_semaphore: Semaphore, /// Launcher metadata pub metadata: Metadata, + // TODO: settings API /// Launcher configuration pub settings: RwLock, /// Launcher profile metadata - pub profiles: RwLock, + pub(crate) profiles: RwLock, + /// Launcher user account info + pub(crate) users: RwLock, } impl State { @@ -51,11 +55,12 @@ impl State { let settings = Settings::init(&directories.settings_file()).await?; - // Metadata - let metadata = Metadata::init(&database).await?; - - // Profiles - let profiles = Profiles::init(&database).await?; + // Launcher data + let (metadata, profiles) = tokio::try_join! { + Metadata::init(&database), + Profiles::init(&database), + }?; + let users = Users::init(&database)?; // Loose initializations let io_semaphore = @@ -68,6 +73,7 @@ impl State { metadata, settings: RwLock::new(settings), profiles: RwLock::new(profiles), + users: RwLock::new(users), })) }) .await diff --git a/theseus/src/state/profiles.rs b/theseus/src/state/profiles.rs index 5b10b8d2e..10b15d0a6 100644 --- a/theseus/src/state/profiles.rs +++ b/theseus/src/state/profiles.rs @@ -13,7 +13,7 @@ const PROFILE_JSON_PATH: &str = "profile.json"; const PROFILE_SUBTREE: &[u8] = b"profiles"; #[derive(Debug)] -pub struct Profiles(pub HashMap>); +pub(crate) struct Profiles(pub HashMap>); // TODO: possibly add defaults to some of these values pub const CURRENT_FORMAT_VERSION: u32 = 1; diff --git a/theseus/src/state/settings.rs b/theseus/src/state/settings.rs index 863a3b9ac..11efa46c6 100644 --- a/theseus/src/state/settings.rs +++ b/theseus/src/state/settings.rs @@ -19,6 +19,7 @@ pub struct Settings { pub custom_java_args: Vec, pub java_8_path: Option, pub java_17_path: Option, + pub default_user: Option, pub hooks: Hooks, pub max_concurrent_downloads: usize, pub version: u32, @@ -32,6 +33,7 @@ impl Default for Settings { custom_java_args: Vec::new(), java_8_path: None, java_17_path: None, + default_user: None, hooks: Hooks::default(), max_concurrent_downloads: 64, version: CURRENT_FORMAT_VERSION, diff --git a/theseus/src/state/users.rs b/theseus/src/state/users.rs new file mode 100644 index 000000000..47bce1be2 --- /dev/null +++ b/theseus/src/state/users.rs @@ -0,0 +1,67 @@ +//! User login info +use crate::{auth::Credentials, config::BINCODE_CONFIG}; + +const USER_DB_TREE: &[u8] = b"users"; + +/// The set of users stored in the launcher +#[derive(Debug, Clone)] +pub(crate) struct Users(pub(crate) sled::Tree); + +impl Users { + pub fn init(db: &sled::Db) -> crate::Result { + Ok(Self(db.open_tree(USER_DB_TREE)?)) + } + + pub fn insert( + &mut self, + credentials: &Credentials, + ) -> crate::Result<&Self> { + let id = credentials.id.as_bytes(); + self.0.insert( + id, + bincode::encode_to_vec(credentials, *BINCODE_CONFIG)?, + )?; + Ok(self) + } + + pub fn get(&self, id: uuid::Uuid) -> crate::Result> { + self.0.get(id.as_bytes())?.map_or(Ok(None), |prof| { + bincode::decode_from_slice(&prof, *BINCODE_CONFIG) + .map_err(crate::Error::from) + .map(|it| Some(it.0)) + }) + } + + pub fn remove(&mut self, id: uuid::Uuid) -> crate::Result<&Self> { + self.0.remove(id.as_bytes())?; + Ok(self) + } + + pub fn iter(&self) -> UserIter { + UserIter(self.0.iter().keys(), false) + } +} + +alias_trait! {pub UserInnerIter: Iterator>, Send, Sync} + +/// An iterator over the set of users +#[derive(Debug)] +pub struct UserIter(I, bool); + +impl Iterator for UserIter { + type Item = crate::Result; + + fn next(&mut self) -> Option { + if self.1 { + return None; + } + + let it = self.0.next()?; + let res = it.map_err(crate::Error::from).and_then(|it| { + Ok(bincode::decode_from_slice(&it, *BINCODE_CONFIG)?.0) + }); + + self.1 = res.is_err(); + Some(res) + } +} diff --git a/theseus/src/util/mod.rs b/theseus/src/util/mod.rs index 8c6fab4ea..a0ac4cddb 100644 --- a/theseus/src/util/mod.rs +++ b/theseus/src/util/mod.rs @@ -2,8 +2,9 @@ pub mod fetch; pub mod platform; +/// Wrap a builder which uses a mut reference into one which outputs an owned value macro_rules! wrap_ref_builder { - ($id:ident < $init:expr => $transform:block) => {{ + ($id:ident = $init:expr => $transform:block) => {{ let mut it = $init; { let $id = &mut it; @@ -12,3 +13,11 @@ macro_rules! wrap_ref_builder { it }}; } + +/// Alias a trait, used to avoid needing nightly features +macro_rules! alias_trait { + ($scope:vis $name:ident : $bound:path $(, $bounds:path)*) => { + $scope trait $name: $bound $(+ $bounds)* {} + impl $name for T {} + } +} diff --git a/theseus_cli/src/subcommands/mod.rs b/theseus_cli/src/subcommands/mod.rs index 573e20f6d..8720baefd 100644 --- a/theseus_cli/src/subcommands/mod.rs +++ b/theseus_cli/src/subcommands/mod.rs @@ -1,17 +1,20 @@ use eyre::Result; mod profile; +mod user; #[derive(argh::FromArgs)] #[argh(subcommand)] pub enum SubCommand { Profile(profile::ProfileCommand), + User(user::UserCommand), } impl crate::Args { pub async fn dispatch(&self) -> Result<()> { match self.subcommand { SubCommand::Profile(ref cmd) => cmd.dispatch(self).await, + SubCommand::User(ref cmd) => cmd.dispatch(self).await, } } } diff --git a/theseus_cli/src/subcommands/profile.rs b/theseus_cli/src/subcommands/profile.rs index 56f8d68d1..0bb1f3247 100644 --- a/theseus_cli/src/subcommands/profile.rs +++ b/theseus_cli/src/subcommands/profile.rs @@ -310,16 +310,15 @@ impl ProfileList { _args: &crate::Args, _largs: &ProfileCommand, ) -> Result<()> { - let state = State::get().await?; - let profiles = state.profiles.read().await; - let profiles = profiles.0.iter().map(|(path, prof)| { + let profiles = profile::list().await?; + let rows = profiles.iter().map(|(path, prof)| { prof.as_ref().map_or_else( || ProfileRow::from(path.as_path()), ProfileRow::from, ) }); - let table = Table::new(profiles).with(tabled::Style::psql()).with( + let table = Table::new(rows).with(tabled::Style::psql()).with( tabled::Modify::new(tabled::Column(1..=1)) .with(tabled::MaxWidth::wrapping(40)), ); @@ -370,6 +369,10 @@ pub struct ProfileRun { #[argh(positional, default = "std::env::current_dir().unwrap()")] /// the profile to run profile: PathBuf, + + #[argh(option)] + /// the user to authenticate with + user: Option, } impl ProfileRun { @@ -386,12 +389,18 @@ impl ProfileRun { "Profile not managed by Theseus (if it exists, try using `profile add` first!)", ); - // TODO: credential storage and refresh - let (tx, rx) = oneshot::channel::(); - let auth_flow = tokio::spawn(authenticate(tx)); - let url = rx.await?; - webbrowser::open(url.as_str())?; - let credentials = auth_flow.await??; + let id = future::ready(self.user.ok_or(())) + .or_else(|_| async move { + let state = State::get().await?; + let settings = state.settings.read().await; + + settings.default_user + .ok_or(eyre::eyre!( + "Could not find any users, please add one using the `user add` command." + )) + }) + .await?; + let credentials = auth::refresh(id, false).await?; let mut proc = profile::run(&path, &credentials).await?; profile::wait_for(&mut proc).await?; diff --git a/theseus_cli/src/subcommands/user.rs b/theseus_cli/src/subcommands/user.rs new file mode 100644 index 000000000..1825af1bb --- /dev/null +++ b/theseus_cli/src/subcommands/user.rs @@ -0,0 +1,60 @@ +//! User management subcommand +use eyre::Result; +use paris::*; +use theseus::prelude::*; +use tokio::sync::oneshot; + +#[derive(argh::FromArgs)] +#[argh(subcommand, name = "user")] +/// user management +pub struct UserCommand { + #[argh(subcommand)] + action: UserSubcommand, +} + +#[derive(argh::FromArgs)] +#[argh(subcommand)] +pub enum UserSubcommand { + Add(UserAdd), +} + +#[derive(argh::FromArgs)] +/// Add a new user to Theseus +#[argh(subcommand, name = "add")] +pub struct UserAdd { + #[argh(option)] + /// the browser to authenticate using + browser: Option, +} + +impl UserAdd { + pub async fn run( + &self, + _args: &crate::Args, + _largs: &UserCommand, + ) -> Result<()> { + info!("Adding new user account to Theseus"); + info!("A browser window will now open, follow the login flow there."); + + let (tx, rx) = oneshot::channel::(); + let flow = tokio::spawn(auth::authenticate(tx)); + + let url = rx.await?; + match self.browser { + Some(browser) => webbrowser::open_browser(browser, url.as_str()), + None => webbrowser::open(url.as_str()), + }?; + + let credentials = flow.await??; + success!("Logged in user {}.", credentials.username); + Ok(()) + } +} + +impl UserCommand { + pub async fn dispatch(&self, args: &crate::Args) -> Result<()> { + match &self.action { + UserSubcommand::Add(ref cmd) => cmd.run(args, self).await, + } + } +} From cfe6c600ddcec9b3b55b97923266290df57ebf14 Mon Sep 17 00:00:00 2001 From: Danielle Hutzley Date: Mon, 11 Jul 2022 19:21:15 -0700 Subject: [PATCH 3/7] Add user list, remove unused dependencies, add spantraces --- Cargo.lock | 381 +++++++++---------------- flake.nix | 18 +- shell.nix | 8 - theseus/Cargo.toml | 8 +- theseus/src/api/auth.rs | 9 +- theseus/src/api/profile.rs | 50 ++-- theseus/src/error.rs | 39 ++- theseus/src/launcher/args.rs | 32 ++- theseus/src/launcher/auth.rs | 24 +- theseus/src/launcher/download.rs | 15 +- theseus/src/launcher/mod.rs | 16 +- theseus/src/state/dirs.rs | 7 +- theseus/src/state/metadata.rs | 6 +- theseus/src/state/mod.rs | 71 ++--- theseus/src/state/profiles.rs | 28 +- theseus/src/state/settings.rs | 8 +- theseus/src/state/users.rs | 7 +- theseus/src/util/fetch.rs | 8 +- theseus_cli/Cargo.toml | 12 +- theseus_cli/src/main.rs | 42 ++- theseus_cli/src/subcommands/mod.rs | 12 +- theseus_cli/src/subcommands/profile.rs | 44 +-- theseus_cli/src/subcommands/user.rs | 66 ++++- theseus_cli/src/util.rs | 21 +- 24 files changed, 507 insertions(+), 425 deletions(-) delete mode 100644 shell.nix diff --git a/Cargo.lock b/Cargo.lock index b6ae6f69d..30c599753 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -82,17 +91,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38de00daab4eac7d753e97697066238d67ce9d7e2d823ab4f72fe14af29f3f33" -[[package]] -name = "async-trait" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "async-tungstenite" version = "0.17.2" @@ -151,23 +149,27 @@ dependencies = [ "wildmatch", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide 0.5.3", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.0" @@ -214,34 +216,13 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" dependencies = [ - "generic-array 0.14.5", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", + "generic-array", ] [[package]] @@ -280,12 +261,6 @@ version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "byteorder" version = "1.4.3" @@ -448,6 +423,33 @@ dependencies = [ "objc", ] +[[package]] +name = "color-eyre" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ebf286c900a6d5867aeff75cfee3192857bb7f24b547d4f0df2ed6baa812c90" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + [[package]] name = "combine" version = "4.6.4" @@ -473,26 +475,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "const_format" -version = "0.2.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" -dependencies = [ - "const_format_proc_macros", -] - -[[package]] -name = "const_format_proc_macros" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - [[package]] name = "convert_case" version = "0.4.0" @@ -598,7 +580,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ccfd8c0ee4cce11e45b3fd6f9d5e69e0cc62912aa6a0cb1bf4617b0eba5a12f" dependencies = [ - "generic-array 0.14.5", + "generic-array", "typenum", ] @@ -757,22 +739,13 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - [[package]] name = "digest" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ - "block-buffer 0.10.2", + "block-buffer", "crypto-common", ] @@ -859,19 +832,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "eyre" version = "0.6.8" @@ -882,12 +842,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "fastrand" version = "1.7.0" @@ -972,12 +926,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fs_extra" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" - [[package]] name = "futf" version = "0.1.5" @@ -1191,15 +1139,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.5" @@ -1232,6 +1171,12 @@ dependencies = [ "wasi 0.10.2+wasi-snapshot-preview1", ] +[[package]] +name = "gimli" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" + [[package]] name = "gio" version = "0.15.12" @@ -1495,15 +1440,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hyper" version = "0.14.15" @@ -1733,17 +1669,6 @@ dependencies = [ "treediff", ] -[[package]] -name = "json5" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" -dependencies = [ - "pest", - "pest_derive", - "serde", -] - [[package]] name = "kuchiki" version = "0.8.1" @@ -1847,12 +1772,6 @@ dependencies = [ "libc", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - [[package]] name = "markup5ever" version = "0.10.1" @@ -2160,16 +2079,19 @@ dependencies = [ ] [[package]] -name = "once_cell" -version = "1.13.0" +name = "object" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "memchr", +] [[package]] -name = "opaque-debug" -version = "0.2.3" +name = "once_cell" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "open" @@ -2244,6 +2166,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "owo-colors" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "decf7381921fea4dcb2549c5667eda59b3ec297ab7e2b5fc33eac69d2e7da87b" + [[package]] name = "pango" version = "0.15.10" @@ -2321,12 +2249,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" -[[package]] -name = "path-clean" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd" - [[package]] name = "pathdiff" version = "0.2.1" @@ -2348,40 +2270,6 @@ dependencies = [ "ucd-trie", ] -[[package]] -name = "pest_derive" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pest_meta" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" -dependencies = [ - "maplit", - "pest", - "sha-1 0.8.2", -] - [[package]] name = "phf" version = "0.8.0" @@ -2480,6 +2368,26 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78203e83c48cffbe01e4a2d35d566ca4de445d79a85372fc64e378bfc812a260" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710faf75e1b33345361201d36d04e98ac1ed8909151a017ed384700836104c74" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.7" @@ -2560,16 +2468,6 @@ dependencies = [ "output_vt100", ] -[[package]] -name = "pretty_env_logger" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" -dependencies = [ - "env_logger", - "log", -] - [[package]] name = "proc-macro-crate" version = "1.1.3" @@ -2625,12 +2523,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" version = "1.0.10" @@ -2854,6 +2746,12 @@ dependencies = [ "windows 0.37.0", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc_version" version = "0.3.3" @@ -3099,18 +2997,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "sha-1" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug", -] - [[package]] name = "sha-1" version = "0.10.0" @@ -3119,7 +3005,7 @@ checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.3", + "digest", ] [[package]] @@ -3136,7 +3022,7 @@ checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.3", + "digest", ] [[package]] @@ -3643,15 +3529,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - [[package]] name = "terminal_size" version = "0.1.17" @@ -3667,20 +3544,15 @@ name = "theseus" version = "0.1.0" dependencies = [ "argh", - "async-trait", "async-tungstenite", "bincode 2.0.0-rc.1", "bytes", "chrono", - "const_format", "daedalus", "dirs", - "fs_extra", "futures", - "json5", "log", "once_cell", - "path-clean", "pretty_assertions", "regex", "reqwest", @@ -3691,10 +3563,11 @@ dependencies = [ "sys-info", "thiserror", "tokio", + "tracing", + "tracing-error", "url", "uuid 0.8.2", "zip", - "zip-extensions", ] [[package]] @@ -3702,18 +3575,21 @@ name = "theseus_cli" version = "0.1.0" dependencies = [ "argh", + "color-eyre", "daedalus", "dialoguer", "dirs", "eyre", "futures", - "log", "paris", - "pretty_env_logger", "tabled", "theseus", "tokio", "tokio-stream", + "tracing", + "tracing-error", + "tracing-futures", + "tracing-subscriber", "url", "uuid 0.8.2", "webbrowser", @@ -3912,6 +3788,26 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + [[package]] name = "tracing-log" version = "0.1.3" @@ -3970,7 +3866,7 @@ dependencies = [ "log", "native-tls", "rand 0.8.4", - "sha-1 0.10.0", + "sha-1", "thiserror", "url", "utf-8", @@ -4021,12 +3917,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - [[package]] name = "url" version = "2.2.2" @@ -4623,15 +4513,6 @@ dependencies = [ "time 0.1.43", ] -[[package]] -name = "zip-extensions" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c3c977bc3434ce2d4bcea8ad3c644672de0f2c402b72b9171ca80a8885d14" -dependencies = [ - "zip", -] - [[package]] name = "zstd" version = "0.9.2+zstd.1.5.1" diff --git a/flake.nix b/flake.nix index 3bc06f971..04c6538f9 100644 --- a/flake.nix +++ b/flake.nix @@ -57,20 +57,10 @@ cli = utils.mkApp { drv = self.packages.${system}.theseus-cli; }; - cli-test = utils.mkApp { - drv = pkgs.writeShellApplication { - name = "theseus-test-cli"; - runtimeInputs = [ - (self.packages.${system}.theseus-cli.overrideAttrs (old: old // { - release = false; - })) - ]; - text = '' - DUMMY_ID="$(printf '%0.sa' {1..32})" - theseus_cli profile run -t "" -n "Test" -i "$DUMMY_ID" "$@" - ''; - }; - }; + cli-dev = utils.mkApp { + drv = self.packages.${system}.theseus-cli.overrideAttrs (old: old // { + release = false; + }); }; devShell = pkgs.mkShell { diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 69a7fa416..000000000 --- a/shell.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.mkShell { - buildInputs = with pkgs; [ - rustc cargo clippy openssl pkg-config - gtk4 gdk-pixbuf atk webkitgtk - ]; -} diff --git a/theseus/Cargo.toml b/theseus/Cargo.toml index 98dd3d279..c229923bc 100644 --- a/theseus/Cargo.toml +++ b/theseus/Cargo.toml @@ -9,9 +9,6 @@ edition = "2018" [dependencies] bytes = "1" bincode = { version = "2.0.0-rc.1", features = ["serde"] } -const_format = "0.2.22" -fs_extra = "1.2.0" -json5 = "0.4.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" sha1 = { version = "0.6.0", features = ["std"]} @@ -19,18 +16,17 @@ sled = { version = "0.34.7", features = ["compression"] } url = "2.2" uuid = { version = "0.8", features = ["serde", "v4"] } zip = "0.5" -zip-extensions = "0.6" chrono = { version = "0.4.19", features = ["serde"] } daedalus = { version = "0.1.16", features = ["bincode"] } dirs = "4.0" log = "0.4.14" -path-clean = "0.1.0" regex = "1.5" sys-info = "0.9.0" thiserror = "1.0" +tracing = "0.1" +tracing-error = "0.2" -async-trait = "0.1.51" async-tungstenite = { version = "0.17", features = ["tokio-runtime", "tokio-native-tls"] } futures = "0.3" once_cell = "1.9.0" diff --git a/theseus/src/api/auth.rs b/theseus/src/api/auth.rs index 1001b13bb..fd4547986 100644 --- a/theseus/src/api/auth.rs +++ b/theseus/src/api/auth.rs @@ -9,6 +9,7 @@ pub use inner::Credentials; /// To run this, you need to first spawn this function as a task, then /// open a browser to the given URL and finally wait on the spawned future /// with the ability to cancel in case the browser is closed before finishing +#[tracing::instrument] pub async fn authenticate( browser_url: oneshot::Sender, ) -> crate::Result { @@ -18,7 +19,7 @@ pub async fn authenticate( let url = flow.prepare_login_url().await?; browser_url.send(url).map_err(|url| { - crate::Error::OtherError(format!( + crate::ErrorKind::OtherError(format!( "Error sending browser url to parent: {url}" )) })?; @@ -36,6 +37,7 @@ pub async fn authenticate( } /// Refresh some credentials using Hydra, if needed +#[tracing::instrument] pub async fn refresh( user: uuid::Uuid, update_name: bool, @@ -44,9 +46,10 @@ pub async fn refresh( let mut users = state.users.write().await; futures::future::ready(users.get(user)?.ok_or_else(|| { - crate::Error::OtherError(format!( + crate::ErrorKind::OtherError(format!( "Tried to refresh nonexistent user with ID {user}" )) + .as_error() })) .and_then(|mut credentials| async move { if chrono::offset::Utc::now() > credentials.expires { @@ -62,6 +65,7 @@ pub async fn refresh( } /// Remove a user account from the database +#[tracing::instrument] pub async fn remove(user: uuid::Uuid) -> crate::Result<()> { let state = State::get().await?; let mut users = state.users.write().await; @@ -80,6 +84,7 @@ pub async fn remove(user: uuid::Uuid) -> crate::Result<()> { } /// Get a copy of the list of all user credentials +#[tracing::instrument] pub async fn users() -> crate::Result> { let state = State::get().await?; let users = state.users.read().await; diff --git a/theseus/src/api/profile.rs b/theseus/src/api/profile.rs index a9acd3264..787791d1c 100644 --- a/theseus/src/api/profile.rs +++ b/theseus/src/api/profile.rs @@ -11,6 +11,7 @@ use std::{ use tokio::process::{Child, Command}; /// Add a profile to the in-memory state +#[tracing::instrument] pub async fn add(profile: Profile) -> crate::Result<()> { let state = State::get().await?; let mut profiles = state.profiles.write().await; @@ -20,6 +21,7 @@ pub async fn add(profile: Profile) -> crate::Result<()> { } /// Add a path as a profile in-memory +#[tracing::instrument] pub async fn add_path(path: &Path) -> crate::Result<()> { let state = State::get().await?; let mut profiles = state.profiles.write().await; @@ -29,6 +31,7 @@ pub async fn add_path(path: &Path) -> crate::Result<()> { } /// Remove a profile +#[tracing::instrument] pub async fn remove(path: &Path) -> crate::Result<()> { let state = State::get().await?; let mut profiles = state.profiles.write().await; @@ -38,19 +41,22 @@ pub async fn remove(path: &Path) -> crate::Result<()> { } /// Get a profile by path, +#[tracing::instrument] pub async fn get(path: &Path) -> crate::Result> { let state = State::get().await?; let profiles = state.profiles.read().await; profiles.0.get(path).map_or(Ok(None), |prof| match prof { Some(prof) => Ok(Some(prof.clone())), - None => Err(crate::Error::UnloadedProfileError( + None => Err(crate::ErrorKind::UnloadedProfileError( path.display().to_string(), - )), + ) + .as_error()), }) } /// Check if a profile is already managed by Theseus +#[tracing::instrument] pub async fn is_managed(profile: &Path) -> crate::Result { let state = State::get().await?; let profiles = state.profiles.read().await; @@ -58,6 +64,7 @@ pub async fn is_managed(profile: &Path) -> crate::Result { } /// Check if a profile is loaded +#[tracing::instrument] pub async fn is_loaded(profile: &Path) -> crate::Result { let state = State::get().await?; let profiles = state.profiles.read().await; @@ -82,16 +89,19 @@ where match profiles.0.get_mut(path) { Some(&mut Some(ref mut profile)) => action(profile).await, - Some(&mut None) => Err(crate::Error::UnloadedProfileError( + Some(&mut None) => Err(crate::ErrorKind::UnloadedProfileError( path.display().to_string(), - )), - None => Err(crate::Error::UnmanagedProfileError( + ) + .as_error()), + None => Err(crate::ErrorKind::UnmanagedProfileError( path.display().to_string(), - )), + ) + .as_error()), } } /// Get a copy of the profile set +#[tracing::instrument] pub async fn list( ) -> crate::Result>> { let state = State::get().await?; @@ -100,6 +110,7 @@ pub async fn list( } /// Run Minecraft using a profile +#[tracing::instrument] pub async fn run( path: &Path, credentials: &crate::auth::Credentials, @@ -107,7 +118,7 @@ pub async fn run( let state = State::get().await.unwrap(); let settings = state.settings.read().await; let profile = get(path).await?.ok_or_else(|| { - crate::Error::OtherError(format!( + crate::ErrorKind::OtherError(format!( "Tried to run a nonexistent or unloaded profile at path {}!", path.display() )) @@ -120,7 +131,7 @@ pub async fn run( .iter() .find(|it| it.id == profile.metadata.game_version.as_ref()) .ok_or_else(|| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Invalid or unknown Minecraft version: {}", profile.metadata.game_version )) @@ -140,10 +151,11 @@ pub async fn run( .await?; if !result.success() { - return Err(crate::Error::LauncherError(format!( + return Err(crate::ErrorKind::LauncherError(format!( "Non-zero exit code for pre-launch hook: {}", result.code().unwrap_or(-1) - ))); + )) + .as_error()); } } @@ -163,7 +175,7 @@ pub async fn run( settings.java_8_path.as_ref() } .ok_or_else(|| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "No Java installed for version {}", version_info.java_version.map_or(8, |it| it.major_version), )) @@ -171,10 +183,11 @@ pub async fn run( }; if !java_install.exists() { - return Err(crate::Error::LauncherError(format!( + return Err(crate::ErrorKind::LauncherError(format!( "Could not find Java install: {}", java_install.display() - ))); + )) + .as_error()); } let ref java_args = profile @@ -205,21 +218,26 @@ pub async fn run( .await } +#[tracing::instrument] pub async fn kill(running: &mut Child) -> crate::Result<()> { running.kill().await?; wait_for(running).await } +#[tracing::instrument] pub async fn wait_for(running: &mut Child) -> crate::Result<()> { let result = running.wait().await.map_err(|err| { - crate::Error::LauncherError(format!("Error running minecraft: {err}")) + crate::ErrorKind::LauncherError(format!( + "Error running minecraft: {err}" + )) })?; match result.success() { - false => Err(crate::Error::LauncherError(format!( + false => Err(crate::ErrorKind::LauncherError(format!( "Minecraft exited with non-zero code {}", result.code().unwrap_or(-1) - ))), + )) + .as_error()), true => Ok(()), } } diff --git a/theseus/src/error.rs b/theseus/src/error.rs index d93aba5a3..f97822f0b 100644 --- a/theseus/src/error.rs +++ b/theseus/src/error.rs @@ -1,6 +1,8 @@ //! Theseus error type +use tracing_error::InstrumentError; + #[derive(thiserror::Error, Debug)] -pub enum Error { +pub enum ErrorKind { #[error("Filesystem error: {0}")] FSError(String), @@ -11,10 +13,10 @@ pub enum Error { UUIDError(#[from] uuid::Error), #[error("Serialization error (Bincode): {0}")] - EncodeError(#[from] bincode::error::DecodeError), + EncodeError(#[from] bincode::error::EncodeError), #[error("Deserialization error (Bincode): {0}")] - DecodeError(#[from] bincode::error::EncodeError), + DecodeError(#[from] bincode::error::DecodeError), #[error("Error parsing URL: {0}")] URLError(#[from] url::ParseError), @@ -67,4 +69,35 @@ pub enum Error { OtherError(String), } +#[derive(Debug)] +pub struct Error { + source: tracing_error::TracedError, +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + self.source.source() + } +} + +impl std::fmt::Display for Error { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(fmt, "{}", self.source) + } +} + +impl> From for Error { + fn from(source: E) -> Self { + Self { + source: Into::::into(source).in_current_span(), + } + } +} + +impl ErrorKind { + pub fn as_error(self) -> Error { + self.into() + } +} + pub type Result = core::result::Result; diff --git a/theseus/src/launcher/args.rs b/theseus/src/launcher/args.rs index 4fadcb146..6544960b6 100644 --- a/theseus/src/launcher/args.rs +++ b/theseus/src/launcher/args.rs @@ -40,10 +40,11 @@ pub fn get_class_paths( client_path .canonicalize() .map_err(|_| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Specified class path {} does not exist", client_path.to_string_lossy() )) + .as_error() })? .to_string_lossy() .to_string(), @@ -70,10 +71,11 @@ pub fn get_lib_path(libraries_path: &Path, lib: &str) -> crate::Result { path.push(get_path_from_artifact(lib.as_ref())?); let path = &path.canonicalize().map_err(|_| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Library file at path {} does not exist", path.to_string_lossy() )) + .as_error() })?; Ok(path.to_string_lossy().to_string()) @@ -104,10 +106,11 @@ pub fn get_jvm_arguments( "-Djava.library.path={}", &natives_path .canonicalize() - .map_err(|_| crate::Error::LauncherError(format!( + .map_err(|_| crate::ErrorKind::LauncherError(format!( "Specified natives path {} does not exist", natives_path.to_string_lossy() - )))? + )) + .as_error())? .to_string_lossy() .to_string() )); @@ -142,10 +145,11 @@ fn parse_jvm_argument( &natives_path .canonicalize() .map_err(|_| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Specified natives path {} does not exist", natives_path.to_string_lossy() )) + .as_error() })? .to_string_lossy(), ) @@ -154,10 +158,11 @@ fn parse_jvm_argument( &libraries_path .canonicalize() .map_err(|_| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Specified libraries path {} does not exist", libraries_path.to_string_lossy() )) + .as_error() })? .to_string_lossy() .to_string(), @@ -249,10 +254,11 @@ fn parse_minecraft_argument( &game_directory .canonicalize() .map_err(|_| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Specified game directory {} does not exist", game_directory.to_string_lossy() )) + .as_error() })? .to_string_lossy() .to_owned(), @@ -262,10 +268,11 @@ fn parse_minecraft_argument( &assets_directory .canonicalize() .map_err(|_| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Specified assets directory {} does not exist", assets_directory.to_string_lossy() )) + .as_error() })? .to_string_lossy() .to_owned(), @@ -275,10 +282,11 @@ fn parse_minecraft_argument( &assets_directory .canonicalize() .map_err(|_| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Specified assets directory {} does not exist", assets_directory.to_string_lossy() )) + .as_error() })? .to_string_lossy() .to_owned(), @@ -361,17 +369,19 @@ pub async fn get_processor_main_class( Ok(tokio::task::spawn_blocking(move || { let zipfile = std::fs::File::open(&path)?; let mut archive = zip::ZipArchive::new(zipfile).map_err(|_| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Cannot read processor at {}", path )) + .as_error() })?; let file = archive.by_name("META-INF/MANIFEST.MF").map_err(|_| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Cannot read processor manifest at {}", path )) + .as_error() })?; let reader = BufReader::new(file); diff --git a/theseus/src/launcher/auth.rs b/theseus/src/launcher/auth.rs index 8b0de5c51..0e6fee712 100644 --- a/theseus/src/launcher/auth.rs +++ b/theseus/src/launcher/auth.rs @@ -19,7 +19,7 @@ struct ErrorJSON { impl ErrorJSON { pub fn unwrap<'a, T: Deserialize<'a>>(data: &'a [u8]) -> crate::Result { if let Ok(err) = serde_json::from_slice::(data) { - Err(crate::Error::HydraError(err.error)) + Err(crate::ErrorKind::HydraError(err.error).as_error()) } else { Ok(serde_json::from_slice::(data)?) } @@ -54,7 +54,7 @@ pub struct Credentials { pub refresh_token: String, #[bincode(with_serde)] pub expires: DateTime, - _ctor_scope: (), + _ctor_scope: std::marker::PhantomData<()>, } // Implementation @@ -77,9 +77,12 @@ impl HydraAuthFlow { .socket .try_next() .await? - .ok_or(crate::Error::WSClosedError(String::from( - "login socket ID", - )))? + .ok_or( + crate::ErrorKind::WSClosedError(String::from( + "login socket ID", + )) + .as_error(), + )? .into_data(); let code = ErrorJSON::unwrap::(&code_resp)?; Ok(wrap_ref_builder!( @@ -94,9 +97,12 @@ impl HydraAuthFlow { .socket .try_next() .await? - .ok_or(crate::Error::WSClosedError(String::from( - "login socket ID", - )))? + .ok_or( + crate::ErrorKind::WSClosedError(String::from( + "login socket ID", + )) + .as_error(), + )? .into_data(); let token = ErrorJSON::unwrap::(&token_resp)?; let expires = @@ -112,7 +118,7 @@ impl HydraAuthFlow { refresh_token: token.refresh_token, access_token: token.token, expires, - _ctor_scope: (), + _ctor_scope: std::marker::PhantomData, }) } } diff --git a/theseus/src/launcher/download.rs b/theseus/src/launcher/download.rs index 6cb0ff2f8..807c8a449 100644 --- a/theseus/src/launcher/download.rs +++ b/theseus/src/launcher/download.rs @@ -15,6 +15,7 @@ use daedalus::{ use futures::prelude::*; use tokio::{fs, sync::OnceCell}; +#[tracing::instrument] pub async fn download_minecraft( st: &State, version: &GameVersionInfo, @@ -32,6 +33,7 @@ pub async fn download_minecraft( Ok(()) } +#[tracing::instrument] pub async fn download_version_info( st: &State, version: &GameVersion, @@ -68,6 +70,7 @@ pub async fn download_version_info( Ok(res) } +#[tracing::instrument] pub async fn download_client( st: &State, version_info: &GameVersionInfo, @@ -77,9 +80,12 @@ pub async fn download_client( let client_download = version_info .downloads .get(&d::minecraft::DownloadType::Client) - .ok_or(crate::Error::LauncherError(format!( - "No client downloads exist for version {version}" - )))?; + .ok_or( + crate::ErrorKind::LauncherError(format!( + "No client downloads exist for version {version}" + )) + .as_error(), + )?; let path = st .directories .version_dir(version) @@ -98,6 +104,7 @@ pub async fn download_client( Ok(()) } +#[tracing::instrument] pub async fn download_assets_index( st: &State, version: &GameVersionInfo, @@ -125,6 +132,7 @@ pub async fn download_assets_index( Ok(res) } +#[tracing::instrument] pub async fn download_assets( st: &State, with_legacy: bool, @@ -179,6 +187,7 @@ pub async fn download_assets( Ok(()) } +#[tracing::instrument] pub async fn download_libraries( st: &State, libraries: &[Library], diff --git a/theseus/src/launcher/mod.rs b/theseus/src/launcher/mod.rs index f84c73dfe..35a32bc1a 100644 --- a/theseus/src/launcher/mod.rs +++ b/theseus/src/launcher/mod.rs @@ -10,6 +10,7 @@ pub mod auth; mod download; +#[tracing::instrument] pub fn parse_rule(rule: &d::minecraft::Rule) -> bool { use d::minecraft::{Rule, RuleAction}; @@ -43,6 +44,7 @@ macro_rules! processor_rules { } } +#[tracing::instrument] pub async fn launch_minecraft( game_version: &str, loader_version: &Option, @@ -63,7 +65,7 @@ pub async fn launch_minecraft( .versions .iter() .find(|it| it.id == game_version) - .ok_or(crate::Error::LauncherError(format!( + .ok_or(crate::ErrorKind::LauncherError(format!( "Invalid game version: {game_version}" )))?; @@ -130,7 +132,7 @@ pub async fn launch_minecraft( )?) .await? .ok_or_else(|| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Could not find processor main class for {}", processor.jar )) @@ -144,16 +146,17 @@ pub async fn launch_minecraft( .output() .await .map_err(|err| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Error running processor: {err}", )) })?; if !child.status.success() { - return Err(crate::Error::LauncherError(format!( + return Err(crate::ErrorKind::LauncherError(format!( "Processor error: {}", String::from_utf8_lossy(&child.stderr) - ))); + )) + .as_error()); } } } @@ -202,10 +205,11 @@ pub async fn launch_minecraft( .stderr(Stdio::inherit()); command.spawn().map_err(|err| { - crate::Error::LauncherError(format!( + crate::ErrorKind::LauncherError(format!( "Error running Minecraft (minecraft-{} @ {}): {err}", &version.id, instance_path.display() )) + .as_error() }) } diff --git a/theseus/src/state/dirs.rs b/theseus/src/state/dirs.rs index 3ba115cfc..37a572392 100644 --- a/theseus/src/state/dirs.rs +++ b/theseus/src/state/dirs.rs @@ -10,10 +10,11 @@ pub struct DirectoryInfo { impl DirectoryInfo { /// Get all paths needed for Theseus to operate properly + #[tracing::instrument] pub async fn init() -> crate::Result { // Working directory let working_dir = std::env::current_dir().map_err(|err| { - crate::Error::FSError(format!( + crate::ErrorKind::FSError(format!( "Could not open working directory: {err}" )) })?; @@ -21,12 +22,12 @@ impl DirectoryInfo { // Config directory let config_dir = Self::env_path("THESEUS_CONFIG_DIR") .or_else(|| Some(dirs::config_dir()?.join("theseus"))) - .ok_or(crate::Error::FSError( + .ok_or(crate::ErrorKind::FSError( "Could not find valid config dir".to_string(), ))?; fs::create_dir_all(&config_dir).await.map_err(|err| { - crate::Error::FSError(format!( + crate::ErrorKind::FSError(format!( "Error creating Theseus config directory: {err}" )) })?; diff --git a/theseus/src/state/metadata.rs b/theseus/src/state/metadata.rs index e666c0d51..cf43fd7d9 100644 --- a/theseus/src/state/metadata.rs +++ b/theseus/src/state/metadata.rs @@ -49,6 +49,7 @@ impl Metadata { }) } + #[tracing::instrument] pub async fn init(db: &sled::Db) -> crate::Result { let mut metadata = None; @@ -85,7 +86,10 @@ impl Metadata { db.flush_async().await?; Ok(meta) } else { - Err(crate::Error::NoValueFor(String::from("launcher metadata"))) + Err( + crate::ErrorKind::NoValueFor(String::from("launcher metadata")) + .as_error(), + ) } } } diff --git a/theseus/src/state/mod.rs b/theseus/src/state/mod.rs index a89b1b925..1a379f97c 100644 --- a/theseus/src/state/mod.rs +++ b/theseus/src/state/mod.rs @@ -39,47 +39,52 @@ pub struct State { } impl State { + #[tracing::instrument] /// Get the current launcher state, initializing it if needed pub async fn get() -> crate::Result> { LAUNCHER_STATE - .get_or_try_init(|| async { - // Directories - let directories = DirectoryInfo::init().await?; - - // Database - // TODO: make database versioned - let database = - sled_config().path(directories.database_file()).open()?; - - // Settings - let settings = - Settings::init(&directories.settings_file()).await?; - - // Launcher data - let (metadata, profiles) = tokio::try_join! { - Metadata::init(&database), - Profiles::init(&database), - }?; - let users = Users::init(&database)?; - - // Loose initializations - let io_semaphore = - Semaphore::new(settings.max_concurrent_downloads); - - Ok(Arc::new(Self { - database, - directories, - io_semaphore, - metadata, - settings: RwLock::new(settings), - profiles: RwLock::new(profiles), - users: RwLock::new(users), - })) + .get_or_try_init(|| { + async { + // Directories + let directories = DirectoryInfo::init().await?; + + // Database + // TODO: make database versioned + let database = sled_config() + .path(directories.database_file()) + .open()?; + + // Settings + let settings = + Settings::init(&directories.settings_file()).await?; + + // Launcher data + let (metadata, profiles) = tokio::try_join! { + Metadata::init(&database), + Profiles::init(&database), + }?; + let users = Users::init(&database)?; + + // Loose initializations + let io_semaphore = + Semaphore::new(settings.max_concurrent_downloads); + + Ok(Arc::new(Self { + database, + directories, + io_semaphore, + metadata, + settings: RwLock::new(settings), + profiles: RwLock::new(profiles), + users: RwLock::new(users), + })) + } }) .await .map(Arc::clone) } + #[tracing::instrument] /// Synchronize in-memory state with persistent state pub async fn sync() -> crate::Result<()> { let state = Self::get().await?; diff --git a/theseus/src/state/profiles.rs b/theseus/src/state/profiles.rs index 10b15d0a6..b6e23c752 100644 --- a/theseus/src/state/profiles.rs +++ b/theseus/src/state/profiles.rs @@ -84,15 +84,17 @@ pub struct JavaSettings { } impl Profile { + #[tracing::instrument] pub async fn new( name: String, version: String, path: PathBuf, ) -> crate::Result { if name.trim().is_empty() { - return Err(crate::Error::InputError(String::from( + return Err(crate::ErrorKind::InputError(String::from( "Empty name for instance!", - ))); + )) + .into()); } Ok(Self { @@ -114,11 +116,13 @@ impl Profile { // TODO: deduplicate these builder methods // They are flat like this in order to allow builder-style usage + #[tracing::instrument] pub fn with_name(&mut self, name: String) -> &mut Self { self.metadata.name = name; self } + #[tracing::instrument] pub async fn with_icon<'a>( &'a mut self, icon: &'a Path, @@ -136,17 +140,20 @@ impl Profile { Ok(self) } else { - Err(crate::Error::InputError(format!( + Err(crate::ErrorKind::InputError(format!( "Unsupported image type: {ext}" - ))) + )) + .into()) } } + #[tracing::instrument] pub fn with_game_version(&mut self, version: String) -> &mut Self { self.metadata.game_version = version; self } + #[tracing::instrument] pub fn with_loader( &mut self, loader: ModLoader, @@ -157,6 +164,7 @@ impl Profile { self } + #[tracing::instrument] pub fn with_java_settings( &mut self, settings: Option, @@ -165,6 +173,7 @@ impl Profile { self } + #[tracing::instrument] pub fn with_memory( &mut self, settings: Option, @@ -173,6 +182,7 @@ impl Profile { self } + #[tracing::instrument] pub fn with_resolution( &mut self, resolution: Option, @@ -181,6 +191,7 @@ impl Profile { self } + #[tracing::instrument] pub fn with_hooks(&mut self, hooks: Option) -> &mut Self { self.hooks = hooks; self @@ -188,6 +199,7 @@ impl Profile { } impl Profiles { + #[tracing::instrument] pub async fn init(db: &sled::Db) -> crate::Result { let profile_db = db.get(PROFILE_SUBTREE)?.map_or( Ok(Default::default()), @@ -218,19 +230,23 @@ impl Profiles { Ok(Self(profiles)) } + #[tracing::instrument] pub fn insert(&mut self, profile: Profile) -> crate::Result<&Self> { self.0.insert( profile .path .canonicalize()? .to_str() - .ok_or(crate::Error::UTFError(profile.path.clone()))? + .ok_or( + crate::ErrorKind::UTFError(profile.path.clone()).as_error(), + )? .into(), Some(profile), ); Ok(self) } + #[tracing::instrument] pub async fn insert_from<'a>( &'a mut self, path: &'a Path, @@ -238,12 +254,14 @@ impl Profiles { self.insert(Self::read_profile_from_dir(&path.canonicalize()?).await?) } + #[tracing::instrument] pub fn remove(&mut self, path: &Path) -> crate::Result<&Self> { let path = PathBuf::from(path.canonicalize()?.to_str().unwrap()); self.0.remove(&path); Ok(self) } + #[tracing::instrument] pub async fn sync<'a>( &'a self, batch: &'a mut sled::Batch, diff --git a/theseus/src/state/settings.rs b/theseus/src/state/settings.rs index 11efa46c6..308ebe2d8 100644 --- a/theseus/src/state/settings.rs +++ b/theseus/src/state/settings.rs @@ -42,14 +42,16 @@ impl Default for Settings { } impl Settings { + #[tracing::instrument] pub async fn init(file: &Path) -> crate::Result { if file.exists() { fs::read(&file) .await .map_err(|err| { - crate::Error::FSError(format!( + crate::ErrorKind::FSError(format!( "Error reading settings file: {err}" )) + .as_error() }) .and_then(|it| { serde_json::from_slice::(&it) @@ -60,13 +62,15 @@ impl Settings { } } + #[tracing::instrument] pub async fn sync(&self, to: &Path) -> crate::Result<()> { fs::write(to, serde_json::to_vec_pretty(self)?) .await .map_err(|err| { - crate::Error::FSError(format!( + crate::ErrorKind::FSError(format!( "Error saving settings to file: {err}" )) + .as_error() }) } } diff --git a/theseus/src/state/users.rs b/theseus/src/state/users.rs index 47bce1be2..c098811d4 100644 --- a/theseus/src/state/users.rs +++ b/theseus/src/state/users.rs @@ -38,11 +38,13 @@ impl Users { } pub fn iter(&self) -> UserIter { - UserIter(self.0.iter().keys(), false) + UserIter(self.0.iter().values(), false) } } -alias_trait! {pub UserInnerIter: Iterator>, Send, Sync} +alias_trait! { + pub UserInnerIter: Iterator>, Send, Sync +} /// An iterator over the set of users #[derive(Debug)] @@ -51,6 +53,7 @@ pub struct UserIter(I, bool); impl Iterator for UserIter { type Item = crate::Result; + #[tracing::instrument(skip(self))] fn next(&mut self) -> Option { if self.1 { return None; diff --git a/theseus/src/util/fetch.rs b/theseus/src/util/fetch.rs index fce3ce6cf..ddb7f9d6c 100644 --- a/theseus/src/util/fetch.rs +++ b/theseus/src/util/fetch.rs @@ -10,6 +10,7 @@ use tokio::{ const FETCH_ATTEMPTS: usize = 3; +#[tracing::instrument] pub async fn fetch<'a>( url: &str, sha1: Option<&str>, @@ -25,10 +26,11 @@ pub async fn fetch<'a>( if let Some(hash) = sha1 { let actual_hash = sha1_async(bytes.clone()).await; if actual_hash != hash { - return Err(crate::Error::HashError( + return Err(crate::ErrorKind::HashError( actual_hash, String::from(hash), - )); + ) + .into()); } } @@ -45,6 +47,7 @@ pub async fn fetch<'a>( // This is implemented, as it will be useful in porting modpacks // For now, allow it to be dead code #[allow(dead_code)] +#[tracing::instrument] pub async fn fetch_mirrors( urls: &[&str], sha1: Option<&str>, @@ -70,6 +73,7 @@ pub async fn fetch_mirrors( .map(|it| it.0) } +#[tracing::instrument] pub async fn write<'a>( path: &Path, bytes: &[u8], diff --git a/theseus_cli/Cargo.toml b/theseus_cli/Cargo.toml index fc95382e4..98a515ea6 100644 --- a/theseus_cli/Cargo.toml +++ b/theseus_cli/Cargo.toml @@ -15,12 +15,16 @@ futures = "0.3" argh = "0.1" paris = { version = "1.5", features = ["macros", "no_logger"] } dialoguer = "0.10" -eyre = "0.6" tabled = "0.5" dirs = "4.0" uuid = {version = "0.8", features = ["v4", "serde"]} url = "2.2" -# TODO: merge logging with paris logging -pretty_env_logger = "0.4" -log = "0.4.14" + +color-eyre = "0.6" +eyre = "0.6" +tracing = "0.1" +tracing-error = "0.2" +tracing-futures = "0.2" +tracing-subscriber = {version = "0.3", features = ["env-filter"]} + webbrowser = "0.7" \ No newline at end of file diff --git a/theseus_cli/src/main.rs b/theseus_cli/src/main.rs index 6b92766d3..17e04006b 100644 --- a/theseus_cli/src/main.rs +++ b/theseus_cli/src/main.rs @@ -1,26 +1,46 @@ use eyre::Result; use futures::TryFutureExt; use paris::*; +use tracing_error::ErrorLayer; +use tracing_futures::WithSubscriber; +use tracing_subscriber::prelude::*; +use tracing_subscriber::{fmt, EnvFilter}; -mod subcommands; +#[macro_use] mod util; -#[derive(argh::FromArgs)] +mod subcommands; + +#[derive(argh::FromArgs, Debug)] /// The official Modrinth CLI pub struct Args { #[argh(subcommand)] - pub subcommand: subcommands::SubCommand, + pub subcommand: subcommands::Subcommand, } -#[tokio::main] -async fn main() -> Result<()> { +#[tracing::instrument] +fn main() -> Result<()> { let args = argh::from_env::(); - pretty_env_logger::formatted_builder() - .filter_module("theseus", log::LevelFilter::Info) - .target(pretty_env_logger::env_logger::Target::Stderr) + + color_eyre::install()?; + let filter = EnvFilter::try_from_default_env() + .or_else(|_| EnvFilter::try_new("info"))?; + + tracing_subscriber::registry() + .with(fmt::layer().with_target(false)) + .with(filter) + .with(ErrorLayer::default()) .init(); - args.dispatch() - .inspect_err(|_| error!("An error has occurred!\n")) - .await + tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build()? + .block_on( + async move { + args.dispatch() + .inspect_err(|_| error!("An error has occurred!\n")) + .await + } + .with_current_subscriber(), + ) } diff --git a/theseus_cli/src/subcommands/mod.rs b/theseus_cli/src/subcommands/mod.rs index 8720baefd..04cc48080 100644 --- a/theseus_cli/src/subcommands/mod.rs +++ b/theseus_cli/src/subcommands/mod.rs @@ -3,18 +3,18 @@ use eyre::Result; mod profile; mod user; -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] #[argh(subcommand)] -pub enum SubCommand { +pub enum Subcommand { Profile(profile::ProfileCommand), User(user::UserCommand), } impl crate::Args { pub async fn dispatch(&self) -> Result<()> { - match self.subcommand { - SubCommand::Profile(ref cmd) => cmd.dispatch(self).await, - SubCommand::User(ref cmd) => cmd.dispatch(self).await, - } + dispatch!(self.subcommand, (self) => { + Subcommand::Profile, + Subcommand::User + }) } } diff --git a/theseus_cli/src/subcommands/profile.rs b/theseus_cli/src/subcommands/profile.rs index 0bb1f3247..d06c3482a 100644 --- a/theseus_cli/src/subcommands/profile.rs +++ b/theseus_cli/src/subcommands/profile.rs @@ -1,18 +1,18 @@ //! Profile management subcommand use crate::util::{ - confirm_async, prompt_async, select_async, table_path_display, + confirm_async, prompt_async, select_async, table, table_path_display, }; use daedalus::modded::LoaderVersion; use eyre::{ensure, Result}; use futures::prelude::*; use paris::*; use std::path::{Path, PathBuf}; -use tabled::{Table, Tabled}; +use tabled::Tabled; use theseus::prelude::*; -use tokio::{fs, sync::oneshot}; +use tokio::fs; use tokio_stream::wrappers::ReadDirStream; -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] #[argh(subcommand, name = "profile")] /// profile management pub struct ProfileCommand { @@ -20,7 +20,7 @@ pub struct ProfileCommand { action: ProfileSubcommand, } -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] #[argh(subcommand)] pub enum ProfileSubcommand { Add(ProfileAdd), @@ -30,7 +30,7 @@ pub enum ProfileSubcommand { Run(ProfileRun), } -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] #[argh(subcommand, name = "add")] /// add a new profile to Theseus pub struct ProfileAdd { @@ -40,6 +40,7 @@ pub struct ProfileAdd { } impl ProfileAdd { + #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -70,7 +71,7 @@ impl ProfileAdd { } } -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] #[argh(subcommand, name = "init")] /// create a new profile and manage it with Theseus pub struct ProfileInit { @@ -100,6 +101,7 @@ pub struct ProfileInit { } impl ProfileInit { + #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -259,7 +261,7 @@ impl ProfileInit { } } -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] /// list all managed profiles #[argh(subcommand, name = "list")] pub struct ProfileList {} @@ -305,6 +307,7 @@ impl<'a> From<&'a Path> for ProfileRow<'a> { } impl ProfileList { + #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -318,7 +321,7 @@ impl ProfileList { ) }); - let table = Table::new(rows).with(tabled::Style::psql()).with( + let table = table(rows).with( tabled::Modify::new(tabled::Column(1..=1)) .with(tabled::MaxWidth::wrapping(40)), ); @@ -328,7 +331,7 @@ impl ProfileList { } } -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] /// unmanage a profile #[argh(subcommand, name = "remove")] pub struct ProfileRemove { @@ -338,6 +341,7 @@ pub struct ProfileRemove { } impl ProfileRemove { + #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -362,7 +366,7 @@ impl ProfileRemove { } } -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] /// run a profile #[argh(subcommand, name = "run")] pub struct ProfileRun { @@ -376,6 +380,7 @@ pub struct ProfileRun { } impl ProfileRun { + #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -411,14 +416,15 @@ impl ProfileRun { } impl ProfileCommand { - pub async fn dispatch(&self, args: &crate::Args) -> Result<()> { - match &self.action { - ProfileSubcommand::Add(ref cmd) => cmd.run(args, self).await, - ProfileSubcommand::Init(ref cmd) => cmd.run(args, self).await, - ProfileSubcommand::List(ref cmd) => cmd.run(args, self).await, - ProfileSubcommand::Remove(ref cmd) => cmd.run(args, self).await, - ProfileSubcommand::Run(ref cmd) => cmd.run(args, self).await, - } + #[tracing::instrument] + pub async fn run(&self, args: &crate::Args) -> Result<()> { + dispatch!(&self.action, (args, self) => { + ProfileSubcommand::Add, + ProfileSubcommand::Init, + ProfileSubcommand::List, + ProfileSubcommand::Remove, + ProfileSubcommand::Run + }) } } diff --git a/theseus_cli/src/subcommands/user.rs b/theseus_cli/src/subcommands/user.rs index 1825af1bb..58c7a894e 100644 --- a/theseus_cli/src/subcommands/user.rs +++ b/theseus_cli/src/subcommands/user.rs @@ -1,10 +1,12 @@ //! User management subcommand +use crate::util::table; use eyre::Result; use paris::*; +use tabled::Tabled; use theseus::prelude::*; use tokio::sync::oneshot; -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] #[argh(subcommand, name = "user")] /// user management pub struct UserCommand { @@ -12,14 +14,15 @@ pub struct UserCommand { action: UserSubcommand, } -#[derive(argh::FromArgs)] +#[derive(argh::FromArgs, Debug)] #[argh(subcommand)] pub enum UserSubcommand { Add(UserAdd), + List(UserList), } -#[derive(argh::FromArgs)] -/// Add a new user to Theseus +#[derive(argh::FromArgs, Debug)] +/// add a new user to Theseus #[argh(subcommand, name = "add")] pub struct UserAdd { #[argh(option)] @@ -28,6 +31,7 @@ pub struct UserAdd { } impl UserAdd { + #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -51,10 +55,56 @@ impl UserAdd { } } -impl UserCommand { - pub async fn dispatch(&self, args: &crate::Args) -> Result<()> { - match &self.action { - UserSubcommand::Add(ref cmd) => cmd.run(args, self).await, +#[derive(argh::FromArgs, Debug)] +/// list all known users +#[argh(subcommand, name = "list")] +pub struct UserList {} + +#[derive(Tabled)] +struct UserRow<'a> { + id: uuid::Uuid, + username: &'a str, + default: bool, +} + +impl<'a> UserRow<'a> { + pub fn from( + credentials: &'a Credentials, + default: Option, + ) -> Self { + Self { + id: credentials.id, + username: &credentials.username, + default: Some(credentials.id) == default, } } } + +impl UserList { + #[tracing::instrument] + pub async fn run( + &self, + _args: &crate::Args, + _largs: &UserCommand, + ) -> Result<()> { + let state = State::get().await?; + let default = state.settings.read().await.default_user; + + let users = auth::users().await?; + let rows = users.iter().map(|user| UserRow::from(user, default)); + + let table = table(rows); + println!("{table}"); + + Ok(()) + } +} + +impl UserCommand { + pub async fn run(&self, args: &crate::Args) -> Result<()> { + dispatch!(&self.action, (args, self) => { + UserSubcommand::Add, + UserSubcommand::List + }) + } +} diff --git a/theseus_cli/src/util.rs b/theseus_cli/src/util.rs index b40391cd7..6fc27af08 100644 --- a/theseus_cli/src/util.rs +++ b/theseus_cli/src/util.rs @@ -1,6 +1,7 @@ use dialoguer::{Confirm, Input, Select}; use eyre::Result; use std::{borrow::Cow, path::Path}; +use tabled::{Table, Tabled}; // TODO: make primarily async to avoid copies @@ -56,7 +57,11 @@ pub async fn confirm_async(prompt: String, default: bool) -> Result { tokio::task::spawn_blocking(move || confirm(&prompt, default)).await? } -// Table display helpers +// Table helpers +pub fn table(rows: impl IntoIterator) -> Table { + Table::new(rows).with(tabled::Style::psql()) +} + pub fn table_path_display(path: &Path) -> String { let mut res = path.display().to_string(); @@ -67,6 +72,20 @@ pub fn table_path_display(path: &Path) -> String { res } +// Dispatch macros +macro_rules! dispatch { + ($on:expr, $args:tt => {$($option:path),+}) => { + match $on { + $($option (ref cmd) => dispatch!(@apply cmd => $args)),+ + } + }; + + (@apply $cmd:expr => ($($args:expr),*)) => {{ + use tracing_futures::WithSubscriber; + $cmd.run($($args),*).with_current_subscriber().await + }}; +} + // Internal helpers fn print_prompt(prompt: &str) { println!( From a2e3a9e9d609ebfa8c3da45b7c41f9d697a52ee6 Mon Sep 17 00:00:00 2001 From: Danielle Hutzley Date: Mon, 11 Jul 2022 20:01:14 -0700 Subject: [PATCH 4/7] Implement user remove, update UUID crate --- Cargo.lock | 9 ++---- flake.nix | 1 + theseus/Cargo.toml | 2 +- theseus/src/api/auth.rs | 12 ++++++-- theseus/src/launcher/args.rs | 2 +- theseus/src/state/users.rs | 9 ++++++ theseus_cli/Cargo.toml | 2 +- theseus_cli/src/subcommands/user.rs | 45 ++++++++++++++++++++++++++--- 8 files changed, 67 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30c599753..be86ee670 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3566,7 +3566,7 @@ dependencies = [ "tracing", "tracing-error", "url", - "uuid 0.8.2", + "uuid 1.1.2", "zip", ] @@ -3591,7 +3591,7 @@ dependencies = [ "tracing-futures", "tracing-subscriber", "url", - "uuid 0.8.2", + "uuid 1.1.2", "webbrowser", ] @@ -3941,10 +3941,6 @@ name = "uuid" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" -dependencies = [ - "getrandom 0.2.3", - "serde", -] [[package]] name = "uuid" @@ -3953,6 +3949,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" dependencies = [ "getrandom 0.2.3", + "serde", ] [[package]] diff --git a/flake.nix b/flake.nix index 04c6538f9..703964f1a 100644 --- a/flake.nix +++ b/flake.nix @@ -61,6 +61,7 @@ drv = self.packages.${system}.theseus-cli.overrideAttrs (old: old // { release = false; }); + }; }; devShell = pkgs.mkShell { diff --git a/theseus/Cargo.toml b/theseus/Cargo.toml index c229923bc..b71e1bd82 100644 --- a/theseus/Cargo.toml +++ b/theseus/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0" sha1 = { version = "0.6.0", features = ["std"]} sled = { version = "0.34.7", features = ["compression"] } url = "2.2" -uuid = { version = "0.8", features = ["serde", "v4"] } +uuid = { version = "1.1", features = ["serde", "v4"] } zip = "0.5" chrono = { version = "0.4.19", features = ["serde"] } diff --git a/theseus/src/api/auth.rs b/theseus/src/api/auth.rs index fd4547986..8e9951824 100644 --- a/theseus/src/api/auth.rs +++ b/theseus/src/api/auth.rs @@ -32,7 +32,6 @@ pub async fn authenticate( settings.default_user = Some(credentials.id); } - State::sync().await?; Ok(credentials) } @@ -66,7 +65,7 @@ pub async fn refresh( /// Remove a user account from the database #[tracing::instrument] -pub async fn remove(user: uuid::Uuid) -> crate::Result<()> { +pub async fn remove_user(user: uuid::Uuid) -> crate::Result<()> { let state = State::get().await?; let mut users = state.users.write().await; @@ -83,6 +82,15 @@ pub async fn remove(user: uuid::Uuid) -> crate::Result<()> { Ok(()) } +/// Check if a user exists in Theseus +#[tracing::instrument] +pub async fn has_user(user: uuid::Uuid) -> crate::Result { + let state = State::get().await?; + let users = state.users.read().await; + + Ok(users.contains(user)?) +} + /// Get a copy of the list of all user credentials #[tracing::instrument] pub async fn users() -> crate::Result> { diff --git a/theseus/src/launcher/args.rs b/theseus/src/launcher/args.rs index 6544960b6..20d9becaf 100644 --- a/theseus/src/launcher/args.rs +++ b/theseus/src/launcher/args.rs @@ -244,7 +244,7 @@ fn parse_minecraft_argument( .replace("${auth_access_token}", access_token) .replace("${auth_session}", access_token) .replace("${auth_player_name}", username) - .replace("${auth_uuid}", &uuid.to_hyphenated().to_string()) + .replace("${auth_uuid}", &uuid.hyphenated().to_string()) .replace("${user_properties}", "{}") .replace("${user_type}", "mojang") .replace("${version_name}", version) diff --git a/theseus/src/state/users.rs b/theseus/src/state/users.rs index c098811d4..6b5caf42e 100644 --- a/theseus/src/state/users.rs +++ b/theseus/src/state/users.rs @@ -8,10 +8,12 @@ const USER_DB_TREE: &[u8] = b"users"; pub(crate) struct Users(pub(crate) sled::Tree); impl Users { + #[tracing::instrument] pub fn init(db: &sled::Db) -> crate::Result { Ok(Self(db.open_tree(USER_DB_TREE)?)) } + #[tracing::instrument] pub fn insert( &mut self, credentials: &Credentials, @@ -24,6 +26,12 @@ impl Users { Ok(self) } + #[tracing::instrument] + pub fn contains(&self, id: uuid::Uuid) -> crate::Result { + Ok(self.0.contains_key(id.as_bytes())?) + } + + #[tracing::instrument] pub fn get(&self, id: uuid::Uuid) -> crate::Result> { self.0.get(id.as_bytes())?.map_or(Ok(None), |prof| { bincode::decode_from_slice(&prof, *BINCODE_CONFIG) @@ -32,6 +40,7 @@ impl Users { }) } + #[tracing::instrument] pub fn remove(&mut self, id: uuid::Uuid) -> crate::Result<&Self> { self.0.remove(id.as_bytes())?; Ok(self) diff --git a/theseus_cli/Cargo.toml b/theseus_cli/Cargo.toml index 98a515ea6..149288044 100644 --- a/theseus_cli/Cargo.toml +++ b/theseus_cli/Cargo.toml @@ -17,7 +17,7 @@ paris = { version = "1.5", features = ["macros", "no_logger"] } dialoguer = "0.10" tabled = "0.5" dirs = "4.0" -uuid = {version = "0.8", features = ["v4", "serde"]} +uuid = {version = "1.1", features = ["v4", "serde"]} url = "2.2" color-eyre = "0.6" diff --git a/theseus_cli/src/subcommands/user.rs b/theseus_cli/src/subcommands/user.rs index 58c7a894e..5e06a6f53 100644 --- a/theseus_cli/src/subcommands/user.rs +++ b/theseus_cli/src/subcommands/user.rs @@ -1,5 +1,5 @@ //! User management subcommand -use crate::util::table; +use crate::util::{confirm_async, table}; use eyre::Result; use paris::*; use tabled::Tabled; @@ -19,6 +19,7 @@ pub struct UserCommand { pub enum UserSubcommand { Add(UserAdd), List(UserList), + Remove(UserRemove), } #[derive(argh::FromArgs, Debug)] @@ -50,6 +51,7 @@ impl UserAdd { }?; let credentials = flow.await??; + State::sync().await?; success!("Logged in user {}.", credentials.username); Ok(()) } @@ -62,8 +64,8 @@ pub struct UserList {} #[derive(Tabled)] struct UserRow<'a> { - id: uuid::Uuid, username: &'a str, + id: uuid::Uuid, default: bool, } @@ -73,8 +75,8 @@ impl<'a> UserRow<'a> { default: Option, ) -> Self { Self { - id: credentials.id, username: &credentials.username, + id: credentials.id, default: Some(credentials.id) == default, } } @@ -100,11 +102,46 @@ impl UserList { } } +#[derive(argh::FromArgs, Debug)] +/// remove a user +#[argh(subcommand, name = "remove")] +pub struct UserRemove { + /// the user to remove + #[argh(positional)] + user: uuid::Uuid, +} + +impl UserRemove { + #[tracing::instrument] + pub async fn run( + &self, + _args: &crate::Args, + _largs: &UserCommand, + ) -> Result<()> { + info!("Removing user {}", self.user.as_hyphenated()); + + if confirm_async(String::from("Do you wish to continue"), true).await? { + if !auth::has_user(self.user).await? { + warn!("Profile was not managed by Theseus!"); + } else { + auth::remove_user(self.user).await?; + State::sync().await?; + success!("User removed!"); + } + } else { + error!("Aborted!"); + } + + Ok(()) + } +} + impl UserCommand { pub async fn run(&self, args: &crate::Args) -> Result<()> { dispatch!(&self.action, (args, self) => { UserSubcommand::Add, - UserSubcommand::List + UserSubcommand::List, + UserSubcommand::Remove }) } } From 311b1da636d7d4efd93526e312a39d9d7cba9416 Mon Sep 17 00:00:00 2001 From: Danielle Hutzley Date: Mon, 11 Jul 2022 20:38:08 -0700 Subject: [PATCH 5/7] Add user set-default --- theseus_cli/src/subcommands/profile.rs | 2 +- theseus_cli/src/subcommands/user.rs | 39 ++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/theseus_cli/src/subcommands/profile.rs b/theseus_cli/src/subcommands/profile.rs index d06c3482a..6cf4440ce 100644 --- a/theseus_cli/src/subcommands/profile.rs +++ b/theseus_cli/src/subcommands/profile.rs @@ -14,7 +14,7 @@ use tokio_stream::wrappers::ReadDirStream; #[derive(argh::FromArgs, Debug)] #[argh(subcommand, name = "profile")] -/// profile management +/// manage Minecraft instances pub struct ProfileCommand { #[argh(subcommand)] action: ProfileSubcommand, diff --git a/theseus_cli/src/subcommands/user.rs b/theseus_cli/src/subcommands/user.rs index 5e06a6f53..f30bd2a28 100644 --- a/theseus_cli/src/subcommands/user.rs +++ b/theseus_cli/src/subcommands/user.rs @@ -8,7 +8,7 @@ use tokio::sync::oneshot; #[derive(argh::FromArgs, Debug)] #[argh(subcommand, name = "user")] -/// user management +/// manage Minecraft accounts pub struct UserCommand { #[argh(subcommand)] action: UserSubcommand, @@ -20,6 +20,7 @@ pub enum UserSubcommand { Add(UserAdd), List(UserList), Remove(UserRemove), + SetDefault(UserDefault), } #[derive(argh::FromArgs, Debug)] @@ -136,12 +137,46 @@ impl UserRemove { } } +#[derive(argh::FromArgs, Debug)] +/// set the default user +#[argh(subcommand, name = "set-default")] +pub struct UserDefault { + /// the user to set as default + #[argh(positional)] + user: uuid::Uuid, +} + +impl UserDefault { + #[tracing::instrument] + pub async fn run( + &self, + _args: &crate::Args, + _largs: &UserCommand, + ) -> Result<()> { + info!("Setting user {} as default", self.user.as_hyphenated()); + + // TODO: settings API + let state: std::sync::Arc = State::get().await?; + let mut settings = state.settings.write().await; + + if settings.default_user == Some(self.user) { + warn!("User is already the default!"); + } else { + settings.default_user = Some(self.user); + success!("User set as default!"); + } + + Ok(()) + } +} + impl UserCommand { pub async fn run(&self, args: &crate::Args) -> Result<()> { dispatch!(&self.action, (args, self) => { UserSubcommand::Add, UserSubcommand::List, - UserSubcommand::Remove + UserSubcommand::Remove, + UserSubcommand::SetDefault }) } } From 48d3f70b91b21daed180bf19f05a62c9835c5e4c Mon Sep 17 00:00:00 2001 From: Danielle Hutzley Date: Wed, 13 Jul 2022 07:31:21 -0700 Subject: [PATCH 6/7] Revert submodule macro usage --- theseus/src/state/mod.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/theseus/src/state/mod.rs b/theseus/src/state/mod.rs index 1a379f97c..1878678f6 100644 --- a/theseus/src/state/mod.rs +++ b/theseus/src/state/mod.rs @@ -4,18 +4,20 @@ use std::sync::Arc; use tokio::sync::{Mutex, OnceCell, RwLock, Semaphore}; // Submodules -macro_rules! submodule { - ($name:ident) => { - mod $name; - pub use self::$name::*; - }; -} +mod dirs; +pub use self::dirs::*; + +mod metadata; +pub use self::metadata::*; + +mod profiles; +pub use self::profiles::*; + +mod settings; +pub use self::settings::*; -submodule!(dirs); -submodule!(metadata); -submodule!(profiles); -submodule!(settings); -submodule!(users); +mod users; +pub use self::users::*; // Global state static LAUNCHER_STATE: OnceCell> = OnceCell::const_new(); From b8c95a80702b4de4c1ccf1992a80470931cc1389 Mon Sep 17 00:00:00 2001 From: Danielle Hutzley Date: Thu, 14 Jul 2022 09:39:11 -0700 Subject: [PATCH 7/7] Make tracing significantly less verbose --- theseus/Cargo.toml | 1 + theseus/src/api/profile.rs | 2 +- theseus/src/launcher/auth.rs | 2 +- theseus/src/launcher/download.rs | 12 ++++++------ theseus/src/launcher/mod.rs | 11 +++++------ theseus/src/lib.rs | 2 +- theseus/src/state/metadata.rs | 2 +- theseus/src/state/mod.rs | 1 - theseus/src/state/profiles.rs | 11 +++++------ theseus/src/state/settings.rs | 2 +- theseus/src/state/users.rs | 12 ++++++------ theseus/src/util/fetch.rs | 6 +++--- theseus_cli/src/main.rs | 8 +++++++- theseus_cli/src/subcommands/profile.rs | 6 ------ theseus_cli/src/subcommands/user.rs | 4 ---- 15 files changed, 38 insertions(+), 44 deletions(-) diff --git a/theseus/Cargo.toml b/theseus/Cargo.toml index b71e1bd82..b87e99c4f 100644 --- a/theseus/Cargo.toml +++ b/theseus/Cargo.toml @@ -20,6 +20,7 @@ zip = "0.5" chrono = { version = "0.4.19", features = ["serde"] } daedalus = { version = "0.1.16", features = ["bincode"] } dirs = "4.0" +# TODO: possibly replace with tracing to have structured logging log = "0.4.14" regex = "1.5" sys-info = "0.9.0" diff --git a/theseus/src/api/profile.rs b/theseus/src/api/profile.rs index 787791d1c..68f059e08 100644 --- a/theseus/src/api/profile.rs +++ b/theseus/src/api/profile.rs @@ -110,7 +110,7 @@ pub async fn list( } /// Run Minecraft using a profile -#[tracing::instrument] +#[tracing::instrument(skip_all)] pub async fn run( path: &Path, credentials: &crate::auth::Credentials, diff --git a/theseus/src/launcher/auth.rs b/theseus/src/launcher/auth.rs index 0e6fee712..b12d1d428 100644 --- a/theseus/src/launcher/auth.rs +++ b/theseus/src/launcher/auth.rs @@ -45,7 +45,7 @@ struct ProfileInfoJSON { } // Login information -#[derive(Debug, Encode, Decode)] +#[derive(Encode, Decode)] pub struct Credentials { #[bincode(with_serde)] pub id: uuid::Uuid, diff --git a/theseus/src/launcher/download.rs b/theseus/src/launcher/download.rs index 807c8a449..af9a8d2e5 100644 --- a/theseus/src/launcher/download.rs +++ b/theseus/src/launcher/download.rs @@ -15,7 +15,7 @@ use daedalus::{ use futures::prelude::*; use tokio::{fs, sync::OnceCell}; -#[tracing::instrument] +#[tracing::instrument(skip_all)] pub async fn download_minecraft( st: &State, version: &GameVersionInfo, @@ -33,7 +33,7 @@ pub async fn download_minecraft( Ok(()) } -#[tracing::instrument] +#[tracing::instrument(skip_all, fields(version = version.id.as_str(), loader = ?loader))] pub async fn download_version_info( st: &State, version: &GameVersion, @@ -70,7 +70,7 @@ pub async fn download_version_info( Ok(res) } -#[tracing::instrument] +#[tracing::instrument(skip_all)] pub async fn download_client( st: &State, version_info: &GameVersionInfo, @@ -104,7 +104,7 @@ pub async fn download_client( Ok(()) } -#[tracing::instrument] +#[tracing::instrument(skip_all)] pub async fn download_assets_index( st: &State, version: &GameVersionInfo, @@ -132,7 +132,7 @@ pub async fn download_assets_index( Ok(res) } -#[tracing::instrument] +#[tracing::instrument(skip(st, index))] pub async fn download_assets( st: &State, with_legacy: bool, @@ -187,7 +187,7 @@ pub async fn download_assets( Ok(()) } -#[tracing::instrument] +#[tracing::instrument(skip(st, libraries))] pub async fn download_libraries( st: &State, libraries: &[Library], diff --git a/theseus/src/launcher/mod.rs b/theseus/src/launcher/mod.rs index 35a32bc1a..21ede9cfb 100644 --- a/theseus/src/launcher/mod.rs +++ b/theseus/src/launcher/mod.rs @@ -44,7 +44,7 @@ macro_rules! processor_rules { } } -#[tracing::instrument] +#[tracing::instrument(skip_all, fields(path = ?instance_path))] pub async fn launch_minecraft( game_version: &str, loader_version: &Option, @@ -116,8 +116,9 @@ pub async fn launch_minecraft( } } - let mut cp = processor.classpath.clone(); - cp.push(processor.jar.clone()); + let cp = wrap_ref_builder!(cp = processor.classpath.clone() => { + cp.push(processor.jar.clone()) + }); let child = Command::new("java") .arg("-cp") @@ -165,9 +166,7 @@ pub async fn launch_minecraft( let args = version_info.arguments.clone().unwrap_or_default(); let mut command = match wrapper { Some(hook) => { - let mut cmd = Command::new(hook); - cmd.arg(java_install); - cmd + wrap_ref_builder!(it = Command::new(hook) => {it.arg(java_install)}) } None => Command::new(String::from(java_install.to_string_lossy())), }; diff --git a/theseus/src/lib.rs b/theseus/src/lib.rs index 61ca15e23..337eab2fb 100644 --- a/theseus/src/lib.rs +++ b/theseus/src/lib.rs @@ -4,7 +4,7 @@ Theseus is a library which provides utilities for launching minecraft, creating Modrinth mod packs, and launching Modrinth mod packs */ -#![warn(unused_import_braces, missing_debug_implementations)] +#![warn(unused_import_braces)] #![deny(unused_must_use)] #[macro_use] diff --git a/theseus/src/state/metadata.rs b/theseus/src/state/metadata.rs index cf43fd7d9..76f9713db 100644 --- a/theseus/src/state/metadata.rs +++ b/theseus/src/state/metadata.rs @@ -49,7 +49,7 @@ impl Metadata { }) } - #[tracing::instrument] + #[tracing::instrument(skip_all)] pub async fn init(db: &sled::Db) -> crate::Result { let mut metadata = None; diff --git a/theseus/src/state/mod.rs b/theseus/src/state/mod.rs index 1878678f6..169f69f79 100644 --- a/theseus/src/state/mod.rs +++ b/theseus/src/state/mod.rs @@ -21,7 +21,6 @@ pub use self::users::*; // Global state static LAUNCHER_STATE: OnceCell> = OnceCell::const_new(); -#[derive(Debug)] pub struct State { /// Database, used to store some information pub(self) database: sled::Db, diff --git a/theseus/src/state/profiles.rs b/theseus/src/state/profiles.rs index b6e23c752..36e8390d3 100644 --- a/theseus/src/state/profiles.rs +++ b/theseus/src/state/profiles.rs @@ -12,7 +12,6 @@ use tokio::fs; const PROFILE_JSON_PATH: &str = "profile.json"; const PROFILE_SUBTREE: &[u8] = b"profiles"; -#[derive(Debug)] pub(crate) struct Profiles(pub HashMap>); // TODO: possibly add defaults to some of these values @@ -199,7 +198,7 @@ impl Profile { } impl Profiles { - #[tracing::instrument] + #[tracing::instrument(skip(db))] pub async fn init(db: &sled::Db) -> crate::Result { let profile_db = db.get(PROFILE_SUBTREE)?.map_or( Ok(Default::default()), @@ -230,7 +229,7 @@ impl Profiles { Ok(Self(profiles)) } - #[tracing::instrument] + #[tracing::instrument(skip(self))] pub fn insert(&mut self, profile: Profile) -> crate::Result<&Self> { self.0.insert( profile @@ -246,7 +245,7 @@ impl Profiles { Ok(self) } - #[tracing::instrument] + #[tracing::instrument(skip(self))] pub async fn insert_from<'a>( &'a mut self, path: &'a Path, @@ -254,14 +253,14 @@ impl Profiles { self.insert(Self::read_profile_from_dir(&path.canonicalize()?).await?) } - #[tracing::instrument] + #[tracing::instrument(skip(self))] pub fn remove(&mut self, path: &Path) -> crate::Result<&Self> { let path = PathBuf::from(path.canonicalize()?.to_str().unwrap()); self.0.remove(&path); Ok(self) } - #[tracing::instrument] + #[tracing::instrument(skip_all)] pub async fn sync<'a>( &'a self, batch: &'a mut sled::Batch, diff --git a/theseus/src/state/settings.rs b/theseus/src/state/settings.rs index 308ebe2d8..563998d11 100644 --- a/theseus/src/state/settings.rs +++ b/theseus/src/state/settings.rs @@ -62,7 +62,7 @@ impl Settings { } } - #[tracing::instrument] + #[tracing::instrument(skip(self))] pub async fn sync(&self, to: &Path) -> crate::Result<()> { fs::write(to, serde_json::to_vec_pretty(self)?) .await diff --git a/theseus/src/state/users.rs b/theseus/src/state/users.rs index 6b5caf42e..84d49ffe5 100644 --- a/theseus/src/state/users.rs +++ b/theseus/src/state/users.rs @@ -4,16 +4,16 @@ use crate::{auth::Credentials, config::BINCODE_CONFIG}; const USER_DB_TREE: &[u8] = b"users"; /// The set of users stored in the launcher -#[derive(Debug, Clone)] +#[derive(Clone)] pub(crate) struct Users(pub(crate) sled::Tree); impl Users { - #[tracing::instrument] + #[tracing::instrument(skip(db))] pub fn init(db: &sled::Db) -> crate::Result { Ok(Self(db.open_tree(USER_DB_TREE)?)) } - #[tracing::instrument] + #[tracing::instrument(skip_all)] pub fn insert( &mut self, credentials: &Credentials, @@ -26,12 +26,12 @@ impl Users { Ok(self) } - #[tracing::instrument] + #[tracing::instrument(skip(self))] pub fn contains(&self, id: uuid::Uuid) -> crate::Result { Ok(self.0.contains_key(id.as_bytes())?) } - #[tracing::instrument] + #[tracing::instrument(skip(self))] pub fn get(&self, id: uuid::Uuid) -> crate::Result> { self.0.get(id.as_bytes())?.map_or(Ok(None), |prof| { bincode::decode_from_slice(&prof, *BINCODE_CONFIG) @@ -40,7 +40,7 @@ impl Users { }) } - #[tracing::instrument] + #[tracing::instrument(skip(self))] pub fn remove(&mut self, id: uuid::Uuid) -> crate::Result<&Self> { self.0.remove(id.as_bytes())?; Ok(self) diff --git a/theseus/src/util/fetch.rs b/theseus/src/util/fetch.rs index ddb7f9d6c..eea15f705 100644 --- a/theseus/src/util/fetch.rs +++ b/theseus/src/util/fetch.rs @@ -10,7 +10,7 @@ use tokio::{ const FETCH_ATTEMPTS: usize = 3; -#[tracing::instrument] +#[tracing::instrument(skip(_permit))] pub async fn fetch<'a>( url: &str, sha1: Option<&str>, @@ -47,7 +47,7 @@ pub async fn fetch<'a>( // This is implemented, as it will be useful in porting modpacks // For now, allow it to be dead code #[allow(dead_code)] -#[tracing::instrument] +#[tracing::instrument(skip(sem))] pub async fn fetch_mirrors( urls: &[&str], sha1: Option<&str>, @@ -73,7 +73,7 @@ pub async fn fetch_mirrors( .map(|it| it.0) } -#[tracing::instrument] +#[tracing::instrument(skip(bytes, _permit))] pub async fn write<'a>( path: &Path, bytes: &[u8], diff --git a/theseus_cli/src/main.rs b/theseus_cli/src/main.rs index 17e04006b..ff868b4b4 100644 --- a/theseus_cli/src/main.rs +++ b/theseus_cli/src/main.rs @@ -26,8 +26,14 @@ fn main() -> Result<()> { let filter = EnvFilter::try_from_default_env() .or_else(|_| EnvFilter::try_new("info"))?; + let format = fmt::layer() + .without_time() + .with_writer(std::io::stderr) + .with_target(false) + .compact(); + tracing_subscriber::registry() - .with(fmt::layer().with_target(false)) + .with(format) .with(filter) .with(ErrorLayer::default()) .init(); diff --git a/theseus_cli/src/subcommands/profile.rs b/theseus_cli/src/subcommands/profile.rs index 6cf4440ce..859749bb3 100644 --- a/theseus_cli/src/subcommands/profile.rs +++ b/theseus_cli/src/subcommands/profile.rs @@ -40,7 +40,6 @@ pub struct ProfileAdd { } impl ProfileAdd { - #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -101,7 +100,6 @@ pub struct ProfileInit { } impl ProfileInit { - #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -307,7 +305,6 @@ impl<'a> From<&'a Path> for ProfileRow<'a> { } impl ProfileList { - #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -341,7 +338,6 @@ pub struct ProfileRemove { } impl ProfileRemove { - #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -380,7 +376,6 @@ pub struct ProfileRun { } impl ProfileRun { - #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -416,7 +411,6 @@ impl ProfileRun { } impl ProfileCommand { - #[tracing::instrument] pub async fn run(&self, args: &crate::Args) -> Result<()> { dispatch!(&self.action, (args, self) => { ProfileSubcommand::Add, diff --git a/theseus_cli/src/subcommands/user.rs b/theseus_cli/src/subcommands/user.rs index f30bd2a28..36c813c94 100644 --- a/theseus_cli/src/subcommands/user.rs +++ b/theseus_cli/src/subcommands/user.rs @@ -33,7 +33,6 @@ pub struct UserAdd { } impl UserAdd { - #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -84,7 +83,6 @@ impl<'a> UserRow<'a> { } impl UserList { - #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -113,7 +111,6 @@ pub struct UserRemove { } impl UserRemove { - #[tracing::instrument] pub async fn run( &self, _args: &crate::Args, @@ -147,7 +144,6 @@ pub struct UserDefault { } impl UserDefault { - #[tracing::instrument] pub async fn run( &self, _args: &crate::Args,