diff --git a/Cargo.lock b/Cargo.lock index 2926664..b72407b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -821,7 +821,6 @@ dependencies = [ "reqwest", "rootcause", "serde", - "serde_bytes", "serde_json", "sha2", "thiserror 2.0.18", @@ -1452,16 +1451,6 @@ dependencies = [ "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]] name = "serde_core" version = "1.0.228" diff --git a/examples/minimal/src/main.rs b/examples/minimal/src/main.rs index 61eeab0..a68aeb3 100644 --- a/examples/minimal/src/main.rs +++ b/examples/minimal/src/main.rs @@ -3,7 +3,10 @@ use std::env; use isideload::{ anisette::remote_v3::RemoteV3AnisetteProvider, auth::apple_account::AppleAccount, - dev::developer_session::{AppGroupsApi, DeveloperSession, TeamsApi}, + dev::{ + certificates::CertificatesApi, + developer_session::{DeveloperSession, TeamsApi}, + }, }; use tracing::Level; @@ -59,10 +62,16 @@ async fn main() { .get(0) .expect("No developer teams available for this account"); + // let app_ids = dev_session + // .list_app_ids(team, None) + // .await + // .expect("Failed to add appid"); + // let app_id = app_ids.app_ids.get(0).cloned().unwrap(); + let res = dev_session - .add_app_group(team, "Example", "group.me.nabdev.example.59AV98CNR7", None) + .list_all_development_certs(team, None) .await - .expect("Failed to add appid"); + .expect("Failed to list dev certs"); println!("{:?}", res); } diff --git a/isideload/Cargo.toml b/isideload/Cargo.toml index 934529b..657d926 100644 --- a/isideload/Cargo.toml +++ b/isideload/Cargo.toml @@ -38,4 +38,3 @@ hmac = "0.12.1" cbc = { version = "0.1.2", features = ["std"] } aes = "0.8.4" aes-gcm = "0.10.3" -serde_bytes = "0.11.19" diff --git a/isideload/src/dev/app_groups.rs b/isideload/src/dev/app_groups.rs index e3cc176..2d0f5f9 100644 --- a/isideload/src/dev/app_groups.rs +++ b/isideload/src/dev/app_groups.rs @@ -1,12 +1,9 @@ -use crate::{ - dev::{ - developer_session::DeveloperSession, - device_type::{DeveloperDeviceType, dev_url}, - teams::DeveloperTeam, - }, - util::plist::SensitivePlistAttachment, +use crate::dev::{ + app_ids::AppId, + developer_session::DeveloperSession, + device_type::{DeveloperDeviceType, dev_url}, + teams::DeveloperTeam, }; -use plist::{Date, Dictionary, Value}; use plist_macro::plist; use rootcause::prelude::*; use serde::Deserialize; @@ -70,6 +67,30 @@ pub trait AppGroupsApi { Ok(app_group) } + + async fn assign_app_group( + &self, + team: &DeveloperTeam, + app_group: &AppGroup, + app_id: &AppId, + device_type: impl Into> + Send, + ) -> Result<(), Report> { + let body = plist!(dict { + "teamId": &team.team_id, + "applicationGroups": &app_group.application_group, + "appIdId": &app_id.app_id_id, + }); + + self.developer_session() + .send_dev_request_no_response( + &dev_url("assignApplicationGroupToAppId", device_type), + body, + ) + .await + .context("Failed to assign developer app group")?; + + Ok(()) + } } impl AppGroupsApi for DeveloperSession<'_> { diff --git a/isideload/src/dev/app_ids.rs b/isideload/src/dev/app_ids.rs index baf68a1..b9a9386 100644 --- a/isideload/src/dev/app_ids.rs +++ b/isideload/src/dev/app_ids.rs @@ -6,7 +6,7 @@ use crate::{ }, util::plist::SensitivePlistAttachment, }; -use plist::{Date, Dictionary, Value}; +use plist::{Data, Date, Dictionary, Value}; use plist_macro::plist; use rootcause::prelude::*; use serde::Deserialize; @@ -29,6 +29,27 @@ pub struct ListAppIdsResponse { pub available_quantity: Option, } +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Profile { + pub encoded_profile: Data, + pub filename: String, + pub provisioning_profile_id: String, + pub name: String, + pub status: String, + pub r#type: String, + pub distribution_method: String, + pub pro_pro_platorm: Option, + #[serde(rename = "UUID")] + pub uuid: String, + pub date_expire: Date, + pub managing_app: Option, + pub app_id_id: String, + pub is_template_profile: bool, + pub is_team_profile: Option, + pub is_free_provisioning_profile: Option, +} + #[async_trait::async_trait] pub trait AppIdsApi { fn developer_session(&self) -> &DeveloperSession<'_>; @@ -89,7 +110,7 @@ pub trait AppIdsApi { &self, team: &DeveloperTeam, app_id: &AppId, - features: &Dictionary, + features: Dictionary, device_type: impl Into> + Send, ) -> Result { let mut body = plist!(dict { @@ -126,6 +147,30 @@ pub trait AppIdsApi { Ok(()) } + + async fn download_team_provisioning_profile( + &self, + team: &DeveloperTeam, + app_id: &AppId, + device_type: impl Into> + Send, + ) -> Result { + let body = plist!(dict { + "teamId": &team.team_id, + "appIdId": &app_id.app_id_id, + }); + + let response: Profile = self + .developer_session() + .send_dev_request( + &dev_url("downloadTeamProvisioningProfile", device_type), + body, + "provisioningProfile", + ) + .await + .context("Failed to download provisioning profile")?; + + Ok(response) + } } impl AppIdsApi for DeveloperSession<'_> { diff --git a/isideload/src/dev/certificates.rs b/isideload/src/dev/certificates.rs index bc434e5..9aaaa86 100644 --- a/isideload/src/dev/certificates.rs +++ b/isideload/src/dev/certificates.rs @@ -3,10 +3,10 @@ use crate::dev::{ device_type::{DeveloperDeviceType, dev_url}, teams::DeveloperTeam, }; +use plist::Data; use plist_macro::plist; use rootcause::prelude::*; use serde::Deserialize; -use serde_bytes::ByteBuf; use uuid::Uuid; #[derive(Deserialize, Clone)] @@ -16,7 +16,7 @@ pub struct DevelopmentCertificate { pub certificate_id: Option, pub serial_number: Option, pub machine_id: Option, - pub cert_content: Option, + pub cert_content: Option, } #[derive(Deserialize, Debug, Clone)] @@ -38,7 +38,7 @@ impl std::fmt::Debug for DevelopmentCertificate { &self .cert_content .as_ref() - .map(|c| format!("Some([{} bytes])", c.len())) + .map(|c| format!("Some([{} bytes])", c.as_ref().len())) .unwrap_or("None".to_string()), ) .finish()