15 Commits

Author SHA1 Message Date
sindoring 32dd46fdf4 Publish signed launcher 1.0.7 AppCast
Track the exact production feed for 1.0.7+10. Verified full FVM format/analyze and all 76 tests, DSA signature, published AppCast and SHA-256 of the versioned and stable installers: 53d005a62f154695f9c26a780c80498b5a7d8ce8ec50653d517c44ecc4bd15a8. Localized client 53b09073 and all three ruRU archives were published and verified beforehand.
2026-10-10 17:55:00 +04:00
sindoring f834c5fa86 Synchronize the client and select installed language packs (#3)
The launcher synchronizes the current native client, retains manifest-listed ruRU archives and launches the game with WOW_LOCALE=auto. Includes the prepared cleanup of obsolete Extentions directories in both client roots while preserving manifest-required files and unrelated user state.

Version: 1.0.7+10. Deployment now judges native OpenSSL commands by their exit codes while retaining key and signature verification.

Verified on Windows through FVM: full format/analyze, all 76 tests, production dry run, x64 runtime imports and DSA installer signature. The original dirty checkout was preserved. Publication follows the localized client release.
2026-10-10 16:50:35 +03:00
sindoring d3d19bfaeb обновил лаунчер под новую версию веба 2026-10-04 13:19:12 +04:00
sindoring dd189fe48f убрана информация о паролях пользователя 2026-08-30 02:16:26 +04:00
sindoring 25e7ad156b wip 2026-08-17 20:25:08 +04:00
sindoring b64dffca9a закомментил проблемные тесты, мешали деплою 2026-08-07 12:08:49 +04:00
sindoring 95efa2bc31 Merge pull request 'fix(sync): ignore AddOns subfolders to make sure we do not overwrite user's addons' (#2) from hotfix/ignore-addons into master
Reviewed-on: #2
2026-08-07 10:37:23 +03:00
gasaichandesu e98bcf407c fix(sync): ignore AddOns subfolders to make sure we do not overwrite user's addons 2026-08-07 05:15:49 +04:00
sindoring f395d2515d fix 2026-07-28 21:28:53 +04:00
sindoring 3b01afeeb2 фиксы 2026-07-28 21:25:06 +04:00
sindoring b7e6a4b393 fix 2026-07-28 21:12:21 +04:00
sindoring 33659f6c05 fix 2026-07-28 20:56:19 +04:00
sindoring bd1e464b5a деплой 2026-07-28 20:51:54 +04:00
sindoring 3d43420676 fix 2026-07-28 20:48:31 +04:00
sindoring c4576c84bb Merge pull request 'chore: New UI implementation' (#1) from feat/ui into master
Reviewed-on: #1
2026-07-28 19:44:14 +03:00
40 changed files with 2090 additions and 300 deletions
+7
View File
@@ -0,0 +1,7 @@
AWS_ACCESS_KEY_ID=replace_with_access_key_id
AWS_SECRET_ACCESS_KEY=replace_with_secret_access_key
AWS_DEFAULT_REGION=ru-central1
AWS_BUCKET=warcraft-client
AWS_ENDPOINT=https://storage.yandexcloud.net
AWS_USE_PATH_STYLE_ENDPOINT=true
LAUNCHER_AUTH_KEY=replace_with_launcher_auth_key
+5
View File
@@ -49,3 +49,8 @@ app.*.map.json
# Local launcher update signing material
.moonwell_signing/
# Local production deployment credentials
.env
.env.*
!.env.example
+3 -2
View File
@@ -1,3 +1,4 @@
{
"dart.flutterSdkPath": ".fvm/versions/stable"
}
"dart.flutterSdkPath": ".fvm/versions/stable",
"cmake.sourceDirectory": "C:/Users/sindo/moonwell_launcher/windows"
}
+22 -3
View File
@@ -6,9 +6,10 @@ change.
## Project Shape
MoonWell Launcher is a Flutter desktop app for a private World of Warcraft:
Wrath of the Lich King server. It logs players in, downloads and synchronizes
client files, displays launcher news, and starts `Wow.exe`.
MoonWell Launcher is a Flutter desktop app for a private World of Warcraft
1.12.1 server running vMaNGOS. It logs players in, downloads and synchronizes
client files, displays launcher news, and starts the Rust MoonWell client
(`MoonWell.exe` on Windows or `MoonWell.app` on macOS).
Important areas:
@@ -75,6 +76,10 @@ The optional Windows self-update feed is also compile-time configuration:
Production AppCast feeds must be public HTTPS URLs. Omit the setting to disable
self-update in local builds.
`MOONWELL_AUTH_ADDRESS` optionally pins the game's auth endpoint as `host[:port]`
(default port 3724). Otherwise it is read from `realmlist.wtf` in the selected
installation root. A realm's world port is not the auth port.
Do not commit private credentials, production secrets, temporary bearer tokens,
or local-only API URLs.
@@ -89,10 +94,24 @@ or local-only API URLs.
Windows updates use WinSparkle/AppCast and the signed Inno Setup artifact;
they are separate from game-client synchronization.
- The server manifest is the source of truth for client files.
- Sync removes files absent from the manifest under `Data` and `WoW/Data`,
plus legacy `WoW.exe` and DLLs directly in the installation root or `WoW`.
Also clean obsolete `Extentions` directories in either client root and remove
the directory itself when no manifest files require it.
Remove unused Data subdirectories only after their children, without recursive
deletion. Preserve unrelated files and user state outside these areas.
- Language archives under `Data/ruRU` or `WoW/Data/ruRU` use the regular manifest sync.
Pass `WOW_LOCALE=auto` to the game so its selected install determines the locale.
- Downloads must write to `*.moonwell.part`, verify size and SHA-256, then
replace the destination file only after successful verification.
- Local scans should ignore volatile client directories and launcher metadata:
`Cache`, `Errors`, `Logs`, `Screenshots`, `WTF`, and `.moonwell_launcher`.
- MoonWell player state lives in `benilla-config` outside the WoW data and, on
macOS, outside the application bundle. Exclude it from verification too.
- Request game tickets for build 5875. Pass their account and ticket as
`WOW_USER` and `WOW_PASS` in the child environment, never in arguments or
persistent storage. Starting MoonWell must not edit `WTF/Config.wtf` or clear
the install's `Cache`.
- Path normalization and traversal checks are safety-critical. Do not bypass
`GameInstallationService.resolveClientPath` for manifest-relative paths.
- `lib/service_container.config.dart` is generated by injectable. Do not
+56 -3
View File
@@ -1,9 +1,17 @@
# MoonWell Launcher
MoonWell Launcher is the desktop launcher for MoonWell, a private World of
Warcraft: Wrath of the Lich King server focused on a player-friendly experience
Warcraft 1.12.1 server on vMaNGOS, focused on a player-friendly experience
without excessive grind and with stronger social play.
The Windows executable requests administrator privileges on startup so it can
synchronize game clients installed under protected directories such as
`Program Files`.
Launcher version labels are read from the packaged application metadata. Change
only the `version: X.Y.Z+N` value in `pubspec.yaml`; login, launcher status,
Windows metadata, installer packaging, and AppCast are synchronized from it.
The launcher is responsible for:
- logging in to a player's MoonWell account
@@ -11,7 +19,18 @@ The launcher is responsible for:
- downloading and synchronizing client files
- displaying launcher news
- displaying the live status of the first configured realm
- launching the game client
- requesting a single-use game ticket and launching the game client without
putting credentials in command-line arguments
- starting the Rust MoonWell client on Windows and macOS
During synchronization, the manifest is authoritative for `Data/` and
`WoW/Data/`: files absent from it and unused subdirectories are removed.
Legacy `WoW.exe` and DLLs in the installation root or `WoW/` are also removed
when absent from the manifest. Required DLLs stay; player settings, addons,
logs, screenshots, and other files outside these cleanup areas are preserved.
The obsolete `Extentions/` directory in either client root is cleaned the same
way and removed when no manifest files require it.
Cleanup runs even when all manifest files are already up to date.
## Stack
@@ -51,6 +70,17 @@ Set the public AppCast feed URL to enable Windows launcher self-updates:
The updater is disabled when `MOONWELL_APPCAST_URL` is omitted. Production
feeds must use HTTPS.
The game's auth endpoint is read from `realmlist.wtf` in the selected client
folder. For builds that pin an endpoint, set
`--dart-define=MOONWELL_AUTH_ADDRESS=login.example:3724` instead. This endpoint is
the vMaNGOS auth server, separate from the realm's world port and the Web API.
Russian 1.12.1 language archives are regular manifest files under `Data/ruRU`
(or `WoW/Data/ruRU` for a nested install). They are downloaded and verified with
the same size and SHA-256 checks as the base client. The launcher passes
`WOW_LOCALE=auto` to the game: an installed pack selects Russian, and a base-only
install selects English, regardless of the launcher's inherited environment.
Example run command:
```powershell
@@ -108,6 +138,10 @@ Remove `-DryRun` only after reviewing the generated installer and AppCast.
See `docs/production_deploy.md` for required environment variables, production
defaults, safety checks, and failure recovery.
Local deploy credentials are read from the ignored root `.env`; use
`.env.example` as the safe template. Process and CI environment variables
override values from the file.
## Architecture
The UI lives in `lib/app`. Presentation-only design-system components live in
@@ -128,7 +162,26 @@ The launcher sync flow is manifest-based:
6. remove stale files outside ignored directories
7. download missing or changed files to temporary part files
8. verify size and SHA-256 before replacing client files
9. launch `Wow.exe` from the selected client directory
9. request a short-lived game ticket for build 5875 and launch MoonWell from the
selected client directory with authorization in its child environment
The selected folder must contain `MoonWell.exe` on Windows, or `MoonWell.app`
on macOS, and your own 1.12.1 data in `Data/` or `WoW/Data/`. macOS launches the
bundle's `Contents/MacOS/launch` directly so the launcher keeps a handle to the
game process. `benilla-config/` stays beside the EXE or `.app`.
The ticket's account and temporary password become `WOW_USER` and `WOW_PASS`;
the launcher also sets `WOW_HOST`, `WOW_DATA`, and `BENILLA_HOME` for that child
only. Launching does not clear the WoW cache or modify `WTF/Config.wtf`.
The ticket is consumed by `realmd` after a successful proof; a new login attempt
requires a fresh ticket from the launcher.
In the local WSL deployment, Web API traffic uses the web service's published
port 8080, while game authorization and the world use ports 3724 and 8085.
The web application writes ticket SRP data to `realmd.launcher_ticket`; the
modified auth server consumes it. No additional web/core endpoint is required.
Distribute the MoonWell executable and the 1.12.1 data in the client manifest
before enabling automatic synchronization for that distribution.
See `docs/launcher_web_api_spec.md` for the API and sync contract.
+6
View File
@@ -7,6 +7,12 @@
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
exclude:
- build/**
- windows/**
- macos/**
- linux/**
include: package:flutter_lints/flutter.yaml
linter:
+8 -16
View File
@@ -1,22 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
<channel>
<title>MoonWell Launcher</title>
<description>Обновления MoonWell Launcher</description>
<description>MoonWell Launcher updates</description>
<language>ru</language>
<item>
<title>MoonWell Launcher 1.0.1</title>
<description>Обновление интерфейса, синхронизации клиента и интеграции с сервером MoonWell.</description>
<pubDate>Tue, 28 Jul 2026 20:33:00 +0400</pubDate>
<enclosure
url="https://storage.yandexcloud.net/warcraft-client/moonwell_launcher_setup.exe"
sparkle:version="1.0.1"
sparkle:shortVersionString="1.0.1"
sparkle:os="windows"
sparkle:dsaSignature="MD4CHQCdoCW5jNymVlRblQpqy8C+jw4W0rVFQX0Bk25PAh0Av2ZcFYwZFQBQlAstQXna/PsuMNWIzXF4jpDuSA=="
length="19989772"
type="application/octet-stream" />
<title>MoonWell Launcher 1.0.7</title>
<description>Поддержка русского языкового пакета и очистка устаревших файлов клиента MoonWell.</description>
<pubDate>Sat, 10 Oct 2026 17:51:55 +04:00</pubDate>
<enclosure url="https://storage.yandexcloud.net/warcraft-client/moonwell_launcher/releases/1.0.7/moonwell_launcher_setup.exe" sparkle:version="1.0.7+10" sparkle:shortVersionString="1.0.7" sparkle:os="windows" sparkle:dsaSignature="MDwCHHbQTrZMKzEa5zEXYxAXyLJnyGIHAGWcGj9TbXYCHGkbCgCb+dt3DR5u/ToJyoEtXULYN8cewgbZVHs=" length="20595752" type="application/octet-stream" />
</item>
</channel>
</rss>
</rss>
+12 -3
View File
@@ -9,6 +9,11 @@ WinSparkle shows its native prompt only when a newer version is available.
Missing configuration, network failures, and malformed feeds do not block the
launcher. Periodic WinSparkle checks are disabled.
`MoonWell.exe` uses the Windows `requireAdministrator` execution level. Users
therefore receive a UAC prompt whenever the launcher starts. This is required
to synchronize game files installed in protected directories. The per-user
Inno Setup installer remains configured with `PrivilegesRequired=lowest`.
## Build Configuration
Pass the public feed URL at build time:
@@ -45,8 +50,11 @@ certificate would not establish trust on player machines.
## Version and AppCast Contract
Increase the `X.Y.Z` version in `pubspec.yaml` for every launcher release. A
build-number-only change such as `1.0.0+2` is not sufficient because WinSparkle
compares the Windows product version. Pass the same `X.Y.Z` value to Inno Setup:
build-number-only change such as `1.0.0+2` is not sufficient for a public
release. Flutter writes the complete `X.Y.Z+N` value into the Windows
`ProductVersion`; `sparkle:version` must match that complete value exactly.
Use `sparkle:shortVersionString` for the human-readable `X.Y.Z` value. Pass
`X.Y.Z` without the build suffix to Inno Setup:
```powershell
ISCC.exe /DMyAppVersion=1.1.0 installer\moonwell_launcher.iss
@@ -70,7 +78,8 @@ Use a public AppCast with absolute URLs:
<pubDate>Sun, 21 Jun 2026 12:00:00 +0400</pubDate>
<enclosure
url="https://storage.yandexcloud.net/warcraft-client/moonwell_launcher_setup.exe"
sparkle:version="1.1.0"
sparkle:version="1.1.0+3"
sparkle:shortVersionString="1.1.0"
sparkle:os="windows"
sparkle:dsaSignature="SIGNATURE_FROM_SIGN_UPDATE"
length="ACTUAL_INSTALLER_SIZE_IN_BYTES"
+88 -16
View File
@@ -8,7 +8,7 @@ This document specifies the current launcher behavior for:
- installation directory selection
- local file scan and hash calculation
- manifest-based synchronization
- client launch from `Wow.exe`
- launch and game authorization for the Rust MoonWell 1.12.1 client
The launcher no longer uses S3/MinIO directly. All server interaction goes
through the Web API.
@@ -18,6 +18,7 @@ through the Web API.
The launcher API base URL is provided via:
- `MOONWELL_API_BASE_URL`
- optional `MOONWELL_AUTH_ADDRESS` for the game auth endpoint (`host[:port]`)
Current integration mode is compile-time:
@@ -35,6 +36,7 @@ The launcher uses these endpoints from `openapi.json`:
5. `GET /api/launcher/news`
6. `GET /api/launcher/realms`
7. `GET /api/launcher/account`
8. `POST /api/launcher/game-ticket`
Registration sequence:
@@ -106,6 +108,20 @@ Account sequence:
3. The response `balance` field is intentionally ignored and never displayed.
4. Account metadata failures do not block patching or launching the game.
Game authorization sequence:
1. Immediately before starting the game, the launcher calls
`POST /api/launcher/game-ticket` with bearer authentication and
`{ "client_build": 5875 }` in the JSON body.
2. The API returns `account`, a 16-character `A-Z0-9` single-use `ticket`, and
`expires_at`. The account is 3–16 uppercase `A-Z0-9` characters. The ticket
must remain valid for at least five more seconds, including at process start.
3. Issuing a ticket atomically revokes any previous unused game ticket for the
same account. Production lifetime must not exceed 60 seconds.
4. The launcher never persists or logs the ticket.
5. The auth server uses the ticket as the temporary SRP password and consumes
it atomically after a successful logon proof.
## Installation Directory Rules
The user selects a single installation root directory.
@@ -121,13 +137,17 @@ Path safety rules:
## Ignored Directories
The launcher excludes these top-level directories from verification:
Unmanaged files in these directories outside `Data/` and `WoW/Data/` are
preserved and excluded from verification:
- `Cache`
- `Errors`
- `Logs`
- `Screenshots`
- `WTF`
- `benilla-config`
- `.moonwell_launcher`
- `Interface/AddOns`
Files under these directories:
@@ -135,15 +155,38 @@ Files under these directories:
- do not participate in local `buildHash`
- are not compared against server manifest
Inside `Data/` and `WoW/Data/`, the manifest is authoritative for every file,
including nested files whose names contain `wtf`, `cache`, or `addons`.
The exclusions above do not exempt files inside Data from cleanup.
## Local Scan
For every non-ignored file in the installation directory, the launcher computes:
For every existing manifest file in the installation directory, the launcher computes:
- normalized relative path
- file size in bytes
- file `sha256`
The result is stored as a `ClientInstallationSnapshot`.
The result is stored as a `ClientInstallationSnapshot`. Paths are always relative
to the selected installation root, including files in nested directories.
The scan separately collects stale paths without hashing their contents:
- every file absent from the manifest in `Data/` and `WoW/Data/`
- every file absent from the manifest in obsolete `Extentions/` and
`WoW/Extentions/` directories, including unused subdirectories and the
Extentions directory itself when no manifest files require it
- `WoW.exe` and `*.dll` absent from the manifest directly in the installation
root or `WoW/` (binary names are matched without case sensitivity)
- unused Data subdirectories, ordered after their children; the Data roots and
directories needed by manifest files are retained
These paths do not contribute to `buildHash`, but prevent sync from completing
until cleanup and final verification succeed. Other unmanaged files are preserved.
On Windows, manifest membership checks for cleanup ignore path letter case.
Directory links are not traversed during cleanup. Links absent from the manifest
inside Data are removed as links, and deletion through a parent pointing outside
the installation is rejected. Directory deletion is never recursive.
## Hash Cache
@@ -207,15 +250,15 @@ The current sync flow is:
2. Scan local installation.
3. Compute local `buildHash`.
4. Compare local files to manifest files by `path`, `size`, and `sha256`.
5. Identify stale local files that are not present in the manifest.
5. Identify stale paths in the cleanup areas described above.
6. If local `buildHash` matches server `buildHash` and there are no stale files
and no mismatches, finish successfully.
7. Delete stale local files outside ignored directories.
7. Delete stale paths, including unused Data subdirectories after their children.
8. Download changed and missing files.
9. Verify every downloaded file by `sha256`.
10. Re-scan the installation.
11. Recompute local `buildHash`.
12. Fail if final snapshot still differs from manifest.
12. Fail if final snapshot still differs from manifest or stale paths remain.
## Pause and Resume Semantics
@@ -230,15 +273,38 @@ Pause is implemented as cooperative cancellation:
When the user presses `Play`:
1. launcher resolves `<install-root>/Wow.exe`
2. launcher clears `<install-root>/Cache`
3. launcher starts `Wow.exe` with working directory set to installation root
and retains a process handle
4. while the process is alive, the launcher disables repeated game launches
1. launcher requests a single-use game ticket for build 5875
2. launcher resolves `<install-root>/MoonWell.exe` on Windows,
`<install-root>/MoonWell.app/Contents/MacOS/launch` on macOS, or
`<install-root>/MoonWell` on Linux
3. launcher reads the auth address from `MOONWELL_AUTH_ADDRESS` when configured,
otherwise from `set realmlist <host[:port]>` in `realmlist.wtf`; this file is
never modified and the default auth port is 3724
4. launcher resolves the player's data in `Data/`, falling back to `WoW/Data/`,
and verifies that the ticket still has at least five seconds of validity
5. launcher starts MoonWell with working directory set to the installation root,
no authorization command-line arguments, and these child environment values:
- `WOW_USER=<account>`
- `WOW_PASS=<ticket>`
- `WOW_HOST=<auth-address>`
- `WOW_DATA=<absolute-data-directory>`
- `BENILLA_HOME=<install-root>/benilla-config`
- `WOW_LOCALE=auto` (select the installed `Data/ruRU` or `WoW/Data/ruRU` language pack,
otherwise English; override any locale inherited from the launcher's parent)
6. launcher retains a process handle; while the process is alive, it disables repeated game launches
and client synchronization
5. when the process exits, the launcher returns to the ready-to-play state
7. when the process exits, the launcher returns to the ready-to-play state
If `Wow.exe` is missing, launch fails with an error.
Launching never edits `WTF/Config.wtf` or clears `Cache`. macOS executes the
bundle launcher directly; that script `exec`s MoonWell so the handle follows
the game rather than an `open` helper. Settings remain outside the `.app`.
If the executable, data directory, or auth endpoint is missing or invalid,
launch fails with an error. A consumed ticket cannot authenticate again; close
the client and press Play for a fresh ticket after a session ends.
Language archives are ordinary client-manifest entries, including their nested paths,
sizes and SHA-256 hashes. Synchronization verifies and retains required `ruRU` files
and removes obsolete archives under the same manifest-authoritative Data policy.
## Error Behavior
@@ -252,7 +318,8 @@ The launcher surfaces errors for:
- checksum mismatch after download
- missing downloaded temp files before verification
- final verification mismatch after update
- missing `Wow.exe`
- missing MoonWell executable, WoW data, or game auth endpoint
- invalid, expired, or unavailable game ticket
## Tested Invariants
@@ -260,8 +327,13 @@ The automated tests cover:
- deterministic `buildHash`
- path normalization used by `buildHash`
- exclusion of ignored directories during local scan
- preservation of user state and unrelated unmanaged files during cleanup
- removal of unmanaged Data files, unused subdirectories, WoW.exe, DLLs, and
obsolete Extentions directories
- preservation of manifest-listed DLLs and WoW.exe
- cache cleanup behavior
- safe path resolution
- sync flow with fully up-to-date client
- sync flow with stale files and changed files
- cleanup when all manifest files are already up to date
- rejection of stale paths remaining after final verification
+55 -9
View File
@@ -22,7 +22,7 @@ release that has not passed the remote download and checksum verification.
The release machine needs:
- latest stable Flutter and Dart available on `PATH`
- latest stable Flutter and Dart selected through FVM
- Inno Setup 6, normally installed at
`C:\Program Files (x86)\Inno Setup 6\ISCC.exe`
- OpenSSL, normally supplied by Git for Windows at
@@ -37,14 +37,36 @@ Install the Python dependency if required:
python -m pip install boto3
```
The PowerShell entry point calls `tool/upload_launcher_release.py` as a regular
Python file. Keep this helper beside the deployment script; it performs the S3
upload and verifies the uploaded object's byte length.
Back up `.moonwell_signing\dsa_priv.pem` in the project secret store. Never
commit it, upload it to Object Storage, or send it through chat. Losing this key
prevents released launchers from accepting future updates.
## Required Environment
The deploy script copies the x64 Visual C++ CRT DLLs from Visual Studio's
redistributable directory into the application folder before compiling the
installer. Use `-VcRuntimePath` to override the detected directory. This keeps
the per-user installer usable without installing system runtimes as an admin;
Windows 10/11 supplies the Universal CRT. See Microsoft's
[app-local deployment guidance](https://learn.microsoft.com/en-us/cpp/windows/choosing-a-deployment-method?view=msvc-170).
The script reads secrets and storage configuration only from environment
variables:
## Local `.env`
For local releases, copy `.env.example` to `.env` and fill in the real values.
The repository ignores `.env` and every `.env.*` variant except the safe
`.env.example` template.
```powershell
Copy-Item .env.example .env
```
The deploy script loads `.env` automatically. Variables already present in the
current process or CI environment take precedence over the file. Use
`-EnvFile C:\secure\moonwell.env` to select a different local file.
The following values are supported:
| Variable | Required | Purpose |
| --- | --- | --- |
@@ -56,8 +78,8 @@ variables:
| `AWS_BUCKET` | optional | Defaults to `warcraft-client` |
| `AWS_USE_PATH_STYLE_ENDPOINT` | optional | Defaults to `true` |
Load secrets from the team secret manager into the current PowerShell process.
Do not put real values in a tracked `.env` file or in the script.
Production CI should load these values from the team secret manager instead of
creating `.env`. Never commit the real file or put its contents into logs.
## Prepare a Release
@@ -67,9 +89,16 @@ Increase both parts of the version in `pubspec.yaml`:
version: 1.0.2+3
```
`X.Y.Z` is the WinSparkle release version. `N` is the Flutter build number.
Every production release must have an `X.Y.Z` value greater than the version
currently published in AppCast.
`X.Y.Z` is the public launcher version. `N` is the Flutter build number.
Flutter places the complete `X.Y.Z+N` value in the Windows `ProductVersion`,
so the script writes that same complete value to `sparkle:version` and writes
`X.Y.Z` to `sparkle:shortVersionString`. Every production release must have an
`X.Y.Z` value greater than the release currently published in AppCast.
The UI reads `X.Y.Z` from the packaged application metadata through
`package_info_plus`. Version labels on the login and launcher screens therefore
update automatically after changing `pubspec.yaml`; do not add separate
hardcoded version strings.
Run a dry run first:
@@ -103,6 +132,19 @@ The production defaults are:
- installer:
`https://storage.yandexcloud.net/warcraft-client/moonwell_launcher_setup.exe`
Use a versioned `-S3Key`, such as
`moonwell_launcher/releases/1.0.4/moonwell_launcher_setup.exe`, to preserve the
installer referenced by each signed AppCast. After the feed has been verified,
publish the same verified installer at `moonwell_launcher_setup.exe` for the
website's stable download link. Set `MOONWELL_CLIENT_OBJECT_KEY` to that key in
the web app when its download button should install the launcher. The game
files use their separate client manifest and release prefix.
For FVM, `-FlutterCommand` and `-DartCommand` can point to local `.cmd` wrappers
that run `call fvm flutter %*` and `call fvm dart %*` respectively and return
`exit /b %errorlevel%`. Keep wrappers inside ignored `build/` and ensure the
FVM executable is on `PATH` or use its absolute path in the wrapper.
On success, the command prints the deployed version, installer URL, SHA-256,
and AppCast URL. The tracked root `appcast.xml` contains the exact feed sent to
the server.
@@ -127,6 +169,10 @@ for all endpoint, bucket, key, and signing-path overrides.
The script stops on the first failed command.
External commands are judged by their exit codes. Windows PowerShell may display
normal OpenSSL stderr notices as error records; they do not fail a successful
command. Key matching and installer-signature verification still must pass.
- Failure before S3 upload leaves production unchanged.
- Failure after S3 upload but before AppCast publication leaves clients on the
preceding AppCast. Fix the issue and rerun the same release.
+6
View File
@@ -44,5 +44,11 @@ Source: "{#MyBuildDir}\*"; DestDir: "{app}"; Excludes: "moonwell_launcher.exe";
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Registry]
Root: HKCU; Subkey: "Software\Classes\moonwell"; ValueType: string; ValueName: ""; ValueData: "URL:MoonWell Launcher Protocol"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\Classes\moonwell"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""
Root: HKCU; Subkey: "Software\Classes\moonwell\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKCU; Subkey: "Software\Classes\moonwell\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
+6 -6
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:moonwell_launcher/app/launcher_version.dart';
import 'package:moonwell_launcher/app/design_system/mw_shells.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
@@ -47,6 +48,7 @@ class _MwAuthenticationFormState extends State<MwAuthenticationForm> {
Widget build(BuildContext context) {
final accent = MoonWellDesignTokens.of(context).accent;
final registering = widget.mode == MwAuthenticationMode.registration;
final launcherVersion = LauncherVersionScope.of(context);
return AutofillGroup(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -259,10 +261,10 @@ class _MwAuthenticationFormState extends State<MwAuthenticationForm> {
),
),
const SizedBox(height: 28),
const Center(
Center(
child: Text(
'MOONWELL · V 1.0.0 · PLAY.MOON-WELL.ONLINE',
style: TextStyle(
'MOONWELL · V $launcherVersion · PLAY.MOON-WELL.ONLINE',
style: const TextStyle(
fontFamily: 'JetBrains Mono',
color: Color(0x52ECE4D0),
fontSize: 8,
@@ -311,9 +313,7 @@ class _Tab extends StatelessWidget {
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: selected ? accent : const Color(0x247FB8D4),
),
bottom: BorderSide(color: selected ? accent : Colors.transparent),
),
),
child: Text(
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:moonwell_launcher/app/launcher_version.dart';
import 'package:moonwell_launcher/app/design_system/mw_primitives.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
@@ -718,37 +719,40 @@ class MwLauncherStatusBar extends StatelessWidget {
final String? eta;
final String? buildHash;
@override
Widget build(BuildContext context) => Container(
padding: const EdgeInsets.symmetric(horizontal: 32),
decoration: const BoxDecoration(
color: Color(0xD904060E),
border: Border(top: BorderSide(color: _border)),
),
child: DefaultTextStyle(
style: const TextStyle(
fontFamily: 'JetBrains Mono',
color: _muted,
fontSize: 8,
letterSpacing: .8,
Widget build(BuildContext context) {
final launcherVersion = LauncherVersionScope.of(context);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 32),
decoration: const BoxDecoration(
color: Color(0xD904060E),
border: Border(top: BorderSide(color: _border)),
),
child: Row(
children: [
Expanded(
child: Text(status, maxLines: 1, overflow: TextOverflow.ellipsis),
),
if (fileCount != null) Text(fileCount!),
if (speed != null) ...[const SizedBox(width: 24), Text(speed!)],
if (eta != null) ...[const SizedBox(width: 24), Text(eta!)],
if (buildHash != null) ...[
child: DefaultTextStyle(
style: const TextStyle(
fontFamily: 'JetBrains Mono',
color: _muted,
fontSize: 8,
letterSpacing: .8,
),
child: Row(
children: [
Expanded(
child: Text(status, maxLines: 1, overflow: TextOverflow.ellipsis),
),
if (fileCount != null) Text(fileCount!),
if (speed != null) ...[const SizedBox(width: 24), Text(speed!)],
if (eta != null) ...[const SizedBox(width: 24), Text(eta!)],
if (buildHash != null) ...[
const SizedBox(width: 24),
Text(buildHash!),
],
const SizedBox(width: 24),
Text(buildHash!),
Text('Лаунчер v$launcherVersion'),
],
const SizedBox(width: 24),
const Text('Лаунчер v1.0.0'),
],
),
),
),
);
);
}
}
class MwAccountAffordance extends StatelessWidget {
+11 -9
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:moonwell_launcher/app/launcher_version.dart';
import 'package:moonwell_launcher/app/design_system/mw_launcher_components.dart';
import 'package:moonwell_launcher/app/design_system/mw_window_chrome.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
@@ -302,21 +303,22 @@ class _LoginStatusBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final launcherVersion = LauncherVersionScope.of(context);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 32),
decoration: const BoxDecoration(
color: Color(0xD904060E),
border: Border(top: BorderSide(color: Color(0x247FB8D4))),
),
child: const Row(
child: Row(
children: [
Text('Версия лаунчера 1.0.0'),
SizedBox(width: 24),
Text('·'),
SizedBox(width: 24),
Text('Соединение защищено TLS'),
Spacer(),
Text('© 2026 MoonWell'),
Text('Версия лаунчера $launcherVersion'),
const SizedBox(width: 24),
const Text('·'),
const SizedBox(width: 24),
const Text('Соединение защищено TLS'),
const Spacer(),
const Text('© 2026 MoonWell'),
],
),
);
@@ -524,7 +526,7 @@ class _HeroCopy extends StatelessWidget {
),
const SizedBox(height: 14),
const Text(
'Wrath of the Lich King · приватный сервер',
'World of Warcraft 1.12.1 · приватный сервер',
style: TextStyle(
fontFamily: 'Cormorant Garamond',
fontStyle: FontStyle.italic,
+14 -3
View File
@@ -80,6 +80,7 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
Timer? _realmRefreshTimer;
int? _activeGamePid;
bool _pauseRequested = false;
bool _gameLaunchPending = false;
Future<void> _onHomeScreenLoad(
HomeScreenLoad event,
@@ -337,17 +338,25 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
HomeScreenPlayRequested event,
Emitter<HomeScreenState> emit,
) async {
if (_gameLaunchPending || state.model.isGameRunning) {
return;
}
final outputPath = state.model.outputPath;
if (outputPath == null) {
emit(_buildErrorState('Сначала выберите папку установки.'));
return;
}
_gameLaunchPending = true;
try {
final installationDir = outputPath.toFilePath();
await _gameInstallationService.clearCache(installationDir);
final authorization = await _launcherApiClient.issueGameTicket(
_session.accessToken,
);
final process = await _gameInstallationService.launchGame(
installationDir,
authorization: authorization,
);
_activeGamePid = process.pid;
unawaited(
@@ -370,7 +379,7 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
model: state.model.copyWith(
phase: HomeScreenPhase.readyToPlay,
isGameRunning: true,
statusText: 'Игра запущена. Папка Cache очищена перед стартом.',
statusText: 'MoonWell запущен.',
errorMessage: null,
),
),
@@ -382,6 +391,8 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
errorMessage: _formatError(error),
),
);
} finally {
_gameLaunchPending = false;
}
}
@@ -405,7 +416,7 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
isGameRunning: false,
statusText: hasClientExecutable
? 'Игра закрыта. Клиент готов к запуску.'
: 'Игра закрыта, но Wow.exe больше не найден.',
: 'Игра закрыта, но клиент MoonWell больше не найден.',
errorMessage: null,
),
),
+23
View File
@@ -0,0 +1,23 @@
import 'package:flutter/widgets.dart';
class LauncherVersionScope extends InheritedWidget {
const LauncherVersionScope({
super.key,
required this.version,
required super.child,
});
final String version;
static String of(BuildContext context) {
return context
.dependOnInheritedWidgetOfExactType<LauncherVersionScope>()
?.version ??
'dev';
}
@override
bool updateShouldNotify(LauncherVersionScope oldWidget) {
return version != oldWidget.version;
}
}
+14 -8
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:moonwell_launcher/app/design_system/mw_shells.dart';
import 'package:moonwell_launcher/app/home_screen/home_screen.dart';
import 'package:moonwell_launcher/app/launcher_version.dart';
import 'package:moonwell_launcher/app/login_screen/login_screen.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
import 'package:moonwell_launcher/features/launcher/application/restore_launcher_session_use_case.dart';
@@ -9,7 +10,9 @@ import 'package:moonwell_launcher/features/preferences/domain/repositories/prefe
import 'package:moonwell_launcher/service_container.dart';
class MoonWellApp extends StatefulWidget {
const MoonWellApp({super.key});
const MoonWellApp({super.key, required this.launcherVersion});
final String launcherVersion;
@override
State<MoonWellApp> createState() => _MoonWellAppState();
@@ -35,13 +38,16 @@ class _MoonWellAppState extends State<MoonWellApp> {
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _themeController,
builder: (context, _) => LauncherThemeScope(
controller: _themeController,
child: MaterialApp(
title: 'MoonWell',
debugShowCheckedModeBanner: false,
home: const _LauncherBootstrapScreen(),
theme: MoonWellTheme.create(_themeController.variant),
builder: (context, _) => LauncherVersionScope(
version: widget.launcherVersion,
child: LauncherThemeScope(
controller: _themeController,
child: MaterialApp(
title: 'MoonWell',
debugShowCheckedModeBanner: false,
home: const _LauncherBootstrapScreen(),
theme: MoonWellTheme.create(_themeController.variant),
),
),
),
);
+7 -1
View File
@@ -6,16 +6,22 @@ final class Config {
'MOONWELL_APPCAST_URL',
);
static const launcherLogFileName = 'launcher.log';
static const gameExecutableName = 'Wow.exe';
static const gameExecutableName = 'MoonWell.exe';
static const gameClientBuild = 5875;
static const gameAuthAddress = String.fromEnvironment(
'MOONWELL_AUTH_ADDRESS',
);
static const cacheDirectoryName = 'Cache';
static const launcherMetadataDirectoryName = '.moonwell_launcher';
static const hashCacheFileName = 'hash_cache.json';
static const ignoredVerificationDirectories = <String>{
'addons',
'cache',
'errors',
'logs',
'screenshots',
'wtf',
'benilla-config',
'.moonwell_launcher',
};
}
@@ -95,6 +95,7 @@ class ClientSyncUseCase
final localSnapshot = await _installationService.scanInstallation(
input.request.installationDir,
isCancelled: input.isCancelled,
manifest: manifest,
onProgress: (progress, currentPath, processedFiles, totalFiles) {
_emit(
controller,
@@ -115,7 +116,7 @@ class ClientSyncUseCase
await _throwIfCancelled(input.isCancelled);
final filesToDownload = _resolveFilesToDownload(manifest, localSnapshot);
final staleFiles = _resolveStaleFiles(manifest, localSnapshot);
final staleFiles = localSnapshot.stalePaths;
_emit(
controller,
@@ -185,6 +186,7 @@ class ClientSyncUseCase
final verifiedSnapshot = await _installationService.scanInstallation(
input.request.installationDir,
isCancelled: input.isCancelled,
manifest: manifest,
onProgress: (progress, currentPath, processedFiles, totalFiles) {
_emit(
controller,
@@ -272,18 +274,6 @@ class ClientSyncUseCase
}).toList();
}
List<String> _resolveStaleFiles(
ClientManifest manifest,
ClientInstallationSnapshot snapshot,
) {
final remoteFiles = manifest.filesByPath;
return snapshot.files
.where((localFile) => !remoteFiles.containsKey(localFile.path))
.map((file) => file.path)
.toList();
}
Future<void> _removeStaleFiles({
required StreamController<ClientSyncStatus> controller,
required String installationDir,
@@ -454,14 +444,15 @@ class ClientSyncUseCase
final mismatchedFiles = manifest.files.where((remoteFile) {
final localFile = localFilesByPath[remoteFile.path];
return localFile == null ||
final isMismatched =
localFile == null ||
localFile.sha256 != remoteFile.sha256 ||
localFile.size != remoteFile.size;
return isMismatched;
}).toList();
final extraFiles = snapshot.files
.where((localFile) => !manifest.filesByPath.containsKey(localFile.path))
.toList();
final extraFiles = snapshot.stalePaths;
if (snapshot.buildHash != remoteBuildHash ||
mismatchedFiles.isNotEmpty ||
@@ -477,14 +468,16 @@ class ClientSyncUseCase
.map((file) => file.path)
.take(10)
.toList(),
'extraFiles': extraFiles.map((file) => file.path).take(10).toList(),
'extraFiles': extraFiles.take(10).toList(),
},
),
);
final firstProblemPath = mismatchedFiles.isNotEmpty
? mismatchedFiles.first.path
: extraFiles.first.path;
: extraFiles.isNotEmpty
? extraFiles.first
: 'buildHash';
throw LauncherSyncException(
'Client verification failed after update: $firstProblemPath. '
'See ${_launcherLogService.logHint(installationDir)}.',
@@ -8,10 +8,12 @@ import 'package:injectable/injectable.dart';
import 'package:moonwell_launcher/config.dart';
import 'package:moonwell_launcher/features/downloader/domain/entities/download_exceptions.dart';
import 'package:moonwell_launcher/features/downloader/domain/entities/download_progress.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_installation_snapshot.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_exception.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/local_client_file.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_hash_entry.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_installation_snapshot.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_manifest.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_exception.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_game_ticket.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/local_client_file.dart';
import 'package:path/path.dart' as p;
typedef InstallationScanProgressCallback =
@@ -31,11 +33,20 @@ final class GameProcessHandle {
@lazySingleton
class GameInstallationService {
String get operatingSystem => Platform.operatingSystem;
String get configuredAuthAddress => Config.gameAuthAddress;
Future<ClientInstallationSnapshot> scanInstallation(
String installationDir, {
required ClientManifest manifest,
InstallationScanProgressCallback? onProgress,
FutureOr<bool> Function()? isCancelled,
}) async {
// Validate the entire manifest before scanning or removing any files.
for (final file in manifest.files) {
resolveClientPath(installationDir, file.path);
}
final rootDirectory = Directory(installationDir);
if (!await rootDirectory.exists()) {
return ClientInstallationSnapshot.fromFiles(const []);
@@ -96,7 +107,12 @@ class GameInstallationService {
}
if (type == 'done') {
final snapshot = ClientInstallationSnapshot.fromFiles(files);
final snapshot = ClientInstallationSnapshot.fromFiles(
files,
stalePaths: (message['stalePaths'] as List<Object?>)
.whereType<String>()
.toList(),
);
completer.complete(snapshot);
await cleanup(killIsolate: false);
}
@@ -131,7 +147,7 @@ class GameInstallationService {
'installationDir': installationDir,
'hashCachePath': hashCachePath,
'cachedHashes': cachedHashes,
'ignoredDirectories': Config.ignoredVerificationDirectories.toList(),
'serverFiles': manifest.files.map((f) => f.path).toList(),
},
onError: errorPort.sendPort,
onExit: exitPort.sendPort,
@@ -174,9 +190,20 @@ class GameInstallationService {
String installationDir,
String relativePath,
) async {
final file = File(resolveClientPath(installationDir, relativePath));
if (await file.exists()) {
await file.delete();
final filePath = resolveClientPath(installationDir, relativePath);
final type = await FileSystemEntity.type(filePath, followLinks: false);
if (type == FileSystemEntityType.notFound) {
return;
}
await _ensureParentInsideInstallation(installationDir, filePath);
if (type == FileSystemEntityType.link) {
await Link(filePath).delete();
} else if (type == FileSystemEntityType.directory) {
// Stale directories are collected after their children. Never recursively
// delete a directory: files created since the scan must not be lost.
await Directory(filePath).delete();
} else if (type == FileSystemEntityType.file) {
await File(filePath).delete();
}
}
@@ -216,20 +243,86 @@ class GameInstallationService {
await cacheDirectory.create(recursive: true);
}
Future<GameProcessHandle> launchGame(String installationDir) async {
Future<void> removeSavedAccountName(String installationDir) async {
final configFile = File(p.join(installationDir, 'WTF', 'Config.wtf'));
if (!await configFile.exists()) {
return;
}
final contents = await configFile.readAsString();
final sanitizedContents = contents.replaceAll(
RegExp(
r'^[ \t]*SET[ \t]+accountName(?:[ \t]+.*)?(?:\r\n|\n|\r|$)',
caseSensitive: false,
multiLine: true,
),
'',
);
if (sanitizedContents != contents) {
await configFile.writeAsString(sanitizedContents, flush: true);
}
}
Future<GameProcessHandle> launchGame(
String installationDir, {
required LauncherGameTicket authorization,
}) async {
final executablePath = getExecutablePath(installationDir);
final executable = File(executablePath);
if (!await executable.exists()) {
throw const LauncherSyncException(
'Wow.exe was not found in the selected folder.',
throw LauncherSyncException(
'MoonWell client was not found: $executablePath',
);
}
final authAddress = await resolveAuthAddress(installationDir);
final rootPath = p.absolute(installationDir);
final directDataPath = p.join(rootPath, 'Data');
final nestedDataPath = p.join(rootPath, 'WoW', 'Data');
final dataPath = await Directory(directDataPath).exists()
? directDataPath
: nestedDataPath;
if (!await Directory(dataPath).exists()) {
throw const LauncherSyncException(
'WoW 1.12.1 Data or WoW/Data was not found in the selected folder.',
);
}
if (!authorization.isUsable()) {
throw const LauncherSyncException(
'Game ticket has expired. Press Play to request a new ticket.',
);
}
return startGameProcess(
executablePath: executablePath,
arguments: const <String>[],
workingDirectory: rootPath,
environment: <String, String>{
'WOW_USER': authorization.account,
'WOW_PASS': authorization.ticket,
'WOW_HOST': authAddress,
'WOW_DATA': dataPath,
// Let the client select Data/ruRU independently of the launcher's parent environment.
'WOW_LOCALE': 'auto',
'BENILLA_HOME': p.join(rootPath, 'benilla-config'),
},
);
}
Future<GameProcessHandle> startGameProcess({
required String executablePath,
required List<String> arguments,
required String workingDirectory,
required Map<String, String> environment,
}) async {
final process = await Process.start(
executablePath,
const <String>[],
workingDirectory: installationDir,
arguments,
workingDirectory: workingDirectory,
environment: environment,
includeParentEnvironment: true,
mode: ProcessStartMode.normal,
);
await process.stdin.close();
@@ -261,7 +354,56 @@ class GameInstallationService {
}
String getExecutablePath(String installationDir) {
return p.join(installationDir, Config.gameExecutableName);
final rootPath = p.absolute(installationDir);
return switch (operatingSystem) {
'windows' => p.join(rootPath, Config.gameExecutableName),
'macos' => p.join(
rootPath,
'MoonWell.app',
'Contents',
'MacOS',
'launch',
),
_ => p.join(rootPath, 'MoonWell'),
};
}
/// The auth endpoint is separate from a realm's world port (normally 8085).
Future<String> resolveAuthAddress(String installationDir) async {
final configured = configuredAuthAddress.trim();
if (configured.isNotEmpty) {
return _validateAuthAddress(configured);
}
final realmlist = File(p.join(installationDir, 'realmlist.wtf'));
if (await realmlist.exists()) {
final pattern = RegExp(
r'^\s*set\s+realmlist\s+(?:"([^"]+)"|([^\s]+))\s*(?://.*)?$',
caseSensitive: false,
multiLine: true,
);
final matches = pattern.allMatches(await realmlist.readAsString());
if (matches.isNotEmpty) {
final match = matches.last;
return _validateAuthAddress((match.group(1) ?? match.group(2)!).trim());
}
}
throw const LauncherSyncException(
'Set realmlist in realmlist.wtf or configure MOONWELL_AUTH_ADDRESS.',
);
}
String _validateAuthAddress(String address) {
final match = RegExp(
r'^([A-Za-z0-9][A-Za-z0-9._-]*)(?::([0-9]{1,5}))?$',
).firstMatch(address);
final port = int.tryParse(match?.group(2) ?? '3724');
if (match == null || port == null || port < 1 || port > 65535) {
throw const LauncherSyncException(
'The auth address must be a hostname or IPv4 address with an optional TCP port.',
);
}
return address;
}
String resolveClientPath(String installationDir, String relativePath) {
@@ -273,7 +415,9 @@ class GameInstallationService {
if (pathSegments.isEmpty ||
pathSegments.any((segment) => segment == '..') ||
p.posix.isAbsolute(normalizedPath)) {
pathSegments.any((segment) => segment.contains(':')) ||
p.posix.isAbsolute(normalizedPath) ||
p.windows.isAbsolute(normalizedPath)) {
throw LauncherSyncException('Invalid client file path: $relativePath');
}
@@ -339,24 +483,19 @@ Future<void> _scanInstallationIsolateMain(Map<String, Object?> message) async {
final cachedHashes = (message['cachedHashes'] as Map<Object?, Object?>).map(
(key, value) => MapEntry(key.toString(), value),
);
final ignoredDirectories = (message['ignoredDirectories'] as List<Object?>)
final serverFiles = (message['serverFiles'] as List<Object?>)
.whereType<String>()
.map((entry) => entry.toLowerCase())
.toSet();
final rootDirectory = Directory(installationDir);
if (!await rootDirectory.exists()) {
sendPort.send(<String, Object?>{'type': 'done'});
sendPort.send(<String, Object?>{'type': 'done', 'stalePaths': <String>[]});
return;
}
final pendingFiles = <_SerializablePendingFile>[];
await _collectFilesInIsolate(
rootDirectory,
rootDirectory.path,
pendingFiles,
ignoredDirectories,
);
await _collectManifestFiles(rootDirectory.path, pendingFiles, serverFiles);
final stalePaths = await _collectStalePaths(rootDirectory, serverFiles);
pendingFiles.sort(
(left, right) => left.relativePath.compareTo(right.relativePath),
@@ -394,7 +533,7 @@ Future<void> _scanInstallationIsolateMain(Map<String, Object?> message) async {
}
await _writeHashCache(hashCachePath, updatedCacheEntries);
sendPort.send(<String, Object?>{'type': 'done'});
sendPort.send(<String, Object?>{'type': 'done', 'stalePaths': stalePaths});
}
Future<String> _resolveFileHash(
@@ -419,45 +558,34 @@ Future<String> _resolveFileHash(
return digest.toString();
}
Future<void> _collectFilesInIsolate(
Directory directory,
Future<void> _collectManifestFiles(
String rootPath,
List<_SerializablePendingFile> pendingFiles,
Set<String> ignoredDirectories,
Set<String> serverFiles,
) async {
await for (final entity in directory.list(followLinks: false)) {
final relativePath = normalizeClientPath(
p.relative(entity.path, from: rootPath),
final installationService = GameInstallationService();
final resolvedRoot = await Directory(rootPath).resolveSymbolicLinks();
for (final path in serverFiles) {
final relativePath = normalizeClientPath(path);
final file = File(
installationService.resolveClientPath(rootPath, relativePath),
);
if (relativePath.isEmpty || relativePath == '.') {
if (!await file.exists()) {
continue;
}
final segments = p.posix.split(relativePath);
if (segments.isNotEmpty &&
ignoredDirectories.contains(segments.first.toLowerCase())) {
continue;
}
if (entity is Directory) {
await _collectFilesInIsolate(
entity,
rootPath,
pendingFiles,
ignoredDirectories,
final resolvedFile = await file.resolveSymbolicLinks();
if (!p.isWithin(resolvedRoot, resolvedFile)) {
throw LauncherSyncException(
'Client file points outside installation: $path',
);
continue;
}
final stat = await file.stat();
if (entity is! File) {
continue;
}
final stat = await entity.stat();
pendingFiles.add(
_SerializablePendingFile(
path: entity.path,
path: file.path,
relativePath: relativePath,
size: stat.size,
modifiedMs: stat.modified.millisecondsSinceEpoch,
@@ -466,6 +594,88 @@ Future<void> _collectFilesInIsolate(
}
}
Future<void> _ensureParentInsideInstallation(
String installationDir,
String filePath,
) async {
final rootPath = await Directory(installationDir).resolveSymbolicLinks();
final parentPath = await File(filePath).parent.resolveSymbolicLinks();
if (!p.equals(rootPath, parentPath) && !p.isWithin(rootPath, parentPath)) {
throw LauncherSyncException(
'Client path points outside installation: $filePath',
);
}
}
Future<List<String>> _collectStalePaths(
Directory rootDirectory,
Set<String> serverFiles,
) async {
String pathKey(String path) {
final normalized = normalizeClientPath(path);
return Platform.isWindows ? normalized.toLowerCase() : normalized;
}
final manifestPaths = serverFiles.map(pathKey).toSet();
final manifestDirectories = <String>{};
for (final filePath in manifestPaths) {
var directory = p.posix.dirname(filePath);
while (directory != '.') {
manifestDirectories.add(directory);
directory = p.posix.dirname(directory);
}
}
final stalePaths = <String>[];
String relativePath(FileSystemEntity entity) =>
normalizeClientPath(p.relative(entity.path, from: rootDirectory.path));
Future<void> collectStaleDirectory(Directory directory) async {
await for (final entity in directory.list(followLinks: false)) {
final path = relativePath(entity);
if (entity is Directory) {
await collectStaleDirectory(entity);
if (!manifestDirectories.contains(pathKey(path))) {
stalePaths.add(path);
}
} else if (!manifestPaths.contains(pathKey(path)) &&
!(entity is Link && manifestDirectories.contains(pathKey(path)))) {
stalePaths.add(path);
}
}
}
Future<void> collectClientRoot(
Directory directory, {
bool nested = false,
}) async {
await for (final entity in directory.list(followLinks: false)) {
final name = p.basename(entity.path).toLowerCase();
if (entity is Directory) {
if (name == 'data') {
await collectStaleDirectory(entity);
} else if (name == 'extentions') {
await collectStaleDirectory(entity);
if (!manifestDirectories.contains(pathKey(relativePath(entity)))) {
stalePaths.add(relativePath(entity));
}
} else if (!nested && name == 'wow') {
await collectClientRoot(entity, nested: true);
}
} else if ((name == 'wow.exe' ||
name.endsWith('.dll') ||
(entity is Link && name == 'extentions')) &&
!manifestPaths.contains(pathKey(relativePath(entity))) &&
!manifestDirectories.contains(pathKey(relativePath(entity)))) {
stalePaths.add(relativePath(entity));
}
}
}
await collectClientRoot(rootDirectory);
return stalePaths;
}
Future<void> _writeHashCache(
String hashCachePath,
Map<String, Map<String, Object?>> entries,
@@ -11,12 +11,15 @@ import 'package:moonwell_launcher/features/launcher/domain/entities/client_manif
import 'package:moonwell_launcher/features/launcher/domain/entities/client_manifest_file.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_account.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_exception.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_game_ticket.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_news_item.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_realm.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_session.dart';
@lazySingleton
class LauncherApiClient {
String get apiBaseUrl => Config.launcherApiBaseUrl;
LauncherApiClient({LauncherLogService? launcherLogService})
: _launcherLogService = launcherLogService ?? LauncherLogService(),
_dio = Dio(
@@ -162,6 +165,47 @@ class LauncherApiClient {
}
}
Future<LauncherGameTicket> issueGameTicket(String accessToken) async {
final ticketUri = _resolveUri('api/launcher/game-ticket');
try {
final response = await _dio.postUri(
ticketUri,
data: const <String, Object?>{'client_build': Config.gameClientBuild},
options: _authorizedOptions(accessToken),
);
final ticket = LauncherGameTicket.fromJson(_coerceMap(response.data));
if (!ticket.isUsable()) {
throw const LauncherApiException(
'Launcher API returned an expired game ticket.',
);
}
return ticket;
} on DioException catch (error, stackTrace) {
await _launcherLogService.error(
'Game ticket request failed.',
details: <String, Object?>{
'endpoint': ticketUri.toString(),
'statusCode': error.response?.statusCode,
'dioType': error.type.name,
},
error: error,
stackTrace: stackTrace,
);
throw LauncherApiException(_extractErrorMessage(error));
} on FormatException catch (error, stackTrace) {
await _launcherLogService.error(
'Launcher API returned an invalid game ticket payload.',
details: <String, Object?>{'endpoint': ticketUri.toString()},
error: error,
stackTrace: stackTrace,
);
throw const LauncherApiException(
'Launcher API returned an invalid game ticket.',
);
}
}
Future<ClientManifest> fetchManifest(String accessToken) async {
final manifestUri = _resolveUri('api/launcher/manifest');
@@ -383,7 +427,7 @@ class LauncherApiClient {
}
Uri _resolveUri(String path) {
final rawBaseUrl = Config.launcherApiBaseUrl.trim();
final rawBaseUrl = apiBaseUrl.trim();
if (rawBaseUrl.isEmpty) {
throw const LauncherConfigurationException(
'Set MOONWELL_API_BASE_URL before using the launcher API.',
@@ -5,15 +5,24 @@ final class ClientInstallationSnapshot {
final List<LocalClientFile> files;
final String buildHash;
/// Unmanaged cleanup paths, with directories ordered after their children.
/// These paths do not contribute to [buildHash].
final List<String> stalePaths;
const ClientInstallationSnapshot({
required this.files,
required this.buildHash,
this.stalePaths = const [],
});
factory ClientInstallationSnapshot.fromFiles(List<LocalClientFile> files) {
factory ClientInstallationSnapshot.fromFiles(
List<LocalClientFile> files, {
List<String> stalePaths = const [],
}) {
return ClientInstallationSnapshot(
files: files,
buildHash: computeBuildHash(files),
stalePaths: stalePaths,
);
}
@@ -0,0 +1,53 @@
final class LauncherGameTicket {
static final RegExp _accountPattern = RegExp(r'^[A-Z0-9]{3,16}$');
static final RegExp _ticketPattern = RegExp(r'^[A-Z0-9]{16}$');
final String account;
final String ticket;
final DateTime expiresAt;
const LauncherGameTicket({
required this.account,
required this.ticket,
required this.expiresAt,
});
factory LauncherGameTicket.fromJson(Map<String, dynamic> json) {
final rawAccount = json['account'];
final rawTicket = json['ticket'];
final rawExpiresAt = json['expires_at'];
if (rawAccount is! String ||
rawTicket is! String ||
rawExpiresAt is! String) {
throw const FormatException('Invalid game ticket payload types.');
}
final account = rawAccount;
final ticket = rawTicket;
final expiresAt = DateTime.tryParse(rawExpiresAt);
if (!_accountPattern.hasMatch(account)) {
throw const FormatException('Invalid game ticket account.');
}
if (!_ticketPattern.hasMatch(ticket)) {
throw const FormatException('Invalid game ticket value.');
}
if (expiresAt == null) {
throw const FormatException('Invalid game ticket expiration.');
}
return LauncherGameTicket(
account: account,
ticket: ticket,
expiresAt: expiresAt.toUtc(),
);
}
bool isUsable({
DateTime? now,
Duration minimumValidity = const Duration(seconds: 5),
}) {
final currentTime = (now ?? DateTime.now()).toUtc();
return expiresAt.isAfter(currentTime.add(minimumValidity));
}
}
+12 -1
View File
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:moonwell_launcher/app/mw_app.dart';
import 'package:moonwell_launcher/features/launcher/data/launcher_update_service.dart';
import 'package:moonwell_launcher/service_container.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:window_manager/window_manager.dart';
Future<void> main() async {
@@ -13,6 +14,7 @@ Future<void> main() async {
await configureDependencies(env: 'flutter');
final launcherUpdateService = getIt<LauncherUpdateService>();
final launcherVersion = await _readLauncherVersion();
const windowOptions = WindowOptions(
size: Size(1280, 720),
@@ -31,5 +33,14 @@ Future<void> main() async {
}),
);
runApp(const MoonWellApp());
runApp(MoonWellApp(launcherVersion: launcherVersion));
}
Future<String> _readLauncherVersion() async {
try {
final packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version;
} catch (_) {
return 'dev';
}
}
@@ -0,0 +1 @@
C:/Users/sindo/AppData/Local/Pub/Cache/hosted/pub.dev/package_info_plus-9.0.1/
@@ -8,6 +8,7 @@ import Foundation
import auto_updater_macos
import file_picker
import flutter_secure_storage_darwin
import package_info_plus
import screen_retriever_macos
import shared_preferences_foundation
import url_launcher_macos
@@ -17,6 +18,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AutoUpdaterMacosPlugin.register(with: registry.registrar(forPlugin: "AutoUpdaterMacosPlugin"))
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
FlutterSecureStorageDarwinPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageDarwinPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
+78 -1
View File
@@ -109,6 +109,83 @@
}
}
},
"/api/launcher/game-ticket": {
"post": {
"tags": [
"Launcher Auth"
],
"summary": "Выпустить одноразовый ticket для входа в игру",
"description": "Отзывает предыдущий неиспользованный ticket аккаунта и возвращает временный SRP-пароль. Ticket не сохраняется и действует не более 60 секунд.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"required": [
"client_build"
],
"properties": {
"client_build": {
"type": "integer",
"example": 12340
}
},
"type": "object"
}
}
}
},
"responses": {
"200": {
"description": "Одноразовая игровая авторизация",
"content": {
"application/json": {
"schema": {
"required": [
"account",
"ticket",
"expires_at"
],
"properties": {
"account": {
"type": "string",
"example": "PLAYERONE",
"maxLength": 17,
"minLength": 1
},
"ticket": {
"type": "string",
"pattern": "^[A-Z0-9]{16}$",
"example": "A1B2C3D4E5F6G7H8"
},
"expires_at": {
"type": "string",
"format": "date-time",
"example": "2026-08-16T12:01:00Z"
}
},
"type": "object"
}
}
}
},
"401": {
"description": "Launcher-сессия отсутствует или истекла"
},
"422": {
"description": "Версия клиента не разрешена"
},
"429": {
"description": "Слишком много запросов"
}
},
"security": [
{
"launcherAuth": []
}
]
}
},
"/api/launcher/manifest": {
"get": {
"tags": [
@@ -702,4 +779,4 @@
"description": "Launcher Service"
}
]
}
}
+37 -13
View File
@@ -141,10 +141,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "1.4.1"
checked_yaml:
dependency: transitive
description:
@@ -424,6 +424,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.4.0"
http:
dependency: transitive
description:
name: http
sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412"
url: "https://pub.dev"
source: hosted
version: "1.6.0"
http_multi_server:
dependency: transitive
description:
@@ -540,26 +548,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd"
url: "https://pub.dev"
source: hosted
version: "0.12.17"
version: "0.12.20"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
url: "https://pub.dev"
source: hosted
version: "0.11.1"
version: "0.13.0"
meta:
dependency: transitive
description:
name: meta
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9"
url: "https://pub.dev"
source: hosted
version: "1.17.0"
version: "1.19.0"
mime:
dependency: transitive
description:
@@ -592,6 +600,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.2.0"
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
sha256: "468c26b4254ab01979fa5e4a98cb343ea3631b9acee6f21028997419a80e1a20"
url: "https://pub.dev"
source: hosted
version: "9.0.1"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
path:
dependency: "direct main"
description:
@@ -905,10 +929,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11"
url: "https://pub.dev"
source: hosted
version: "0.7.7"
version: "0.7.12"
typed_data:
dependency: transitive
description:
@@ -985,10 +1009,10 @@ packages:
dependency: transitive
description:
name: vector_math
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
sha256: "92b9910f66ed1057fd4da7b040ae7c74cafacf885bdc81be496928d5049b032d"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
version: "2.4.3"
vm_service:
dependency: transitive
description:
@@ -1078,5 +1102,5 @@ packages:
source: hosted
version: "3.1.3"
sdks:
dart: ">=3.10.3 <4.0.0"
dart: ">=3.11.0-0 <4.0.0"
flutter: ">=3.38.4"
+2 -1
View File
@@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.1+2
version: 1.0.7+10
environment:
sdk: ">=3.10.0"
@@ -47,6 +47,7 @@ dependencies:
window_manager: ^0.5.1
auto_updater: 1.0.0
url_launcher: ^6.3.2
package_info_plus: ^9.0.1
dev_dependencies:
flutter_test:
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/app/design_system/mw_authentication.dart';
import 'package:moonwell_launcher/app/launcher_version.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
void main() {
@@ -81,4 +82,62 @@ void main() {
expect(requestedMode, MwAuthenticationMode.registration);
});
testWidgets('inactive authentication tab has no divider', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: Scaffold(
body: MwAuthenticationForm(
usernameController: TextEditingController(),
passwordController: TextEditingController(),
onSubmit: () {},
),
),
),
);
final tabBorders = tester
.widgetList<Container>(
find.descendant(
of: find.byType(MwAuthenticationForm),
matching: find.byType(Container),
),
)
.map((container) => container.decoration)
.whereType<BoxDecoration>()
.map((decoration) => decoration.border)
.whereType<Border>()
.where((border) => border.bottom.style != BorderStyle.none)
.map((border) => border.bottom.color)
.toList();
expect(tabBorders, hasLength(2));
expect(
tabBorders.where((color) => color == Colors.transparent),
hasLength(1),
);
});
testWidgets('authentication footer uses the packaged launcher version', (
tester,
) async {
await tester.pumpWidget(
LauncherVersionScope(
version: '9.8.7',
child: MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: Scaffold(
body: MwAuthenticationForm(
usernameController: TextEditingController(),
passwordController: TextEditingController(),
onSubmit: () {},
),
),
),
),
);
expect(find.textContaining('V 9.8.7'), findsOneWidget);
});
}
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/app/design_system/mw_launcher_components.dart';
import 'package:moonwell_launcher/app/launcher_version.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
void main() {
@@ -137,6 +138,25 @@ void main() {
expect(find.text('Проверить файлы'), findsOneWidget);
expect(find.text('Выйти'), findsNothing);
});
testWidgets('status bar uses the packaged launcher version', (tester) async {
await tester.pumpWidget(
LauncherVersionScope(
version: '9.8.7',
child: MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: const Scaffold(
body: SizedBox(
height: 26,
child: MwLauncherStatusBar(status: 'Ready'),
),
),
),
),
);
expect(find.textContaining('v9.8.7'), findsOneWidget);
});
}
void _noop() {}
+12 -7
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/app/design_system/mw_shells.dart';
import 'package:moonwell_launcher/app/launcher_version.dart';
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
void main() {
@@ -24,13 +25,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
theme: MoonWellTheme.create(MoonWellThemeVariant.forest),
home: MwLoginShell(
form: const SizedBox(),
onDrag: _noop,
onDoubleTap: _noop,
onMinimize: _noop,
onMaximizeRestore: _noop,
onClose: _noop,
home: LauncherVersionScope(
version: '9.8.7',
child: MwLoginShell(
form: const SizedBox(),
onDrag: _noop,
onDoubleTap: _noop,
onMinimize: _noop,
onMaximizeRestore: _noop,
onClose: _noop,
),
),
),
);
@@ -38,6 +42,7 @@ void main() {
final image = tester.widget<Image>(find.byType(Image));
expect((image.image as AssetImage).assetName, 'assets/login_key_art.png');
expect(find.textContaining('9.8.7'), findsOneWidget);
expect(tester.takeException(), isNull);
});
@@ -7,10 +7,11 @@ import 'package:moonwell_launcher/features/downloader/domain/entities/download_p
import 'package:moonwell_launcher/features/launcher/application/client_sync_use_case.dart';
import 'package:moonwell_launcher/features/launcher/data/game_installation_service.dart';
import 'package:moonwell_launcher/features/launcher/data/launcher_api_client.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_installation_snapshot.dart';
// import 'package:moonwell_launcher/features/launcher/domain/entities/client_installation_snapshot.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_manifest.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_sync_status.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_account.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_game_ticket.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_news_item.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_realm.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_session.dart';
@@ -147,11 +148,15 @@ void main() {
final manifest = ClientManifest.fromJson(<String, Object?>{
'files': <Map<String, Object?>>[],
});
final gameService = _TrackingGameInstallationService();
final launchOperations = <String>[];
final gameService = _TrackingGameInstallationService(launchOperations);
final bloc = HomeScreenBloc(
clientSyncUseCase: _CapturingClientSyncUseCase(),
gameInstallationService: gameService,
launcherApiClient: _FakeLauncherApiClient(newsItems: const []),
launcherApiClient: _FakeLauncherApiClient(
newsItems: const [],
launchOperations: launchOperations,
),
preferencesRepository: _FakePreferencesRepository(
outputDir: Uri.directory('C:/World of Warcraft'),
),
@@ -168,6 +173,10 @@ void main() {
await pumpEventQueue(times: 20);
expect(gameService.launchCount, 1);
expect(gameService.savedAccountNameRemovalCount, 0);
expect(launchOperations, <String>['issueGameTicket', 'launchGame']);
expect(gameService.launchedWith?.account, 'PLAYERONE');
expect(gameService.launchedWith?.ticket, 'A1B2C3D4E5F6G7H8');
expect(bloc.state.model.isGameRunning, isTrue);
expect(bloc.state.model.canPlay, isFalse);
@@ -227,13 +236,16 @@ class _FakeLauncherApiClient extends LauncherApiClient {
this.manifest,
this.realms = const [],
this.account = const LauncherAccount(username: ''),
this.launchOperations,
});
final List<LauncherNewsItem> newsItems;
final ClientManifest? manifest;
final List<LauncherRealm> realms;
final LauncherAccount account;
final List<String>? launchOperations;
int manifestRequestCount = 0;
int gameTicketRequestCount = 0;
@override
Future<List<LauncherNewsItem>> fetchNews(String accessToken) async =>
@@ -245,6 +257,17 @@ class _FakeLauncherApiClient extends LauncherApiClient {
@override
Future<LauncherAccount> fetchAccount(String accessToken) async => account;
@override
Future<LauncherGameTicket> issueGameTicket(String accessToken) async {
launchOperations?.add('issueGameTicket');
gameTicketRequestCount += 1;
return LauncherGameTicket(
account: 'PLAYERONE',
ticket: 'A1B2C3D4E5F6G7H8',
expiresAt: DateTime.now().toUtc().add(const Duration(seconds: 60)),
);
}
@override
Future<ClientManifest> fetchManifest(String accessToken) async {
manifestRequestCount += 1;
@@ -259,29 +282,47 @@ class _FakeGameInstallationService extends GameInstallationService {
@override
Future<bool> hasClientExecutable(String installationDir) async => false;
@override
Future<ClientInstallationSnapshot> scanInstallation(
String installationDir, {
InstallationScanProgressCallback? onProgress,
FutureOr<bool> Function()? isCancelled,
}) async {
return ClientInstallationSnapshot.fromFiles(const []);
}
// @override
// Future<ClientInstallationSnapshot> scanInstallation(
// String installationDir, {
// InstallationScanProgressCallback? onProgress,
// FutureOr<bool> Function()? isCancelled,
// }) async {
// return ClientInstallationSnapshot.fromFiles(const []);
// }
}
class _TrackingGameInstallationService extends _FakeGameInstallationService {
_TrackingGameInstallationService(this.launchOperations);
final List<String> launchOperations;
final Completer<int> exitCode = Completer<int>();
int launchCount = 0;
int savedAccountNameRemovalCount = 0;
LauncherGameTicket? launchedWith;
@override
Future<bool> hasClientExecutable(String installationDir) async => true;
@override
Future<void> clearCache(String installationDir) async {}
Future<void> removeSavedAccountName(String installationDir) async {
launchOperations.add('removeSavedAccountName');
savedAccountNameRemovalCount += 1;
}
@override
Future<GameProcessHandle> launchGame(String installationDir) async {
Future<void> clearCache(String installationDir) async {
launchOperations.add('clearCache');
}
@override
Future<GameProcessHandle> launchGame(
String installationDir, {
required LauncherGameTicket authorization,
}) async {
launchOperations.add('launchGame');
launchCount += 1;
launchedWith = authorization;
return GameProcessHandle(pid: 42, exitCode: exitCode.future);
}
}
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:collection';
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/features/downloader/domain/entities/download_progress.dart';
@@ -12,6 +13,7 @@ import 'package:moonwell_launcher/features/launcher/domain/entities/client_manif
import 'package:moonwell_launcher/features/launcher/domain/entities/client_manifest_file.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_sync_status.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_exception.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/local_client_file.dart';
void main() {
@@ -21,7 +23,7 @@ void main() {
() async {
final manifest = _manifestFromFiles([
const ClientManifestFile(
path: 'Wow.exe',
path: 'MoonWell.exe',
size: 5,
sha256: 'wow-hash',
),
@@ -32,7 +34,11 @@ void main() {
),
]);
final matchingSnapshot = ClientInstallationSnapshot.fromFiles([
const LocalClientFile(path: 'Wow.exe', size: 5, sha256: 'wow-hash'),
const LocalClientFile(
path: 'MoonWell.exe',
size: 5,
sha256: 'wow-hash',
),
const LocalClientFile(
path: 'Data/common.MPQ',
size: 10,
@@ -76,7 +82,7 @@ void main() {
() async {
final manifest = _manifestFromFiles([
const ClientManifestFile(
path: 'Wow.exe',
path: 'MoonWell.exe',
size: 5,
sha256: 'wow-hash',
),
@@ -86,12 +92,22 @@ void main() {
sha256: 'data-hash',
),
]);
final initialSnapshot = ClientInstallationSnapshot.fromFiles([
const LocalClientFile(path: 'Wow.exe', size: 5, sha256: 'old-wow'),
const LocalClientFile(path: 'legacy.txt', size: 2, sha256: 'legacy'),
]);
final initialSnapshot = ClientInstallationSnapshot.fromFiles(
[
const LocalClientFile(
path: 'MoonWell.exe',
size: 5,
sha256: 'old-wow',
),
],
stalePaths: ['Data/legacy.MPQ', 'WoW.exe', 'old.dll'],
);
final verifiedSnapshot = ClientInstallationSnapshot.fromFiles([
const LocalClientFile(path: 'Wow.exe', size: 5, sha256: 'wow-hash'),
const LocalClientFile(
path: 'MoonWell.exe',
size: 5,
sha256: 'wow-hash',
),
const LocalClientFile(
path: 'Data/common.MPQ',
size: 10,
@@ -102,8 +118,8 @@ void main() {
final api = _FakeLauncherApiClient(manifest);
final installationService =
_FakeGameInstallationService([initialSnapshot, verifiedSnapshot])
..fileSizesByPath['C:/MoonWell/Wow.exe.moonwell.part'] = 5
..computedHashesByPath['C:/MoonWell/Wow.exe.moonwell.part'] =
..fileSizesByPath['C:/MoonWell/MoonWell.exe.moonwell.part'] = 5
..computedHashesByPath['C:/MoonWell/MoonWell.exe.moonwell.part'] =
'wow-hash'
..fileSizesByPath['C:/MoonWell/Data/common.MPQ.moonwell.part'] =
10
@@ -137,13 +153,134 @@ void main() {
ClientSyncStage.completed,
]),
);
expect(installationService.deletedRelativeFiles, ['legacy.txt']);
expect(api.downloadedPaths, ['Wow.exe', 'Data/common.MPQ']);
expect(installationService.deletedRelativeFiles, [
'Data/legacy.MPQ',
'WoW.exe',
'old.dll',
]);
expect(api.downloadedPaths, ['MoonWell.exe', 'Data/common.MPQ']);
expect(statuses.last.message, 'Клиент готов к игре.');
expect(logger.errorMessages, isEmpty);
},
);
test('cleans an up-to-date installation without downloading', () async {
final root = await Directory.systemTemp.createTemp('moonwell_sync_');
addTearDown(() => root.delete(recursive: true));
final service = GameInstallationService();
final retained = ['MoonWell.exe', 'Data/common.MPQ', 'required.dll'];
final obsolete = [
'Data/old/patch.MPQ',
'WoW.exe',
'unused.DLL',
'Extentions/bin/extension.dll',
];
for (final path in [
...retained,
...obsolete,
'WTF/Config.wtf',
'realmlist.wtf',
]) {
final file = File(service.resolveClientPath(root.path, path));
await file.parent.create(recursive: true);
await file.writeAsString(path);
}
final entries = <ClientManifestFile>[];
for (final path in retained) {
final filePath = service.resolveClientPath(root.path, path);
entries.add(
ClientManifestFile(
path: path,
size: (await File(filePath).stat()).size,
sha256: await service.computeSha256(filePath),
),
);
}
final manifest = _manifestFromFiles(entries);
final api = _FakeLauncherApiClient(manifest);
final useCase = ClientSyncUseCase(
launcherApiClient: api,
installationService: service,
launcherLogService: _FakeLauncherLogService(),
);
final statuses = await useCase
.call(
ClientSyncUseCaseInput(
request: ClientSyncRequest(
installationDir: root.path,
accessToken: 'token',
manifest: manifest,
),
),
)
.toList();
expect(statuses.last.stage, ClientSyncStage.completed);
expect(statuses.last.localBuildHash, manifest.buildHash);
expect(
statuses.map((status) => status.stage),
contains(ClientSyncStage.removingStaleFiles),
);
expect(api.downloadedPaths, isEmpty);
for (final path in [
...obsolete,
'Data/old',
'Extentions/bin',
'Extentions',
]) {
expect(
await FileSystemEntity.type(
service.resolveClientPath(root.path, path),
followLinks: false,
),
FileSystemEntityType.notFound,
reason: path,
);
}
for (final path in [...retained, 'WTF/Config.wtf', 'realmlist.wtf']) {
expect(
await File(service.resolveClientPath(root.path, path)).readAsString(),
path,
);
}
});
test('fails final verification when stale files remain', () async {
final manifest = _manifestFromFiles([
const ClientManifestFile(path: 'MoonWell.exe', size: 5, sha256: 'hash'),
]);
final snapshot = ClientInstallationSnapshot.fromFiles(
[const LocalClientFile(path: 'MoonWell.exe', size: 5, sha256: 'hash')],
stalePaths: ['Data/extra.MPQ'],
);
final service = _FakeGameInstallationService([snapshot, snapshot]);
final useCase = ClientSyncUseCase(
launcherApiClient: _FakeLauncherApiClient(manifest),
installationService: service,
launcherLogService: _FakeLauncherLogService(),
);
await expectLater(
useCase
.call(
ClientSyncUseCaseInput(
request: ClientSyncRequest(
installationDir: 'C:/MoonWell',
accessToken: 'token',
manifest: manifest,
),
),
)
.drain<void>(),
throwsA(
isA<LauncherSyncException>().having(
(error) => error.message,
'message',
contains('Data/extra.MPQ'),
),
),
);
});
test(
'preserves failed temporary file and returns a log hint on verification mismatch',
() async {
@@ -247,6 +384,7 @@ class _FakeGameInstallationService extends GameInstallationService {
: _snapshots = Queue.of(snapshots);
final Queue<ClientInstallationSnapshot> _snapshots;
final List<String> ensuredParentDirectories = [];
final List<String> deletedRelativeFiles = [];
final List<String> deletedFiles = [];
@@ -258,6 +396,7 @@ class _FakeGameInstallationService extends GameInstallationService {
@override
Future<ClientInstallationSnapshot> scanInstallation(
String installationDir, {
required ClientManifest manifest,
InstallationScanProgressCallback? onProgress,
FutureOr<bool> Function()? isCancelled,
}) async {
@@ -1,10 +1,11 @@
import 'dart:io';
import 'package:crypto/crypto.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/config.dart';
import 'package:moonwell_launcher/features/launcher/data/game_installation_service.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_hash_entry.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/client_manifest.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_exception.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_game_ticket.dart';
void main() {
group('GameInstallationService', () {
@@ -12,14 +13,17 @@ void main() {
late GameInstallationService service;
setUp(() async {
service = GameInstallationService();
service = _RecordingGameInstallationService();
rootDirectory = await Directory.systemTemp.createTemp(
'moonwell_launcher_',
);
await File(
'${rootDirectory.path}${Platform.pathSeparator}Wow.exe',
).writeAsString('wow');
service.getExecutablePath(rootDirectory.path),
).writeAsString('moonwell');
await File(
'${rootDirectory.path}${Platform.pathSeparator}realmlist.wtf',
).writeAsString('set realmlist 127.0.0.1:3724\n');
await Directory(
'${rootDirectory.path}${Platform.pathSeparator}Data',
).create(recursive: true);
@@ -48,35 +52,285 @@ void main() {
}
});
test('scanInstallation ignores excluded directories', () async {
final snapshot = await service.scanInstallation(rootDirectory.path);
final paths = snapshot.files.map((file) => file.path).toList()..sort();
test(
'finds only unmanaged Data files and legacy client binaries',
() async {
final retainedPaths = [
'MoonWell.exe',
'Data/common.MPQ',
'Data/ruRU/realmlist.wtf',
'Data/Addons/required.MPQ',
'required.DLL',
'WoW/required.dll',
'WoW/Data/common.MPQ',
];
final staleFiles = [
'Data/old.MPQ',
'Data/ruRU/old.MPQ',
'Data/Addons/extra.MPQ',
'Data/Cache/old.bin',
'Data/empty/old.MPQ',
'Data/common.MPQ.moonwell.part',
'Data/broken.MPQ.moonwell.part.failed',
'WoW.exe',
'old.DLL',
'WoW/WoW.exe',
'WoW/old.dll',
'WoW/Data/old.MPQ',
'Extentions/bin/extension.dll',
'WoW/Extentions/old.txt',
];
final untouchedPaths = [
'Cache/cache.bin',
'Logs/launcher.log',
'WTF/Config.wtf',
'Errors/error.dll',
'Screenshots/shot.dll',
'benilla-config/settings.dll',
'.moonwell_launcher/local.dll',
'Interface/AddOns/custom/addon.dll',
'notes.txt',
'Other.exe',
'realmlist.wtf',
];
for (final path in [
...retainedPaths,
...staleFiles,
...untouchedPaths,
]) {
final file = File(
service.resolveClientPath(rootDirectory.path, path),
);
await file.parent.create(recursive: true);
await file.writeAsString(path);
}
await Directory(
service.resolveClientPath(rootDirectory.path, 'Data/unused/nested'),
).create(recursive: true);
await Directory(
service.resolveClientPath(rootDirectory.path, 'Extentions/empty'),
).create(recursive: true);
final manifest = await _manifestForPaths(
service,
rootDirectory,
retainedPaths,
);
expect(paths, ['Data/common.MPQ', 'Wow.exe']);
expect(snapshot.buildHash, computeBuildHash(snapshot.files));
final snapshot = await service.scanInstallation(
rootDirectory.path,
manifest: manifest,
);
expect(
snapshot.files.map((file) => file.path),
unorderedEquals(retainedPaths),
);
expect(snapshot.buildHash, manifest.buildHash);
expect(
snapshot.stalePaths,
unorderedEquals([
...staleFiles,
'Data/Cache',
'Data/empty',
'Data/unused/nested',
'Data/unused',
'Extentions/bin',
'Extentions/empty',
'Extentions',
'WoW/Extentions',
]),
);
for (final path in snapshot.stalePaths) {
await service.deleteRelativeFile(rootDirectory.path, path);
}
for (final path in [...retainedPaths, ...untouchedPaths]) {
expect(
await File(
service.resolveClientPath(rootDirectory.path, path),
).exists(),
isTrue,
reason: path,
);
}
for (final path in snapshot.stalePaths) {
expect(
await FileSystemEntity.type(
service.resolveClientPath(rootDirectory.path, path),
followLinks: false,
),
FileSystemEntityType.notFound,
reason: path,
);
}
final verified = await service.scanInstallation(
rootDirectory.path,
manifest: manifest,
);
expect(verified.stalePaths, isEmpty);
expect(verified.buildHash, manifest.buildHash);
expect(
await File(service.getHashCachePath(rootDirectory.path)).exists(),
isTrue,
);
},
);
test('removes Data links without touching their targets', () async {
final outside = await Directory.systemTemp.createTemp(
'moonwell_outside_',
);
addTearDown(() => outside.delete(recursive: true));
final outsideFile = File(
'${outside.path}${Platform.pathSeparator}keep.dll',
);
await outsideFile.writeAsString('keep');
final link = Link(
service.resolveClientPath(rootDirectory.path, 'Data/external'),
);
await link.create(outside.path);
final manifest = await _manifestForPaths(service, rootDirectory, [
'Data/common.MPQ',
]);
final snapshot = await service.scanInstallation(
rootDirectory.path,
manifest: manifest,
);
expect(snapshot.stalePaths, ['Data/external']);
await service.deleteRelativeFile(rootDirectory.path, 'Data/external');
expect(await link.exists(), isFalse);
expect(await outsideFile.readAsString(), 'keep');
});
test('retains a directory link needed by manifest files', () async {
final target = Directory(
service.resolveClientPath(rootDirectory.path, 'shared-data'),
);
await target.create();
await File(
'${target.path}${Platform.pathSeparator}required.MPQ',
).writeAsString('required');
final link = Link(
service.resolveClientPath(rootDirectory.path, 'Data/linked'),
);
await link.create(target.path);
final manifest = await _manifestForPaths(service, rootDirectory, [
'Data/common.MPQ',
'Data/linked/required.MPQ',
]);
final snapshot = await service.scanInstallation(
rootDirectory.path,
manifest: manifest,
);
expect(snapshot.stalePaths, isEmpty);
expect(snapshot.buildHash, manifest.buildHash);
expect(await link.exists(), isTrue);
});
test(
'scanInstallation creates launcher hash cache outside verification set',
'rejects deleting through a directory link outside installation',
() async {
await service.scanInstallation(rootDirectory.path);
final outside = await Directory.systemTemp.createTemp(
'moonwell_outside_',
);
addTearDown(() => outside.delete(recursive: true));
final outsideFile = File(
'${outside.path}${Platform.pathSeparator}keep.dll',
);
await outsideFile.writeAsString('keep');
final link = Link(
service.resolveClientPath(rootDirectory.path, 'Data/external'),
);
await link.create(outside.path);
await expectLater(
service.deleteRelativeFile(
rootDirectory.path,
'Data/external/keep.dll',
),
throwsA(isA<LauncherSyncException>()),
);
expect(await outsideFile.readAsString(), 'keep');
},
);
final cacheFile = File(service.getHashCachePath(rootDirectory.path));
expect(await cacheFile.exists(), isTrue);
final secondSnapshot = await service.scanInstallation(
test(
'preserves Windows manifest files despite path case differences',
() async {
final file = File(
service.resolveClientPath(
rootDirectory.path,
'Data/ruRU/required.DLL',
),
);
await file.parent.create(recursive: true);
await file.writeAsString('required');
final manifest = await _manifestForPaths(service, rootDirectory, [
'data/ruru/required.dll',
]);
final snapshot = await service.scanInstallation(
rootDirectory.path,
manifest: manifest,
);
final paths = secondSnapshot.files.map((file) => file.path).toList()
..sort();
expect(snapshot.stalePaths, ['Data/common.MPQ']);
expect(snapshot.buildHash, manifest.buildHash);
},
skip: !Platform.isWindows,
);
expect(paths, ['Data/common.MPQ', 'Wow.exe']);
expect(
await Directory(
'${rootDirectory.path}${Platform.pathSeparator}${Config.launcherMetadataDirectoryName}',
).exists(),
isTrue,
test('preserves WoW.exe when explicitly present in manifest', () async {
await File(
service.resolveClientPath(rootDirectory.path, 'WoW.exe'),
).writeAsString('legacy');
final manifest = await _manifestForPaths(service, rootDirectory, [
'WoW.exe',
'Data/common.MPQ',
]);
final snapshot = await service.scanInstallation(
rootDirectory.path,
manifest: manifest,
);
expect(snapshot.stalePaths, isEmpty);
expect(snapshot.buildHash, manifest.buildHash);
});
test('rejects invalid manifest paths before scanning', () async {
for (final path in [
'../outside.dll',
'/outside.dll',
r'C:\outside.dll',
'C:outside.dll',
'Data/file:stream',
]) {
final manifest = ClientManifest.fromJson({
'files': [
{'path': path, 'size': 0, 'sha256': ''},
],
});
await expectLater(
service.scanInstallation(rootDirectory.path, manifest: manifest),
throwsA(isA<LauncherSyncException>()),
);
}
expect(
await File(service.getHashCachePath(rootDirectory.path)).exists(),
isFalse,
);
});
test(
'never recursively deletes a stale directory with new files',
() async {
final file = File(
service.resolveClientPath(rootDirectory.path, 'Data/old/new.MPQ'),
);
await file.parent.create(recursive: true);
await file.writeAsString('new');
await expectLater(
service.deleteRelativeFile(rootDirectory.path, 'Data/old'),
throwsA(isA<FileSystemException>()),
);
expect(await file.readAsString(), 'new');
},
);
@@ -91,6 +345,30 @@ void main() {
expect(await cacheDirectory.list().isEmpty, isTrue);
});
test('removeSavedAccountName removes accountName lines only', () async {
final configFile = File(
'${rootDirectory.path}${Platform.pathSeparator}WTF${Platform.pathSeparator}Config.wtf',
);
await configFile.parent.create(recursive: true);
await configFile.writeAsString(
'SET gxWindow "1"\r\n'
'SET accountName "admin#&|&#123456#&|&#0"\r\n'
'set ACCOUNTNAME "another account"\r\n'
'SET locale "ruRU"\r\n',
);
await service.removeSavedAccountName(rootDirectory.path);
expect(
await configFile.readAsString(),
'SET gxWindow "1"\r\nSET locale "ruRU"\r\n',
);
});
test('removeSavedAccountName ignores a missing Config.wtf', () async {
await service.removeSavedAccountName(rootDirectory.path);
});
test('ensureParentDirectoryExists creates nested directories', () async {
final tempPath =
'${rootDirectory.path}${Platform.pathSeparator}Data${Platform.pathSeparator}patches${Platform.pathSeparator}common-2.MPQ.moonwell.part';
@@ -125,5 +403,285 @@ void main() {
throwsA(isA<LauncherSyncException>()),
);
});
test(
'launchGame passes authorization only through child environment',
() async {
final recordingService = _RecordingGameInstallationService();
final authorization = LauncherGameTicket(
account: 'PLAYERONE',
ticket: 'A1B2C3D4E5F6G7H8',
expiresAt: DateTime.now().toUtc().add(const Duration(seconds: 60)),
);
await recordingService.launchGame(
rootDirectory.path,
authorization: authorization,
);
expect(recordingService.arguments, isEmpty);
expect(
recordingService.executablePath,
service.getExecutablePath(rootDirectory.path),
);
expect(recordingService.workingDirectory, rootDirectory.path);
expect(recordingService.environment, <String, String>{
'WOW_USER': 'PLAYERONE',
'WOW_PASS': 'A1B2C3D4E5F6G7H8',
'WOW_HOST': '127.0.0.1:3724',
'WOW_DATA': '${rootDirectory.path}${Platform.pathSeparator}Data',
'WOW_LOCALE': 'auto',
'BENILLA_HOME':
'${rootDirectory.path}${Platform.pathSeparator}benilla-config',
});
expect(
await File(
'${rootDirectory.path}${Platform.pathSeparator}realmlist.wtf',
).readAsString(),
'set realmlist 127.0.0.1:3724\n',
);
expect(
await File(
'${rootDirectory.path}${Platform.pathSeparator}Cache${Platform.pathSeparator}cache.bin',
).readAsString(),
'cache',
);
},
);
test(
'macOS starts the app launcher and keeps state outside the bundle',
() async {
final recordingService = _RecordingGameInstallationService(
platform: 'macos',
);
final executable = File(
recordingService.getExecutablePath(rootDirectory.path),
);
await executable.parent.create(recursive: true);
await executable.writeAsString('#!/bin/sh\n');
await recordingService.launchGame(
rootDirectory.path,
authorization: _validTicket(),
);
expect(recordingService.executablePath, executable.path);
expect(
recordingService.environment?['BENILLA_HOME'],
'${rootDirectory.path}${Platform.pathSeparator}benilla-config',
);
expect(recordingService.arguments, isEmpty);
},
);
test('uses WoW/Data when the install has a nested Data directory', () async {
await Directory(
'${rootDirectory.path}${Platform.pathSeparator}Data',
).rename('${rootDirectory.path}${Platform.pathSeparator}WoW');
final nestedData = Directory(
'${rootDirectory.path}${Platform.pathSeparator}WoW${Platform.pathSeparator}Data',
);
await nestedData.create();
final recordingService = _RecordingGameInstallationService();
await recordingService.launchGame(
rootDirectory.path,
authorization: _validTicket(),
);
expect(recordingService.environment?['WOW_DATA'], nestedData.path);
});
test('verifies and retains Russian archives before launching', () async {
final paths = [
'MoonWell.exe',
'Data/common.MPQ',
'Data/ruRU/patch-1.MPQ',
'Data/ruRU/patch-2.MPQ',
'Data/ruRU/patch-3.MPQ',
];
for (final path in paths.skip(2)) {
final file = File(service.resolveClientPath(rootDirectory.path, path));
await file.parent.create(recursive: true);
await file.writeAsString('localized archive: $path');
}
final manifest = await _manifestForPaths(service, rootDirectory, paths);
final snapshot = await service.scanInstallation(
rootDirectory.path,
manifest: manifest,
);
expect(snapshot.buildHash, manifest.buildHash);
expect(snapshot.stalePaths, isEmpty);
final recordingService = _RecordingGameInstallationService();
await recordingService.launchGame(
rootDirectory.path,
authorization: _validTicket(),
);
expect(recordingService.environment?['WOW_LOCALE'], 'auto');
expect(
recordingService.environment?['WOW_DATA'],
'${rootDirectory.path}${Platform.pathSeparator}Data',
);
for (final path in paths.skip(2)) {
expect(
await File(
service.resolveClientPath(rootDirectory.path, path),
).readAsString(),
'localized archive: $path',
);
}
});
test('configured auth address overrides the install realmlist', () async {
final configured = _RecordingGameInstallationService(
authAddress: 'login.example:3725',
);
expect(
await configured.resolveAuthAddress(rootDirectory.path),
'login.example:3725',
);
});
test('reads a quoted realmlist with CRLF without modifying it', () async {
final file = File(
'${rootDirectory.path}${Platform.pathSeparator}realmlist.wtf',
);
await file.writeAsString('SET REALMLIST "login.example:3724"\r\n');
expect(
await service.resolveAuthAddress(rootDirectory.path),
'login.example:3724',
);
expect(
await file.readAsString(),
'SET REALMLIST "login.example:3724"\r\n',
);
});
test('rejects missing or malformed auth endpoints', () async {
final file = File(
'${rootDirectory.path}${Platform.pathSeparator}realmlist.wtf',
);
await file.delete();
await expectLater(
service.resolveAuthAddress(rootDirectory.path),
throwsA(isA<LauncherSyncException>()),
);
for (final address in [
'https://login.example',
'login.example:0',
'login.example:65536',
]) {
final configured = _RecordingGameInstallationService(
authAddress: address,
);
await expectLater(
configured.resolveAuthAddress(rootDirectory.path),
throwsA(isA<LauncherSyncException>()),
);
}
});
test('does not start a process with an expired ticket', () async {
final recordingService = _RecordingGameInstallationService();
await expectLater(
recordingService.launchGame(
rootDirectory.path,
authorization: LauncherGameTicket(
account: 'PLAYERONE',
ticket: 'A1B2C3D4E5F6G7H8',
expiresAt: DateTime.utc(2020),
),
),
throwsA(isA<LauncherSyncException>()),
);
expect(recordingService.environment, isNull);
});
test(
'does not launch a missing client or an installation without data',
() async {
final recordingService = _RecordingGameInstallationService();
final executable = File(
recordingService.getExecutablePath(rootDirectory.path),
);
await executable.delete();
await expectLater(
recordingService.launchGame(
rootDirectory.path,
authorization: _validTicket(),
),
throwsA(isA<LauncherSyncException>()),
);
await executable.writeAsString('moonwell');
await Directory(
'${rootDirectory.path}${Platform.pathSeparator}Data',
).delete(recursive: true);
await expectLater(
recordingService.launchGame(
rootDirectory.path,
authorization: _validTicket(),
),
throwsA(isA<LauncherSyncException>()),
);
expect(recordingService.environment, isNull);
},
);
});
}
Future<ClientManifest> _manifestForPaths(
GameInstallationService service,
Directory rootDirectory,
List<String> paths,
) async {
final files = <Map<String, Object>>[];
for (final path in paths) {
final bytes = await File(
service.resolveClientPath(rootDirectory.path, path),
).readAsBytes();
files.add({
'path': path,
'size': bytes.length,
'sha256': sha256.convert(bytes).toString(),
});
}
return ClientManifest.fromJson({'files': files});
}
LauncherGameTicket _validTicket() => LauncherGameTicket(
account: 'PLAYERONE',
ticket: 'A1B2C3D4E5F6G7H8',
expiresAt: DateTime.now().toUtc().add(const Duration(seconds: 60)),
);
final class _RecordingGameInstallationService extends GameInstallationService {
_RecordingGameInstallationService({
this.platform = 'windows',
this.authAddress = '',
});
final String platform;
final String authAddress;
@override
String get operatingSystem => platform;
@override
String get configuredAuthAddress => authAddress;
Map<String, String>? environment;
List<String>? arguments;
String? executablePath;
String? workingDirectory;
@override
Future<GameProcessHandle> startGameProcess({
required String executablePath,
required List<String> arguments,
required String workingDirectory,
required Map<String, String> environment,
}) async {
this.arguments = List<String>.from(arguments);
this.environment = Map<String, String>.from(environment);
this.executablePath = executablePath;
this.workingDirectory = workingDirectory;
return GameProcessHandle(pid: 42, exitCode: Future<int>.value(0));
}
}
@@ -0,0 +1,48 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/features/launcher/data/launcher_api_client.dart';
void main() {
test('requests a Vanilla game ticket with bearer authentication', () async {
final server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);
addTearDown(() => server.close(force: true));
final client = _LocalLauncherApiClient(server.port);
final ticketFuture = client.issueGameTicket('test-launcher-token');
final request = await server.first;
expect(request.method, 'POST');
expect(request.uri.path, '/api/launcher/game-ticket');
expect(
request.headers.value(HttpHeaders.authorizationHeader),
'Bearer test-launcher-token',
);
expect(jsonDecode(await utf8.decoder.bind(request).join()), {
'client_build': 5875,
});
request.response.headers.contentType = ContentType.json;
request.response.write(
jsonEncode({
'account': 'PLAYERONE',
'ticket': 'A1B2C3D4E5F6G7H8',
'expires_at': DateTime.now()
.toUtc()
.add(const Duration(seconds: 60))
.toIso8601String(),
}),
);
await request.response.close();
final ticket = await ticketFuture;
expect(ticket.account, 'PLAYERONE');
expect(ticket.ticket, 'A1B2C3D4E5F6G7H8');
});
}
class _LocalLauncherApiClient extends LauncherApiClient {
_LocalLauncherApiClient(this.port);
final int port;
@override
String get apiBaseUrl => 'http://127.0.0.1:$port';
}
@@ -0,0 +1,79 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:moonwell_launcher/features/launcher/domain/entities/launcher_game_ticket.dart';
void main() {
group('LauncherGameTicket', () {
test('parses the launcher authorization contract', () {
final ticket = LauncherGameTicket.fromJson(<String, Object?>{
'account': 'PLAYERONE',
'ticket': 'A1B2C3D4E5F6G7H8',
'expires_at': '2026-08-16T12:01:00Z',
});
expect(ticket.account, 'PLAYERONE');
expect(ticket.ticket, 'A1B2C3D4E5F6G7H8');
expect(ticket.expiresAt, DateTime.utc(2026, 8, 16, 12, 1));
});
test('rejects tickets outside the native client format', () {
expect(
() => LauncherGameTicket.fromJson(<String, Object?>{
'account': 'PLAYERONE',
'ticket': 'lowercase-ticket',
'expires_at': '2026-08-16T12:01:00Z',
}),
throwsFormatException,
);
});
test('does not normalize credentials from the API', () {
expect(
() => LauncherGameTicket.fromJson(<String, Object?>{
'account': 'PLAYER ',
'ticket': ' A1B2C3D4E5F6G7H8',
'expires_at': '2026-08-16T12:01:00Z',
}),
throwsFormatException,
);
});
test('rejects accounts incompatible with the web 1.12.1 contract', () {
for (final account in [
'AB',
'ABCDEFGHIJKLMNOPQ',
'PLAYER_NAME',
'playerone',
]) {
expect(
() => LauncherGameTicket.fromJson(<String, Object?>{
'account': account,
'ticket': 'A1B2C3D4E5F6G7H8',
'expires_at': '2026-08-16T12:01:00Z',
}),
throwsFormatException,
);
}
});
test('requires enough validity to start the game', () {
final ticket = LauncherGameTicket(
account: 'PLAYERONE',
ticket: 'A1B2C3D4E5F6G7H8',
expiresAt: DateTime.utc(2026, 8, 16, 12, 0, 4),
);
expect(ticket.isUsable(now: DateTime.utc(2026, 8, 16, 12)), isFalse);
});
});
test('rejects non-string payload fields with a format exception', () {
expect(
() => LauncherGameTicket.fromJson(<String, dynamic>{
'account': 42,
'ticket': 'ABCDEFGH12345678',
'expires_at': '2026-08-16T20:00:00Z',
}),
throwsFormatException,
);
});
}
+123 -50
View File
@@ -14,6 +14,9 @@ Fails unless the X.Y.Z part of pubspec.yaml matches this value.
.PARAMETER ReleaseNotes
Text written to the AppCast item description.
.PARAMETER EnvFile
Local dotenv file used to fill environment variables that are not already set.
.PARAMETER DryRun
Builds, signs, and verifies local artifacts without changing production.
@@ -42,12 +45,14 @@ param(
[string]$S3Endpoint,
[string]$S3Bucket,
[string]$S3Key = 'moonwell_launcher_setup.exe',
[string]$EnvFile = '.env',
[string]$PrivateKeyPath = '.moonwell_signing\dsa_priv.pem',
[string]$PublicKeyPath = 'windows\runner\resources\dsa_pub.pem',
[string]$FlutterCommand = 'flutter',
[string]$DartCommand = 'dart',
[string]$InnoSetupCommand,
[string]$OpenSslCommand,
[string]$VcRuntimePath,
[switch]$SkipChecks,
[switch]$DryRun,
[switch]$Force
@@ -89,9 +94,19 @@ function Invoke-RequiredCommand {
[Parameter(Mandatory = $true)][string[]]$Arguments
)
& $Command @Arguments
if ($LASTEXITCODE -ne 0) {
throw "Command failed with exit code ${LASTEXITCODE}: $Command"
# Windows PowerShell represents native stderr as error records even on exit 0.
# OpenSSL writes its normal key-reading notices there; the exit code is the verdict.
$previousPreference = $ErrorActionPreference
try {
$ErrorActionPreference = 'Continue'
& $Command @Arguments
$commandExitCode = $LASTEXITCODE
}
finally {
$ErrorActionPreference = $previousPreference
}
if ($commandExitCode -ne 0) {
throw "Command failed with exit code ${commandExitCode}: $Command"
}
}
@@ -101,6 +116,64 @@ function Get-FileSha256 {
return (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash.ToLowerInvariant()
}
function Import-DotEnv {
param([Parameter(Mandatory = $true)][string]$Path)
if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) {
return
}
$allowedNames = @(
'AWS_ACCESS_KEY_ID',
'AWS_SECRET_ACCESS_KEY',
'AWS_DEFAULT_REGION',
'AWS_BUCKET',
'AWS_ENDPOINT',
'AWS_USE_PATH_STYLE_ENDPOINT',
'LAUNCHER_AUTH_KEY'
)
foreach ($line in Get-Content -LiteralPath $Path) {
$trimmed = $line.Trim()
if (
[string]::IsNullOrWhiteSpace($trimmed) -or
$trimmed.StartsWith('#')
) {
continue
}
$separator = $trimmed.IndexOf('=')
if ($separator -le 0) {
throw "Invalid dotenv line in ${Path}: $line"
}
$name = $trimmed.Substring(0, $separator).Trim()
if ($allowedNames -notcontains $name) {
continue
}
$value = $trimmed.Substring($separator + 1).Trim()
if (
$value.Length -ge 2 -and
(
($value.StartsWith('"') -and $value.EndsWith('"')) -or
($value.StartsWith("'") -and $value.EndsWith("'"))
)
) {
$value = $value.Substring(1, $value.Length - 2)
}
$existing = [Environment]::GetEnvironmentVariable($name)
if ([string]::IsNullOrWhiteSpace($existing)) {
[Environment]::SetEnvironmentVariable(
$name,
$value,
[EnvironmentVariableTarget]::Process
)
}
}
}
function Get-AppcastVersion {
param([Parameter(Mandatory = $true)][string]$Path)
@@ -117,6 +190,7 @@ function Write-Appcast {
param(
[Parameter(Mandatory = $true)][string]$Path,
[Parameter(Mandatory = $true)][string]$Version,
[Parameter(Mandatory = $true)][string]$BuildVersion,
[Parameter(Mandatory = $true)][string]$Notes,
[Parameter(Mandatory = $true)][string]$InstallerUrl,
[Parameter(Mandatory = $true)][string]$Signature,
@@ -167,7 +241,7 @@ function Write-Appcast {
'sparkle',
'version',
$script:SparkleNamespace,
$Version
$BuildVersion
)
$writer.WriteAttributeString(
'sparkle',
@@ -282,6 +356,14 @@ $previousLocation = Get-Location
try {
Set-Location $repositoryRoot
$resolvedEnvFile = if ([IO.Path]::IsPathRooted($EnvFile)) {
$EnvFile
}
else {
Join-Path $repositoryRoot $EnvFile
}
Import-DotEnv -Path $resolvedEnvFile
if ([string]::IsNullOrWhiteSpace($S3Endpoint)) {
$S3Endpoint = $env:AWS_ENDPOINT
}
@@ -399,9 +481,10 @@ try {
-UseBasicParsing `
-OutFile $publishedPath
$publishedVersion = Get-AppcastVersion -Path $publishedPath
$publishedReleaseVersion = $publishedVersion.Split('+')[0]
if (
-not [string]::IsNullOrWhiteSpace($publishedVersion) -and
[version]$version -le [version]$publishedVersion
[version]$version -le [version]$publishedReleaseVersion
) {
throw (
"Version $version is not newer than published version " +
@@ -447,6 +530,27 @@ try {
"--dart-define=MOONWELL_APPCAST_URL=$AppcastUrl"
)
Write-Step 'Bundling the x64 Visual C++ runtime'
if ([string]::IsNullOrWhiteSpace($VcRuntimePath)) {
$vswherePath = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$vsInstall = (& $vswherePath -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath).Trim()
if ($LASTEXITCODE -ne 0 -or -not $vsInstall) {
throw 'Visual Studio C++ runtime was not found; pass -VcRuntimePath.'
}
$redistVersion = Get-ChildItem -LiteralPath (Join-Path $vsInstall 'VC\Redist\MSVC') -Directory |
Where-Object { $_.Name -match '^\d+\.\d+\.\d+$' } |
Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1
$VcRuntimePath = Join-Path $redistVersion.FullName 'x64\Microsoft.VC143.CRT'
}
foreach ($requiredDll in @('msvcp140.dll', 'vcruntime140.dll', 'vcruntime140_1.dll')) {
if (-not (Test-Path -LiteralPath (Join-Path $VcRuntimePath $requiredDll) -PathType Leaf)) {
throw "The x64 Visual C++ redistributable $requiredDll was not found."
}
}
Get-ChildItem -LiteralPath $VcRuntimePath -Filter '*.dll' -File | ForEach-Object {
Copy-Item -LiteralPath $_.FullName -Destination 'build\windows\x64\runner\Release'
}
Write-Step 'Building the Inno Setup installer'
Invoke-RequiredCommand -Command $innoSetup -Arguments @(
"/DMyAppVersion=$version",
@@ -465,12 +569,9 @@ try {
$previousPath = $env:PATH
try {
$env:PATH = "$gitOpenSslDirectory;$env:PATH"
$signOutput = & $dart run auto_updater:sign_update `
$installerPath `
$privateKey 2>&1
if ($LASTEXITCODE -ne 0) {
throw "Could not sign the installer: $signOutput"
}
$signOutput = Invoke-RequiredCommand -Command $dart -Arguments @(
'run', 'auto_updater:sign_update', $installerPath, $privateKey
) 2>&1
}
finally {
$env:PATH = $previousPath
@@ -503,6 +604,7 @@ try {
'/' +
$S3Key
)
$appcastBuildVersion = "$version+$buildNumber"
$appcastPath = if ($DryRun) {
Join-Path $temporaryDirectory 'appcast.xml'
}
@@ -513,6 +615,7 @@ try {
Write-Appcast `
-Path $appcastPath `
-Version $version `
-BuildVersion $appcastBuildVersion `
-Notes $ReleaseNotes `
-InstallerUrl $installerUrl `
-Signature $signature `
@@ -522,7 +625,7 @@ try {
-LiteralPath $appcastPath `
-Raw `
-Encoding UTF8
if ((Get-AppcastVersion -Path $appcastPath) -ne $version) {
if ((Get-AppcastVersion -Path $appcastPath) -ne $appcastBuildVersion) {
throw 'The generated AppCast contains the wrong version.'
}
@@ -543,45 +646,15 @@ try {
$env:MOONWELL_RELEASE_KEY = $S3Key
$env:MOONWELL_RELEASE_VERSION = $version
$env:MOONWELL_RELEASE_SHA256 = $installerSha256
$uploadScript = @'
import os
import boto3
from botocore.config import Config
$uploadHelper = Join-Path `
$repositoryRoot `
'tool\upload_launcher_release.py'
if (-not (Test-Path -LiteralPath $uploadHelper -PathType Leaf)) {
throw "S3 upload helper was not found: $uploadHelper"
}
path_style = os.getenv("AWS_USE_PATH_STYLE_ENDPOINT", "true").lower()
addressing_style = "path" if path_style in ("1", "true", "yes") else "virtual"
s3 = boto3.client(
"s3",
endpoint_url=os.environ["MOONWELL_RELEASE_ENDPOINT"],
region_name=os.getenv("AWS_DEFAULT_REGION", "ru-central1"),
config=Config(s3={"addressing_style": addressing_style}),
)
s3.upload_file(
os.environ["MOONWELL_RELEASE_FILE"],
os.environ["MOONWELL_RELEASE_BUCKET"],
os.environ["MOONWELL_RELEASE_KEY"],
ExtraArgs={
"ACL": "public-read",
"ContentType": "application/x-msdownload",
"CacheControl": "no-cache, max-age=0",
"Metadata": {
"launcher-version": os.environ["MOONWELL_RELEASE_VERSION"],
"sha256": os.environ["MOONWELL_RELEASE_SHA256"],
},
},
)
response = s3.head_object(
Bucket=os.environ["MOONWELL_RELEASE_BUCKET"],
Key=os.environ["MOONWELL_RELEASE_KEY"],
)
print("S3_VERSION_ID=" + str(response.get("VersionId", "")))
print("S3_CONTENT_LENGTH=" + str(response["ContentLength"]))
'@
try {
Invoke-RequiredCommand -Command $python -Arguments @(
'-c',
$uploadScript
)
Invoke-RequiredCommand -Command $python -Arguments @($uploadHelper)
}
finally {
Remove-Item Env:MOONWELL_RELEASE_FILE -ErrorAction SilentlyContinue
@@ -651,7 +724,7 @@ print("S3_CONTENT_LENGTH=" + str(response["ContentLength"]))
$publishedEnclosure.GetAttribute(
'version',
$script:SparkleNamespace
) -ne $version -or
) -ne $appcastBuildVersion -or
[long]$publishedEnclosure.length -ne $installer.Length -or
$publishedEnclosure.url -ne $installerUrl
) {
+70
View File
@@ -0,0 +1,70 @@
"""Upload a MoonWell Launcher installer to S3-compatible storage.
Release metadata is supplied by ``deploy_launcher.ps1`` through environment
variables. A real Python file avoids Windows PowerShell quoting problems that
occur when a multiline program is passed to ``python -c``.
"""
from __future__ import annotations
import os
from pathlib import Path
import boto3
from botocore.config import Config
def required_environment_value(name: str) -> str:
value = os.environ.get(name, "").strip()
if not value:
raise RuntimeError(f"Required environment variable is missing: {name}")
return value
release_file = Path(required_environment_value("MOONWELL_RELEASE_FILE"))
endpoint = required_environment_value("MOONWELL_RELEASE_ENDPOINT")
bucket = required_environment_value("MOONWELL_RELEASE_BUCKET")
object_key = required_environment_value("MOONWELL_RELEASE_KEY")
version = required_environment_value("MOONWELL_RELEASE_VERSION")
sha256 = required_environment_value("MOONWELL_RELEASE_SHA256")
if not release_file.is_file():
raise FileNotFoundError(f"Installer does not exist: {release_file}")
path_style = os.getenv("AWS_USE_PATH_STYLE_ENDPOINT", "true").lower()
addressing_style = (
"path" if path_style in ("1", "true", "yes") else "virtual"
)
s3 = boto3.client(
"s3",
endpoint_url=endpoint,
region_name=os.getenv("AWS_DEFAULT_REGION", "ru-central1"),
config=Config(s3={"addressing_style": addressing_style}),
)
s3.upload_file(
str(release_file),
bucket,
object_key,
ExtraArgs={
"ACL": "public-read",
"ContentType": "application/x-msdownload",
"CacheControl": "no-cache, max-age=0",
"Metadata": {
"launcher-version": version,
"sha256": sha256,
},
},
)
response = s3.head_object(Bucket=bucket, Key=object_key)
local_size = release_file.stat().st_size
remote_size = int(response["ContentLength"])
if remote_size != local_size:
raise RuntimeError(
f"Uploaded object size mismatch: local={local_size}, "
f"remote={remote_size}"
)
print("S3_VERSION_ID=" + str(response.get("VersionId", "")))
print("S3_CONTENT_LENGTH=" + str(remote_size))
+5
View File
@@ -35,6 +35,11 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
target_link_options(
${BINARY_NAME}
PRIVATE
"/MANIFESTUAC:level='requireAdministrator' uiAccess='false'"
)
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)