@@ -34,6 +34,22 @@ struct AuthRequest {
3434 password : String
3535}
3636
37+ #[ derive( Serialize ) ]
38+ #[ serde( rename_all = "camelCase" ) ]
39+ struct V2AuthRequest {
40+ delegates : Value ,
41+ protocol_version : String ,
42+ user_info : V2AuthUserInfo ,
43+ }
44+
45+ #[ derive( Serialize ) ]
46+ #[ serde( rename_all = "kebab-case" ) ]
47+ struct V2AuthUserInfo {
48+ client_id : String ,
49+ language : String ,
50+ timezone : String ,
51+ }
52+
3753#[ derive( Clone , Copy ) ]
3854pub enum LoginDelegate {
3955 IDS ,
@@ -189,7 +205,7 @@ pub struct IDSDelegateResponse {
189205#[ derive( Deserialize ) ]
190206pub struct MobileMeDelegateResponse {
191207 pub tokens : HashMap < String , String > ,
192- #[ serde( rename = "com.apple.mobileme" ) ]
208+ #[ serde( default ) ]
193209 pub config : Dictionary ,
194210}
195211
@@ -350,11 +366,21 @@ pub async fn login_apple_delegates<T: AnisetteProvider>(account: &AppleAccount<T
350366
351367 let username = account. username . as_ref ( ) . unwrap ( ) ;
352368
353- let request = AuthRequest {
354- apple_id : username. to_string ( ) ,
355- client_id : Uuid :: new_v4 ( ) . to_string ( ) ,
369+ // let request = AuthRequest {
370+ // apple_id: username.to_string(),
371+ // client_id: Uuid::new_v4().to_string(),
372+ // delegates: Value::Dictionary(Dictionary::from_iter(delegates.iter().map(|d| d.delegate()))),
373+ // password: pet.to_string()
374+ // };
375+
376+ let request = V2AuthRequest {
356377 delegates : Value :: Dictionary ( Dictionary :: from_iter ( delegates. iter ( ) . map ( |d| d. delegate ( ) ) ) ) ,
357- password : pet. to_string ( )
378+ protocol_version : "1.0" . to_string ( ) ,
379+ user_info : V2AuthUserInfo {
380+ client_id : Uuid :: new_v4 ( ) . to_string ( ) . to_uppercase ( ) ,
381+ language : "en-US" . to_string ( ) ,
382+ timezone : "America/New_York" . to_string ( ) ,
383+ }
358384 } ;
359385
360386 let validation_data = os_config. generate_validation_data ( ) . await ?;
@@ -414,9 +440,15 @@ pub async fn login_apple_delegates<T: AnisetteProvider>(account: &AppleAccount<T
414440
415441 let delegates = parsed_dict. get ( "delegates" ) . unwrap ( ) . as_dictionary ( ) . unwrap ( ) ;
416442
443+ let mut mme: Option < MobileMeDelegateResponse > = get_delegate ( delegates, "com.apple.mobileme" ) ?;
444+
445+ if let Some ( mme) = & mut mme {
446+ mme. config = get_delegate ( delegates, "com.apple.mobileme" ) ?. expect ( "No MME??" ) ;
447+ }
448+
417449 Ok ( DelegateResponses {
418450 ids : get_delegate ( delegates, "com.apple.private.ids" ) ?,
419- mobileme : get_delegate ( delegates , "com.apple.mobileme" ) ? ,
451+ mobileme : mme ,
420452 } )
421453}
422454
0 commit comments