Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Flathub](https://img.shields.io/flathub/v/org.unitystation.StationHub?style=flat-square)](https://flathub.org/apps/details/org.unitystation.StationHub)
[![Discord](https://img.shields.io/discord/273774715741667329?style=flat-square)](https://discord.com/invite/tFcTpBp)

StationHub is the official launcher for Unitystation, it handles downloading, updating, and joining servers.
This is the official launcher for Unitystation, it handles account creation, downloading, updating, and server joining.

## Tech-stack

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public List<Installation> GetInstallations()
throw new NotImplementedException();
}

public (bool, string) StartInstallation(Guid installationId, string? server = null, short? port = null)
public Task<(bool, string)> StartInstallation(Guid installationId, string? server = null, short? port = null)
{
throw new NotImplementedException();
}
Expand Down
Binary file added UnitystationLauncher/Assets/buttoncontext.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@
</screenshots>

<releases>
<release version="939" date="2025-08-10">
<description>
<p>New:</p>
<ul>
<li>login is now in the hub</li>
<li>Hub now supports a new authentication flow</li>
</ul>
</description>
</release>
<release version="938" date="2024-12-13">
<description>
<p>Fix:</p>
Expand Down
Binary file added UnitystationLauncher/Assets/userbg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added UnitystationLauncher/Assets/userico.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion UnitystationLauncher/Constants/ApiUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace UnitystationLauncher.Constants;

public static class ApiUrls
{
private static string ApiBaseUrl => "https://api.unitystation.org";
public static string ApiBaseUrl => "https://api.unitystation.org";
public static string ServerListUrl => $"{ApiBaseUrl}/serverlist";
public static string ValidateUrl => $"{ApiBaseUrl}/validatehubclient";
public static string ValidateTokenUrl => $"{ApiBaseUrl}/validatetoken?data=";
Expand All @@ -21,4 +21,7 @@ public static class ApiUrls
public static string TTSFiles => $"{CdnBaseUrl}/STTBundleTTS/TTS";
public static string TTSVersionFile => $"{TTSFiles}/version.txt";


public static string ApiBaseUrlLogin => "https://prod-api.unitystation.org";

}
2 changes: 1 addition & 1 deletion UnitystationLauncher/Constants/AppInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ public static class AppInfo
{
// Whenever you change the currentBuild here, please also update the one in
// UnitystationLauncher/Assets/org.unitystation.StationHub.metainfo.xml
public const int CurrentBuild = 938;
public const int CurrentBuild = 939;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,32 @@

public class PipeHubBuildCommunication : IDisposable
{
private NamedPipeServerStream _serverPipe;
private StreamReader? _reader;
private StreamWriter? _writer;
private static NamedPipeServerStream? _serverPipe;
private static StreamReader? _reader;
private static StreamWriter? _writer;

private const string Unitystation_Hub_Build_Communication = "Unitystation_Hub_Build_Communication";
public PipeHubBuildCommunication()
{
_serverPipe = new("Unitystation_Hub_Build_Communication", PipeDirection.InOut, 1,
_serverPipe?.Close();
_serverPipe?.Dispose();
_reader?.Close();
_reader?.Dispose();
_writer?.Close();
_writer?.Dispose();

_serverPipe = new(Unitystation_Hub_Build_Communication, PipeDirection.InOut, 1,

Check warning on line 30 in UnitystationLauncher/GameCommunicationPipe/PipeHubBuildCommunication.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

UnitystationLauncher/GameCommunicationPipe/PipeHubBuildCommunication.cs#L30

Remove this assignment of '_serverPipe' or initialize it statically.
PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
}

public async Task StartServerPipe()
public static async Task StartServerPipe()

Check failure on line 34 in UnitystationLauncher/GameCommunicationPipe/PipeHubBuildCommunication.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

UnitystationLauncher/GameCommunicationPipe/PipeHubBuildCommunication.cs#L34

Add a way to break out of this method's recursion.

Check warning on line 34 in UnitystationLauncher/GameCommunicationPipe/PipeHubBuildCommunication.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

UnitystationLauncher/GameCommunicationPipe/PipeHubBuildCommunication.cs#L34

The Cyclomatic Complexity of this method is 12 which is greater than 10 authorized.

Check warning on line 34 in UnitystationLauncher/GameCommunicationPipe/PipeHubBuildCommunication.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

UnitystationLauncher/GameCommunicationPipe/PipeHubBuildCommunication.cs#L34

This method 'StartServerPipe' has 103 lines, which is greater than the 80 lines authorized. Split it into smaller methods.
{
if (_serverPipe == null)
{
_serverPipe = new(Unitystation_Hub_Build_Communication, PipeDirection.InOut, 1,
PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
}

await _serverPipe.WaitForConnectionAsync();
_reader = new(_serverPipe);
_writer = new(_serverPipe);
Expand All @@ -42,7 +56,7 @@
{
Log.Error(e.ToString());
_serverPipe.Close();
_serverPipe = new("Unitystation_Hub_Build_Communication", PipeDirection.InOut,
_serverPipe = new(Unitystation_Hub_Build_Communication, PipeDirection.InOut,
1,
PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
await _serverPipe.WaitForConnectionAsync();
Expand Down Expand Up @@ -137,8 +151,11 @@

public void Dispose()
{
_serverPipe.Dispose();
_serverPipe?.Close();
_serverPipe?.Dispose();
_reader?.Close();
_reader?.Dispose();
_writer?.Close();
_writer?.Dispose();

GC.SuppressFinalize(this);
Expand Down
6 changes: 6 additions & 0 deletions UnitystationLauncher/Models/Api/CharacterTokenResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace UnitystationLauncher.Models.Api;

public class CharacterTokenResponse : JsonObject
{
public string token { get; set; }

Check warning on line 5 in UnitystationLauncher/Models/Api/CharacterTokenResponse.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Non-nullable property 'token' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 5 in UnitystationLauncher/Models/Api/CharacterTokenResponse.cs

View workflow job for this annotation

GitHub Actions / Build MacOS

Non-nullable property 'token' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 5 in UnitystationLauncher/Models/Api/CharacterTokenResponse.cs

View workflow job for this annotation

GitHub Actions / Build Linux Flatpak

Non-nullable property 'token' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check notice on line 5 in UnitystationLauncher/Models/Api/CharacterTokenResponse.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

UnitystationLauncher/Models/Api/CharacterTokenResponse.cs#L5

Rename property 'token' to match pascal case naming rules, consider using 'Token'.
}
7 changes: 6 additions & 1 deletion UnitystationLauncher/Models/Api/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
[Serializable]
public class Server
{
public Server(string forkName, int buildVersion, string serverIp, int serverPort)
public Server(string forkName, int buildVersion, string serverIp, int serverPort, int ServerConnectionNegotiationPort)

Check warning on line 11 in UnitystationLauncher/Models/Api/Server.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Non-nullable property 'ServerConnectionPublicKey' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 11 in UnitystationLauncher/Models/Api/Server.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Non-nullable property 'ServerPublicKey' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 11 in UnitystationLauncher/Models/Api/Server.cs

View workflow job for this annotation

GitHub Actions / Build MacOS

Non-nullable property 'ServerConnectionPublicKey' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 11 in UnitystationLauncher/Models/Api/Server.cs

View workflow job for this annotation

GitHub Actions / Build MacOS

Non-nullable property 'ServerPublicKey' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 11 in UnitystationLauncher/Models/Api/Server.cs

View workflow job for this annotation

GitHub Actions / Build Linux Flatpak

Non-nullable property 'ServerConnectionPublicKey' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 11 in UnitystationLauncher/Models/Api/Server.cs

View workflow job for this annotation

GitHub Actions / Build Linux Flatpak

Non-nullable property 'ServerPublicKey' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
{
ForkName = forkName;
BuildVersion = buildVersion;
ServerIp = serverIp;
ServerPort = serverPort;
this.ServerConnectionNegotiationPort = ServerConnectionNegotiationPort;
}

public string? ServerName { get; set; }
Expand All @@ -26,11 +27,15 @@
public int PlayerCountMax { get; set; }
public string ServerIp { get; }
public int ServerPort { get; }
public int ServerConnectionNegotiationPort { get; }
public string? WinDownload { get; set; }
public string? OsxDownload { get; set; }
public string? LinuxDownload { get; set; }

public string GoodFileVersion { get; set; } = string.Empty;
public string ServerPublicKey { get; set; }

public string ServerConnectionPublicKey { get; set; }

public (string, int) ForkAndVersion => (ForkName, BuildVersion);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace UnitystationLauncher.Models.Api;

public class ServerConnectionAuthenticationRequest
{
public string? ClientFork { get; set; }

public string? ClientVersion { get; set; }

public string? GoodFileVersion { get; set; }
public string? EncryptedSharedSecret { get; set; }
public string? EncryptedAccountID { get; set; }

public string? ConnectionPublicServerKey { get; set; }
}
190 changes: 190 additions & 0 deletions UnitystationLauncher/Models/AuthenticationStuff.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.Json.Nodes;
using Newtonsoft.Json;

namespace UnitystationLauncher.Models;

public abstract class JsonObject
{
public virtual string ToJson()
{
return JsonConvert.SerializeObject(this);
}

public virtual StringContent ToStringContent()
{
return new StringContent(ToJson(), Encoding.UTF8, "application/json");
}
}


[Serializable]
public class AccountRegister : JsonObject
{
[JsonProperty("unique_identifier")]
public string? UniqueIdentifier { get; set; }

[JsonProperty("email")]
public string? Email { get; set; }

[JsonProperty("username")]
public string? Username { get; set; }

[JsonProperty("password")]
public string? Password { get; set; }
}


[Serializable]
public class ForgotPasswordModel : JsonObject
{
[JsonProperty("email")]
public string? Email { get; set; }
}

[Serializable]
public class Registersha512token : JsonObject

Check notice on line 50 in UnitystationLauncher/Models/AuthenticationStuff.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

UnitystationLauncher/Models/AuthenticationStuff.cs#L50

Rename class 'Registersha512token' to match pascal case naming rules, consider using 'Registersha512Token'.
{
[JsonProperty("sha512_token")]
public string? sha512_token { get; set; }
}


[Serializable]
public class GetCharacterForkToken : JsonObject
{
[JsonProperty("fork_compatibility")]
public string? fork_compatibility { get; set; }
}


[Serializable]
public class AccountRegisterResponse : JsonObject
{
[JsonProperty("account")]
public AccountRegisterDetails Account { get; set; }

Check warning on line 69 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Non-nullable property 'Account' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 69 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux Flatpak

Non-nullable property 'Account' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}

[Serializable]
public class AccountRegisterDetails : JsonObject
{
[JsonProperty("unique_identifier")]
public string UniqueIdentifier { get; set; }

Check warning on line 76 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Non-nullable property 'UniqueIdentifier' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 76 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux Flatpak

Non-nullable property 'UniqueIdentifier' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonProperty("email")]
public string Email { get; set; }

Check warning on line 79 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Non-nullable property 'Email' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 79 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux Flatpak

Non-nullable property 'Email' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonProperty("username")]
public string Username { get; set; }

Check warning on line 82 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Non-nullable property 'Username' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 82 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux Flatpak

Non-nullable property 'Username' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}

[Serializable]
public class AccountLoginResponse : JsonObject
{
[JsonProperty("token")] public string Token { get; set; } = "";

[JsonProperty("account")]
public AccountGetResponse Account { get; set; }

Check warning on line 91 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Non-nullable property 'Account' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 91 in UnitystationLauncher/Models/AuthenticationStuff.cs

View workflow job for this annotation

GitHub Actions / Build Linux Flatpak

Non-nullable property 'Account' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}

[Serializable]
public class AccountGetResponse : JsonObject
{
[JsonProperty("unique_identifier")]
public string UniqueIdentifier { get; set; } = "";

[JsonProperty("username")]
public string Username { get; set; } = "";

[JsonProperty("is_verified")]
public bool IsVerified { get; set; }
}

[Serializable]
public class AccountLoginToken : JsonObject, ITokenAuthable
{
public string Token { get; set; } = "";
}

[Serializable]
public class AccountLogout : JsonObject, ITokenAuthable
{
public string Token { get; set; } = "";
}

[Serializable]
public class AccountResendEmailConfirmationRequest : JsonObject
{
[JsonProperty("email")]
public string Email { get; set; } = "";
}

[Serializable]
public class AccountLoginCredentials : JsonObject
{
[JsonProperty("email")]
public string Email { get; set; } = "";

[JsonProperty("password")] public string Password { get; set; } = "";
}

public class ApiResult<T> : JsonObject where T : JsonObject

{
public HttpStatusCode StatusCode { get; set; }
public T Data { get; set; }
public ApiHttpException? Exception { get; set; }

public bool IsSuccess => Exception == null;

private ApiResult(HttpStatusCode statusCode, T data, ApiHttpException? exception = null)
{
StatusCode = statusCode;
Data = data;
Exception = exception;
}

public static ApiResult<T> Success(HttpStatusCode statusCode, T data) => new(statusCode, data);
public static ApiResult<T> Failure(HttpStatusCode statusCode, T data, ApiHttpException exception) => new(statusCode, data, exception);
}

/// <summary>
/// Error class for any HTTP-related errors as returned by the API server.
/// </summary>
public class ApiHttpException : Exception
{
public HttpStatusCode StatusCode { get; private set; }

public ApiHttpException(string message, HttpStatusCode code) : base(message)
{
StatusCode = code;
}
}

/// <summary>
/// Marks an API request as having or requiring an authentication token.
/// </summary>
public interface ITokenAuthable
{
string Token { get; }
}

/// <summary>
/// Error class for any usage-specific API errors as returned by the API server.
/// </summary>
public class ApiRequestException : ApiHttpException
{
/// <summary>A list of all error messages returned by the API server.</summary>
/// <remarks>You can use <c>Message</c> to get the first one.</remarks>
public List<string> Messages { get; set; }

public ApiRequestException(string message, HttpStatusCode statusCode) : base(message, statusCode)
{
Messages = new List<string>();
}
}

2 changes: 2 additions & 0 deletions UnitystationLauncher/Models/Installation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class Installation
public string? ForkName { get; set; }
public int BuildVersion { get; set; }

public string? GoodFileVersion { get; set; }

public string? InstallationPath { get; set; }

public DateTime LastPlayedDate { get; set; }
Expand Down
Loading
Loading