Skip to content

Commit

Permalink
Rewrite injector download mechanism
Browse files Browse the repository at this point in the history
Closes #3
  • Loading branch information
Octol1ttle committed Nov 2, 2023
1 parent f51a66d commit 54daf32
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 155 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@ jobs:
msystem: clang64
vcvars_arch: 'amd64_x86'

- os: windows-2022
name: "Windows-MSVC-Legacy"
msystem: ''
architecture: 'win32'
vcvars_arch: 'amd64_x86'
qt_ver: 5
qt_host: windows
qt_arch: 'win32_msvc2019'
qt_version: '5.15.2'
qt_modules: ''
qt_tools: 'tools_openssl_x86'

- os: windows-2022
name: "Windows-MSVC"
msystem: ''
Expand Down Expand Up @@ -387,8 +375,8 @@ jobs:
cd ${{ env.INSTALL_DIR }}
if ("${{ matrix.qt_ver }}" -eq "5")
{
Copy-Item D:/a/PrismLauncher/Qt/Tools/OpenSSL/Win_x86/bin/libcrypto-1_1.dll -Destination libcrypto-1_1.dll
Copy-Item D:/a/PrismLauncher/Qt/Tools/OpenSSL/Win_x86/bin/libssl-1_1.dll -Destination libssl-1_1.dll
Copy-Item D:/a/PrismLauncher-elyby/Qt/Tools/OpenSSL/Win_x86/bin/libcrypto-1_1.dll -Destination libcrypto-1_1.dll
Copy-Item D:/a/PrismLauncher-elyby/Qt/Tools/OpenSSL/Win_x86/bin/libssl-1_1.dll -Destination libssl-1_1.dll
}
cd ${{ github.workspace }}
Expand Down Expand Up @@ -481,7 +469,7 @@ jobs:
cp -r ${{ github.workspace }}/JREs/jre17/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk
cp -r /home/runner/work/PrismLauncher/Qt/${{ matrix.qt_version }}/gcc_64/plugins/iconengines/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines
cp -r /home/runner/work/PrismLauncher-elyby/Qt/${{ matrix.qt_version }}/gcc_64/plugins/iconengines/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines
cp /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/
cp /usr/lib/x86_64-linux-gnu/libssl.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/codeql.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/winget.yml

This file was deleted.

44 changes: 6 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,21 @@
</p>

<p align="center">
Prism Launcher is a custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once.<br />
<br />This is a <b>fork</b> of the MultiMC Launcher and is <b>not</b> endorsed by it.
This <b>fork</b> of Prism Launcher replaces legacy Mojang accounts with Ely.by accounts<br />
<br />This is <b>not</b> endorsed by Prism Launcher.
</p>

## Installation

<a href="https://repology.org/project/prismlauncher/versions">
<img src="https://repology.org/badge/vertical-allrepos/prismlauncher.svg" alt="Packaging status" align="right">
</a>

- All downloads and instructions for Prism Launcher can be found on our [Website](https://prismlauncher.org/download).
- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions).
- All downloads can be found [here](https://github.com/Octol1ttle/PrismLauncher-elyby/releases/latest).
- Last build status can be found in the [GitHub Actions](https://github.com/Octol1ttle/PrismLauncher-elyby/actions).

### Development Builds

There are development builds available [here](https://github.com/PrismLauncher/PrismLauncher/actions). These have debug information in the binaries, so their file sizes are relatively larger.
There are development builds available [here](https://github.com/Octol1ttle/PrismLauncher-elyby/actions). These have debug information in the binaries, so their file sizes are relatively larger.

Prebuilt Development builds are provided for **Linux**, **Windows** and **macOS**.

For **Arch**, **Debian**, **Fedora**, **OpenSUSE (Tumbleweed)** and **Gentoo**, respectively, you can use these packages for the latest development versions:

[![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--git-1793D1?label=AUR&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-git) [![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--qt5--git-1793D1?label=AUR&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-qt5-git) [![prismlauncher-git](https://img.shields.io/badge/mpr-prismlauncher--git-A80030?label=MPR&logo=debian&logoColor=white)](https://mpr.makedeb.org/packages/prismlauncher-git)<br />[![prismlauncher-nightly](https://img.shields.io/badge/copr-prismlauncher--nightly-51A2DA?label=COPR&logo=fedora&logoColor=white)](https://copr.fedorainfracloud.org/coprs/g3tchoo/prismlauncher/) [![prismlauncher-nightly](https://img.shields.io/badge/OBS-prismlauncher--nightly-3AB6A9?logo=opensuse&logoColor=white)](https://build.opensuse.org/project/show/home:getchoo) [![prismlauncher-9999](https://img.shields.io/badge/gentoo-prismlauncher--9999-4D4270?label=Gentoo&logo=gentoo&logoColor=white)](https://packages.gentoo.org/packages/games-action/prismlauncher)

These packages are also availiable to all the distributions based on the ones mentioned above.

## Community & Support

Feel free to create a GitHub issue if you find a bug or want to suggest a new feature. We have multiple community spaces where other community members can help you:

- **Our Discord server:**

[![Prism Launcher Discord server](https://discordapp.com/api/guilds/1031648380885147709/widget.png?style=banner3)](https://prismlauncher.org/discord)

- **Our Matrix space:**

[![PrismLauncher Space](https://img.shields.io/matrix/prismlauncher:matrix.org?style=for-the-badge&label=Matrix%20Space&logo=matrix&color=purple)](https://prismlauncher.org/matrix)

- **Our Subreddit:**

[![r/PrismLauncher](https://img.shields.io/reddit/subreddit-subscribers/prismlauncher?style=for-the-badge&logo=reddit)](https://prismlauncher.org/reddit)

## Translations

The translation effort for PrismLauncher is hosted on [Weblate](https://hosted.weblate.org/projects/prismlauncher/launcher/) and information about translating Prism Launcher is available at <https://github.com/PrismLauncher/Translations>

## Building

If you want to build Prism Launcher yourself, check the [Build Instructions](https://prismlauncher.org/wiki/development/build-instructions/).

## Sponsors & Partners
Expand Down Expand Up @@ -96,7 +64,7 @@ Be aware that if you build this software without removing the provided API keys

If you do not agree with these terms and conditions, then remove the associated API keys from the [CMakeLists.txt](CMakeLists.txt) file by setting them to an empty string (`""`).

## License [![https://github.com/PrismLauncher/PrismLauncher/blob/develop/LICENSE](https://img.shields.io/github/license/PrismLauncher/PrismLauncher?label=License&logo=gnu&color=C4282D)](LICENSE)
## License ![https://github.com/PrismLauncher/PrismLauncher/blob/develop/LICENSE](https://img.shields.io/github/license/PrismLauncher/PrismLauncher?label=License&logo=gnu&color=C4282D)

All launcher code is available under the GPL-3.0-only license.

Expand Down
2 changes: 1 addition & 1 deletion buildconfig/BuildConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Config {

QString RESOURCE_BASE = "https://resources.download.minecraft.net/";
QString LIBRARY_BASE = "https://libraries.minecraft.net/";
QString AUTH_BASE = "https://authserver.mojang.com/";
QString AUTH_BASE = "https://authserver.ely.by/auth";
QString IMGUR_BASE_URL = "https://api.imgur.com/3/";
QString FMLLIBS_BASE_URL = "https://files.prismlauncher.org/fmllibs/"; // FIXME: move into CMakeLists
QString TRANSLATIONS_BASE_URL = "https://i18n.prismlauncher.org/"; // FIXME: move into CMakeLists
Expand Down
1 change: 1 addition & 0 deletions injector-download.url
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/yushijinhun/authlib-injector/releases/download/v1.2.4/authlib-injector-1.2.4.jar
4 changes: 2 additions & 2 deletions launcher/LaunchController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ void LaunchController::decideAccount()
auto reply = CustomMessageBox::selectable(
m_parentWidget,
tr("No Accounts"),
tr("In order to play Minecraft, you must have at least one Microsoft or Mojang "
"account logged in. Mojang accounts can only be used offline. "
tr("In order to play Minecraft, you must have at least one Microsoft or Ely.by "
"account logged in. "
"Would you like to open the account manager to add an account now?"),
QMessageBox::Information,
QMessageBox::Yes | QMessageBox::No
Expand Down
4 changes: 2 additions & 2 deletions launcher/minecraft/auth/AccountData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ bool AccountData::resumeStateFromV2(QJsonObject data) {
// The JSON object must at least have a username for it to be valid.
if (!data.value("username").isString())
{
qCritical() << "Can't load Mojang account info from JSON object. Username field is missing or of the wrong type.";
qCritical() << "Can't load Ely.by account info from JSON object. Username field is missing or of the wrong type.";
return false;
}

Expand All @@ -289,7 +289,7 @@ bool AccountData::resumeStateFromV2(QJsonObject data) {
QJsonArray profileArray = data.value("profiles").toArray();
if (profileArray.size() < 1)
{
qCritical() << "Can't load Mojang account with username \"" << userName << "\". No profiles found.";
qCritical() << "Can't load Ely.by account with username \"" << userName << "\". No profiles found.";
return false;
}

Expand Down
12 changes: 7 additions & 5 deletions launcher/minecraft/auth/AccountList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ int AccountList::findAccountByProfileId(const QString& profileId) const {
}

MinecraftAccountPtr AccountList::getAccountByProfileName(const QString& profileName) const {
MinecraftAccountPtr toReturn = nullptr;
for (int i = 0; i < count(); i++) {
MinecraftAccountPtr account = at(i);
if (account->profileName() == profileName) {
return account;
if (toReturn) return nullptr;
toReturn = account;
}
}
return nullptr;
return toReturn;
}

const MinecraftAccountPtr AccountList::at(int i) const
Expand Down Expand Up @@ -398,7 +400,7 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r
case NameColumn:
return tr("User name of the account.");
case TypeColumn:
return tr("Type of the account - Mojang or MSA.");
return tr("Type of the account - Ely.by or MSA.");
case StatusColumn:
return tr("Current status of the account.");
case MigrationColumn:
Expand Down Expand Up @@ -457,7 +459,7 @@ bool AccountList::loadList()
{
if (m_listFilePath.isEmpty())
{
qCritical() << "Can't load Mojang account list. No file path given and no default set.";
qCritical() << "Can't load Ely.by account list. No file path given and no default set.";
return false;
}

Expand Down Expand Up @@ -586,7 +588,7 @@ bool AccountList::saveList()
{
if (m_listFilePath.isEmpty())
{
qCritical() << "Can't save Mojang account list. No file path given and no default set.";
qCritical() << "Can't save Ely.by account list. No file path given and no default set.";
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions launcher/minecraft/auth/Yggdrasil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void Yggdrasil::refresh() {
req.insert("requestUser", false);
QJsonDocument doc(req);

QUrl reqUrl("https://authserver.mojang.com/refresh");
QUrl reqUrl("https://authserver.ely.by/auth/refresh");
QByteArray requestData = doc.toJson();

sendRequest(reqUrl, requestData);
Expand Down Expand Up @@ -129,7 +129,7 @@ void Yggdrasil::login(QString password) {

QJsonDocument doc(req);

QUrl reqUrl("https://authserver.mojang.com/authenticate");
QUrl reqUrl("https://authserver.ely.by/auth/authenticate");
QNetworkRequest netRequest(reqUrl);
QByteArray requestData = doc.toJson();

Expand Down Expand Up @@ -271,7 +271,7 @@ void Yggdrasil::processReply() {
case QNetworkReply::ContentGoneError: {
changeState(
AccountTaskState::STATE_FAILED_GONE,
tr("The Mojang account no longer exists. It may have been migrated to a Microsoft account.")
tr("The Ely.by account no longer exists.")
);
return;
}
Expand Down
49 changes: 28 additions & 21 deletions launcher/minecraft/auth/steps/MigrationEligibilityStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <QNetworkRequest>

#include "minecraft/auth/AuthRequest.h"
#include "Application.h"
#include "minecraft/auth/Parsers.h"

MigrationEligibilityStep::MigrationEligibilityStep(AccountData* data) : AuthStep(data) {
Expand All @@ -16,30 +16,37 @@ QString MigrationEligibilityStep::describe() {
}

void MigrationEligibilityStep::perform() {
auto url = QUrl("https://api.minecraftservices.com/rollout/v1/msamigration");
QNetworkRequest request = QNetworkRequest(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8());

AuthRequest *requestor = new AuthRequest(this);
connect(requestor, &AuthRequest::finished, this, &MigrationEligibilityStep::onRequestDone);
requestor->get(request);
m_filesNetJob.reset(new NetJob(tr("Injector URL download"), APPLICATION->network()));

m_filesNetJob->addNetAction(Net::Download::makeByteArray(QUrl(injector_download_url), m_response));

connect(m_filesNetJob.get(), &NetJob::succeeded, this, &MigrationEligibilityStep::onUrlRequestDone);
connect(m_filesNetJob.get(), &NetJob::failed, this, &MigrationEligibilityStep::downloadFailed);

m_filesNetJob->start();
}

void MigrationEligibilityStep::rehydrate() {
// NOOP, for now. We only save bools and there's nothing to check.
}

void MigrationEligibilityStep::onRequestDone(
QNetworkReply::NetworkError error,
QByteArray data,
QList<QNetworkReply::RawHeaderPair> headers
) {
auto requestor = qobject_cast<AuthRequest *>(QObject::sender());
requestor->deleteLater();

if (error == QNetworkReply::NoError) {
Parsers::parseRolloutResponse(data, m_data->canMigrateToMSA);
}
emit finished(AccountTaskState::STATE_WORKING, tr("Got migration flags"));
void MigrationEligibilityStep::onUrlRequestDone() {
m_filesNetJob.reset(new NetJob(tr("Injector download"), APPLICATION->network()));

m_filesNetJob->addNetAction(Net::Download::makeFile(QUrl(*m_response), "authlib-injector.jar"));

connect(m_filesNetJob.get(), &NetJob::succeeded, this, &MigrationEligibilityStep::onDownloadDone);
connect(m_filesNetJob.get(), &NetJob::failed, this, &MigrationEligibilityStep::downloadFailed);

m_filesNetJob->start();
}

void MigrationEligibilityStep::onDownloadDone()
{
emit finished(AccountTaskState::STATE_WORKING, tr("Downloaded injector"));
}

void MigrationEligibilityStep::downloadFailed(QString reason)
{
emit finished(AccountTaskState::STATE_OFFLINE, tr("Injector download failed"));
}
12 changes: 10 additions & 2 deletions launcher/minecraft/auth/steps/MigrationEligibilityStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

#include "QObjectPtr.h"
#include "minecraft/auth/AuthStep.h"
#include "net/NetJob.h"


static const char* const injector_download_url =
"https://raw.githubusercontent.com/Octol1ttle/PrismLauncher-elyby/develop/injector-download.url";
class MigrationEligibilityStep : public AuthStep {
Q_OBJECT

Expand All @@ -17,6 +19,12 @@ class MigrationEligibilityStep : public AuthStep {

QString describe() override;

private:
NetJob::Ptr m_filesNetJob;
std::shared_ptr<QByteArray> m_response = std::make_shared<QByteArray>();

private slots:
void onRequestDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
void onUrlRequestDone();
void onDownloadDone();
void downloadFailed(QString reason);
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void MinecraftProfileStepMojang::perform() {
}

// use session server instead of profile due to profile endpoint being locked for locked Mojang accounts
QUrl url = QUrl("https://sessionserver.mojang.com/session/minecraft/profile/" + m_data->minecraftProfile.id);
QUrl url = QUrl("https://account.ely.by/api/minecraft/session/profile/" + m_data->minecraftProfile.id);
QNetworkRequest req = QNetworkRequest(url);
AuthRequest *request = new AuthRequest(this);
connect(request, &AuthRequest::finished, this, &MinecraftProfileStepMojang::onRequestDone);
Expand Down
Loading

0 comments on commit 54daf32

Please sign in to comment.