mirror of
https://github.com/nab138/isideload.git
synced 2026-03-02 06:26:16 +01:00
Add list development certs to dev session api
This commit is contained in:
13
Cargo.lock
generated
13
Cargo.lock
generated
@@ -821,6 +821,7 @@ dependencies = [
|
|||||||
"reqwest",
|
"reqwest",
|
||||||
"rootcause",
|
"rootcause",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_bytes",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
@@ -1374,7 +1375,7 @@ dependencies = [
|
|||||||
"security-framework",
|
"security-framework",
|
||||||
"security-framework-sys",
|
"security-framework-sys",
|
||||||
"webpki-root-certs",
|
"webpki-root-certs",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1451,6 +1452,16 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_bytes"
|
||||||
|
version = "0.11.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_core"
|
name = "serde_core"
|
||||||
version = "1.0.228"
|
version = "1.0.228"
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ use isideload::{
|
|||||||
dev::developer_session::DeveloperSession,
|
dev::developer_session::DeveloperSession,
|
||||||
};
|
};
|
||||||
|
|
||||||
use plist_macro::pretty_print_dictionary;
|
use tracing::Level;
|
||||||
use tracing::{Level, debug};
|
|
||||||
use tracing_subscriber::FmtSubscriber;
|
use tracing_subscriber::FmtSubscriber;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -60,7 +59,7 @@ async fn main() {
|
|||||||
.expect("No developer teams available for this account");
|
.expect("No developer teams available for this account");
|
||||||
|
|
||||||
let res = dev_session
|
let res = dev_session
|
||||||
.list_devices(team, None)
|
.list_all_development_certs(team, None)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to list developer devices");
|
.expect("Failed to list developer devices");
|
||||||
|
|
||||||
|
|||||||
@@ -37,4 +37,5 @@ pbkdf2 = "0.12.2"
|
|||||||
hmac = "0.12.1"
|
hmac = "0.12.1"
|
||||||
cbc = { version = "0.1.2", features = ["std"] }
|
cbc = { version = "0.1.2", features = ["std"] }
|
||||||
aes = "0.8.4"
|
aes = "0.8.4"
|
||||||
aes-gcm = "0.10.3"
|
aes-gcm = "0.10.3"
|
||||||
|
serde_bytes = "0.11.19"
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ use crate::{
|
|||||||
dev::structures::{
|
dev::structures::{
|
||||||
DeveloperDevice,
|
DeveloperDevice,
|
||||||
DeveloperDeviceType::{self, *},
|
DeveloperDeviceType::{self, *},
|
||||||
DeveloperTeam, ListDevicesResponse, ListTeamsResponse,
|
DeveloperTeam, DevelopmentCertificate, ListCertificatesResponse, ListDevicesResponse,
|
||||||
|
ListTeamsResponse,
|
||||||
},
|
},
|
||||||
util::plist::PlistDataExtract,
|
util::plist::PlistDataExtract,
|
||||||
};
|
};
|
||||||
@@ -136,6 +137,30 @@ impl<'a> DeveloperSession<'a> {
|
|||||||
|
|
||||||
Ok(response.devices)
|
Ok(response.devices)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn list_all_development_certs(
|
||||||
|
&self,
|
||||||
|
team: &DeveloperTeam,
|
||||||
|
device_type: impl Into<Option<DeveloperDeviceType>>,
|
||||||
|
) -> Result<Vec<DevelopmentCertificate>, Report> {
|
||||||
|
let body = plist!(dict {
|
||||||
|
"teamId": &team.team_id,
|
||||||
|
});
|
||||||
|
|
||||||
|
let response: ListCertificatesResponse = self
|
||||||
|
.send_developer_request(&dev_url("listAllDevelopmentCerts", device_type), body)
|
||||||
|
.await
|
||||||
|
.context("Failed to list development certificates")?;
|
||||||
|
|
||||||
|
if response.result_code != 0 {
|
||||||
|
warn!(
|
||||||
|
"Non-zero list development certs response code: {}",
|
||||||
|
response.result_code
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(response.certificates)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dev_url(endpoint: &str, device_type: impl Into<Option<DeveloperDeviceType>>) -> String {
|
fn dev_url(endpoint: &str, device_type: impl Into<Option<DeveloperDeviceType>>) -> String {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use serde_bytes::ByteBuf;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum DeveloperDeviceType {
|
pub enum DeveloperDeviceType {
|
||||||
@@ -50,3 +51,20 @@ pub struct ListDevicesResponse {
|
|||||||
pub devices: Vec<DeveloperDevice>,
|
pub devices: Vec<DeveloperDevice>,
|
||||||
pub result_code: i64,
|
pub result_code: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct DevelopmentCertificate {
|
||||||
|
pub name: String,
|
||||||
|
pub certificate_id: String,
|
||||||
|
pub serial_number: Option<String>,
|
||||||
|
pub machine_id: Option<String>,
|
||||||
|
pub cert_content: Option<ByteBuf>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct ListCertificatesResponse {
|
||||||
|
pub certificates: Vec<DevelopmentCertificate>,
|
||||||
|
pub result_code: i64,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user