From 7addde4a40940ed6ecf40c5298204672f3798bd2 Mon Sep 17 00:00:00 2001 From: sneedium Date: Sun, 3 Jul 2022 00:02:25 -0400 Subject: [PATCH] Added Curseforge API Key fetching This commit also improves the existing MSA Client ID fetching. Signed-off-by: sneedium --- CMakeLists.txt | 21 +++++---------------- cf.sh | 25 +++++++++++++++++++++++++ id.sh | 11 ++--------- 3 files changed, 32 insertions(+), 25 deletions(-) create mode 100755 cf.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index be8f2547..c16f2136 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,9 +87,6 @@ set(Launcher_META_URL "https://meta.multimc.org/v1/" CACHE STRING "URL to fetch # Imgur API Client ID set(Launcher_IMGUR_CLIENT_ID "5b97b0713fba4a3" CACHE STRING "Client ID you can get from Imgur when you register an application") -# MSA Client ID -execute_process(COMMAND ./id.sh OUTPUT_VARIABLE Launcher_MSA_CLIENT_ID) - # Bug tracker URL set(Launcher_BUG_TRACKER_URL "https://github.com/Sneederix/SneedMC/issues" CACHE STRING "URL for the bug tracker.") @@ -112,21 +109,13 @@ set(Launcher_FORCE_BUNDLED_LIBS OFF CACHE BOOL "Prevent using system libraries, set(Launcher_QT_VERSION_MAJOR "5" CACHE STRING "Major Qt version to build against") # API Keys -# NOTE: These API keys are here for convenience. If you rebrand this software or intend to break the terms of service -# of these platforms, please change these API keys beforehand. -# Be aware that if you were to use these API keys for malicious purposes they might get revoked, which might cause -# breakage to thousands of users. -# If you don't plan to use these features of this software, you can just remove these values. +# NOTE: These API keys are here for you to abuse. -# By using this key in your builds you accept the terms of use laid down in -# https://docs.microsoft.com/en-us/legal/microsoft-identity-platform/terms-of-use -set(Launcher_MSA_CLIENT_ID "549033b2-1532-4d4e-ae77-1bbaa46f9d74" CACHE STRING "Client ID you can get from Microsoft Identity Platform when you register an application") - -# By using this key in your builds you accept the terms and conditions laid down in -# https://support.curseforge.com/en/support/solutions/articles/9000207405-curse-forge-3rd-party-api-terms-and-conditions -# NOTE: CurseForge requires you to change this if you make any kind of derivative work. -set(Launcher_CURSEFORGE_API_KEY "$2a$10$1Oqr2MX3O4n/ilhFGc597u8tfI3L2Hyr9/rtWDAMRjghSQV2QUuxq" CACHE STRING "CurseForge API Key") +# MSA Client ID +execute_process(COMMAND ./id.sh OUTPUT_VARIABLE Launcher_MSA_CLIENT_ID) +# Curseforge API Key +execute_process(COMMAND ./cf.sh OUTPUT_VARIABLE Launcher_CURSEFORGE_API_KEY) #### Check the current Git commit and branch include(GetGitRevisionDescription) diff --git a/cf.sh b/cf.sh new file mode 100755 index 00000000..c1ca5a3a --- /dev/null +++ b/cf.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# Copyleft (C) 2022 Chuckium +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program. If not, see . + +command -v wscat &> /dev/null || { echo "YOU MUST HAVE wscat INSTALLED." 1>&2 && exit 1; } + +wget -qO- https://curseforge.overwolf.com/downloads/curseforge-latest-linux.zip | funzip > cf.AppImage +chmod +x cf.AppImage + +./cf.AppImage --appimage-extract &> /dev/null +squashfs-root/resources/plugins/curse/linux/Curse.Agent.Host &> /dev/null & + +sleep 15 + +printf '{"type":"method","id":0,"name":"getSystemProperties","args":[]}' | timeout 2 wscat -i /dev/stdin -c ws://127.0.0.1:12345/CurseForge | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | jq -r .result.data.Ak | tr -d '\n' + +rm cf.AppImage &> /dev/null +rm -rf squashfs-root &> /dev/null + +kill %1 diff --git a/id.sh b/id.sh index 41fbf236..248379c4 100755 --- a/id.sh +++ b/id.sh @@ -1,10 +1,7 @@ #!/bin/sh +# Credit to Lenny for this script. -#git fetch --all - -#git reset --hard origin/develop - -wget "https://files.multimc.org/downloads/mmc-stable-lin64.tar.gz" +wget -q "https://files.multimc.org/downloads/mmc-stable-lin64.tar.gz" tar xzf mmc-stable-lin64.tar.gz @@ -19,7 +16,3 @@ cd ../../ echo -n $client_id rm -rf mmc-stable-lin64.tar.gz MultiMC - -#sed -i "s/.*Launcher_MSA_CLIENT_ID.*/set(Launcher_MSA_CLIENT_ID \"$client_id\" CACHE STRING \"Client ID you can get from Microsoft Identity Platform when you register an application\")/g" CMakeLists.txt - -#git commit -S -am "update to new MultiMC MSA ID" || echo "not changing ID" && (git remote | xargs -L1 git push --all)