mirror of
https://github.com/nab138/isideload.git
synced 2026-03-02 06:26:16 +01:00
Keep scaffolding apple account
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -529,9 +529,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idevice"
|
name = "idevice"
|
||||||
version = "0.1.50"
|
version = "0.1.51"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "effc7c8fe1bfa5051717c4dc20c3bcc4828b13009a6c95ff6fc8c3f8ccdf4d43"
|
checksum = "d99be8d1969168237987908274fe41bcb2c8a1f9a37aa12fd15d5713acb9dd2b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"plist",
|
"plist",
|
||||||
@@ -866,7 +866,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tracing",
|
"tracing",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1027,7 +1027,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]]
|
||||||
@@ -1619,7 +1619,7 @@ version = "0.1.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
use std::{env, path::PathBuf};
|
||||||
|
|
||||||
|
use isideload::auth::apple_account::AppleAccountBuilder;
|
||||||
|
|
||||||
fn main() {
|
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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ default = ["install"]
|
|||||||
install = ["dep:idevice"]
|
install = ["dep:idevice"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
idevice = { version = "0.1.50", optional = true }
|
idevice = { version = "0.1.51", optional = true }
|
||||||
plist = "1.8.0"
|
plist = "1.8.0"
|
||||||
plist-macro = "0.1.0"
|
plist-macro = "0.1.0"
|
||||||
reqwest = { version = "0.13.1", features = ["json", "gzip"] }
|
reqwest = { version = "0.13.1", features = ["json", "gzip"] }
|
||||||
|
|||||||
@@ -10,16 +10,63 @@ pub struct AppleAccount {
|
|||||||
pub anisette: Box<dyn crate::anisette::AnisetteProvider>,
|
pub anisette: Box<dyn crate::anisette::AnisetteProvider>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppleAccount {
|
#[derive(Debug)]
|
||||||
/// Create a new AppleAccount with the given email
|
pub struct AppleAccountBuilder {
|
||||||
|
email: String,
|
||||||
|
debug: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AppleAccountBuilder {
|
||||||
|
/// Create a new AppleAccountBuilder with the given email
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// - `email`: The Apple ID email address
|
/// - `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 {
|
Ok(AppleAccount {
|
||||||
email: email.to_string(),
|
email: email.to_string(),
|
||||||
spd: None,
|
spd: None,
|
||||||
client: Self::build_client(false)?,
|
client,
|
||||||
anisette: Box::new(crate::anisette::DefaultAnisetteProvider {}),
|
anisette: Box::new(crate::anisette::DefaultAnisetteProvider {}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -28,6 +75,8 @@ impl AppleAccount {
|
|||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// - `debug`: DANGER, If true, accept invalid certificates and enable verbose connection logging
|
/// - `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> {
|
pub fn build_client(debug: bool) -> Result<reqwest::Client> {
|
||||||
let cert = Certificate::from_der(APPLE_ROOT)?;
|
let cert = Certificate::from_der(APPLE_ROOT)?;
|
||||||
let client = ClientBuilder::new()
|
let client = ClientBuilder::new()
|
||||||
|
|||||||
@@ -10,5 +10,3 @@ pub enum Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
pub fn test() -> () {}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user