Keep scaffolding apple account

This commit is contained in:
nab138
2026-01-17 09:25:00 -05:00
parent d97e4b95d0
commit f4687ac3be
5 changed files with 77 additions and 13 deletions

10
Cargo.lock generated
View File

@@ -529,9 +529,9 @@ dependencies = [
[[package]]
name = "idevice"
version = "0.1.50"
version = "0.1.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "effc7c8fe1bfa5051717c4dc20c3bcc4828b13009a6c95ff6fc8c3f8ccdf4d43"
checksum = "d99be8d1969168237987908274fe41bcb2c8a1f9a37aa12fd15d5713acb9dd2b"
dependencies = [
"base64",
"plist",
@@ -866,7 +866,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
"windows-sys 0.52.0",
"windows-sys 0.60.2",
]
[[package]]
@@ -1027,7 +1027,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -1619,7 +1619,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]

View File

@@ -1,3 +1,20 @@
use std::{env, path::PathBuf};
use isideload::auth::apple_account::AppleAccountBuilder;
fn main() {
isideload::test();
let args: Vec<String> = env::args().collect();
let app_path = PathBuf::from(
args.get(1)
.expect("Please provide the path to the app to install"),
);
let apple_id = args
.get(2)
.expect("Please provide the Apple ID to use for installation");
let apple_password = args.get(3).expect("Please provide the Apple ID password");
let account = AppleAccountBuilder::new(apple_id)
.danger_debug(true)
.build()
.unwrap();
}

View File

@@ -15,7 +15,7 @@ default = ["install"]
install = ["dep:idevice"]
[dependencies]
idevice = { version = "0.1.50", optional = true }
idevice = { version = "0.1.51", optional = true }
plist = "1.8.0"
plist-macro = "0.1.0"
reqwest = { version = "0.13.1", features = ["json", "gzip"] }

View File

@@ -10,16 +10,63 @@ pub struct AppleAccount {
pub anisette: Box<dyn crate::anisette::AnisetteProvider>,
}
impl AppleAccount {
/// Create a new AppleAccount with the given email
#[derive(Debug)]
pub struct AppleAccountBuilder {
email: String,
debug: Option<bool>,
}
impl AppleAccountBuilder {
/// Create a new AppleAccountBuilder with the given email
///
/// # Arguments
/// - `email`: The Apple ID email address
pub fn new(email: &str) -> Result<Self> {
pub fn new(email: &str) -> Self {
Self {
email: email.to_string(),
debug: None,
}
}
/// DANGER Set whether to enable debug mode
///
/// # Arguments
/// - `debug`: If true, accept invalid certificates and enable verbose connection logging
pub fn danger_debug(mut self, debug: bool) -> Self {
self.debug = Some(debug);
self
}
/// Build the AppleAccount
///
/// # Errors
/// Returns an error if the reqwest client cannot be built
pub fn login(self) -> Result<AppleAccount> {
let debug = self.debug.unwrap_or(false);
AppleAccount::login(&self.email, debug)
}
}
impl AppleAccount {
/// Create a new AppleAccountBuilder with the given email
///
/// # Arguments
/// - `email`: The Apple ID email address
pub fn builder(email: &str) -> AppleAccountBuilder {
AppleAccountBuilder::new(email)
}
/// Log in to an Apple account with the given email
///
/// Reccomended to use the AppleAccountBuilder instead
pub fn login(email: &str, debug: bool) -> Result<Self> {
let client = Self::build_client(debug)?;
Ok(AppleAccount {
email: email.to_string(),
spd: None,
client: Self::build_client(false)?,
client,
anisette: Box::new(crate::anisette::DefaultAnisetteProvider {}),
})
}
@@ -28,6 +75,8 @@ impl AppleAccount {
///
/// # Arguments
/// - `debug`: DANGER, If true, accept invalid certificates and enable verbose connection logging
/// # Errors
/// Returns an error if the reqwest client cannot be built
pub fn build_client(debug: bool) -> Result<reqwest::Client> {
let cert = Certificate::from_der(APPLE_ROOT)?;
let client = ClientBuilder::new()

View File

@@ -10,5 +10,3 @@ pub enum Error {
}
pub type Result<T> = std::result::Result<T, Error>;
pub fn test() -> () {}