Skip to content

armgit / soju

Public Imported from GitHub
0

Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.

Use approved purchase affiliates automatically when available (#36)

Mikek2b82e37fbfce
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
index d5e65ce5fea..7247059f277 100644
--- a/.github/workflows/check.yml
+++ b/.github/workflows/check.yml
@@ -16,5 +16,9 @@ jobs:
for script in scripts/*.sh scripts/soju; do bash -n "$script"; done
python3 -m unittest discover -s tests -q
node --test tests/test_steam_login.cjs
+ - name: Purchase link routing
+ run: |
+ swiftc app/PurchaseLinks.swift tests/test_purchase_links.swift -o /tmp/soju-purchase-tests
+ /tmp/soju-purchase-tests
- name: Build and verify the native app
run: bash scripts/build-app.sh
diff --git a/README.md b/README.md
index 89a415c3955..9c31b31e0de 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ CodeWeavers' published sources; Steam uses a separate wine-stable setup.
Apple's proprietary GPTK/D3DMetal is downloaded separately. Games and store
clients are not included.
-**Current release: [v1.6.1](https://github.com/BCD1210/soju/releases/tag/v1.6.1).**
+**Current release: [v1.6.2](https://github.com/BCD1210/soju/releases/tag/v1.6.2).**
The compatibility examples below were verified on M4 Pro / macOS 26.5.
D2R and Hogwarts Legacy are examples of supported games, not the scope of the project.
@@ -91,7 +91,7 @@ soju install # then: soju battlenet / soju d2r / soju steam / soju epic / so
The installer asks which launchers you want **before downloading anything**. Steam-only installs skip the CX engine and Apple GPTK. Steam rendering components are downloaded with SHA-256 verification and installed in a Soju-owned Wine 11.0 runtime. Battle.net, Epic and GOG use the shared CX engine and your separately downloaded Apple GPTK. Each official client keeps its own bottle and shortcut in `~/Applications`.
-[Download Soju for Mac](https://github.com/BCD1210/soju/releases/download/v1.6.1/Soju-1.6.1-macos-arm64.zip) — the native desktop preview includes installed and owned games, store search, favorites, game launching and platform management. See [desktop setup and requirements](docs/DESKTOP.md).
+[Download Soju for Mac](https://github.com/BCD1210/soju/releases/download/v1.6.2/Soju-1.6.2-macos-arm64.zip) — the native desktop preview includes installed and owned games, store search, favorites, game launching and platform management. See [desktop setup and requirements](docs/DESKTOP.md).
## Everyday commands
diff --git a/VERSION b/VERSION
index 9c6d6293b1a..fdd3be6df54 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.6.1
+1.6.2
diff --git a/app/Discover.swift b/app/Discover.swift
index 234f654da75..7257a9eefa7 100644
--- a/app/Discover.swift
+++ b/app/Discover.swift
@@ -57,13 +57,14 @@ struct DiscoverView: View {
@State private var query = ""
@State private var country = "US"
@State private var platform = "all"
+ @State private var purchaseLinks = PurchaseLinks.empty
private var shown: [StoreItem] { store.results.filter { platform == "all" || $0.platform.rawValue == platform } }
var body: some View {
VStack(alignment: .leading, spacing: 18) {
HStack {
VStack(alignment: .leading, spacing: 7) {
Text("Find your next game").font(.system(size: 30, weight: .bold, design: .rounded))
- Text("Search Steam and GOG. Compare listings, then visit the official store.").font(.callout).foregroundStyle(.secondary)
+ Text("Search Steam and GOG. Compare games and prices.").font(.callout).foregroundStyle(.secondary)
}
Spacer()
}
@@ -109,20 +110,18 @@ struct DiscoverView: View {
}.padding(.vertical, 3)
}
}
- Divider()
- HStack(spacing: 14) {
- Text("Search directly:").font(.caption).foregroundStyle(.secondary)
- ForEach(Launcher.allCases) { launcher in
- Button(launcher == .gog ? "GOG" : launcher.title) { openSearch(launcher) }
- .buttonStyle(.link)
- }
+ if purchaseLinks.hasAffiliateLinks {
+ Text("Links marked ‘Supports Soju’ may earn us a commission if you buy, at no extra cost to you.")
+ .font(.caption).foregroundStyle(.secondary)
}
+ Divider()
Text("Prices are for the selected region and may change at checkout. Listings can include add-ons and bundles. Store availability does not confirm compatibility with Soju.")
.font(.caption).foregroundStyle(.secondary)
- }.padding(28).onDisappear { store.cancel() }
+ }.padding(28).onAppear { purchaseLinks = PurchaseLinks.load(root: model.root) }.onDisappear { store.cancel() }
}
private func listing(_ item: StoreItem) -> some View {
let owned = model.games.first { $0.id == item.id }
+ let purchase = purchaseLinks.resolve(item.url)
return VStack(alignment: .leading, spacing: 12) {
ZStack {
Color.primary.opacity(0.04)
@@ -148,31 +147,17 @@ struct DiscoverView: View {
}.disabled(model.busy)
}
Spacer()
- Button("View in store") {
- if let url = URL(string: item.url), url.scheme == "https",
- ["store.steampowered.com", "www.gog.com"].contains(url.host ?? "") { NSWorkspace.shared.open(url) }
- }.buttonStyle(.borderedProminent)
+ if let purchase {
+ VStack(alignment: .trailing, spacing: 4) {
+ Button("View in store") { NSWorkspace.shared.open(purchase.url) }
+ .buttonStyle(.borderedProminent)
+ if purchase.isAffiliate {
+ Text("Supports Soju").font(.caption2).foregroundStyle(.secondary)
+ }
+ }
+ }
}
}.padding(16).frame(maxWidth: .infinity, alignment: .leading)
.background(Color.primary.opacity(0.035), in: RoundedRectangle(cornerRadius: 13))
}
- private func openSearch(_ launcher: Launcher) {
- var url: URLComponents
- let query = query.trimmingCharacters(in: .whitespacesAndNewlines)
- switch launcher {
- case .steam:
- url = URLComponents(string: "https://store.steampowered.com/search/")!
- url.queryItems = [URLQueryItem(name: "term", value: query), URLQueryItem(name: "cc", value: country)]
- case .gog:
- url = URLComponents(string: "https://www.gog.com/en/games")!
- url.queryItems = [URLQueryItem(name: "query", value: query)]
- case .epic:
- url = URLComponents(string: "https://store.epicgames.com/en-US/browse")!
- url.queryItems = [URLQueryItem(name: "q", value: query), URLQueryItem(name: "sortBy", value: "relevancy")]
- case .battlenet:
- url = URLComponents(string: "https://us.shop.battle.net/en-us/search")!
- url.queryItems = [URLQueryItem(name: "q", value: query)]
- }
- if let url = url.url { NSWorkspace.shared.open(url) }
- }
}
diff --git a/app/PurchaseLinks.swift b/app/PurchaseLinks.swift
new file mode 100644
index 00000000000..507dc4fa674
--- /dev/null
+++ b/app/PurchaseLinks.swift
@@ -0,0 +1,56 @@
+import Foundation
+
+/// Reviewed links shipped with the app, never supplied by search responses.
+struct PurchaseLinks: Decodable {
+ struct Entry: Decodable {
+ let destination: String
+ let affiliate: String
+ }
+ struct Route {
+ let url: URL
+ let isAffiliate: Bool
+ }
+ let schema: Int
+ let enabled: Bool
+ let links: [Entry]
+ static let empty = PurchaseLinks(schema: 1, enabled: false, links: [])
+
+ static func load(root: URL) -> PurchaseLinks {
+ let file = root.appendingPathComponent("resources/purchase-links.json")
+ guard let data = try? Data(contentsOf: file), data.count <= 256 * 1024,
+ let config = try? JSONDecoder().decode(Self.self, from: data),
+ config.schema == 1, config.links.count <= 500 else { return .empty }
+ var seen = Set<String>()
+ for link in config.links {
+ guard let destination = safeURL(link.destination, hosts: ["www.gog.com"]),
+ destination.path.hasPrefix("/en/game/") || destination.path.hasPrefix("/game/"),
+ destination.query == nil, destination.fragment == nil,
+ safeURL(link.affiliate, hosts: ["www.gog.com", "af.gog.com"]) != nil,
+ seen.insert(link.destination).inserted else { return .empty }
+ }
+ return config
+ }
+
+ var hasAffiliateLinks: Bool { enabled && !links.isEmpty }
+
+ func resolve(_ destination: String) -> Route? {
+ guard let direct = Self.safeURL(destination, hosts: [
+ "store.steampowered.com", "www.gog.com", "store.epicgames.com", "us.shop.battle.net"
+ ]) else { return nil }
+ if schema == 1, enabled, direct.host == "www.gog.com",
+ let entry = links.first(where: { $0.destination == destination }),
+ let affiliate = Self.safeURL(entry.affiliate, hosts: ["www.gog.com", "af.gog.com"]) {
+ return Route(url: affiliate, isAffiliate: true)
+ }
+ return Route(url: direct, isAffiliate: false)
+ }
+
+ private static func safeURL(_ value: String, hosts: Set<String>) -> URL? {
+ guard value.count <= 8192, !value.contains("\\"),
+ !value.unicodeScalars.contains(where: { CharacterSet.controlCharacters.contains($0) }),
+ let url = URL(string: value), url.scheme == "https",
+ url.user == nil, url.password == nil, url.port == nil || url.port == 443,
+ let host = url.host, hosts.contains(host) else { return nil }
+ return url
+ }
+}
diff --git a/docs/DESKTOP.md b/docs/DESKTOP.md
index 9419ba74812..134bd365a0b 100644
--- a/docs/DESKTOP.md
+++ b/docs/DESKTOP.md
@@ -1,6 +1,6 @@
# Soju for Mac
-[Download v1.6.1](https://github.com/BCD1210/soju/releases/download/v1.6.1/Soju-1.6.1-macos-arm64.zip)
+[Download v1.6.2](https://github.com/BCD1210/soju/releases/download/v1.6.2/Soju-1.6.2-macos-arm64.zip)
1. Unzip and move **Soju.app** into Applications or ~/Applications.
2. Open **Platforms** to install or open Battle.net, Steam, Epic Games or GOG GALAXY.
diff --git a/docs/index.html b/docs/index.html
index c8b947ddf40..48a36a6f5ba 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -100,7 +100,7 @@ its own login, purchases, downloads and game updates.</p>
<section id="install" aria-labelledby="install-title">
<h2 id="install-title">Choose your launchers. Get set up.</h2>
-<p><a class="btn" href="https://github.com/BCD1210/soju/releases/download/v1.6.1/Soju-1.6.1-macos-arm64.zip">Download Soju for Mac</a></p>
+<p><a class="btn" href="https://github.com/BCD1210/soju/releases/download/v1.6.2/Soju-1.6.2-macos-arm64.zip">Download Soju for Mac</a></p>
<p>The native desktop preview combines installed and imported owned games, searches stores and manages all four launchers.
Apple Silicon · app UI: macOS 14+ · Steam component build: macOS 26+.
<a href="https://github.com/BCD1210/soju/blob/main/docs/DESKTOP.md">Setup and signing notes</a>.</p>
diff --git a/docs/purchase-affiliates.md b/docs/purchase-affiliates.md
new file mode 100644
index 00000000000..0a597881ebe
--- /dev/null
+++ b/docs/purchase-affiliates.md
@@ -0,0 +1,50 @@
+# Purchase referrals
+
+Soju remains free. The first integration targets GOG product listings in Discover.
+Store search and result ordering do not depend on affiliate eligibility.
+Checkout remains in the official store in the user's browser.
+
+## Current status
+
+- GOG: application emailed to [email protected] on 2026-09-06. Asked for
+ desktop-app placement permission, the approved network/link format,
+ commission and attribution terms, and catalog/search permission.
+- Green Man Gaming: official Business Affiliate Program leads to Impact.
+ Sign-in is required; no application has been submitted.
+- No affiliate links are active and no commissions are being claimed.
+
+## Activation
+
+Only activate after written acceptance of Soju and its desktop-app placement.
+Obtain the links from Soju's approved publisher account; never reuse another
+project's affiliate identifiers. Store public links only, never credentials.
+
+Edit resources/purchase-links.json with schema 1, enabled true, and links
+containing exact destination and affiliate URL pairs. Destinations must match
+the canonical GOG product URL returned by Discover. The initial implementation
+accepts HTTPS www.gog.com and af.gog.com affiliate links only. If the approved
+network uses another host or dynamic deep-link format, add a reviewed adapter
+and destination-preservation tests before activation. Do not guess tracking
+parameters or turn a search result into a different product or edition.
+
+Before release, verify each approved link reaches the same product, region and
+edition, and confirm attribution using the network's approved test procedure.
+Do not make self-purchases to generate commissions. Record the approval and
+private account details outside this public repository.
+
+Discover automatically uses the approved affiliate link when a matching mapping
+exists. Products without an active mapping use their ordinary official-store
+link. There is no user toggle to bypass an available affiliate link, and no
+duplicate direct store-search shortcuts. Affiliate purchase buttons are marked
+Supports Soju with a commission disclosure. Missing, disabled or invalid
+configuration falls back to ordinary store links.
+
+No click collection, user identifiers, redirect server or background requests
+are added by the referral layer. Third-party tracking starts only after a user
+chooses an affiliated link. Disable the bundled configuration to stop referrals.
+
+## Sources
+
+- https://support.gog.com/hc/en-us/articles/4405004689297-How-to-join-the-GOG-Affiliate-Program
+- https://affiliate.gog.com/
+- https://www.greenmangaming.com/affiliates/
diff --git a/resources/purchase-links.json b/resources/purchase-links.json
new file mode 100644
index 00000000000..a5c7ba106a3
--- /dev/null
+++ b/resources/purchase-links.json
@@ -0,0 +1,5 @@
+{
+ "schema": 1,
+ "enabled": false,
+ "links": []
+}
diff --git a/scripts/build-app.sh b/scripts/build-app.sh
index ae16ee0107c..a1794f41aed 100755
--- a/scripts/build-app.sh
+++ b/scripts/build-app.sh
@@ -10,7 +10,7 @@ trap 'rm -rf "$STAGE"' EXIT
APP="$STAGE/Soju.app"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources/soju"
swiftc -swift-version 5 -parse-as-library -O -target arm64-apple-macosx14.0 \
- "$ROOT/app/Soju.swift" "$ROOT/app/Library.swift" "$ROOT/app/Accounts.swift" "$ROOT/app/Discover.swift" "$ROOT/app/SteamLogin.swift" -o "$APP/Contents/MacOS/Soju"
+ "$ROOT/app/Soju.swift" "$ROOT/app/Library.swift" "$ROOT/app/Accounts.swift" "$ROOT/app/Discover.swift" "$ROOT/app/PurchaseLinks.swift" "$ROOT/app/SteamLogin.swift" -o "$APP/Contents/MacOS/Soju"
for dir in scripts tools patches third_party resources; do
ditto "$ROOT/$dir" "$APP/Contents/Resources/soju/$dir"
done
diff --git a/scripts/library_services.py b/scripts/library_services.py
index efe949dcafc..6350f05da18 100644
--- a/scripts/library_services.py
+++ b/scripts/library_services.py
@@ -143,7 +143,7 @@ def search(query, country):
try:
games.extend(job.result())
except Exception:
- warnings.append(jobs[job].title() + ' search is unavailable. You can still open its official store below.')
+ warnings.append(jobs[job].title() + ' search is unavailable. Please retry later.')
unique = {g['id']: g for g in games}
def rank(game):
title, term = game['title'].casefold(), query.casefold()
diff --git a/tests/test_purchase_links.swift b/tests/test_purchase_links.swift
new file mode 100644
index 00000000000..0b058b963a7
--- /dev/null
+++ b/tests/test_purchase_links.swift
@@ -0,0 +1,46 @@
+import Foundation
+
+@main struct PurchaseLinkTests {
+ static func main() throws {
+ let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
+ try FileManager.default.createDirectory(at: root.appendingPathComponent("resources"), withIntermediateDirectories: true)
+ defer { try? FileManager.default.removeItem(at: root) }
+ let file = root.appendingPathComponent("resources/purchase-links.json")
+ let direct = "https://www.gog.com/en/game/test_game"
+ let affiliate = "https://af.gog.com/en/game/test_game?as=TEST_ONLY"
+ func config(_ entries: [[String: String]], enabled: Bool = true, schema: Int = 1) throws -> PurchaseLinks {
+ let data = try JSONSerialization.data(withJSONObject: ["schema": schema, "enabled": enabled, "links": entries])
+ try data.write(to: file)
+ return PurchaseLinks.load(root: root)
+ }
+ let entry = ["destination": direct, "affiliate": affiliate]
+ assert(PurchaseLinks.load(root: root).resolve(direct)?.url.absoluteString == direct)
+ let active = try config([entry])
+ assert(active.hasAffiliateLinks)
+ assert(active.resolve(direct)?.url.absoluteString == affiliate)
+ assert(active.resolve(direct)?.isAffiliate == true)
+ let other = "https://www.gog.com/en/game/another_edition"
+ assert(active.resolve(other)?.url.absoluteString == other)
+ let steam = "https://store.steampowered.com/app/10/"
+ assert(active.resolve(steam)?.url.absoluteString == steam)
+ let disabled = try config([entry], enabled: false)
+ assert(!disabled.hasAffiliateLinks)
+ assert(disabled.resolve(direct)?.url.absoluteString == direct)
+ for bad in ["http://af.gog.com/x", "https://af.gog.com.evil.test/x", "https://[email protected]/x",
+ "https://af.gog.com:8080/x", "file:///etc/passwd", "javascript:alert(1)"] {
+ let value = try config([["destination": direct, "affiliate": bad]])
+ assert(!value.hasAffiliateLinks)
+ assert(value.resolve(direct)?.url.absoluteString == direct)
+ }
+ for bad in ["file:///etc/passwd", "https://www.gog.com.evil.test/x", "https://[email protected]/x"] {
+ assert(active.resolve(bad) == nil)
+ }
+ let duplicate = try config([entry, entry])
+ assert(!duplicate.hasAffiliateLinks)
+ let wrongSchema = try config([entry], schema: 2)
+ assert(!wrongSchema.hasAffiliateLinks)
+ try Data("not json".utf8).write(to: file)
+ assert(!PurchaseLinks.load(root: root).hasAffiliateLinks)
+ print("Purchase links: automatic affiliate preference, exact products, ordinary-link fallback and unsafe URL checks passed")
+ }
+}