Skip to content

Commit

Permalink
add missing X-Apple-I-Client-Time, X-Apple-I-TimeZone, X-Apple-Locale…
Browse files Browse the repository at this point in the history
… headers for V1 requests
  • Loading branch information
amsam0 committed Mar 5, 2023
1 parent a0f26de commit 72b7661
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ base64 = "0.21"
bytestring = "1.3"
parking_lot = "0.12"
clap = { version = "4.1", features = ["derive"] }
chrono = "0.4"

log = "0.4"
simplelog = "0.12"
Expand Down
12 changes: 12 additions & 0 deletions src/provider_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ impl ProviderInstance {
self.set_identifier(self.original_identifier, None)?;
self.set_path(self.original_path.clone())?;
let mut headers = self.provider.get_anisette_headers(false).await?;

// Provision servers give X-MMe-Client-Info because AltServer gives X-MMe-Client-Info.
// However, it's actually incorrect, and omnisette will normalize it to be X-Mme-Client-Info when using provider.get_authentication_headers().
// To maintain backwards compatibility with V1 (and older versions of SideStore), we clone the header to ensure it is in both the correct and incorrect header key.
Expand All @@ -135,6 +136,17 @@ impl ProviderInstance {
} else if let Some(client_info) = headers.get("X-MMe-Client-Info") {
headers.insert("X-Mme-Client-Info".to_string(), client_info.clone());
}

// omnisette doesn't provide X-Apple-I-Client-Time, X-Apple-I-TimeZone or X-Apple-Locale headers because the client should provide them
// for V1 requests, we need to manually add them
let time = chrono::Utc::now();
headers.insert(
"X-Apple-I-Client-Time".to_string(),
time.to_rfc3339_opts(chrono::SecondsFormat::Secs, true), // .format("%Y-%m-%dT%H:%M:%SZ"), // Manually format to ISO 8601 because DateTime's to_rfc3339_opts is too smart
);
headers.insert("X-Apple-I-TimeZone".to_string(), "UTC".to_string());
headers.insert("X-Apple-Locale".to_string(), "en_US".to_string());

Ok(headers)
}

Expand Down

0 comments on commit 72b7661

Please sign in to comment.