diff --git a/README.md b/README.md index efe1cff11b..a6b4a1db2f 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V - Battle.net installs drive Blizzard's Agent the way [@barncastle](https://github.com/barncastle)'s [Battle.Net-Installer](https://github.com/barncastle/Battle.Net-Installer) does, with requests from [wowdev.wiki](https://wowdev.wiki/Agent). Read without taking code: [@mubaraknumann](https://github.com/mubaraknumann)'s [unifideck](https://github.com/mubaraknumann/unifideck), [@djmittens](https://github.com/djmittens)'s [neo-mittens](https://github.com/djmittens/neo-mittens) `bnetswitch`, [@BCD1210](https://github.com/BCD1210)'s [soju](https://github.com/BCD1210/soju) and [Lutris](https://github.com/lutris/lutris)'s `product.db` reader. - World of Warcraft addon imports replace an addon's folder from a temporary copy, as [WowUp](https://github.com/WowUp/WowUp) does, and read flavour folders the way [WoWDeck](https://github.com/sigboe/wowdeck) does. No code from either is used. - The World of Warcraft addon Download window searches [WoWInterface](https://www.wowinterface.com) through its MMOUI API. [CurseForge](https://www.curseforge.com/wow) opens in the user's browser, with no API and no key. -- Xbox games load [@domsvoboda](https://github.com/domsvoboda)'s [xodus-nexus](https://github.com/domsvoboda/xodus-nexus) modules (LGPL-2.1-or-later), including `wintypes.dll`. Minecraft's GameInput setup was checked against [@Wyze3306](https://github.com/Wyze3306)'s [BedrockOnLinux](https://github.com/Wyze3306/BedrockOnLinux) (MIT). +- Xbox games load [@domsvoboda](https://github.com/domsvoboda)'s [xodus-nexus](https://github.com/domsvoboda/xodus-nexus) modules (LGPL-2.1-or-later), including `wintypes.dll`. Content licensing sends delegation-compact device tickets in the licensing wire form, following the [nexus-backend](https://github.com/domsvoboda/nexus-backend) commit `27c335e`. Minecraft's GameInput setup was checked against [@Wyze3306](https://github.com/Wyze3306)'s [BedrockOnLinux](https://github.com/Wyze3306/BedrockOnLinux) (MIT). - The Xbox Cloud Gaming player uses the WebRTC client of [@unknownskl](https://github.com/unknownskl)'s [Greenlight](https://github.com/unknownskl/greenlight) (MIT), and its offer tweaks and sharpening follow [@redphx](https://github.com/redphx)'s [Better xCloud](https://github.com/redphx/better-xcloud) (MIT). See `tools/xcloud-player/NOTICE.md`. - The itch.io butler pack ships butler's `7z.so`, itch.io's build of [7-Zip](https://www.7-zip.org) by Igor Pavlov (LGPL-2.1, unRAR restriction on RAR code), unmodified. Other archives use Apache Commons Compress and the runtime's bsdtar (libarchive). - The Store uses [Flatpak](https://github.com/flatpak/flatpak) (LGPL-2.1) through DroidDeck's own bubblewrap shim. Chromium and Electron apps start directly, since [zypak](https://github.com/refi64/zypak) by [@refi64](https://github.com/refi64) (BSD-3-Clause) always uses Flatpak's spawn portal. diff --git a/tools/xbox/README.md b/tools/xbox/README.md index 986fc1bd75..73afef3803 100644 --- a/tools/xbox/README.md +++ b/tools/xbox/README.md @@ -41,6 +41,12 @@ app's credential socket (`NEXUS_CREDENTIAL_ERROR_V1 socket-refused`, `-denied`, uses a keyed loopback port the app also listens on; some devices refuse the abstract socket from inside PRoot. The key is passed in the backend's environment only. +`droiddeck-licensing-device-ticket.patch` sends a delegation-compact device ticket to content +licensing and Store license tokens in the licensing wire form (`t=` or a bare compact JWE), as +user tickets already are. A plain compact device ticket is sent unchanged. The rule follows +[@domsvoboda](https://github.com/domsvoboda)'s nexus-backend commit `27c335e` and +xodus-gaming/xodus#238. + `droiddeck-credential-diagnostics.patch` names the step behind a `credential-io` failure: the session lock (`lock-dir-owner`, `lock-file-mode`, `lock-flock-`, ...), a socket or loopback exchange that broke after connecting (`socket-exchange-`), a malformed host reply, or a diff --git a/tools/xbox/droiddeck-licensing-device-ticket.patch b/tools/xbox/droiddeck-licensing-device-ticket.patch new file mode 100644 index 0000000000..ffd5edbfa9 --- /dev/null +++ b/tools/xbox/droiddeck-licensing-device-ticket.patch @@ -0,0 +1,136 @@ +diff --git a/crates/xodus-cli/src/license.rs b/crates/xodus-cli/src/license.rs +index 4518c22..5a12753 100644 +--- a/crates/xodus-cli/src/license.rs ++++ b/crates/xodus-cli/src/license.rs +@@ -58,6 +58,7 @@ pub async fn get_license( + let Token::Compact(ms_device_token) = ms_device_token else { + return Err("Unsupported token".to_string()); + }; ++ let ms_device_token = xodus::models::secrets::licensing_device_ticket(ms_device_token); + + let user_token: Token = match user_token { + ExchangeUserTokenOutcome::Fault(_) => { +diff --git a/crates/xodus-service/src/store_license.rs b/crates/xodus-service/src/store_license.rs +index e6b4c58..abede2e 100644 +--- a/crates/xodus-service/src/store_license.rs ++++ b/crates/xodus-service/src/store_license.rs +@@ -63,8 +63,7 @@ async fn issue(context: &SimpleContext, request: StoreLicenseTokenRequest) -> Re + let device_response = xodus::api::live::exchange_device_token(&context.client, device.clone(), + client_id.into(), "www.microsoft.com".into(), Some(soap::PolicyReference::mbi_ssl())) + .await.map_err(|_| FAIL)?; +- if device_response.token_type != "urn:passport:compact" { return Err(FAIL) } +- let Token::Compact(device_token) = Token::try_from(device_response).map_err(|_| FAIL)? else { return Err(FAIL) }; ++ let device_token = device_license_ticket(device_response)?; + let user_response = xodus::api::live::exchange_user_token(&context.client, user_sts, + account.username, device, None, Some("Silent".into()), client_id.into(), + &[("www.microsoft.com".into(), Some(soap::PolicyReference::mbi_ssl()))]) +@@ -98,6 +97,13 @@ async fn issue(context: &SimpleContext, request: StoreLicenseTokenRequest) -> Re + Ok(response.license_token) + } + ++fn device_license_ticket(response: soap::RequestSecurityTokenResponse) -> Result { ++ if !user_ticket_type(&response.token_type) { return Err(FAIL) } ++ let Token::Compact(ticket) = Token::try_from(response).map_err(|_| FAIL)? else { return Err(FAIL) }; ++ if ticket.is_empty() || ticket == "d=" { return Err(FAIL) } ++ Ok(xodus::models::secrets::licensing_device_ticket(ticket)) ++} ++ + fn user_ticket_type(token_type: &str) -> bool { + matches!(token_type, "urn:passport:compact" | "urn:passport:delegationcompact") + } +@@ -134,6 +140,45 @@ mod tests { + } + } + ++ fn device_response(kind: &str, value: Option<&str>) -> soap::RequestSecurityTokenResponse { ++ soap::RequestSecurityTokenResponse { ++ token_type: kind.into(), ++ applies_to: soap::AppliesTo { endpoint_reference: soap::EndpointReference { address: "synthetic.invalid".into() } }, ++ lifetime: soap::Timestamp { id: None, created: "2000-01-01T00:00:00Z".into(), expires: "2099-01-01T00:00:00Z".into() }, ++ requested_security_token: soap::RequestedSecurityToken { encrypted_data: None, ++ binary_security_token: value.map(|value| soap::BinarySecurityTokenRes { ++ id: "synthetic".into(), value: value.into(), value_type: None }) }, ++ requested_proof_token: None, ++ } ++ } ++ ++ #[test] ++ fn store_license_device_compact_tickets_are_sent_unchanged() { ++ let raw = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..aXY.Y2lwaGVy_dGV4dA.dGFn"; ++ for value in ["t=opaque-device&p=", "opaque-device", raw] { ++ assert_eq!(device_license_ticket(device_response("urn:passport:compact", Some(value))), Ok(value.to_string())); ++ } ++ } ++ ++ #[test] ++ fn store_license_device_delegation_tickets_use_the_licensing_wire_form() { ++ let raw = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..aXY.Y2lwaGVy_dGV4dA.dGFn"; ++ assert_eq!(device_license_ticket(device_response("urn:passport:delegationcompact", Some(raw))), Ok(raw.to_string())); ++ assert_eq!(device_license_ticket(device_response("urn:passport:delegationcompact", Some("opaque-device"))), ++ Ok("t=opaque-device".to_string())); ++ } ++ ++ #[test] ++ fn store_license_device_unknown_missing_and_empty_tickets_fail_closed() { ++ for kind in ["urn:passport:legacy", "urn:passport:unknown"] { ++ assert_eq!(device_license_ticket(device_response(kind, Some("opaque-device"))), Err(FAIL)); ++ } ++ for kind in ["urn:passport:compact", "urn:passport:delegationcompact"] { ++ assert_eq!(device_license_ticket(device_response(kind, None)), Err(FAIL)); ++ assert_eq!(device_license_ticket(device_response(kind, Some(""))), Err(FAIL)); ++ } ++ } ++ + fn request(ids: &[&str]) -> StoreLicenseTokenRequest { + StoreLicenseTokenRequest { parent_product_id: "9N4PT8HGCDHQ".into(), + product_ids: ids.iter().map(|s| s.to_string()).collect(), custom_developer_string: "nonce<&>".into() } +diff --git a/crates/xodus/src/models/licensing_ticket_tests.rs b/crates/xodus/src/models/licensing_ticket_tests.rs +index 10ff57e..6db9ff1 100644 +--- a/crates/xodus/src/models/licensing_ticket_tests.rs ++++ b/crates/xodus/src/models/licensing_ticket_tests.rs +@@ -1,5 +1,5 @@ + //! Public synthetic data only, no account, keyring or network access. +-use super::{Token, licensing_ticket, store_ticket, xbox_ticket}; ++use super::{Token, licensing_device_ticket, licensing_ticket, store_ticket, xbox_ticket}; + use crate::models::soap; + use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD}; + use serde_json::json; +@@ -109,3 +109,23 @@ fn credential_xbox_ticket_opaque_and_malformed_tokens_are_preserved() { + } + for ticket in cases { assert_eq!(xbox_ticket(ticket.clone()), ticket); } + } ++ ++#[test] ++fn credential_licensing_device_ticket_delegation_forms_use_the_licensing_wire_form() { ++ for raw in [ ++ jwe(json!({"alg":"dir","enc":"A128CBC-HS256"}), ""), ++ jwe(json!({"alg":"RSA-OAEP-256","enc":"A256GCM"}), "a2V5"), ++ ] { ++ let Token::Compact(original) = delegation(&raw) else { panic!("fixture"); }; ++ assert_eq!(licensing_device_ticket(original), raw); ++ } ++ assert_eq!(licensing_device_ticket("d=opaque-device".into()), "t=opaque-device"); ++} ++ ++#[test] ++fn credential_licensing_device_ticket_plain_compact_forms_stay_byte_exact() { ++ let raw = jwe(json!({"alg":"dir","enc":"A256GCM"}), ""); ++ for ticket in ["t=opaque-device&p=".to_string(), "opaque-device".into(), "".into(), raw.clone(), format!("t={raw}")] { ++ assert_eq!(licensing_device_ticket(ticket.clone()), ticket); ++ } ++} +diff --git a/crates/xodus/src/models/secrets.rs b/crates/xodus/src/models/secrets.rs +index 1ad97be..9de6eea 100644 +--- a/crates/xodus/src/models/secrets.rs ++++ b/crates/xodus/src/models/secrets.rs +@@ -102,6 +102,10 @@ pub fn licensing_ticket(ticket: String) -> String { + if is_compact_jwe(bare) { bare.to_string() } else { store_ticket(ticket) } + } + ++pub fn licensing_device_ticket(ticket: String) -> String { ++ if ticket.starts_with("d=") { licensing_ticket(ticket) } else { ticket } ++} ++ + // This recognizes wire encoding, not authenticity or entitlement. Microsoft + // still validates the entire ticket. Never decrypt, log or rewrite its payload. + fn is_compact_jwe(value: &str) -> bool { diff --git a/tools/xbox/prepare.py b/tools/xbox/prepare.py index ef2b230245..222b887606 100755 --- a/tools/xbox/prepare.py +++ b/tools/xbox/prepare.py @@ -9,7 +9,8 @@ recipe = Path(__file__).resolve().parent cache = Path(sys.argv[1]).resolve() lock = json.loads((recipe / 'backend.lock.json').read_text()) local_patches = ['droiddeck-credentials.patch', 'droiddeck-launch-view.patch', 'droiddeck-library-subscriptions.patch', - 'droiddeck-credential-fallback.patch', 'droiddeck-credential-diagnostics.patch', 'droiddeck-cloud-token.patch', 'droiddeck-xbox-ticket.patch'] + 'droiddeck-credential-fallback.patch', 'droiddeck-credential-diagnostics.patch', 'droiddeck-cloud-token.patch', 'droiddeck-xbox-ticket.patch', + 'droiddeck-licensing-device-ticket.patch'] identity = hashlib.sha256((recipe / 'backend.lock.json').read_bytes() + b''.join((recipe / name).read_bytes() for name in local_patches)).hexdigest() source = cache / ('source-' + identity[:16]) if not (source / '.prepared').is_file():