You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// in the SMS 2fa endpoint, all tokens have format ID:TOKEN:DURATION:EXP (MS SINCE EPOCH)
871
+
872
+
// here, well, the PE token has no duration OR expiration (ID:TOKEN)
873
+
// the HB token has format ID:TOKEN:EXP
874
+
// and the GS tokens (I have checked, god knows there's one that has a different format to mess with me) have format ID:TOKEN:DURATION
875
+
// conclusion
876
+
877
+
// so what to do? Don't trust apple at all. For PET, assume 300s if no duration. For everything else, guess whether the token is epoch time or duration
878
+
// by seeing if the number is greater than 40 years in milliseconds. No token should reasonably have a duration longer than that (besides otherwise its in secs)
let decoded = String::from_utf8(base64::decode(data).unwrap()).unwrap();
922
-
self.tokens.insert("com.apple.gs.idms.pet".to_string(),FetchedToken{token: decoded.split(":").nth(1).unwrap().to_string(),expiration:(decoded.split(":").nth(2).expect("No pet token").parse::<u64>().expect("Bad pet format")*1000u64) + (SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_millis()asu64)});
953
+
self.tokens.insert("com.apple.gs.idms.pet".to_string(),FetchedToken{token: decoded.split(":").nth(1).unwrap().to_string(),expiration:SystemTime::now() + Duration::from_secs(decoded.split(":").nth(2).map(|a| a.parse::<u64>().expect("Bad pet format")).unwrap_or(300))});
0 commit comments