mirror of
https://github.com/nab138/isideload.git
synced 2026-03-02 22:46:15 +01:00
Keep scaffolding apple account
This commit is contained in:
@@ -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"] }
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -10,5 +10,3 @@ pub enum Error {
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
pub fn test() -> () {}
|
||||
|
||||
Reference in New Issue
Block a user