mirror of
https://github.com/nab138/isideload.git
synced 2026-03-02 06:26:16 +01:00
fix clippy
This commit is contained in:
@@ -52,8 +52,7 @@ impl AnisetteData {
|
||||
// "X-Mme-Client-Info".to_string(),
|
||||
// self.device_description.clone(),
|
||||
// ),
|
||||
]
|
||||
.into_iter(),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
@@ -125,11 +124,10 @@ impl AnisetteDataGenerator {
|
||||
&mut self,
|
||||
gs: Arc<GrandSlam>,
|
||||
) -> Result<Arc<AnisetteData>, Report> {
|
||||
if let Some(data) = &self.data {
|
||||
if !data.needs_refresh() {
|
||||
if let Some(data) = &self.data
|
||||
&& !data.needs_refresh() {
|
||||
return Ok(data.clone());
|
||||
}
|
||||
}
|
||||
|
||||
// trying to avoid locking as write unless necessary to promote concurrency
|
||||
let provider = self.provider.read().await;
|
||||
|
||||
@@ -97,7 +97,7 @@ impl AnisetteProvider for RemoteV3AnisetteProvider {
|
||||
.header(CONTENT_TYPE, "application/json")
|
||||
.body(
|
||||
serde_json::json!({
|
||||
"identifier": BASE64_STANDARD.encode(&state.keychain_identifier),
|
||||
"identifier": BASE64_STANDARD.encode(state.keychain_identifier),
|
||||
"adi_pb": BASE64_STANDARD.encode(adi_pb)
|
||||
})
|
||||
.to_string(),
|
||||
@@ -120,7 +120,7 @@ impl AnisetteProvider for RemoteV3AnisetteProvider {
|
||||
routing_info,
|
||||
_device_description: client_info.client_info.clone(),
|
||||
device_unique_identifier: state.get_device_id(),
|
||||
_local_user_id: hex::encode(&state.get_md_lu()),
|
||||
_local_user_id: hex::encode(state.get_md_lu()),
|
||||
generated_at: SystemTime::now(),
|
||||
};
|
||||
|
||||
@@ -128,8 +128,7 @@ impl AnisetteProvider for RemoteV3AnisetteProvider {
|
||||
}
|
||||
AnisetteHeaders::GetHeadersError { message } => {
|
||||
Err(report!("Failed to get anisette headers")
|
||||
.attach(message)
|
||||
.into())
|
||||
.attach(message))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,7 +252,7 @@ impl RemoteV3AnisetteProvider {
|
||||
ws_stream
|
||||
.send(Message::Text(
|
||||
serde_json::json!({
|
||||
"identifier": BASE64_STANDARD.encode(&state.keychain_identifier),
|
||||
"identifier": BASE64_STANDARD.encode(state.keychain_identifier),
|
||||
})
|
||||
.to_string()
|
||||
.into(),
|
||||
@@ -337,15 +336,13 @@ impl RemoteV3AnisetteProvider {
|
||||
ProvisioningMessage::StartProvisioningError { message } => {
|
||||
return Err(
|
||||
report!("Anisette provisioning failed: start provisioning error")
|
||||
.attach(message)
|
||||
.into(),
|
||||
.attach(message),
|
||||
);
|
||||
}
|
||||
ProvisioningMessage::EndProvisioningError { message } => {
|
||||
return Err(
|
||||
report!("Anisette provisioning failed: end provisioning error")
|
||||
.attach(message)
|
||||
.into(),
|
||||
.attach(message),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ fn bin_serialize_opt<S>(x: &Option<Vec<u8>>, s: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
x.clone().map(|i| Data::new(i)).serialize(s)
|
||||
x.clone().map(Data::new).serialize(s)
|
||||
}
|
||||
|
||||
fn bin_deserialize_opt<'de, D>(d: D) -> Result<Option<Vec<u8>>, D::Error>
|
||||
@@ -71,7 +71,7 @@ impl AnisetteState {
|
||||
|
||||
pub fn get_md_lu(&self) -> [u8; 32] {
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(&self.keychain_identifier);
|
||||
hasher.update(self.keychain_identifier);
|
||||
hasher.finalize().into()
|
||||
}
|
||||
|
||||
|
||||
@@ -300,9 +300,9 @@ impl AppleAccount {
|
||||
.await
|
||||
.context("Failed to read SMS 2FA error response text")?;
|
||||
// try to parse as json, if it fails, just bail with the text
|
||||
if let Ok(json) = serde_json::from_str::<serde_json::Value>(&text) {
|
||||
if let Some(service_errors) = json.get("serviceErrors") {
|
||||
if let Some(first_error) = service_errors.as_array().and_then(|arr| arr.get(0))
|
||||
if let Ok(json) = serde_json::from_str::<serde_json::Value>(&text)
|
||||
&& let Some(service_errors) = json.get("serviceErrors")
|
||||
&& let Some(first_error) = service_errors.as_array().and_then(|arr| arr.first())
|
||||
{
|
||||
let code = first_error
|
||||
.get("code")
|
||||
@@ -323,8 +323,6 @@ impl AppleAccount {
|
||||
message
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
bail!(
|
||||
"SMS 2FA code submission failed with http status {}: {}",
|
||||
status,
|
||||
@@ -435,7 +433,7 @@ impl AppleAccount {
|
||||
let hashed_password = Sha256::digest(password.as_bytes());
|
||||
|
||||
let password_hash = if selected_protocol == "s2k_fo" {
|
||||
hex::encode(&hashed_password).into_bytes()
|
||||
hex::encode(hashed_password).into_bytes()
|
||||
} else {
|
||||
hashed_password.to_vec()
|
||||
};
|
||||
@@ -445,7 +443,7 @@ impl AppleAccount {
|
||||
.context("Failed to derive password using PBKDF2")?;
|
||||
|
||||
let verifier: SrpClientVerifier<Sha256> = srp_client
|
||||
.process_reply(&a, &self.email.as_bytes(), &password_buf, salt, b_pub)
|
||||
.process_reply(&a, self.email.as_bytes(), &password_buf, salt, b_pub)
|
||||
.unwrap();
|
||||
|
||||
let req2 = plist!(dict {
|
||||
@@ -486,7 +484,7 @@ impl AppleAccount {
|
||||
.get_data("spd")
|
||||
.context("Failed to get SPD from login response")?;
|
||||
|
||||
let spd_decrypted = Self::decrypt_cbc(&verifier, &spd_encrypted)
|
||||
let spd_decrypted = Self::decrypt_cbc(&verifier, spd_encrypted)
|
||||
.context("Failed to decrypt SPD from login response")?;
|
||||
let spd: plist::Dictionary =
|
||||
plist::from_bytes(&spd_decrypted).context("Failed to parse decrypted SPD plist")?;
|
||||
@@ -575,7 +573,7 @@ impl AppleAccount {
|
||||
.get_data("et")
|
||||
.context("Failed to get encrypted token")?;
|
||||
|
||||
let decrypted_token = Self::decrypt_gcm(&encrypted_token, &session_key)
|
||||
let decrypted_token = Self::decrypt_gcm(encrypted_token, session_key)
|
||||
.context("Failed to decrypt app token")?;
|
||||
|
||||
let token: Dictionary = plist::from_bytes(&decrypted_token)
|
||||
@@ -612,7 +610,7 @@ impl AppleAccount {
|
||||
|
||||
fn create_session_key(usr: &SrpClientVerifier<Sha256>, name: &str) -> Result<Vec<u8>, Report> {
|
||||
Ok(
|
||||
<hmac::Hmac<Sha256> as hmac::Mac>::new_from_slice(&usr.key())?
|
||||
<hmac::Hmac<Sha256> as hmac::Mac>::new_from_slice(usr.key())?
|
||||
.chain_update(name.as_bytes())
|
||||
.finalize()
|
||||
.into_bytes()
|
||||
@@ -627,7 +625,7 @@ impl AppleAccount {
|
||||
|
||||
Ok(
|
||||
cbc::Decryptor::<aes::Aes256>::new_from_slices(&extra_data_key, extra_data_iv)?
|
||||
.decrypt_padded_vec_mut::<Pkcs7>(&data)?,
|
||||
.decrypt_padded_vec_mut::<Pkcs7>(data)?,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ impl GrandSlam {
|
||||
) -> Result<Dictionary, Report> {
|
||||
let resp = self
|
||||
.post(url)?
|
||||
.headers(additional_headers.unwrap_or_else(|| reqwest::header::HeaderMap::new()))
|
||||
.headers(additional_headers.unwrap_or_else(reqwest::header::HeaderMap::new))
|
||||
.body(plist_to_xml_string(body))
|
||||
.send()
|
||||
.await
|
||||
|
||||
@@ -69,7 +69,7 @@ impl DeveloperSession {
|
||||
url: &str,
|
||||
body: impl Into<Option<Dictionary>>,
|
||||
) -> Result<(Dictionary, Option<String>), Report> {
|
||||
let body = body.into().unwrap_or_else(|| Dictionary::new());
|
||||
let body = body.into().unwrap_or_else(Dictionary::new);
|
||||
|
||||
let base = plist!(dict {
|
||||
"clientId": "XABBG36SBA",
|
||||
@@ -147,11 +147,10 @@ impl DeveloperSession {
|
||||
|
||||
let result: Result<T, _> = dict.get_struct(response_key);
|
||||
|
||||
if let Err(_) = &result {
|
||||
if let Some(err) = server_error {
|
||||
if result.is_err()
|
||||
&& let Some(err) = server_error {
|
||||
bail!(err);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(result.context("Failed to extract developer request result")?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user