Impliment provisioning profiles and assigning app groups

This commit is contained in:
nab138
2026-01-30 18:21:42 -05:00
parent 1648537bd0
commit 80121a0b91
6 changed files with 91 additions and 28 deletions

11
Cargo.lock generated
View File

@@ -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"

View File

@@ -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);
}

View File

@@ -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"

View File

@@ -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<Option<DeveloperDeviceType>> + 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<'_> {

View File

@@ -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<u64>,
}
#[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<String>,
#[serde(rename = "UUID")]
pub uuid: String,
pub date_expire: Date,
pub managing_app: Option<String>,
pub app_id_id: String,
pub is_template_profile: bool,
pub is_team_profile: Option<bool>,
pub is_free_provisioning_profile: Option<bool>,
}
#[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<Option<DeveloperDeviceType>> + Send,
) -> Result<AppId, Report> {
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<Option<DeveloperDeviceType>> + Send,
) -> Result<Profile, Report> {
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<'_> {

View File

@@ -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<String>,
pub serial_number: Option<String>,
pub machine_id: Option<String>,
pub cert_content: Option<ByteBuf>,
pub cert_content: Option<Data>,
}
#[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()