From 7fcebc268dae3d6f93b71c09933f37d82ac532ce Mon Sep 17 00:00:00 2001
From: BeniMorBelt <66647326+TuPapaPendejo@users.noreply.github.com>
Date: Wed, 25 Nov 2026 19:07:56 -0600
Subject: [PATCH 1/7] fix: align fresh install device identity with working
client profile
---
.env.example | 4 +-
CHANGELOG.md | 14 ++
README.md | 6 +-
docs/source-audit-2026-11.md | 298 +++++++++++++++++++++++++++++++++++
src/device_info.rs | 6 +-
5 files changed, 321 insertions(+), 7 deletions(-)
create mode 100644 docs/source-audit-2026-11.md
diff --git a/.env.example b/.env.example
index a94d755..21294ad 100644
--- a/.env.example
+++ b/.env.example
@@ -1,7 +1,9 @@
# Optional advanced settings. No .env file is needed for a fresh installation.
# The build helper tags the image as wrapper-v2:local automatically.
# WRAPPER_IMAGE=wrapper-v2:1.0.0-local-arm64
-# WRAPPER_DEVICE_INFO=Music/4.9/Android/10/Samsung S9/7663313/en-US/en-US/your-stable-guid
+# For a manual device override, replace the suffix with a unique, stable
+# 16-character lowercase hexadecimal Android ID. Never rotate it after login.
+# WRAPPER_DEVICE_INFO=Music/5.0.2/Android/10/Pixel 8/7663314/en-US/en-US/0123456789abcdef
# If you already have a session volume from the old Wrapper, keep both its
# existing WRAPPER_DEVICE_INFO and WRAPPER_DATA_DIR rather than starting fresh.
# Optional auto-login: uncomment BOTH lines and provide nonempty values.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8bc1c7a..940da34 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,19 @@
# Changelog
+## Unreleased
+
+- Fix the generated first-install device fingerprint to use the known-working
+ Apple Music client tuple `Music/5.0.2/Android/10/Pixel 8/7663314` and a
+ 64-bit Android ID encoded as 16 lowercase hexadecimal characters. The
+ identity remains generated once and persisted; existing identity files and
+ legacy session hashes are not rewritten.
+- Add regression coverage for the generated fingerprint shape and for
+ preservation of an existing 1.0.0 identity.
+- Correct the documented Android runtime API level for ARM64 to API 21,
+ matching the pinned profile and CMake build configuration.
+- Add a source-level reverse-engineering and security audit with explicit
+ runtime-validation limitations.
+
## 1.0.0 — 2026-11-19
Wrapper v2 1.0.0 is a ground-up rewrite of the original Wrapper v2, built for
diff --git a/README.md b/README.md
index 58663f1..20c6938 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ The server **does not decrypt or download media**. Decryption, when supported, t
| Host | Linux, `x86_64` or `aarch64` |
| Deployment | Docker with Compose **2.24+** (required for optional `.env`) |
| Apple Music | **Version 3.6.0-beta, build 1109**, for the selected architecture |
-| Android runtime | Bundled, architecture-specific Android system files (x86-64: API 21; ARM64: API 22) |
+| Android runtime | Bundled, architecture-specific Android system files (x86-64: API 21; ARM64: API 21) |
| Building | Docker with Buildx/BuildKit and standard Linux shell tools |
| Toolchains | Android NDK **r23b**, Rust, CMake, Ninja, and cross-compilers are installed **inside Docker** |
@@ -69,11 +69,11 @@ The generated image is `wrapper-v2:1.0.0-local-amd64` for x86-64 or `wrapper-v2:
docker compose up -d
```
-**No `.env` file or manual login is needed.** On first startup, Wrapper generates a unique, nine-part device identity and saves it in the persistent Docker volume alongside the session cache. The identity is reused on future restarts and image upgrades. **Preserve this volume**: deleting it (including via `docker compose down -v`) loses both the identity and cached login. The Android runtime is embedded in the image and must not be bind-mounted from the host.
+**No `.env` file or manual login is needed.** On first startup, Wrapper generates a unique, nine-part device identity and saves it in the persistent Docker volume alongside the session cache. New installations use the tested `Music/5.0.2/Android/10/Pixel 8/7663314/en-US/en-US` client fingerprint and a random 16-character lowercase hexadecimal (64-bit) Android ID. The identity is reused on future restarts and image upgrades. **Preserve this volume**: deleting it (including via `docker compose down -v`) loses both the identity and cached login. The Android runtime is embedded in the image and must not be bind-mounted from the host.
To configure an alternative image, port, DNS, device identity, or optional automatic login, copy `.env.example` to `.env` and uncomment only the settings you need. For automatic login, set **both** `WRAPPER_USERNAME` and `WRAPPER_PASSWORD`; otherwise leave them absent. Manual overrides must use a stable, slash-separated nine-field `WRAPPER_DEVICE_INFO`.
-**Existing installations:** Keep your current `.env` values for `WRAPPER_DEVICE_INFO` and `WRAPPER_DATA_DIR` and reuse the same session directory. A legacy cache without a saved generated identity will **not** be assigned a different identity automatically; the server rejects that setup until the original identity is supplied. Do not remove your existing `.env` or switch from a `./data` bind mount to the new named volume without migrating the session state.
+**Existing installations:** Keep your current `.env` values for `WRAPPER_DEVICE_INFO` and `WRAPPER_DATA_DIR` and reuse the same session directory. Existing `.wrapper-device-info` identities are deliberately not rewritten or migrated: this preserves the device hash recorded in `.worker-device` and avoids invalidating cached sessions. A legacy cache without a saved generated identity will **not** be assigned a different identity automatically; the server rejects that setup until the original identity is supplied. Do not remove your existing `.env` or switch from a `./data` bind mount to the new named volume without migrating the session state.
```bash
docker compose logs -f wrapper
diff --git a/docs/source-audit-2026-11.md b/docs/source-audit-2026-11.md
new file mode 100644
index 0000000..4741a7b
--- /dev/null
+++ b/docs/source-audit-2026-11.md
@@ -0,0 +1,298 @@
+# Source audit and reverse-engineering notes — November 2026
+
+## Review identity and limits
+
+- Repository: `TuPapaPendejo/wrapper-v2-Tests`
+- Reviewed baseline: `main` at `9a6f29f493b1bac5325105ab6edf5dbd8caaae8c`
+- Scope: Rust HTTP API and supervisor; native C++ worker, session and playback
+ paths; x86-64 and ARM64 context-capture hooks; launcher and namespaces;
+ runtime profiles and binary pins; APK/APKM staging; Docker/Compose; tests,
+ CI and operational documentation.
+- Method: source and configuration review through the GitHub repository
+ contents API, comparison against the upstream Wrapper Lite device-identity
+ implementation, and review of the supplied reproduction in
+ [glomatico/wrapper-v2 issue 23](https://github.com/glomatico/wrapper-v2/issues/23).
+- This is a **source-level audit**, not a claim of a completed live Apple login
+ test. The proprietary APKM, Apple account credentials, and a privileged Linux
+ Docker runtime were not run in this review environment. CI's synthetic worker
+ cannot validate Apple's proprietary `AuthenticateFlow`.
+
+## Executive findings
+
+1. **Confirmed fresh-install authentication compatibility defect — fixed in this
+ change.** The auto-generated device identity used an obsolete client tuple
+ (`Music/4.9`, Samsung S9, build 7663313) and generated a 128-bit suffix
+ (32 hex characters). Issue 23 comment
+ [7162866962](https://github.com/glomatico/wrapper-v2/issues/23#issuecomment-7162866962)
+ reports a controlled successful login after changing only
+ `WRAPPER_DEVICE_INFO` to the `Music/5.0.2` / Pixel 8 / build 7663314 tuple
+ with an eight-byte random Android ID. The author did not isolate the two
+ fields experimentally. The new default adopts the complete tested tuple
+ and ID representation, and adds tests for that exact shape.
+2. **Persisted sessions are deliberately not migrated.** The Rust identity file
+ and native `.worker-device` hash form a pair. Silently regenerating either
+ value can make an existing Apple Music cache unusable. The patch changes
+ only identities generated for new installations and explicitly tests that
+ an existing 1.0.0 identity is left byte-for-byte unchanged.
+3. **The API is not an internet-facing authenticated service.** There is no
+ built-in HTTP authentication or TLS. In particular,
+ `GET /session/credentials` exports session tokens. Compose publishes the
+ host port on loopback by default; changing that binding or exposing the
+ container port without an authenticated TLS gateway exposes account
+ material and session-control operations.
+4. **The native implementation is highly version- and ABI-specific by design.**
+ Symbols, object layouts, linker behavior, capture hook addresses, register
+ states, byte offsets and expected context sizes are coupled to exact
+ Apple/Android binaries. SHA-256 pins and runtime handshakes fail closed, but
+ they do not replace real integration testing against the pinned APKM.
+5. **The HTTP and lifecycle tests are synthetic.** They give useful coverage of
+ routing, IPC, retry behavior, 2FA orchestration, redaction, staging and
+ namespace teardown. They do not execute Apple's native authentication or
+ prove that a real Apple account can log in.
+
+## Detailed findings
+
+### F-01 — Fresh-install device identity did not match the working client profile
+
+**Severity:** High for first-login availability
+**Status:** Fixed in this change; real Apple login still requires private verification.
+
+Baseline implementation in `src/device_info.rs` used:
+
+- `Music/4.9/Android/10/Samsung S9/7663313/en-US/en-US`
+- 16 random bytes, formatted as a 32-character hexadecimal suffix.
+
+The issue 23 reproduction records the same native failure on a fresh x86-64
+build-1109 install and then a successful 2FA login after changing only the
+device-info override to:
+
+```text
+Music/5.0.2/Android/10/Pixel 8/7663314/en-US/en-US/<16 lowercase hex chars>
+```
+
+The upstream [WorldObservationLog Wrapper Lite source](https://github.com/WorldObservationLog/wrapper/blob/lite/lite/lite_main.cpp)
+also documents the nine-field device tuple and computes Android ID as a
+64-bit FNV-1a value formatted to 16 hexadecimal characters. The issue's
+successful test uses a random 64-bit value instead; this project continues
+to use cryptographically random bytes rather than deriving an ID from the
+account username.
+
+**Change:** new installations now use that known-working client tuple and
+eight random bytes (64 bits). The random ID is persisted atomically with mode
+0600. Temporary-file names retain their independent 128-bit randomness.
+
+**Compatibility:** explicit `WRAPPER_DEVICE_INFO` overrides remain supported.
+Existing `.wrapper-device-info` files are read as-is, including old 32-hex
+suffixes. No old identity, native hash, or saved session is rewritten.
+
+**Unresolved experimental distinction:** the report changed both the client
+tuple and the ID length at once. The evidence proves the combined value works
+in that reporter's environment; it does not establish which individual field
+Apple rejected. A later controlled test can vary one field at a time, but a
+new installation should use the already demonstrated working combination.
+
+### F-02 — Runtime API-level documentation disagreed with the build profiles
+
+**Severity:** Low
+**Status:** Fixed in this change.
+
+The README described the ARM64 Android system image as API 22. Both pinned
+profiles declare API 21, and the Docker/CMake build configures and enforces
+Android platform 21. The requirement table now reports API 21 for both ABIs.
+
+### F-03 — Unauthenticated HTTP API and credential export
+
+**Severity:** High if reachable by an untrusted client
+**Status:** Existing documented design limitation; no protocol change made.
+
+The HTTP service has no authentication middleware or TLS termination.
+`GET /session/credentials` returns developer and media-user tokens; login,
+session close, playback and context routes are also directly callable.
+Compose's published port is bound to `127.0.0.1` by default, and the README
+warns against exposing the service directly.
+
+**Operational control:** keep the host binding on loopback, do not publish the
+container port to an untrusted network, restrict Docker/network access, and
+put any remote access behind an independently authenticated TLS gateway.
+Do not treat a private container network as a substitute for application
+authentication when other tenants or workloads can join it.
+
+### F-04 — Human 2FA wait has no server-side deadline
+
+**Severity:** Medium when an untrusted client can reach the API
+**Status:** Deliberate behavior, retained to avoid expiring legitimate 2FA.
+
+The Rust supervisor holds the single-worker lock while waiting for a human
+challenge response. The native protocol pauses its operation timer only during
+that wait. This prevents a short fixed timeout from killing a valid interactive
+login, but also means one abandoned challenge can keep the worker occupied and
+cause other worker-dependent calls to return `503 worker_busy`.
+
+**Operational control:** restrict access to the API and cancel abandoned
+challenges with an empty code. A future configurable idle timeout would need
+explicit product behavior and regression tests for long-running 2FA.
+
+### F-05 — Native ABI and capture hooks are pinned to exact binary layouts
+
+**Severity:** High impact if pins or offsets drift
+**Status:** Guarded by hashes and fail-closed checks; requires ongoing review.
+
+The native worker uses mangled Apple C++ symbols, hand-declared ABI return
+types, shared-pointer control-block adoption, hard-coded object storage sizes,
+and a fixed offset to read a response payload. The capture implementations
+also use architecture-specific instruction addresses, byte prefixes, register
+predicates, stack ranges, pointer remapping and hundreds of fixed state offsets.
+The runtime verifies Apple shared-library SHA-256 values and hook instruction
+prefixes before use; profile metadata and HTTP response contracts validate
+captured context sizes.
+
+These guards are valuable: do not relax them to make a different APK appear
+compatible. Any Apple Music version, library, NDK, Dobby, linker or ABI change
+must be treated as a separate reverse-engineering target and tested on both
+architectures. A successful compile alone does not prove that native object
+sizes or capture state are correct.
+
+### F-06 — CI does not exercise the proprietary Apple authentication path
+
+**Severity:** Medium
+**Status:** Test-environment limitation.
+
+The current workflow builds the Rust API and launcher, runs Rust/C++ unit
+tests, Linux namespace tests, and Python integration tests using
+`tests/mock_worker.py`. APK staging tests use synthetic archives. The
+workflow does not receive the proprietary APKM or Apple credentials and does
+not execute the native Apple libraries.
+
+Consequently, green CI can validate the HTTP/supervisor contracts but cannot
+confirm `AuthenticateFlow`, live 2FA, token validation, playback, or actual
+Temari context capture. Keep real-device tests private and report their
+architecture, APKM digest, profile, and sanitized result separately.
+
+### F-07 — Builder inputs are not fully reproducible
+
+**Severity:** Medium for supply-chain/rebuild reproducibility
+**Status:** Not changed in this authentication patch.
+
+The Android NDK archive is checksum-verified and external native source
+dependencies are pinned to Git commits. However, the Docker base image is
+referenced by a mutable tag, Debian packages are installed from the current
+repository state, and Rust is installed using the moving `stable` channel.
+Two builds from the same source commit can therefore use different build
+toolchains or base layers over time.
+
+**Recommendation:** pin the Docker base by digest, pin a tested Rust toolchain,
+use a controlled package snapshot, and record toolchain versions in build
+metadata. Keep the existing artifact hash verification.
+
+### F-08 — Authentication validation uses a separately hard-coded request header
+
+**Severity:** Low / investigation item
+**Status:** Not changed; no evidence it caused the reported failure.
+
+`native/session.cpp` constructs a POST header identifying
+`Music/4.9 Android/10 model/Samsung S9 build/7663313`, while the tested
+working `WRAPPER_DEVICE_INFO` tuple is Music 5.0.2 / Pixel 8 / 7663314.
+This header is used by the later signed session-validation request, not to
+construct the nine-field `RequestContext` identity itself. The issue reporter's
+working override shows that this mismatch did not prevent the reported login
+from completing. It should nevertheless be tested during private session
+restore and token validation before changing it; blindly deriving or changing
+the header could introduce a second variable.
+
+### F-09 — Certificate trust is build-host dependent
+
+**Severity:** Medium when the worker must reach an Apple endpoint whose root is
+absent from the builder's CA bundle
+**Status:** Not changed; separate from the demonstrated device-identity fix.
+
+`tools/prepare_rootfs.py` stages the CA bundle supplied by the build
+environment. The issue 23 report separately found that one staged bundle did
+not contain the Apple Root CA needed by `gsa.apple.com`; appending that root
+made `curl` verification succeed, but did not change the native
+`AuthenticateFlow` result. Do not conflate this trust-store correction with
+the device-identity fix. Any future CA addition must be obtained from an
+authoritative Apple certificate source and checked against a published
+fingerprint before being bundled.
+
+### F-10 — Sensitive data is intentionally omitted from logs, but runtime access
+still matters
+
+**Severity:** Medium
+**Status:** Existing controls retained.
+
+The HTTP layer logs allowlisted route names rather than raw paths or query
+strings. Credentials, challenge values, key URIs, tokens and contexts are
+excluded from ordinary logs. Native authentication diagnostics accept only
+bounded enums and numeric fields. However, Docker logs, the data volume,
+`.env`, the Docker socket and the final image remain security-sensitive.
+The image contains extracted proprietary Apple libraries, and the session
+volume contains persistent authentication state. Keep all of them private.
+
+## Architecture map
+
+1. **Build/staging:** `tools/build-docker.sh` supplies the operator's APK/APKM
+ to a named BuildKit context. `tools/prepare_rootfs.py` verifies the selected
+ profile's manifests and Apple library hashes, verifies vendored Android
+ system files, and stages the root filesystem.
+2. **Rust HTTP facade:** `src/main.rs`, `src/http.rs`, `src/config.rs`,
+ `src/profile.rs` parse configuration and expose the unversioned API.
+3. **Supervisor:** `src/worker.rs` serializes operations, frames IPC,
+ enforces timeouts and response limits, handles worker recycling, and
+ coordinates 2FA.
+4. **Namespace launcher:** `native/launcher.cpp` creates mount/PID namespaces,
+ chroots into the staged Android rootfs, starts the Android worker, reaps
+ children and tears down the namespace when IPC closes.
+5. **Native worker:** `native/main.cpp`, `runtime.cpp`, `session.cpp`,
+ `playback.cpp` and `context.cpp` call the pinned Apple libraries.
+6. **Context capture:** `capture_x86_64.cpp` and `capture_arm64.cpp` use
+ different, profile-specific hooks and memory layouts. The Rust profile
+ contract checks the serialized context before it is returned to a client.
+
+## Verification matrix
+
+| Area | Source/test coverage reviewed | Live validation still required |
+| --- | --- | --- |
+| Device identity | persistence, atomic creation, concurrent startup, explicit override and legacy identity tests | new-login and existing-session test with build 1109 |
+| HTTP API | synthetic end-to-end routes, validation, error mapping, redaction | no Apple native path |
+| Supervisor | mock worker recycle/recovery, cancellation, 2FA, client disconnect | actual native worker restart and session restoration |
+| Native protocol | framing, size/depth checks, 2FA continuation validation, SHA-256/base64 tests | Apple IPC behavior |
+| Launcher | disposable PID/mount namespaces, orphan reaping, teardown | target host's Docker seccomp/AppArmor policy |
+| APKM staging | synthetic APK/APKM, manifest/hash/ELF and duplicate-library rejection | actual authorized APKM extraction and full Docker build |
+| x86-64/ARM64 capture | static profiles, offsets, hashes and context length contracts | real playback/context request for each ABI |
+
+## Exact Apple Music package required for private verification
+
+The exact APKMirror listing identified for the build pinned by this repository is:
+
+- Package: `com.apple.android.music`
+- Version: `3.6.0-beta`
+- Build: `1109`
+- Variant: `arm64-v8a + x86_64`, split APKM bundle
+- Listing:
+- APKM SHA-256:
+ `5be907af370a7f6bd73344e646dcfebe2e64c2da3b9ad71192110c91950f3f67`
+
+Verify a downloaded file before building:
+
+```bash
+sha256sum AppleMusic-3.6.0-beta-1109.apkm
+./tools/build-docker.sh /path/to/AppleMusic-3.6.0-beta-1109.apkm --arch x86_64
+./tools/build-docker.sh /path/to/AppleMusic-3.6.0-beta-1109.apkm --arch arm64-v8a
+```
+
+Use only an authorized copy. Do not commit the APKM, extracted proprietary
+libraries, credentials, tokens, or session data to this repository. Do not
+publish the resulting image.
+
+## Change log for this audit branch
+
+- Changed the generated default fingerprint to the tested client tuple and
+ 64-bit Android-ID representation.
+- Kept 128-bit entropy for temporary staging-file names.
+- Added regression coverage for the new fresh-install identity and for the
+ no-migration guarantee on already persisted identities.
+- Updated the `.env.example` manual override.
+- Documented the identity compatibility behavior and corrected the ARM64 API
+ level in the README.
+- Added the findings, limits, architecture map, and private validation matrix
+ in this document.
diff --git a/src/device_info.rs b/src/device_info.rs
index 7936fb7..eb89787 100644
--- a/src/device_info.rs
+++ b/src/device_info.rs
@@ -13,7 +13,7 @@ use crate::error::ApiError;
const FILE_NAME: &str = ".wrapper-device-info";
const LEGACY_FILE_NAME: &str = ".worker-device";
-const DEVICE_PREFIX: &str = "Music/4.9/Android/10/Samsung S9/7663313/en-US/en-US/";
+const DEVICE_PREFIX: &str = "Music/5.0.2/Android/10/Pixel 8/7663314/en-US/en-US/";
fn invalid() -> ApiError {
ApiError::bad_config("WRAPPER_DEVICE_INFO")
@@ -31,11 +31,11 @@ fn validate(value: &str) -> Result<(), ApiError> {
}
fn random_suffix() -> Result {
- let mut random = [0u8; 16];
+ let mut random = [0u8; 8];
File::open("/dev/urandom")
.and_then(|mut file| file.read_exact(&mut random))
.map_err(|_| invalid())?;
- let mut suffix = String::with_capacity(32);
+ let mut suffix = String::with_capacity(16);
for byte in random {
write!(suffix, "{byte:02x}").map_err(|_| invalid())?;
}
From a7d7630be8e17119a92e4654098628dd39d46657 Mon Sep 17 00:00:00 2001
From: BeniMorBelt <66647326+TuPapaPendejo@users.noreply.github.com>
Date: Wed, 25 Nov 2026 19:08:09 -0600
Subject: [PATCH 2/7] test: preserve temp entropy and cover persisted device
identity
---
src/device_info.rs | 57 +++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 51 insertions(+), 6 deletions(-)
diff --git a/src/device_info.rs b/src/device_info.rs
index eb89787..96b444b 100644
--- a/src/device_info.rs
+++ b/src/device_info.rs
@@ -13,6 +13,9 @@ use crate::error::ApiError;
const FILE_NAME: &str = ".wrapper-device-info";
const LEGACY_FILE_NAME: &str = ".worker-device";
+// Match the known-working Apple Music client fingerprint used by the
+// upstream Wrapper implementation. Android IDs in this field are 64-bit
+// values rendered as 16 lowercase hexadecimal characters.
const DEVICE_PREFIX: &str = "Music/5.0.2/Android/10/Pixel 8/7663314/en-US/en-US/";
fn invalid() -> ApiError {
@@ -30,18 +33,23 @@ fn validate(value: &str) -> Result<(), ApiError> {
Ok(())
}
-fn random_suffix() -> Result {
- let mut random = [0u8; 8];
+fn random_hex() -> Result {
+ let mut random = [0u8; N];
File::open("/dev/urandom")
.and_then(|mut file| file.read_exact(&mut random))
.map_err(|_| invalid())?;
- let mut suffix = String::with_capacity(16);
+ let mut suffix = String::with_capacity(N * 2);
for byte in random {
write!(suffix, "{byte:02x}").map_err(|_| invalid())?;
}
Ok(suffix)
}
+fn random_android_id() -> Result {
+ // The native Android client fingerprint uses an eight-byte / 64-bit ID.
+ random_hex::<8>()
+}
+
fn read_identity(path: &Path) -> Result {
if path
.symlink_metadata()
@@ -84,8 +92,13 @@ pub fn resolve(
return Err(invalid());
}
- let identity = format!("{DEVICE_PREFIX}{}", random_suffix()?);
- let temp_path = directory.join(format!(".wrapper-device-info-{}.tmp", random_suffix()?));
+ let identity = format!("{DEVICE_PREFIX}{}", random_android_id()?);
+ // Keep the temporary filename's entropy at 128 bits; it is independent
+ // of the 64-bit Android ID format required by the client fingerprint.
+ let temp_path = directory.join(format!(
+ ".wrapper-device-info-{}.tmp",
+ random_hex::<16>()?
+ ));
let write_result = (|| -> Result<(), ApiError> {
let mut temp = OpenOptions::new()
.write(true)
@@ -116,7 +129,7 @@ mod tests {
fn directory() -> std::path::PathBuf {
let base =
- std::env::temp_dir().join(format!("wrapper-identity-{}", random_suffix().unwrap()));
+ std::env::temp_dir().join(format!("wrapper-identity-{}", random_hex::<8>().unwrap()));
fs::create_dir(&base).unwrap();
base
}
@@ -142,6 +155,38 @@ mod tests {
fs::remove_dir_all(another).unwrap();
}
+ #[test]
+ fn fresh_identity_uses_known_client_prefix_and_64_bit_android_id() {
+ let base = directory();
+ let generated = resolve(&base, "/", None).unwrap();
+ let android_id = generated
+ .strip_prefix(DEVICE_PREFIX)
+ .expect("generated identity must use the pinned client prefix");
+
+ assert_eq!(android_id.len(), 16);
+ assert!(android_id
+ .bytes()
+ .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte)));
+
+ fs::remove_dir_all(base).unwrap();
+ }
+
+ #[test]
+ fn existing_generated_identity_is_never_migrated_or_rotated() {
+ let base = directory();
+ // Existing 1.0.0 installations may have the previous 32-hex suffix.
+ let legacy = "Music/4.9/Android/10/Samsung S9/7663313/en-US/en-US/00112233445566778899aabbccddeeff";
+ fs::write(base.join(FILE_NAME), format!("{legacy}\n")).unwrap();
+
+ assert_eq!(resolve(&base, "/", None).unwrap(), legacy);
+ assert_eq!(
+ fs::read_to_string(base.join(FILE_NAME)).unwrap(),
+ format!("{legacy}\n")
+ );
+
+ fs::remove_dir_all(base).unwrap();
+ }
+
#[test]
fn concurrent_initialization_keeps_a_single_identity() {
let base = directory();
From 14d09cfa9cd6edf4f5f5db811f649870251848d1 Mon Sep 17 00:00:00 2001
From: BeniMorBelt <66647326+TuPapaPendejo@users.noreply.github.com>
Date: Wed, 25 Nov 2026 20:31:12 -0600
Subject: [PATCH 3/7] docs: add validated clean Linux and WSL installation
guide
---
CHANGELOG.md | 7 ++
README.md | 224 +++++++++++++++++++++++++++++++++++
docs/clean-install-linux.md | 195 ++++++++++++++++++++++++++++++
docs/source-audit-2026-11.md | 82 +++++++++++++
4 files changed, 508 insertions(+)
create mode 100644 docs/clean-install-linux.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 940da34..f8d1f4d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,13 @@
## Unreleased
+- Expand the README with a distribution-independent clean Linux installation
+ procedure, exact build-1109 APKM verification, Docker/Buildx prerequisites,
+ Windows Gamdl-to-WSL connectivity, session persistence, and troubleshooting.
+- Record the successful clean x86_64 reproduction on openSUSE Tumbleweed under
+ updated WSL on Windows 10 IoT Enterprise LTSC 2021. Windows Gamdl was installed
+ separately. ARM64 remains expected from the shared identity code but has not
+ been live-tested in this reproduction.
- Fix the generated first-install device fingerprint to use the known-working
Apple Music client tuple `Music/5.0.2/Android/10/Pixel 8/7663314` and a
64-bit Android ID encoded as 16 lowercase hexadecimal characters. The
diff --git a/README.md b/README.md
index 20c6938..72e58fa 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,230 @@ curl -fsS http://127.0.0.1:8080/session
The Compose configuration binds the HTTP service to **127.0.0.1:8080** by default and preserves account data in a named volume. **Do not rebuild the image with account data or publish it to a registry.** `GET /health` confirms the HTTP server is responding; use `GET /session` to check actual worker and authentication state. If using the HTTP API directly instead of Gamdl, send a JSON `POST` to `/session/login` containing `username` and `password`, and complete any required 2FA challenge using the endpoints below. Avoid putting real credentials directly in shell history.
+### 4. Clean Linux installation from scratch (validated procedure)
+
+This procedure is distribution-independent. Install the host prerequisites using the package manager and Docker setup supported by your Linux distribution.
+
+#### 4.1 Validated environment and support boundary
+
+The successful end-to-end reproduction used:
+
+| Component | Tested environment |
+| --- | --- |
+| Windows host | Windows 10 IoT Enterprise LTSC 2021 |
+| Linux runtime | openSUSE Tumbleweed under WSL |
+| WSL | Updated installation available at test time |
+| Wrapper deployment | Docker Compose inside Linux |
+| Wrapper | Version 1.0.0 with the device-identity correction in this branch |
+| Native worker | x86_64 |
+| Apple Music | 3.6.0-beta, build 1109 |
+| Gamdl | Clean installation on Windows, separate from Wrapper |
+
+The test completed fresh Apple Account login, 2FA, credential retrieval, session recovery after worker recycling, playback requests, and `/key` requests.
+
+**Only x86_64 was tested live.** The corrected device-identity code is shared Rust code rather than architecture-specific native code, so the same identity correction is expected to apply to ARM64. ARM64 login, playback, context capture, and the complete ARM64 Docker deployment have not been verified by this reproduction. The two native workers and context-capture implementations remain architecture-specific.
+
+#### 4.2 Linux host prerequisites
+
+Install the following on a supported Linux host:
+
+- Linux on `x86_64` or `aarch64`.
+- Docker Engine with a running daemon.
+- Docker Compose plugin v2.24 or newer.
+- Docker Buildx with BuildKit enabled.
+- Git, Bash, coreutils (including `realpath`, `sha256sum`, and `mktemp`), and `curl`.
+
+The build does not require a host-installed Rust toolchain, Android SDK/NDK, CMake, Ninja, or cross-compiler. Those build toolchains are installed inside the Docker builder.
+
+Ensure your user can access the Docker daemon. On a conventional Linux installation, follow the distribution's documented Docker service setup. Membership in the Docker group is effectively root-equivalent and should be granted only to trusted users.
+
+Verify the host before cloning:
+
+```bash
+uname -m
+git --version
+docker version
+docker compose version
+docker buildx version
+docker buildx inspect --bootstrap
+```
+
+The `docker version` output must contain both client and server sections. Buildx must report a usable builder.
+
+#### 4.3 Clone the corrected source
+
+Until the correction is merged upstream, clone the tested branch from this fork:
+
+```bash
+git clone --branch fix/device-info-apple-auth-1109 --single-branch \
+ https://github.com/TuPapaPendejo/wrapper-v2-Tests.git wrapper-v2
+cd wrapper-v2
+```
+
+After the maintainer merges the corresponding pull request, use the canonical upstream repository:
+
+```bash
+git clone https://github.com/glomatico/wrapper-v2.git
+cd wrapper-v2
+```
+
+Do not assume that upstream `main` contains the fix while its pull request is still under review. Confirm the branch and revision:
+
+```bash
+git status --short --branch
+git log -1 --oneline
+```
+
+#### 4.4 Obtain the exact Apple Music APKM
+
+Wrapper is pinned to **Apple Music 3.6.0-beta, build 1109**. Do not substitute another version or build.
+
+Download the APKM variant containing both `x86_64` and `arm64-v8a` splits from the [exact APKMirror listing](https://www.apkmirror.com/apk/apple/apple-music/apple-music-3-6-0-beta-release/apple-music-3-6-0-beta-4-android-apk-download/).
+
+Pinned package details:
+
+| Property | Required value |
+| --- | --- |
+| Package | `com.apple.android.music` |
+| Version | `3.6.0-beta` |
+| Build | `1109` |
+| Variant | `arm64-v8a + x86_64` |
+| SHA-256 | `5be907af370a7f6bd73344e646dcfebe2e64c2da3b9ad71192110c91950f3f67` |
+
+Verify the downloaded file before building:
+
+```bash
+sha256sum "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm"
+```
+
+Proceed only if the result exactly matches the pinned 64-character SHA-256. If it differs, stop. Do not bypass the validation or substitute another package.
+
+The APKM is supplied to BuildKit through an isolated local context. It is not committed to Git or copied into the ordinary source build context. The resulting runtime image does contain extracted proprietary Apple libraries; keep it private and do not publish or redistribute it.
+
+#### 4.5 Build the x86_64 image
+
+For the architecture tested in the successful reproduction:
+
+```bash
+./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch x86_64
+```
+
+The build helper calculates the APKM checksum and passes it to BuildKit. The Dockerfile verifies the archive, selects the correct architecture split, checks pinned manifests and Apple library hashes, verifies bundled Android system files, compiles the native worker and launcher plus the Rust HTTP server, and stages the Android root filesystem.
+
+The build must finish without checksum, manifest, architecture, missing-library, or compilation errors. Do not use an image produced by an interrupted or failed build.
+
+For ARM64, the documented command is:
+
+```bash
+./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch arm64-v8a
+```
+
+A cross-architecture ARM64 build may require binfmt/QEMU support in the Buildx builder or a remote multi-platform builder. This command is documented, but ARM64 was not included in the live authentication test.
+
+#### 4.6 Start Wrapper
+
+A normal clean installation does not require a `.env` file:
+
+```bash
+docker compose up -d
+docker compose ps
+docker compose logs -f wrapper
+```
+
+The default Compose configuration binds the HTTP service to loopback on port 8080 and creates a persistent named volume for Apple Music session data. The server should report `server.started`; the first native operation should start the Android worker and report `worker.started`.
+
+#### 4.7 Verify service health and the runtime profile
+
+Run the following checks from Linux:
+
+```bash
+curl -fsS http://127.0.0.1:8080/health
+curl -fsS http://127.0.0.1:8080/info
+curl -fsS http://127.0.0.1:8080/session
+```
+
+Expected high-level results:
+
+- `/health`: HTTP 200 and JSON status `ok`.
+- `/info`: HTTP 200, Wrapper version 1.0.0, protocol 1, and the architecture/profile corresponding to the image built.
+- `/session`: a successful response describing the current native session state.
+
+A fresh volume contains no previously authenticated Apple Music session. An attempted restore may therefore return `no_cached_session` or `session_expired`. This alone does not mean the fresh-login path is broken; continue with interactive login.
+
+#### 4.8 Connect Windows Gamdl to Wrapper running under WSL
+
+The validated arrangement installed Gamdl separately on Windows while Wrapper ran inside the Linux/WSL environment.
+
+With WSL localhost forwarding enabled and the default Compose port mapping, the Windows client can reach Wrapper at:
+
+```text
+http://127.0.0.1:8080
+```
+
+Check reachability from PowerShell:
+
+```powershell
+curl.exe -fsS http://127.0.0.1:8080/health
+```
+
+Configure Gamdl to use Wrapper as its authentication provider and enter the Wrapper endpoint when requested. Complete the Apple Account login and any 2FA challenge through Gamdl. Keep the WSL distribution, Docker daemon, and Wrapper container running while the Windows client uses the service.
+
+If Windows cannot reach the endpoint, first check WSL localhost forwarding and the Compose port mapping. Do not work around a localhost issue by exposing Wrapper on every host interface: the API has no built-in authentication or TLS.
+
+#### 4.9 Expected successful login, recovery, and playback sequence
+
+The confirmed x86_64 reproduction followed this sequence:
+
+1. The HTTP server starts and reports `server.started`.
+2. The native worker initializes and reports `worker.started`.
+3. A previous-session restore returns `session_expired` (HTTP 403); a new interactive login is then attempted.
+4. `POST /session/login` returns HTTP 202, indicating a pending 2FA challenge.
+5. `POST /session/challenge` completes with HTTP 200 and Wrapper reports `session.authenticated`.
+6. `GET /session` and `GET /session/credentials` return HTTP 200.
+7. After worker replacement, the replacement reports `worker.started` and Wrapper reports `session.recovered`.
+8. Playback requests return HTTP 200.
+9. The `/key` compatibility endpoint returns HTTP 200.
+
+This confirms more than HTTP liveness: the test exercised fresh login, 2FA, credentials retrieval, worker recycle/session recovery, playback, and key/context HTTP requests on x86_64.
+
+Do not include Apple Account credentials, passwords, 2FA codes, tokens, cookies, or signed playback URLs in public issue reports. Keep operational logs access-restricted even though Wrapper redacts sensitive request data.
+
+#### 4.10 Persistence, rebuilds, and destructive reset
+
+Stop Wrapper without deleting session state:
+
+```bash
+docker compose down
+```
+
+Rebuild and start again while preserving the same Compose volume:
+
+```bash
+./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch x86_64
+docker compose up -d
+```
+
+**Destructive reset — only when intentionally deleting the saved identity and session:**
+
+```bash
+docker compose down -v
+```
+
+The `-v` option deletes the Compose-managed named volume. This removes the persisted device identity and cached Apple Music session. Never use `down -v` as a routine update command or on an installation whose session must be retained.
+
+For a fresh deployment in another directory, Compose normally derives a different project name and creates a separate volume. Inspect `docker compose ls` and `docker volume ls` before removing any data.
+
+#### 4.11 Security notes
+
+- Keep the loopback-only host binding unless remote access is deliberately placed behind an authenticated TLS gateway.
+- Do not expose port 8080 directly to the public Internet.
+- Do not publish the locally built image: it contains extracted proprietary Apple libraries.
+- Do not commit the APKM, extracted libraries, `.env`, credentials, or session volume.
+- Treat Docker daemon access as privileged host access.
+- Preserve the persistent volume so the generated device identity remains paired with the cached session.
+- Do not use `docker compose down -v` unless account/session deletion is intentional.
+
+
## HTTP API
The API is **unversioned** in 1.0.0. Requests and responses use JSON; the internal native-worker IPC protocol is separate.
diff --git a/docs/clean-install-linux.md b/docs/clean-install-linux.md
new file mode 100644
index 0000000..c7d8377
--- /dev/null
+++ b/docs/clean-install-linux.md
@@ -0,0 +1,195 @@
+# Clean Linux installation — Wrapper v2 1.0.0
+
+This guide covers a clean installation of the corrected Wrapper branch. It is
+distribution-independent: install the prerequisites using the package manager
+and Docker setup supported by your Linux distribution.
+
+## Validated environment
+
+The successful test ran Wrapper and Docker Compose inside openSUSE Tumbleweed
+under an updated WSL installation on Windows 10 IoT Enterprise LTSC 2021.
+Gamdl was installed separately on Windows. The tested Wrapper architecture was
+x86_64 only.
+
+The test completed login, 2FA, credentials retrieval, session recovery after
+worker recycling, playback, and `/key` requests. ARM64 is expected to use the
+same shared Rust device-identity code, but was not included in this live test.
+
+## 1. Host prerequisites
+
+Install Linux on x86_64 or aarch64, Docker Engine with a running daemon, Docker
+Compose v2.24 or newer, Docker Buildx/BuildKit, Git, Bash, coreutils, and curl.
+
+No host Rust toolchain, Android SDK/NDK, CMake, Ninja, or cross-compiler is
+required. The Docker build installs compilation toolchains in its builder.
+
+Verify:
+
+```bash
+uname -m
+git --version
+docker version
+docker compose version
+docker buildx version
+docker buildx inspect --bootstrap
+```
+
+The Docker CLI must be able to reach the daemon (the `docker version` output
+must include a server section).
+
+## 2. Clone the corrected branch
+
+Until the correction is merged upstream:
+
+```bash
+git clone --branch fix/device-info-apple-auth-1109 --single-branch \
+ https://github.com/TuPapaPendejo/wrapper-v2-Tests.git wrapper-v2
+cd wrapper-v2
+```
+
+After the upstream maintainer merges the PR, clone the canonical repository:
+
+```bash
+git clone https://github.com/glomatico/wrapper-v2.git
+cd wrapper-v2
+```
+
+Check the current branch and commit before building:
+
+```bash
+git status --short --branch
+git log -1 --oneline
+```
+
+## 3. Download the pinned Apple Music APKM
+
+Download the APKM variant containing x86_64 and arm64-v8a splits from the
+[exact APKMirror 3.6.0-beta listing](https://www.apkmirror.com/apk/apple/apple-music/apple-music-3-6-0-beta-release/apple-music-3-6-0-beta-4-android-apk-download/).
+
+Required package: `com.apple.android.music`, version `3.6.0-beta`, build
+`1109`, variant `arm64-v8a + x86_64`.
+
+Pinned SHA-256:
+
+```text
+5be907af370a7f6bd73344e646dcfebe2e64c2da3b9ad71192110c91950f3f67
+```
+
+Verify the download:
+
+```bash
+sha256sum "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm"
+```
+
+The checksum must match exactly. Do not bypass validation or use another build.
+Do not commit the APKM. The local image contains extracted proprietary Apple
+libraries and must not be published or redistributed.
+
+## 4. Build the Docker image
+
+For the tested architecture:
+
+```bash
+./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch x86_64
+```
+
+The build helper sends the package through an isolated BuildKit context. The
+Dockerfile checks its digest, pinned manifests, Apple library hashes, bundled
+Android system files, and executable architectures, then compiles the native
+worker/launcher and Rust server and stages the Android rootfs.
+
+ARM64 build command (not live-tested in the reported reproduction):
+
+```bash
+./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch arm64-v8a
+```
+
+Cross-building ARM64 may require binfmt/QEMU or a remote multi-platform builder.
+
+## 5. Start and verify Wrapper
+
+No `.env` file is required for a normal fresh installation:
+
+```bash
+docker compose up -d
+docker compose ps
+docker compose logs -f wrapper
+```
+
+Check service health and runtime profile:
+
+```bash
+curl -fsS http://127.0.0.1:8080/health
+curl -fsS http://127.0.0.1:8080/info
+curl -fsS http://127.0.0.1:8080/session
+```
+
+A fresh data volume has no saved Apple Music session. A restore attempt may
+return `no_cached_session` or `session_expired`; proceed with a new login.
+
+## 6. Connect Windows Gamdl to Wrapper under WSL
+
+In the validated arrangement Gamdl ran on Windows while Wrapper ran under WSL.
+With WSL localhost forwarding enabled and the default Compose port mapping,
+use this endpoint from Windows:
+
+```text
+http://127.0.0.1:8080
+```
+
+Test reachability in PowerShell:
+
+```powershell
+curl.exe -fsS http://127.0.0.1:8080/health
+```
+
+Configure Gamdl to use Wrapper as its authentication provider and enter the
+endpoint when requested. Keep WSL, Docker, and the Wrapper container running.
+
+If Windows cannot reach the service, check WSL localhost forwarding and the
+Compose port mapping. Do not expose the service on all host interfaces as a
+workaround; the HTTP API has no built-in authentication or TLS.
+
+## 7. Expected successful flow
+
+The validated x86_64 run showed:
+
+1. `server.started` and `worker.started`.
+2. `POST /session/login` returning HTTP 202 for the pending 2FA challenge.
+3. Challenge completion with HTTP 200 and `session.authenticated`.
+4. `GET /session` and `GET /session/credentials` returning HTTP 200.
+5. `session.recovered` after worker replacement.
+6. Playback and `/key` requests returning HTTP 200.
+
+These results verify the exercised x86_64 paths, not ARM64.
+
+## 8. Preserve or intentionally delete session state
+
+Stop without deleting persisted session state:
+
+```bash
+docker compose down
+```
+
+Rebuild and restart while retaining the same Compose volume:
+
+```bash
+./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch x86_64
+docker compose up -d
+```
+
+Only when intentionally deleting the generated device identity and cached
+Apple Music session:
+
+```bash
+docker compose down -v
+```
+
+Never use `down -v` as a routine update command. Preserve the volume so the
+device identity remains paired with the cached session.
+
+## 9. Security
+
+Keep the default loopback binding, restrict Docker daemon access, and keep the
+data volume and logs private. Do not expose Wrapper directly to the Internet,
+publish the local image, or commit the APKM, credentials, or session data.
diff --git a/docs/source-audit-2026-11.md b/docs/source-audit-2026-11.md
index 4741a7b..28c78f6 100644
--- a/docs/source-audit-2026-11.md
+++ b/docs/source-audit-2026-11.md
@@ -296,3 +296,85 @@ publish the resulting image.
level in the README.
- Added the findings, limits, architecture map, and private validation matrix
in this document.
+
+
+## Successful clean-install reproduction — 25 November 2026 local time
+
+A subsequent clean installation confirmed the identity correction on x86_64.
+The log timestamps below were emitted in UTC on 26 November 2026; the test took
+place on 25 November local time (UTC-06:00).
+
+### Environment
+
+- Windows host: Windows 10 IoT Enterprise LTSC 2021.
+- Linux runtime: openSUSE Tumbleweed under an updated WSL installation.
+- Wrapper deployment: Docker Compose in the Linux environment.
+- Wrapper version: 1.0.0.
+- Native worker: x86_64.
+- Apple Music: pinned 3.6.0-beta, build 1109.
+- Gamdl: freshly installed separately on Windows.
+- Test scope: x86_64 only.
+
+### Authentication evidence
+
+The sanitized log shows:
+
+- The Rust API started successfully.
+- The x86_64 worker initialized successfully.
+- A previous-session restore returned `session_expired` (HTTP 403), which
+ preceded a new interactive login and did not prevent it.
+- `POST /session/login` returned HTTP 202, the expected pending-2FA response.
+- The challenge completed with HTTP 200 and Wrapper emitted
+ `session.authenticated`.
+- `GET /session` and `GET /session/credentials` returned HTTP 200.
+
+### Session-recovery and playback evidence
+
+Later, after the native worker was stopped and replaced:
+
+- The replacement x86_64 worker started.
+- Wrapper emitted `session.recovered`.
+- `GET /session/credentials` returned HTTP 200.
+- Two playback requests returned HTTP 200.
+- Two `/key` requests returned HTTP 200.
+
+This validates the fresh-login/2FA path and the exercised x86_64 session-recovery,
+playback, and key/context HTTP paths in the reported environment. It does not
+validate every catalog item, every media codec, all playback edge cases, or
+the internal correctness of context bytes beyond the successful endpoint
+responses in this test.
+
+### ARM64 qualification
+
+The identity generation and validation reside in shared Rust code, not in
+architecture-specific native capture files. Thus, the device-info change is
+expected to apply identically on ARM64. However, this reproduction did not
+build or run an ARM64 image and did not test ARM64 authentication, playback,
+or context capture. ARM64 must remain marked unverified until those steps are
+performed on an ARM64-capable or emulated Buildx/runtime environment.
+
+### Sanitized log evidence (relevant events)
+
+```jsonl
+{"timestamp":"2026-11-26T01:52:54.580290Z","level":"INFO","event":"server.started","version":"1.0.0","protocol":1,"architecture":"x86_64","host":"0.0.0.0","port":80}
+{"timestamp":"2026-11-26T01:53:31.644440Z","level":"INFO","event":"http.request","request_id":2,"method":"GET","path":"/session","status":200,"duration_ms":1013}
+{"timestamp":"2026-11-26T01:58:32.479258Z","level":"WARN","event":"worker.error","operation":"session.restore","code":"session_expired","restart_required":false}
+{"timestamp":"2026-11-26T01:58:32.479323Z","level":"WARN","event":"http.request","request_id":6,"method":"POST","path":"/session/restore","status":403,"duration_ms":1,"code":"session_expired"}
+{"timestamp":"2026-11-26T01:58:33.853034Z","level":"INFO","event":"http.request","request_id":8,"method":"GET","path":"/session","status":200,"duration_ms":0}
+{"timestamp":"2026-11-26T01:58:46.069488Z","level":"INFO","event":"http.request","request_id":9,"method":"POST","path":"/session/login","status":202,"duration_ms":6311}
+{"timestamp":"2026-11-26T01:59:10.838309Z","level":"INFO","event":"session.authenticated"}
+{"timestamp":"2026-11-26T01:59:10.838357Z","level":"INFO","event":"http.request","request_id":10,"method":"POST","path":"/session/challenge","status":200,"duration_ms":4444}
+{"timestamp":"2026-11-26T01:59:10.846869Z","level":"INFO","event":"http.request","request_id":11,"method":"GET","path":"/session","status":200,"duration_ms":0}
+{"timestamp":"2026-11-26T01:59:10.853881Z","level":"INFO","event":"http.request","request_id":12,"method":"GET","path":"/session/credentials","status":200,"duration_ms":0}
+{"timestamp":"2026-11-26T02:14:39.596825Z","level":"INFO","event":"worker.started","architecture":"x86_64"}
+{"timestamp":"2026-11-26T02:14:43.461339Z","level":"INFO","event":"session.recovered"}
+{"timestamp":"2026-11-26T02:14:43.461481Z","level":"INFO","event":"http.request","request_id":17,"method":"GET","path":"/session","status":200,"duration_ms":4540}
+{"timestamp":"2026-11-26T02:14:43.471588Z","level":"INFO","event":"http.request","request_id":18,"method":"GET","path":"/session/credentials","status":200,"duration_ms":0}
+{"timestamp":"2026-11-26T02:14:45.062051Z","level":"INFO","event":"http.request","request_id":19,"method":"GET","path":"/playback","status":200,"duration_ms":356}
+{"timestamp":"2026-11-26T02:14:45.388081Z","level":"INFO","event":"http.request","request_id":20,"method":"GET","path":"/playback","status":200,"duration_ms":317}
+{"timestamp":"2026-11-26T02:14:47.230518Z","level":"INFO","event":"http.request","request_id":21,"method":"GET","path":"/key","status":200,"duration_ms":321}
+{"timestamp":"2026-11-26T02:14:47.609184Z","level":"INFO","event":"http.request","request_id":22,"method":"GET","path":"/key","status":200,"duration_ms":309}
+```
+
+No username, password, 2FA code, cookie, token value, signed URL, or account
+identifier appears in this event excerpt.
From 6783b3211dbe382fdcc3b0df0bbf331d73add9ab Mon Sep 17 00:00:00 2001
From: BeniMorBelt <66647326+TuPapaPendejo@users.noreply.github.com>
Date: Wed, 25 Nov 2026 20:32:33 -0600
Subject: [PATCH 4/7] docs: make upstream clone path primary after merge
---
README.md | 16 ++++++++++------
docs/clean-install-linux.md | 11 ++++++-----
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index 72e58fa..0e17cc9 100644
--- a/README.md
+++ b/README.md
@@ -137,22 +137,26 @@ The `docker version` output must contain both client and server sections. Buildx
#### 4.3 Clone the corrected source
-Until the correction is merged upstream, clone the tested branch from this fork:
+After the correction is merged upstream, clone the canonical repository:
```bash
-git clone --branch fix/device-info-apple-auth-1109 --single-branch \
- https://github.com/TuPapaPendejo/wrapper-v2-Tests.git wrapper-v2
+git clone https://github.com/glomatico/wrapper-v2.git
cd wrapper-v2
```
-After the maintainer merges the corresponding pull request, use the canonical upstream repository:
+**While the upstream pull request is still awaiting review**, the tested fix is
+available on this fork branch:
```bash
-git clone https://github.com/glomatico/wrapper-v2.git
+git clone --branch fix/device-info-apple-auth-1109 --single-branch \
+ https://github.com/TuPapaPendejo/wrapper-v2-Tests.git wrapper-v2
cd wrapper-v2
```
-Do not assume that upstream `main` contains the fix while its pull request is still under review. Confirm the branch and revision:
+Check out a branch that contains the correction; do not assume that upstream
+`main` has been updated before the maintainer merges the pull request.
+
+Confirm the branch and revision:
```bash
git status --short --branch
diff --git a/docs/clean-install-linux.md b/docs/clean-install-linux.md
index c7d8377..19c57c5 100644
--- a/docs/clean-install-linux.md
+++ b/docs/clean-install-linux.md
@@ -39,18 +39,19 @@ must include a server section).
## 2. Clone the corrected branch
-Until the correction is merged upstream:
+After the correction is merged upstream, clone the canonical repository:
```bash
-git clone --branch fix/device-info-apple-auth-1109 --single-branch \
- https://github.com/TuPapaPendejo/wrapper-v2-Tests.git wrapper-v2
+git clone https://github.com/glomatico/wrapper-v2.git
cd wrapper-v2
```
-After the upstream maintainer merges the PR, clone the canonical repository:
+**While the upstream pull request is still awaiting review**, the tested fix is
+available on this fork branch:
```bash
-git clone https://github.com/glomatico/wrapper-v2.git
+git clone --branch fix/device-info-apple-auth-1109 --single-branch \
+ https://github.com/TuPapaPendejo/wrapper-v2-Tests.git wrapper-v2
cd wrapper-v2
```
From 38b20f2dc956b0fdbe1be9b14d399edd9bf627be Mon Sep 17 00:00:00 2001
From: BeniMorBelt <66647326+TuPapaPendejo@users.noreply.github.com>
Date: Wed, 25 Nov 2026 20:33:40 -0600
Subject: [PATCH 5/7] docs: link the standalone Linux installation runbook
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 0e17cc9..134dc44 100644
--- a/README.md
+++ b/README.md
@@ -89,6 +89,8 @@ The Compose configuration binds the HTTP service to **127.0.0.1:8080** by defaul
This procedure is distribution-independent. Install the host prerequisites using the package manager and Docker setup supported by your Linux distribution.
+A standalone copy of this runbook is also available at [docs/clean-install-linux.md](docs/clean-install-linux.md).
+
#### 4.1 Validated environment and support boundary
The successful end-to-end reproduction used:
From 5d90bdc63a9748b4c5afff719f79744ccabdf599 Mon Sep 17 00:00:00 2001
From: BeniMorBelt <66647326+TuPapaPendejo@users.noreply.github.com>
Date: Wed, 25 Nov 2026 22:00:32 -0600
Subject: [PATCH 6/7] docs: consolidate installation guidance and clarify
package verification
---
CHANGELOG.md | 57 ++--
README.md | 393 ++++-------------------
docs/clean-install-linux.md | 164 +++++-----
docs/source-audit-2026-11.md | 90 +++---
profiles/apple-music-1109-arm64-v8a.json | 1 -
profiles/apple-music-1109-x86_64.json | 1 -
src/device_info.rs | 6 +-
tools/build-docker.sh | 3 +-
8 files changed, 217 insertions(+), 498 deletions(-)
mode change 100755 => 100644 tools/build-docker.sh
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f8d1f4d..1e1ca3e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,24 +2,18 @@
## Unreleased
-- Expand the README with a distribution-independent clean Linux installation
- procedure, exact build-1109 APKM verification, Docker/Buildx prerequisites,
- Windows Gamdl-to-WSL connectivity, session persistence, and troubleshooting.
-- Record the successful clean x86_64 reproduction on openSUSE Tumbleweed under
- updated WSL on Windows 10 IoT Enterprise LTSC 2021. Windows Gamdl was installed
- separately. ARM64 remains expected from the shared identity code but has not
- been live-tested in this reproduction.
-- Fix the generated first-install device fingerprint to use the known-working
- Apple Music client tuple `Music/5.0.2/Android/10/Pixel 8/7663314` and a
- 64-bit Android ID encoded as 16 lowercase hexadecimal characters. The
- identity remains generated once and persisted; existing identity files and
- legacy session hashes are not rewritten.
-- Add regression coverage for the generated fingerprint shape and for
- preservation of an existing 1.0.0 identity.
-- Correct the documented Android runtime API level for ARM64 to API 21,
- matching the pinned profile and CMake build configuration.
-- Add a source-level reverse-engineering and security audit with explicit
- runtime-validation limitations.
+- Correct the generated first-install device fingerprint using the combined
+ client tuple and 64-bit Android-ID representation reported to complete
+ fresh login and 2FA. Existing persisted identities, native identity hashes,
+ and cached sessions are not rewritten.
+- Retain independent 128-bit randomness for temporary identity-file names
+ and add regression coverage for fresh identity generation, concurrent
+ initialization, explicit overrides, and legacy identity preservation.
+- Add one clean Linux installation runbook and a separate source audit with
+ the successful x86_64 reproduction and its limits. The reproduction does
+ not establish ARM64 end-to-end support.
+- Correct the documented Android application build target to API 21, matching
+ the pinned profile and CMake configuration.
## 1.0.0 — 2026-11-19
@@ -39,8 +33,8 @@ decryption locally using [Temari](https://github.com/WorldObservationLog/Temari)
through `/playback`, `/session`, and `/session/credentials`.
- Report supported features, architecture, profile and protocol through `/info`
so clients can reject incompatible servers before attempting authentication.
-- Support native **x86-64** and **ARM64** workers, each with verified
- architecture-specific runtime and Apple Music library profiles.
+- Provide architecture-specific x86-64 and ARM64 worker implementations and
+ runtime profiles. Live validation scope is documented separately.
### Authentication and lifecycle
@@ -58,15 +52,14 @@ decryption locally using [Temari](https://github.com/WorldObservationLog/Temari)
### Docker installation
- Use a multi-stage Docker build for the Rust server, native worker, Linux
- launcher, and full Android runtime. Host-installed Rust and Android NDK are
- not required.
-- Bundle verified Google Android system image components for both supported
- architectures, together with their third-party notices.
-- Accept an authorized, pinned Apple Music **3.6.0-beta (build 1109)** standalone
- `.apk` or `.apkm` bundle directly as an argument to
- `tools/build-docker.sh`. Verify the expected manifests and native libraries
- before staging.
-- Pass the private package through an isolated Docker BuildKit build context
+ launcher, and Android runtime. Host-installed Rust and Android NDK are not
+ required.
+- Bundle Google Android system runtime components for both architectures,
+ together with their original third-party notices.
+- Accept an operator-supplied local Apple Music 3.6.0-beta (build 1109)
+ standalone APK or supported split APKM. Validate the expected manifests,
+ native libraries, and architecture before staging.
+- Pass the private package through an isolated Docker BuildKit named context
rather than copying the raw package into an image layer.
- Start Docker Compose without a `.env` file. Generate a persistent device
identity on first startup and retain it with account/session data in a named
@@ -79,8 +72,8 @@ decryption locally using [Temari](https://github.com/WorldObservationLog/Temari)
- **Breaking change:** Existing clients using the former `/decrypt` endpoint
must migrate to the 1.0.0 session, playback, and Temari context APIs.
-- **No APK is distributed with the source code.** Users must supply their own
- authorized copy of the pinned Apple Music version.
+- **No Apple Music APK is distributed with the source code.** The operator
+ supplies an authorized local package compatible with the pinned profile.
- **Do not publish or redistribute locally built Docker images.** Those images
include Apple's extracted proprietary libraries even though the Git repository
does not.
@@ -88,7 +81,7 @@ decryption locally using [Temari](https://github.com/WorldObservationLog/Temari)
persistent Docker volume and retain existing explicit identity settings when
upgrading an older deployment.
- This rewrite has received substantial AI coding assistance. See the
- [README acknowledgements and AI disclosure](README.md#acknowledgements).
+ [README AI usage note](README.md#ai-usage).
## 0.0.2 and earlier
diff --git a/README.md b/README.md
index 134dc44..94e3766 100644
--- a/README.md
+++ b/README.md
@@ -1,231 +1,60 @@
# Wrapper v2
-**A self-hosted Apple Music playback and Temari-compatible context server.**
+**Self-hosted Apple Music playback and Temari-compatible context server.**
-Wrapper v2 provides an HTTP API for authenticated Apple Music sessions, playback information, and decryption contexts used by compatible clients such as [Gamdl](https://github.com/glomatico/gamdl). The 1.0.0 rewrite uses a Rust HTTP supervisor and a native C++ worker.
+Wrapper v2 exposes an HTTP API for authenticated Apple Music sessions, playback data, and decryption contexts consumed by compatible clients such as [Gamdl](https://github.com/glomatico/gamdl). Version 1.0.0 uses a Rust HTTP supervisor and a native C++ worker.
-For release history and breaking changes, see the [Changelog](CHANGELOG.md).
+The server does **not** download or decrypt media. Decryption is performed by the client. The legacy `/decrypt` endpoint is not part of the 1.0.0 API.
-The server **does not decrypt or download media**. Decryption, when supported, takes place on the client side. The legacy `/decrypt` endpoint is **not** part of the 1.0.0 API.
+See [CHANGELOG.md](CHANGELOG.md) for release history.
-## Features
-
-- **Temari-compatible API** for playback and client-side decryption contexts.
-- **x86-64 and ARM64** Linux hosts, with architecture-specific Android workers.
-- **Session management** with cached authentication, manual login, and two-factor authentication.
-- **Automatic session recovery** and transparent, bounded retries during planned worker recycling.
-- **Isolated native workers** with separate mount and PID namespaces, process supervision, and cleanup.
-- **Self-contained, privately built Docker images** with the verified Android runtime and Apple Music libraries.
-- **Persistent account state** stored separately from the image.
-- **Structured JSON logs** with sanitized request metadata.
-
-## Requirements
-
-| Component | Requirement |
-| --- | --- |
-| Host | Linux, `x86_64` or `aarch64` |
-| Deployment | Docker with Compose **2.24+** (required for optional `.env`) |
-| Apple Music | **Version 3.6.0-beta, build 1109**, for the selected architecture |
-| Android runtime | Bundled, architecture-specific Android system files (x86-64: API 21; ARM64: API 21) |
-| Building | Docker with Buildx/BuildKit and standard Linux shell tools |
-| Toolchains | Android NDK **r23b**, Rust, CMake, Ninja, and cross-compilers are installed **inside Docker** |
-
-The Apple Music build and bundled Android runtime are **strictly pinned**. Other APK versions and substitute libraries are not supported merely because they have the same architecture.
-
-**You must supply your own authorized copy of the pinned Apple Music APK.** The Android system libraries are bundled from [verified Google system images](vendor/android-system/README.md), with their [third-party notices](THIRD_PARTY_NOTICES.md). The APK never enters Git or the ordinary source build context: the build script supplies it through an isolated, read-only BuildKit named context. **The final, locally built image contains the extracted proprietary Apple libraries. Do not publish or redistribute that image.** Login credentials and saved sessions are never built into the image.
-
-## Getting started
-
-The build helper defaults to your host architecture. For ARM64, use the `--arch arm64-v8a` flag instead. **No local Android NDK, Rust toolchain, or Android system image is needed.** Docker compiles both architectures with an x86-64 NDK builder. Cross-architecture builds also require QEMU/binfmt emulation for the target image's runtime setup, or a remote multi-platform Buildx builder. On an x86-64 Linux host without ARM64 emulation, enable it with `docker run --privileged --rm tonistiigi/binfmt --install arm64` (this registers a host-level emulator). Docker Desktop may already provide this support.
-
-### 1. Obtain the supported Apple Music APK or APKM
-
-Clone this repository and obtain your authorized Apple Music **3.6.0-beta (build 1109)** APK/APKM:
-
-```bash
-git clone https://github.com/glomatico/wrapper-v2.git
-cd wrapper-v2
-```
-
-Provide either an `.apkm` bundle (containing `base.apk` and the correct architecture split) or a standalone `.apk` with the pinned architecture-specific native libraries. A `base.apk` taken alone from a split bundle may not contain the required libraries. The Android system files are already in `vendor/android-system/`; the APK manifest and individual Apple libraries are verified against pinned SHA-256 hashes.
+## Current validation status
-### 2. Build everything in Docker
-
-```bash
-./tools/build-docker.sh /path/to/AppleMusic.apk
-# Or an APKM bundle:
-# ./tools/build-docker.sh /path/to/AppleMusic.apkm
-# For an ARM64 image:
-# ./tools/build-docker.sh /path/to/AppleMusic.apkm --arch arm64-v8a
-```
-
-The file path is passed directly to the build script; no environment variable is required. The multi-stage Docker build installs the pinned NDK and a Rust toolchain, compiles the native worker, Linux launcher, and Rust supervisor, and assembles the complete Android rootfs **inside the image**. The APK or APKM is bind-mounted read-only from its isolated named build context (and its SHA-256 controls cache invalidation); the raw package is **not copied into an image layer**. The Docker builder still receives the archive, so use only a trusted, private builder. The verified Apple libraries extracted from it are present in the resulting runtime image.
-
-The generated image is `wrapper-v2:1.0.0-local-amd64` for x86-64 or `wrapper-v2:1.0.0-local-arm64` for ARM64. It is also tagged `wrapper-v2:local`, which Docker Compose uses automatically. Initial builds download the Android NDK and toolchains and therefore require substantial time, network access, and disk space; subsequent builds can reuse Docker layer caches.
-
-### 3. Start Wrapper
-
-```bash
-docker compose up -d
-```
-
-**No `.env` file or manual login is needed.** On first startup, Wrapper generates a unique, nine-part device identity and saves it in the persistent Docker volume alongside the session cache. New installations use the tested `Music/5.0.2/Android/10/Pixel 8/7663314/en-US/en-US` client fingerprint and a random 16-character lowercase hexadecimal (64-bit) Android ID. The identity is reused on future restarts and image upgrades. **Preserve this volume**: deleting it (including via `docker compose down -v`) loses both the identity and cached login. The Android runtime is embedded in the image and must not be bind-mounted from the host.
-
-To configure an alternative image, port, DNS, device identity, or optional automatic login, copy `.env.example` to `.env` and uncomment only the settings you need. For automatic login, set **both** `WRAPPER_USERNAME` and `WRAPPER_PASSWORD`; otherwise leave them absent. Manual overrides must use a stable, slash-separated nine-field `WRAPPER_DEVICE_INFO`.
-
-**Existing installations:** Keep your current `.env` values for `WRAPPER_DEVICE_INFO` and `WRAPPER_DATA_DIR` and reuse the same session directory. Existing `.wrapper-device-info` identities are deliberately not rewritten or migrated: this preserves the device hash recorded in `.worker-device` and avoids invalidating cached sessions. A legacy cache without a saved generated identity will **not** be assigned a different identity automatically; the server rejects that setup until the original identity is supplied. Do not remove your existing `.env` or switch from a `./data` bind mount to the new named volume without migrating the session state.
-
-```bash
-docker compose logs -f wrapper
-curl -fsS http://127.0.0.1:8080/info
-curl -fsS http://127.0.0.1:8080/session
-```
-
-**Ready for Gamdl:** Once the container is running, point [Gamdl](https://github.com/glomatico/gamdl) to your Wrapper v2 endpoint. Gamdl prompts for your Apple Music credentials and handles two-factor authentication (2FA) when needed. You do **not** need to log in through the HTTP API or configure `WRAPPER_USERNAME` / `WRAPPER_PASSWORD` just to use Gamdl.
-
-The Compose configuration binds the HTTP service to **127.0.0.1:8080** by default and preserves account data in a named volume. **Do not rebuild the image with account data or publish it to a registry.** `GET /health` confirms the HTTP server is responding; use `GET /session` to check actual worker and authentication state. If using the HTTP API directly instead of Gamdl, send a JSON `POST` to `/session/login` containing `username` and `password`, and complete any required 2FA challenge using the endpoints below. Avoid putting real credentials directly in shell history.
-
-### 4. Clean Linux installation from scratch (validated procedure)
-
-This procedure is distribution-independent. Install the host prerequisites using the package manager and Docker setup supported by your Linux distribution.
-
-A standalone copy of this runbook is also available at [docs/clean-install-linux.md](docs/clean-install-linux.md).
-
-#### 4.1 Validated environment and support boundary
-
-The successful end-to-end reproduction used:
-
-| Component | Tested environment |
-| --- | --- |
-| Windows host | Windows 10 IoT Enterprise LTSC 2021 |
-| Linux runtime | openSUSE Tumbleweed under WSL |
-| WSL | Updated installation available at test time |
-| Wrapper deployment | Docker Compose inside Linux |
-| Wrapper | Version 1.0.0 with the device-identity correction in this branch |
-| Native worker | x86_64 |
-| Apple Music | 3.6.0-beta, build 1109 |
-| Gamdl | Clean installation on Windows, separate from Wrapper |
-
-The test completed fresh Apple Account login, 2FA, credential retrieval, session recovery after worker recycling, playback requests, and `/key` requests.
-
-**Only x86_64 was tested live.** The corrected device-identity code is shared Rust code rather than architecture-specific native code, so the same identity correction is expected to apply to ARM64. ARM64 login, playback, context capture, and the complete ARM64 Docker deployment have not been verified by this reproduction. The two native workers and context-capture implementations remain architecture-specific.
-
-#### 4.2 Linux host prerequisites
-
-Install the following on a supported Linux host:
-
-- Linux on `x86_64` or `aarch64`.
-- Docker Engine with a running daemon.
-- Docker Compose plugin v2.24 or newer.
-- Docker Buildx with BuildKit enabled.
-- Git, Bash, coreutils (including `realpath`, `sha256sum`, and `mktemp`), and `curl`.
-
-The build does not require a host-installed Rust toolchain, Android SDK/NDK, CMake, Ninja, or cross-compiler. Those build toolchains are installed inside the Docker builder.
-
-Ensure your user can access the Docker daemon. On a conventional Linux installation, follow the distribution's documented Docker service setup. Membership in the Docker group is effectively root-equivalent and should be granted only to trusted users.
-
-Verify the host before cloning:
-
-```bash
-uname -m
-git --version
-docker version
-docker compose version
-docker buildx version
-docker buildx inspect --bootstrap
-```
-
-The `docker version` output must contain both client and server sections. Buildx must report a usable builder.
-
-#### 4.3 Clone the corrected source
-
-After the correction is merged upstream, clone the canonical repository:
-
-```bash
-git clone https://github.com/glomatico/wrapper-v2.git
-cd wrapper-v2
-```
-
-**While the upstream pull request is still awaiting review**, the tested fix is
-available on this fork branch:
-
-```bash
-git clone --branch fix/device-info-apple-auth-1109 --single-branch \
- https://github.com/TuPapaPendejo/wrapper-v2-Tests.git wrapper-v2
-cd wrapper-v2
-```
+- **x86_64:** clean Docker installation, fresh Apple Account login, 2FA, session credentials, worker recycle/session recovery, playback, and `/key` HTTP requests were exercised successfully with Apple Music 3.6.0-beta, build 1109.
+- **ARM64:** architecture-specific profiles and native code are present, but this change has not been validated through a complete live ARM64 build, login, playback, and context run. Treat ARM64 as unverified for this change.
+- The device-fingerprint correction follows the combined configuration reported in [issue #23](https://github.com/glomatico/wrapper-v2/issues/23). The report changed the client tuple and Android ID length together; it did not isolate their individual effects.
-Check out a branch that contains the correction; do not assume that upstream
-`main` has been updated before the maintainer merges the pull request.
+Detailed source findings and sanitized x86_64 evidence are in [the source audit](docs/source-audit-2026-11.md).
-Confirm the branch and revision:
-
-```bash
-git status --short --branch
-git log -1 --oneline
-```
-
-#### 4.4 Obtain the exact Apple Music APKM
-
-Wrapper is pinned to **Apple Music 3.6.0-beta, build 1109**. Do not substitute another version or build.
+## Features
-Download the APKM variant containing both `x86_64` and `arm64-v8a` splits from the [exact APKMirror listing](https://www.apkmirror.com/apk/apple/apple-music/apple-music-3-6-0-beta-release/apple-music-3-6-0-beta-4-android-apk-download/).
+- Temari-compatible playback and context API.
+- Session login, 2FA, cached-session restore, and optional automatic login.
+- Bounded worker supervision, recycling, and session recovery.
+- Separate native workers and context-capture profiles for x86_64 and ARM64.
+- Persistent device identity and session storage.
+- Structured JSON logs with sanitized request metadata.
+- Private Docker image build with architecture-specific Android runtime files and verified Apple native-library inputs.
-Pinned package details:
+## Requirements
-| Property | Required value |
+| Component | Requirement |
| --- | --- |
-| Package | `com.apple.android.music` |
-| Version | `3.6.0-beta` |
-| Build | `1109` |
-| Variant | `arm64-v8a + x86_64` |
-| SHA-256 | `5be907af370a7f6bd73344e646dcfebe2e64c2da3b9ad71192110c91950f3f67` |
-
-Verify the downloaded file before building:
-
-```bash
-sha256sum "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm"
-```
-
-Proceed only if the result exactly matches the pinned 64-character SHA-256. If it differs, stop. Do not bypass the validation or substitute another package.
-
-The APKM is supplied to BuildKit through an isolated local context. It is not committed to Git or copied into the ordinary source build context. The resulting runtime image does contain extracted proprietary Apple libraries; keep it private and do not publish or redistribute it.
-
-#### 4.5 Build the x86_64 image
-
-For the architecture tested in the successful reproduction:
+| Host | Linux, x86_64 or aarch64 |
+| Deployment | Docker Engine, Docker Compose plugin 2.24+, Buildx/BuildKit |
+| Build input | An authorized local Apple Music 3.6.0-beta, build 1109 package for the target ABI; standalone APK or supported split APKM |
+| Host tools | Git, Bash, coreutils, curl |
+| Build toolchains | Android NDK r23b, Rust, CMake, Ninja, and cross-compilers are installed inside Docker |
-```bash
-./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch x86_64
-```
-
-The build helper calculates the APKM checksum and passes it to BuildKit. The Dockerfile verifies the archive, selects the correct architecture split, checks pinned manifests and Apple library hashes, verifies bundled Android system files, compiles the native worker and launcher plus the Rust HTTP server, and stages the Android root filesystem.
-
-The build must finish without checksum, manifest, architecture, missing-library, or compilation errors. Do not use an image produced by an interrupted or failed build.
+The package version, manifests, architecture, and required Apple native libraries are pinned in the profiles. The build accepts a local package path; this repository does not provide the Apple Music package or direct users to a download source.
-For ARM64, the documented command is:
+**Verification boundary:** the build helper calculates the SHA-256 of the supplied package and passes it to BuildKit to keep the input consistent during the build. This is not a trusted, pre-pinned checksum of the original APK/APKM archive. Compatibility is checked using the expected Android manifests and the SHA-256 hashes of the extracted native libraries in the selected profile.
-```bash
-./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch arm64-v8a
-```
+## Quick start
-A cross-architecture ARM64 build may require binfmt/QEMU support in the Buildx builder or a remote multi-platform builder. This command is documented, but ARM64 was not included in the live authentication test.
+Use a source revision containing the device-identity correction. The full procedure, including the current branch to use while the upstream pull request is pending, is in [docs/clean-install-linux.md](docs/clean-install-linux.md).
-#### 4.6 Start Wrapper
-
-A normal clean installation does not require a `.env` file:
+From the repository root, provide the path to your locally held, authorized Apple Music build 1109 package:
```bash
+./tools/build-docker.sh "/absolute/path/to/your/AppleMusic-build-1109.apk" --arch x86_64
docker compose up -d
docker compose ps
-docker compose logs -f wrapper
```
-The default Compose configuration binds the HTTP service to loopback on port 8080 and creates a persistent named volume for Apple Music session data. The server should report `server.started`; the first native operation should start the Android worker and report `worker.started`.
-
-#### 4.7 Verify service health and the runtime profile
+The build helper also accepts a supported `.apkm` split bundle. The tested live path is x86_64; the ARM64 build command is documented in the runbook but has not been validated end to end in the reproduction recorded here.
-Run the following checks from Linux:
+Check the local service:
```bash
curl -fsS http://127.0.0.1:8080/health
@@ -233,137 +62,50 @@ curl -fsS http://127.0.0.1:8080/info
curl -fsS http://127.0.0.1:8080/session
```
-Expected high-level results:
-
-- `/health`: HTTP 200 and JSON status `ok`.
-- `/info`: HTTP 200, Wrapper version 1.0.0, protocol 1, and the architecture/profile corresponding to the image built.
-- `/session`: a successful response describing the current native session state.
-
-A fresh volume contains no previously authenticated Apple Music session. An attempted restore may therefore return `no_cached_session` or `session_expired`. This alone does not mean the fresh-login path is broken; continue with interactive login.
-
-#### 4.8 Connect Windows Gamdl to Wrapper running under WSL
-
-The validated arrangement installed Gamdl separately on Windows while Wrapper ran inside the Linux/WSL environment.
-
-With WSL localhost forwarding enabled and the default Compose port mapping, the Windows client can reach Wrapper at:
-
-```text
-http://127.0.0.1:8080
-```
-
-Check reachability from PowerShell:
+Compose binds the HTTP service to loopback on port 8080 by default and stores account state in the persistent `wrapper_data` volume. No `.env` file is required for a normal fresh installation.
-```powershell
-curl.exe -fsS http://127.0.0.1:8080/health
-```
-
-Configure Gamdl to use Wrapper as its authentication provider and enter the Wrapper endpoint when requested. Complete the Apple Account login and any 2FA challenge through Gamdl. Keep the WSL distribution, Docker daemon, and Wrapper container running while the Windows client uses the service.
-
-If Windows cannot reach the endpoint, first check WSL localhost forwarding and the Compose port mapping. Do not work around a localhost issue by exposing Wrapper on every host interface: the API has no built-in authentication or TLS.
-
-#### 4.9 Expected successful login, recovery, and playback sequence
-
-The confirmed x86_64 reproduction followed this sequence:
-
-1. The HTTP server starts and reports `server.started`.
-2. The native worker initializes and reports `worker.started`.
-3. A previous-session restore returns `session_expired` (HTTP 403); a new interactive login is then attempted.
-4. `POST /session/login` returns HTTP 202, indicating a pending 2FA challenge.
-5. `POST /session/challenge` completes with HTTP 200 and Wrapper reports `session.authenticated`.
-6. `GET /session` and `GET /session/credentials` return HTTP 200.
-7. After worker replacement, the replacement reports `worker.started` and Wrapper reports `session.recovered`.
-8. Playback requests return HTTP 200.
-9. The `/key` compatibility endpoint returns HTTP 200.
-
-This confirms more than HTTP liveness: the test exercised fresh login, 2FA, credentials retrieval, worker recycle/session recovery, playback, and key/context HTTP requests on x86_64.
-
-Do not include Apple Account credentials, passwords, 2FA codes, tokens, cookies, or signed playback URLs in public issue reports. Keep operational logs access-restricted even though Wrapper redacts sensitive request data.
-
-#### 4.10 Persistence, rebuilds, and destructive reset
-
-Stop Wrapper without deleting session state:
-
-```bash
-docker compose down
-```
-
-Rebuild and start again while preserving the same Compose volume:
-
-```bash
-./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch x86_64
-docker compose up -d
-```
-
-**Destructive reset — only when intentionally deleting the saved identity and session:**
-
-```bash
-docker compose down -v
-```
-
-The `-v` option deletes the Compose-managed named volume. This removes the persisted device identity and cached Apple Music session. Never use `down -v` as a routine update command or on an installation whose session must be retained.
-
-For a fresh deployment in another directory, Compose normally derives a different project name and creates a separate volume. Inspect `docker compose ls` and `docker volume ls` before removing any data.
+### Device identity and existing installations
-#### 4.11 Security notes
+A new installation generates a random 64-bit Android ID and persists the complete device identity in the session volume. The identity is reused across restarts and image rebuilds.
-- Keep the loopback-only host binding unless remote access is deliberately placed behind an authenticated TLS gateway.
-- Do not expose port 8080 directly to the public Internet.
-- Do not publish the locally built image: it contains extracted proprietary Apple libraries.
-- Do not commit the APKM, extracted libraries, `.env`, credentials, or session volume.
-- Treat Docker daemon access as privileged host access.
-- Preserve the persistent volume so the generated device identity remains paired with the cached session.
-- Do not use `docker compose down -v` unless account/session deletion is intentional.
+Existing `.wrapper-device-info` identities are not rewritten or migrated. The identity is paired with the native `.worker-device` hash and cached session state. Preserve the original session volume and, for legacy deployments, the existing `WRAPPER_DEVICE_INFO` and `WRAPPER_DATA_DIR` settings. Do not switch a legacy bind mount to the default named volume without migrating the data.
+**Do not run `docker compose down -v` unless deleting the identity and cached session is intentional.**
## HTTP API
-The API is **unversioned** in 1.0.0. Requests and responses use JSON; the internal native-worker IPC protocol is separate.
+The 1.0.0 HTTP API is unversioned. Requests and responses use JSON; the native-worker IPC protocol is separate.
| Method | Endpoint | Purpose |
| --- | --- | --- |
| `GET` | `/health` | HTTP liveness |
-| `GET` | `/info` | Version, features, profile and architecture |
-| `GET` | `/session` | Current session state and operation count |
-| `GET` | `/session/credentials` | Export session credentials for a compatible client |
-| `POST` | `/session/restore` | Restore the previously cached session |
+| `GET` | `/info` | Version, features, profile, and architecture |
+| `GET` | `/session` | Session state and operation count |
+| `GET` | `/session/credentials` | Export session credentials to a compatible client |
+| `POST` | `/session/restore` | Restore a cached session |
| `POST` | `/session/login` | Start login with `username` and `password` |
-| `GET` | `/session/challenge` | Retrieve the pending two-factor challenge |
+| `GET` | `/session/challenge` | Retrieve the pending 2FA challenge |
| `POST` | `/session/challenge` | Submit `challenge_id` and six-digit `code`; empty code cancels |
| `POST` | `/session/close` | Close the session |
-| `GET` | `/playback?adam_id=...` | Obtain playback data for an Apple Music catalog ID |
-| `GET` | `/context?adam_id=...&key_uri=...` | Obtain a Temari-compatible context for a valid `skd://` URI |
+| `GET` | `/playback?adam_id=...` | Retrieve playback data |
+| `GET` | `/context?adam_id=...&key_uri=...` | Retrieve a Temari-compatible context |
| `GET` | `/key?adamId=...&uri=...` | Compatibility alias for `/context` |
-Example requests after authentication:
+Playback and context requests are serialized through a single native worker. Concurrent requests may receive `503 worker_busy`. Eligible requests are retried internally after planned worker recycling.
-```bash
-curl -fsS 'http://127.0.0.1:8080/playback?adam_id=123456789'
-curl -fsS -G 'http://127.0.0.1:8080/context' \
- --data-urlencode 'adam_id=123456789' \
- --data-urlencode 'key_uri=skd://your-key-identifier'
-```
-
-If an interactive login requires 2FA, the login endpoint returns **HTTP 202** with a challenge ID. Use `GET /session/challenge` to retrieve it, then submit:
-
-```json
-{"challenge_id":"","code":"123456"}
-```
-
-to `POST /session/challenge`. The displayed code is an example, **not** a real authentication code.
+## Security and operations
-Errors use the form `{"error":{"code":"...","retryable":false,"restart_required":false}}`. Normal recycling is handled internally for playback and context requests. Simultaneous requests may receive `503 worker_busy` because the server deliberately serializes access to its single native worker.
+**Do not expose the HTTP API directly to the Internet.** It has no built-in authentication or TLS, and `GET /session/credentials` returns sensitive session material. Keep the loopback binding, restrict Docker daemon access, and use an authenticated TLS gateway for deliberate remote access.
-## Security and operational notes
+The container runs the HTTP process as a non-root UID, with a read-only filesystem and an init process. The native launcher temporarily requires `CAP_SYS_ADMIN` and `CAP_SYS_CHROOT` for namespaces, mounts, and chroot. The Compose profile also relaxes AppArmor; this is a deployment security trade-off documented by the current configuration and should not be copied into a more restrictive production policy without testing.
-**Do not expose Wrapper v2 directly to the internet.** There is no built-in HTTP authentication or TLS, and `/session/credentials` returns sensitive account material. Use a loopback binding, a private network, or a separately authenticated TLS gateway. Restrict access to the host, Docker socket, `.env`, staged rootfs, and session volumes. Environment-based auto-login credentials are visible to users with access to Docker container configuration.
+The locally built image contains extracted proprietary Apple libraries. Keep it private; do not publish or redistribute it without the necessary rights. Do not commit the package, extracted libraries, `.env`, credentials, logs containing session data, or the session volume.
-The Compose configuration starts the HTTP process as a non-root UID. The native launcher temporarily needs `CAP_SYS_ADMIN` and `CAP_SYS_CHROOT` for namespaces, mounts, and `chroot`; those privileges are dropped before the Android worker runs. The service also uses a read-only container filesystem and an init process for child reaping. Container runtimes with stricter seccomp/LSM policies may need corresponding namespace/mount permissions. **Any user with permission to pull/export the locally built image can extract its embedded Apple libraries.** Keep the image private and restrict Docker daemon access.
+See [docs/logging.md](docs/logging.md) for log fields and redaction, and [docs/worker-launch.md](docs/worker-launch.md) for namespace and worker lifecycle details.
-Workers have a bounded operation budget and are replaced when necessary, with authenticated sessions restored before protected requests continue. Each worker receives a fresh PID namespace to avoid a known mutex/TID overflow in the pinned Android runtime. See [worker lifecycle](docs/worker-launch.md).
+## Development and tests
-Logs are JSON lines on stderr and intentionally omit raw URLs, query parameters, credentials, key URIs, and contexts. See [logging](docs/logging.md). Treat error logs as sensitive operational data nonetheless.
-
-## Development and testing
+Run the source-level test suite from the repository root:
```bash
cargo fmt --check
@@ -372,30 +114,31 @@ cargo test --locked
python3 -B -m unittest discover -s tests -p 'test_*.py' -v
```
-The automated HTTP tests use a **synthetic worker**; they do not require Apple account credentials or proprietary files. Additional Linux namespace tests require `unshare` support and elevated namespace permissions; follow [worker lifecycle](docs/worker-launch.md) for instructions. Validate the actual architecture-specific worker and cached session before production deployment.
+The HTTP integration tests use a synthetic worker; they do not exercise Apple's proprietary authentication path. Linux namespace tests require `unshare` and the relevant kernel permissions. The GitHub Actions workflow runs formatting, Clippy, Rust unit tests, namespace tests, and Python integration/staging tests. Passing those checks does not replace a live test against the pinned Apple Music build.
-For development, `tools/build.sh` can still build the native worker and launcher on a host with Android NDK r23b installed. Maintainers with the locally provisioned `wrapper-v2:native-build` image can use `tools/build-local.sh --arch arm64-v8a` instead. These are **optional native-only developer workflows**; the recommended Docker build does not require either. When using the host tools, first extract verified Apple libraries with `tools/prepare_rootfs.py --extract-libraries`.
+Optional native-only developer workflows are available through `tools/build.sh` and `tools/build-local.sh`; they require their documented toolchains and are not necessary for the Docker build.
-## Limitations
+## Project documentation
-- Supports only the pinned Apple Music APK build and architecture-specific runtime profiles currently in `profiles/`.
-- Does not implement the previous Wrapper v2 `/decrypt` API or decrypt files server-side.
-- Serves one native operation at a time; concurrent requests may be rejected with `worker_busy`.
-- Requires the operator to supply the pinned Apple Music APK, maintain an authorized Apple Music account, and comply with applicable service and licensing restrictions.
+- [Clean Linux installation runbook](docs/clean-install-linux.md)
+- [Source audit, findings, and x86_64 validation evidence](docs/source-audit-2026-11.md)
+- [Structured logging](docs/logging.md)
+- [Native worker lifecycle](docs/worker-launch.md)
+- [Changelog](CHANGELOG.md)
+- [Third-party notices](THIRD_PARTY_NOTICES.md)
## Acknowledgements
-Wrapper v2 owes a great deal to the projects and people who helped build the Apple Music wrapper ecosystem:
-
-- **[zhaarey/wrapper](https://github.com/zhaarey/wrapper)** — the original Wrapper project, which laid the groundwork for running Apple Music's Android components without a full Android emulator.
-- **[WorldObservationLog](https://github.com/WorldObservationLog)** — for their work on [Wrapper and Wrapper Lite](https://github.com/WorldObservationLog/wrapper/tree/lite), and on the [Temari](https://github.com/WorldObservationLog/Temari) decryption library and related tooling.
+- **[zhaarey/wrapper](https://github.com/zhaarey/wrapper)** — the original Wrapper project.
+- **[WorldObservationLog](https://github.com/WorldObservationLog)** — Wrapper Lite, Temari, and related research.
+- **[@rocketguedes](https://github.com/rocketguedes)** — the diagnostic lead in [issue #23](https://github.com/glomatico/wrapper-v2/issues/23) that identified a device fingerprint configuration which completed fresh login and 2FA in the reported environment.
-Thank you to their contributors and the wider community for sharing their research and making continued development possible. Wrapper v2 1.0.0 is a rewrite with its own implementation; these acknowledgements recognize the preceding work and ideas, not an endorsement of this project by the upstream authors.
+These acknowledgements recognize prior research and diagnostic contributions; they do not imply endorsement by the upstream authors.
## AI usage
-**This project was developed with substantial assistance from AI coding tools.** AI was used throughout development for implementation, architecture discussions, debugging, testing, and documentation. AI-generated suggestions and code can be incorrect or introduce security vulnerabilities, even when automated tests pass. The project maintainer remains responsible for reviewing, testing, and maintaining the published code. Issues and independent reviews are welcome.
+This project received substantial assistance from AI coding tools for implementation, architecture discussion, debugging, testing, and documentation. AI-generated output can be incorrect or introduce security defects. The maintainer remains responsible for reviewing, testing, and maintaining the code.
## License
-Wrapper v2's original source code is released under [The Unlicense](LICENSE). The bundled Android system files retain their own licenses and required notices, documented in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md), and included in locally built images. Apple's proprietary libraries are **not shipped in the source repository** but **are embedded in private Docker builds**. Do not redistribute those images without the necessary rights. This project is not affiliated with or endorsed by Apple.
+The original Wrapper source code is released under [The Unlicense](LICENSE). The bundled Android system files retain their own licenses and notices, documented in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). Apple proprietary libraries are not included in the source repository but are embedded in private Docker builds. This project is not affiliated with or endorsed by Apple.
diff --git a/docs/clean-install-linux.md b/docs/clean-install-linux.md
index 19c57c5..06abd11 100644
--- a/docs/clean-install-linux.md
+++ b/docs/clean-install-linux.md
@@ -1,29 +1,29 @@
-# Clean Linux installation — Wrapper v2 1.0.0
+# Clean Linux installation
-This guide covers a clean installation of the corrected Wrapper branch. It is
-distribution-independent: install the prerequisites using the package manager
-and Docker setup supported by your Linux distribution.
+This runbook describes the validated x86_64 installation path for Wrapper v2 1.0.0. It keeps the complete setup procedure in one place; the repository README contains only the quick start and project overview.
-## Validated environment
+## 1. Validation boundary
-The successful test ran Wrapper and Docker Compose inside openSUSE Tumbleweed
-under an updated WSL installation on Windows 10 IoT Enterprise LTSC 2021.
-Gamdl was installed separately on Windows. The tested Wrapper architecture was
-x86_64 only.
+The live reproduction used Windows 10 IoT Enterprise LTSC 2021, openSUSE Tumbleweed under WSL, Docker Compose inside Linux, Wrapper 1.0.0, an x86_64 native worker, and Apple Music 3.6.0-beta build 1109. Gamdl was installed separately on Windows.
-The test completed login, 2FA, credentials retrieval, session recovery after
-worker recycling, playback, and `/key` requests. ARM64 is expected to use the
-same shared Rust device-identity code, but was not included in this live test.
+Fresh login, 2FA, session-credential retrieval, worker replacement/session recovery, playback, and `/key` HTTP requests succeeded on x86_64. The test did not validate ARM64. Its build and runtime profiles exist, but treat ARM64 live authentication, playback, and context capture as unverified.
-## 1. Host prerequisites
+See [the source audit](source-audit-2026-11.md) for the sanitized event sequence, exact test scope, and unresolved findings.
-Install Linux on x86_64 or aarch64, Docker Engine with a running daemon, Docker
-Compose v2.24 or newer, Docker Buildx/BuildKit, Git, Bash, coreutils, and curl.
+## 2. Linux host prerequisites
-No host Rust toolchain, Android SDK/NDK, CMake, Ninja, or cross-compiler is
-required. The Docker build installs compilation toolchains in its builder.
+Use Linux on x86_64 for the validated path. The codebase also contains an ARM64 build profile, but that target has not been end-to-end validated by this reproduction.
-Verify:
+Install and configure:
+
+- Docker Engine with a running daemon.
+- Docker Compose plugin 2.24 or newer.
+- Docker Buildx with BuildKit enabled.
+- Git, Bash, coreutils (including `realpath`, `sha256sum`, and `mktemp`), and `curl`.
+
+Rust, Android NDK, CMake, Ninja, and cross-compilers are installed inside the Docker builder; they are not required on the host.
+
+Verify the environment:
```bash
uname -m
@@ -34,20 +34,18 @@ docker buildx version
docker buildx inspect --bootstrap
```
-The Docker CLI must be able to reach the daemon (the `docker version` output
-must include a server section).
+The Docker CLI must show both client and server sections. Buildx must report a usable builder. Docker daemon access is effectively privileged host access; grant it only to trusted users.
-## 2. Clone the corrected branch
+## 3. Clone a source revision containing the correction
-After the correction is merged upstream, clone the canonical repository:
+After the upstream pull request is merged, use the canonical repository:
```bash
git clone https://github.com/glomatico/wrapper-v2.git
cd wrapper-v2
```
-**While the upstream pull request is still awaiting review**, the tested fix is
-available on this fork branch:
+While the upstream pull request is pending, the tested correction is on this fork branch:
```bash
git clone --branch fix/device-info-apple-auth-1109 --single-branch \
@@ -55,61 +53,56 @@ git clone --branch fix/device-info-apple-auth-1109 --single-branch \
cd wrapper-v2
```
-Check the current branch and commit before building:
+Confirm that the working tree is clean and the selected revision contains the correction:
```bash
git status --short --branch
git log -1 --oneline
```
-## 3. Download the pinned Apple Music APKM
+Do not assume that upstream `main` contains the correction until the maintainer merges it.
-Download the APKM variant containing x86_64 and arm64-v8a splits from the
-[exact APKMirror 3.6.0-beta listing](https://www.apkmirror.com/apk/apple/apple-music/apple-music-3-6-0-beta-release/apple-music-3-6-0-beta-4-android-apk-download/).
+## 4. Supply the local Apple Music build input
-Required package: `com.apple.android.music`, version `3.6.0-beta`, build
-`1109`, variant `arm64-v8a + x86_64`.
+The runtime profiles target Apple Music package `com.apple.android.music`, version `3.6.0-beta`, build `1109`. Supply your own authorized local package for the selected ABI. The build script accepts either:
-Pinned SHA-256:
+- A standalone APK containing the required manifest and architecture-specific native libraries.
+- A split APKM bundle containing `base.apk` and the matching architecture split.
-```text
-5be907af370a7f6bd73344e646dcfebe2e64c2da3b9ad71192110c91950f3f67
-```
+A base APK extracted by itself from a split package may not contain the required native libraries. The package must match the profile selected by `--arch`. This repository does not host the package and this runbook does not identify third-party download sources.
-Verify the download:
+Set a shell variable to the local file you already possess:
```bash
-sha256sum "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm"
+APPLE_MUSIC_PACKAGE="/absolute/path/to/your/authorized-Apple-Music-build-1109.apk"
+test -f "$APPLE_MUSIC_PACKAGE"
```
-The checksum must match exactly. Do not bypass validation or use another build.
-Do not commit the APKM. The local image contains extracted proprietary Apple
-libraries and must not be published or redistributed.
+The path may point to an `.apkm` file instead. Do not place the package in Git, a shared build context, or an image layer.
-## 4. Build the Docker image
+**What the build verifies:** `tools/prepare_rootfs.py` checks the expected base/split Android manifest digest, the selected ABI, the ELF machine type, and the SHA-256 hash of each required Apple native library. It stages only the allowlisted files. The helper also calculates the complete input archive's SHA-256 and passes that value through BuildKit; this preserves input consistency and cache invalidation, but it is not a publisher-authenticity check or a comparison to a trusted, hard-coded whole-archive checksum.
-For the tested architecture:
+## 5. Build the tested x86_64 image
```bash
-./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch x86_64
+./tools/build-docker.sh "$APPLE_MUSIC_PACKAGE" --arch x86_64
```
-The build helper sends the package through an isolated BuildKit context. The
-Dockerfile checks its digest, pinned manifests, Apple library hashes, bundled
-Android system files, and executable architectures, then compiles the native
-worker/launcher and Rust server and stages the Android rootfs.
+The multi-stage Docker build installs the pinned NDK and Rust toolchain, compiles the native worker and namespace launcher, builds the Rust HTTP service, validates the selected runtime files, and assembles the Android root filesystem inside the image.
+
+The build must complete without manifest, hash, architecture, missing-library, or compilation errors. Do not start an image produced by an interrupted or failed build.
-ARM64 build command (not live-tested in the reported reproduction):
+An ARM64 build can be requested with:
```bash
-./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch arm64-v8a
+./tools/build-docker.sh "$APPLE_MUSIC_PACKAGE" --arch arm64-v8a
```
-Cross-building ARM64 may require binfmt/QEMU or a remote multi-platform builder.
+This command is present in the build scripts, but it is not validated by the live reproduction documented here. Cross-building may require binfmt/QEMU support in Buildx or a remote multi-platform builder. Do not treat a successful image build alone as proof of ARM64 authentication or playback.
-## 5. Start and verify Wrapper
+## 6. Start Wrapper and check the service
-No `.env` file is required for a normal fresh installation:
+A normal clean installation does not need a `.env` file:
```bash
docker compose up -d
@@ -117,7 +110,9 @@ docker compose ps
docker compose logs -f wrapper
```
-Check service health and runtime profile:
+The service binds to `127.0.0.1:8080` on the Linux host and stores session data in the persistent `wrapper_data` volume by default.
+
+Check liveness, runtime profile, and session state:
```bash
curl -fsS http://127.0.0.1:8080/health
@@ -125,72 +120,71 @@ curl -fsS http://127.0.0.1:8080/info
curl -fsS http://127.0.0.1:8080/session
```
-A fresh data volume has no saved Apple Music session. A restore attempt may
-return `no_cached_session` or `session_expired`; proceed with a new login.
+- `/health` confirms that the HTTP server is responding. It does not prove the native worker is authenticated.
+- `/info` reports the version, architecture, and selected runtime profile.
+- `/session` reports the session/worker state.
+
+A new volume has no cached Apple Music session. An initial restore attempt may report `no_cached_session` or `session_expired`; continue through a fresh login.
-## 6. Connect Windows Gamdl to Wrapper under WSL
+## 7. Connect Windows Gamdl to Wrapper under WSL
-In the validated arrangement Gamdl ran on Windows while Wrapper ran under WSL.
-With WSL localhost forwarding enabled and the default Compose port mapping,
-use this endpoint from Windows:
+The validated arrangement ran Wrapper inside WSL and installed Gamdl separately on Windows. With WSL localhost forwarding enabled and the default Compose port mapping, Windows can reach the service at:
```text
http://127.0.0.1:8080
```
-Test reachability in PowerShell:
+Check from PowerShell:
```powershell
curl.exe -fsS http://127.0.0.1:8080/health
```
-Configure Gamdl to use Wrapper as its authentication provider and enter the
-endpoint when requested. Keep WSL, Docker, and the Wrapper container running.
+Configure Gamdl to use Wrapper as its authentication provider and supply the endpoint when prompted. Complete Apple Account login and any 2FA challenge in the client. Keep the WSL distribution, Docker daemon, and Wrapper container running while Gamdl uses the service.
-If Windows cannot reach the service, check WSL localhost forwarding and the
-Compose port mapping. Do not expose the service on all host interfaces as a
-workaround; the HTTP API has no built-in authentication or TLS.
+If Windows cannot reach the endpoint, check WSL localhost forwarding and the Compose port mapping first. Do not expose the unauthenticated HTTP service on all host interfaces as a workaround.
-## 7. Expected successful flow
+## 8. Expected authentication and runtime sequence
-The validated x86_64 run showed:
+The validated x86_64 run exercised this sequence:
-1. `server.started` and `worker.started`.
-2. `POST /session/login` returning HTTP 202 for the pending 2FA challenge.
-3. Challenge completion with HTTP 200 and `session.authenticated`.
-4. `GET /session` and `GET /session/credentials` returning HTTP 200.
-5. `session.recovered` after worker replacement.
-6. Playback and `/key` requests returning HTTP 200.
+1. The API and native worker start.
+2. A fresh `POST /session/login` returns HTTP 202 while the 2FA challenge is pending.
+3. Challenge submission returns HTTP 200 and Wrapper logs `session.authenticated`.
+4. `GET /session` and `GET /session/credentials` return HTTP 200.
+5. After worker replacement, Wrapper logs `session.recovered`.
+6. Playback and `/key` requests return HTTP 200.
-These results verify the exercised x86_64 paths, not ARM64.
+These results confirm the exercised x86_64 routes. They do not validate every catalog item, codec, playback edge case, internal context-byte correctness, or ARM64.
-## 8. Preserve or intentionally delete session state
+## 9. Preserve session state
-Stop without deleting persisted session state:
+Stop the service without deleting the persistent volume:
```bash
docker compose down
```
-Rebuild and restart while retaining the same Compose volume:
+Rebuild and restart while keeping the same Compose project and volume:
```bash
-./tools/build-docker.sh "$HOME/Downloads/AppleMusic-3.6.0-beta-1109.apkm" --arch x86_64
+./tools/build-docker.sh "$APPLE_MUSIC_PACKAGE" --arch x86_64
docker compose up -d
```
-Only when intentionally deleting the generated device identity and cached
-Apple Music session:
+**Destructive reset — use only when intentionally deleting the saved device identity and Apple Music session:**
```bash
docker compose down -v
```
-Never use `down -v` as a routine update command. Preserve the volume so the
-device identity remains paired with the cached session.
+The `-v` option removes the Compose-managed named volume. Never use it as a routine update command. For installations using the legacy `WRAPPER_DATA_DIR=./data` bind mount, preserve that directory and its original `WRAPPER_DEVICE_INFO`; do not silently switch to the named volume.
-## 9. Security
+## 10. Security
-Keep the default loopback binding, restrict Docker daemon access, and keep the
-data volume and logs private. Do not expose Wrapper directly to the Internet,
-publish the local image, or commit the APKM, credentials, or session data.
+- Keep the host binding on loopback. The HTTP API has no built-in authentication or TLS.
+- Do not expose port 8080 directly to the Internet; use a separately authenticated TLS gateway for deliberate remote access.
+- Treat Docker daemon access, the session volume, `.env`, and operational logs as sensitive.
+- Do not commit the Apple Music package, extracted proprietary libraries, credentials, or session state.
+- Do not publish or redistribute the locally built image: it contains extracted proprietary Apple libraries.
+- Keep the generated device identity paired with its session volume across restarts and image upgrades.
diff --git a/docs/source-audit-2026-11.md b/docs/source-audit-2026-11.md
index 28c78f6..36d7b0b 100644
--- a/docs/source-audit-2026-11.md
+++ b/docs/source-audit-2026-11.md
@@ -12,10 +12,11 @@
contents API, comparison against the upstream Wrapper Lite device-identity
implementation, and review of the supplied reproduction in
[glomatico/wrapper-v2 issue 23](https://github.com/glomatico/wrapper-v2/issues/23).
-- This is a **source-level audit**, not a claim of a completed live Apple login
- test. The proprietary APKM, Apple account credentials, and a privileged Linux
- Docker runtime were not run in this review environment. CI's synthetic worker
- cannot validate Apple's proprietary `AuthenticateFlow`.
+- This document records the **source-level review**; that review did not itself
+ execute Apple's proprietary code. A separate clean x86_64 Docker deployment,
+ login, 2FA, session recovery, playback, and key-route reproduction was later
+ supplied and is documented near the end. CI's synthetic worker still cannot
+ validate Apple's proprietary `AuthenticateFlow`.
## Executive findings
@@ -55,7 +56,7 @@
### F-01 — Fresh-install device identity did not match the working client profile
**Severity:** High for first-login availability
-**Status:** Fixed in this change; real Apple login still requires private verification.
+**Status:** Fixed and exercised in the supplied clean x86_64 reproduction. ARM64 and broader native/media behavior remain unverified.
Baseline implementation in `src/device_info.rs` used:
@@ -252,51 +253,40 @@ volume contains persistent authentication state. Keep all of them private.
| Area | Source/test coverage reviewed | Live validation still required |
| --- | --- | --- |
-| Device identity | persistence, atomic creation, concurrent startup, explicit override and legacy identity tests | new-login and existing-session test with build 1109 |
-| HTTP API | synthetic end-to-end routes, validation, error mapping, redaction | no Apple native path |
-| Supervisor | mock worker recycle/recovery, cancellation, 2FA, client disconnect | actual native worker restart and session restoration |
-| Native protocol | framing, size/depth checks, 2FA continuation validation, SHA-256/base64 tests | Apple IPC behavior |
-| Launcher | disposable PID/mount namespaces, orphan reaping, teardown | target host's Docker seccomp/AppArmor policy |
-| APKM staging | synthetic APK/APKM, manifest/hash/ELF and duplicate-library rejection | actual authorized APKM extraction and full Docker build |
-| x86-64/ARM64 capture | static profiles, offsets, hashes and context length contracts | real playback/context request for each ABI |
-
-## Exact Apple Music package required for private verification
-
-The exact APKMirror listing identified for the build pinned by this repository is:
-
-- Package: `com.apple.android.music`
-- Version: `3.6.0-beta`
-- Build: `1109`
-- Variant: `arm64-v8a + x86_64`, split APKM bundle
-- Listing:
-- APKM SHA-256:
- `5be907af370a7f6bd73344e646dcfebe2e64c2da3b9ad71192110c91950f3f67`
-
-Verify a downloaded file before building:
-
-```bash
-sha256sum AppleMusic-3.6.0-beta-1109.apkm
-./tools/build-docker.sh /path/to/AppleMusic-3.6.0-beta-1109.apkm --arch x86_64
-./tools/build-docker.sh /path/to/AppleMusic-3.6.0-beta-1109.apkm --arch arm64-v8a
-```
-
-Use only an authorized copy. Do not commit the APKM, extracted proprietary
-libraries, credentials, tokens, or session data to this repository. Do not
-publish the resulting image.
-
-## Change log for this audit branch
-
-- Changed the generated default fingerprint to the tested client tuple and
- 64-bit Android-ID representation.
-- Kept 128-bit entropy for temporary staging-file names.
-- Added regression coverage for the new fresh-install identity and for the
- no-migration guarantee on already persisted identities.
-- Updated the `.env.example` manual override.
-- Documented the identity compatibility behavior and corrected the ARM64 API
- level in the README.
-- Added the findings, limits, architecture map, and private validation matrix
- in this document.
-
+| Device identity | persistence, atomic creation, concurrent startup, explicit override and legacy identity tests | clean x86_64 fresh login/2FA succeeded; ARM64 live test remains outstanding |
+| HTTP API | synthetic routes, validation, error mapping, and redaction | x86_64 login, challenge, session, credential, playback, and key routes returned expected HTTP responses |
+| Supervisor | mock worker recycle/recovery, cancellation, 2FA, and client disconnect | x86_64 worker replacement and session recovery exercised; failure-mode matrix not exhausted |
+| Native protocol | framing, size/depth checks, 2FA continuation validation, SHA-256/base64 tests | x86_64 Apple authentication and worker IPC exercised; every native edge case remains unverified |
+| Launcher | disposable PID/mount namespaces, orphan reaping, and teardown | clean x86_64 Docker deployment exercised; other kernels and security profiles remain environment-dependent |
+| APK/APKM staging | synthetic package fixtures, manifest/hash/ELF and duplicate-library rejection | the supplied x86_64 deployment completed a private image build; ARM64 build remains unverified |
+| x86-64/ARM64 capture | static profiles, offsets, hashes and context length contracts | x86_64 playback and /key returned HTTP 200; context bytes were not independently validated, and ARM64 was not tested |
+
+## Private build-input and verification boundary
+
+The selected profiles target Apple Music package `com.apple.android.music`,
+version `3.6.0-beta`, build `1109`, with architecture-specific manifest and
+native-library hashes. The operator supplies an authorized local standalone
+APK or supported split APKM; the repository does not distribute that package
+or identify a third-party download source.
+
+`tools/prepare_rootfs.py` verifies the required base/split manifest digest,
+selects the expected architecture split, checks the ELF machine type, and
+compares every extracted Apple native library against the selected profile's
+SHA-256 value. It stages only the allowlisted native libraries and the
+separately pinned Android system files.
+
+The build helper also computes the SHA-256 of the complete local APK/APKM and
+passes it to BuildKit. The Dockerfile recomputes that same value inside the
+builder. This verifies that the supplied build input remains unchanged across
+the BuildKit hand-off and participates in cache invalidation. It is **not** a
+publisher-authenticity check and is not a comparison against a trusted,
+hard-coded whole-archive checksum. The unused `bundle_sha256` profile field
+was removed so the metadata no longer implies an archive-level validation
+that the staging code does not perform.
+
+Do not commit the input package, extracted proprietary libraries, account
+credentials, tokens, or session data. The resulting local image contains
+extracted Apple libraries and must remain private.
## Successful clean-install reproduction — 25 November 2026 local time
diff --git a/profiles/apple-music-1109-arm64-v8a.json b/profiles/apple-music-1109-arm64-v8a.json
index 535a08b..fe3e0dc 100644
--- a/profiles/apple-music-1109-arm64-v8a.json
+++ b/profiles/apple-music-1109-arm64-v8a.json
@@ -5,7 +5,6 @@
"architecture": "arm64-v8a",
"base_manifest_sha256": "9aef5c901453199ddfbca184eabd5237b0a287dc1af4fbdad56368bfd3c9c5f3",
"split_manifest_sha256": "d13b9dc7e896ce4c1427f56b2f8216f5c9e2223ea1fcf66d09c046348bb57f2e",
- "bundle_sha256": "5be907af370a7f6bd73344e646dcfebe2e64c2da3b9ad71192110c91950f3f67",
"apple_libraries": {
"libBlocksRuntime.so": "f7ebfdcf5115c6bf2073c79c498bcf6652f2501a697774a053cab4f6cf3e638a",
"libCoreADI.so": "db8779a9e1b026a087cd9a35c7d69f8af51418a29249ef325e6391ec560f6f47",
diff --git a/profiles/apple-music-1109-x86_64.json b/profiles/apple-music-1109-x86_64.json
index 1c4b9f6..7ca5ff2 100644
--- a/profiles/apple-music-1109-x86_64.json
+++ b/profiles/apple-music-1109-x86_64.json
@@ -5,7 +5,6 @@
"architecture": "x86_64",
"base_manifest_sha256": "9aef5c901453199ddfbca184eabd5237b0a287dc1af4fbdad56368bfd3c9c5f3",
"split_manifest_sha256": "ffec778d2e997ea8ff9852f1d2ba08b8c82ee6cb12e3ef2621ecf1f31da17a2f",
- "bundle_sha256": "5be907af370a7f6bd73344e646dcfebe2e64c2da3b9ad71192110c91950f3f67",
"apple_libraries": {
"libBlocksRuntime.so": "9814b756ae173a546eb12bf1019746f14b17a6546806445ff67f75b0aba8856a",
"libCoreADI.so": "b5b971cea0bbe828bdcfaf219fd91fc1e37cf8daee84001ef917d0b1c2b985ed",
diff --git a/src/device_info.rs b/src/device_info.rs
index 96b444b..b9d09b7 100644
--- a/src/device_info.rs
+++ b/src/device_info.rs
@@ -13,9 +13,9 @@ use crate::error::ApiError;
const FILE_NAME: &str = ".wrapper-device-info";
const LEGACY_FILE_NAME: &str = ".worker-device";
-// Match the known-working Apple Music client fingerprint used by the
-// upstream Wrapper implementation. Android IDs in this field are 64-bit
-// values rendered as 16 lowercase hexadecimal characters.
+// Use the combined client fingerprint reported to complete fresh login
+// and 2FA in issue #23. That report changed the client tuple and Android-ID
+// length together, so the independent effect of each change is not isolated.
const DEVICE_PREFIX: &str = "Music/5.0.2/Android/10/Pixel 8/7663314/en-US/en-US/";
fn invalid() -> ApiError {
diff --git a/tools/build-docker.sh b/tools/build-docker.sh
old mode 100755
new mode 100644
index 44434ce..f529ec2
--- a/tools/build-docker.sh
+++ b/tools/build-docker.sh
@@ -41,7 +41,8 @@ apk=$(realpath -- "$apk_input")
apk_sha256=$(sha256sum "$apk" | cut -d ' ' -f 1)
image=${WRAPPER_IMAGE:-wrapper-v2:1.0.0-local-${platform#linux/}}
-echo "Building $image ($platform) with the verified APK supplied privately to BuildKit."
+echo "Building $image ($platform) with the local Apple Music package supplied privately to BuildKit."
+echo "The builder checks the selected profile manifests and native-library hashes."
echo "NOTE: The resulting image contains Apple's proprietary libraries; do not publish it."
# BuildKit limits the size of --secret inputs on some builders. Use an isolated
From 6918066e51926427c133230ececae6154d4d70dd Mon Sep 17 00:00:00 2001
From: BeniMorBelt <66647326+TuPapaPendejo@users.noreply.github.com>
Date: Wed, 25 Nov 2026 22:01:52 -0600
Subject: [PATCH 7/7] docs: remove obsolete archive-checksum field reference
---
docs/source-audit-2026-11.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/source-audit-2026-11.md b/docs/source-audit-2026-11.md
index 36d7b0b..852bd03 100644
--- a/docs/source-audit-2026-11.md
+++ b/docs/source-audit-2026-11.md
@@ -280,9 +280,9 @@ passes it to BuildKit. The Dockerfile recomputes that same value inside the
builder. This verifies that the supplied build input remains unchanged across
the BuildKit hand-off and participates in cache invalidation. It is **not** a
publisher-authenticity check and is not a comparison against a trusted,
-hard-coded whole-archive checksum. The unused `bundle_sha256` profile field
-was removed so the metadata no longer implies an archive-level validation
-that the staging code does not perform.
+hard-coded whole-archive checksum. Obsolete profile metadata that implied
+archive-level validation was removed because the staging code does not
+perform that check.
Do not commit the input package, extracted proprietary libraries, account
credentials, tokens, or session data. The resulting local image contains