Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

iCloud terms: one way to say them

Yashwanth Kamireddi7b21691da965
diff --git a/crates/quince-auth/src/lib.rs b/crates/quince-auth/src/lib.rs
index 3a5658a..7e96d15 100644
--- a/crates/quince-auth/src/lib.rs
+++ b/crates/quince-auth/src/lib.rs
@@ -120,10 +120,6 @@ pub enum Error {
CoolingDown { seconds: u64 },
#[error("this needs a fresh sign-in — Apple won't accept a resumed session for it")]
ReauthRequired,
- /// Apple holds the session back until new iCloud terms are accepted, which only a browser
- /// or an Apple device can do.
- #[error("Apple has new iCloud terms for this account. Sign in at icloud.com, accept them, then sign in here again.")]
- TermsPending,
// Apple's 429 and its 503 on sign-in both mean "not now", whether from too many tries or
// its own load: say what to do, not which of the two it was.
#[error(
@@ -938,8 +934,8 @@ impl Client {
self.keep();
return Ok(true);
}
- // Signing in again would only meet the same terms, and count as a failed attempt.
- Err(Error::TermsPending) => return Err(Error::TermsPending),
+ // New iCloud terms waiting are not a lapse: `absorb` keeps Apple's flag and the
+ // session stays, so nothing signs in again with the password into the same terms.
Err(e) => e,
};
// Unreachable is not rejected. Offline — no network yet after login, or a resume
@@ -1083,7 +1079,6 @@ impl Client {
| Error::Keyring(_)
| Error::Io(_)
| Error::Json(_)
- | Error::TermsPending
| Error::RepairNeeded,
) => {}
Err(e) => {
@@ -1616,12 +1611,10 @@ impl Client {
let data: Value = serde_json::from_str(&text)?;
diag::account("accountLogin", &data);
// New iCloud terms not yet accepted: Apple answers 200 but opens the session only
- // part-way, without the web cookies every service needs (rclone/rclone#9919), so every
- // sync failed afterwards with nothing to say why. Only icloud.com or a device of the
- // person's own can accept them.
- if data.get("termsUpdateNeeded").and_then(Value::as_bool) == Some(true) {
- return Err(Error::TermsPending);
- }
+ // part-way, without the web cookies every service needs (rclone/rclone#9919). Not an
+ // error: a sign-in that met them is complete — the password proved itself, and is no
+ // failed attempt — and `absorb` keeps `termsUpdateNeeded`, which the window says and
+ // every pass asks again until the person has agreed at icloud.com.
Ok(data)
}
diff --git a/crates/quince-auth/tests/auth_flow.rs b/crates/quince-auth/tests/auth_flow.rs
index 3398619..54c7f1c 100644
--- a/crates/quince-auth/tests/auth_flow.rs
+++ b/crates/quince-auth/tests/auth_flow.rs
@@ -1260,10 +1260,11 @@ async fn trusted_numbers_at_the_top_are_still_texted() {
}
/// New iCloud terms not yet accepted: `accountLogin` answers 200 with `termsUpdateNeeded`
-/// and opens the session only part-way (rclone/rclone#9919). Taken as signed in, every sync
-/// failed after with nothing to say why. It says so, and costs no wait: no password was wrong.
+/// and opens the session only part-way (rclone/rclone#9919). It is a sign-in all the same:
+/// the password proved itself, so it is kept, the terms are said, and it costs no wait.
+/// Signing in again meets the same terms and is never counted as a failed attempt.
#[tokio::test]
-async fn new_terms_to_accept_are_said_not_taken_for_a_sign_in() {
+async fn new_terms_to_accept_are_said_and_cost_no_wait() {
let server = MockServer::start().await;
mount_init(&server, 200).await;
mount_complete(&server, 200).await;
@@ -1279,21 +1280,21 @@ async fn new_terms_to_accept_are_said_not_taken_for_a_sign_in() {
let dir = tempfile::tempdir().unwrap();
let mut client = client_for(&server, dir.path());
for attempt in 0..2 {
- let err = client
+ let outcome = client
.sign_in("[email protected]", "hunter2")
.await
- .unwrap_err();
- assert!(
- matches!(err, quince_auth::Error::TermsPending),
- "attempt {attempt}: {err:?}"
- );
- assert!(err.to_string().contains("icloud.com"), "{err}");
+ .unwrap_or_else(|e| panic!("attempt {attempt}: {e:?}"));
+ assert_eq!(outcome, SignInOutcome::Complete, "attempt {attempt}");
+ assert!(client.session().terms_update_needed, "attempt {attempt}");
+ assert!(client.waits_on_icloud_com());
+ assert_eq!(client.session().consecutive_failures, 0, "no wait");
+ assert!(client.session().retry_after.is_none(), "no wait");
}
- assert!(client.session().webservices.is_none(), "not signed in");
+ assert_eq!(client.session().password.as_deref(), Some("hunter2"));
}
-/// The same for a session already kept: said, and kept, rather than signed in again with
-/// the password into the same terms.
+/// The same for a session already kept: kept, with the terms said, rather than signed in
+/// again with the password into the same terms.
#[tokio::test]
async fn new_terms_on_a_kept_session_keep_it() {
let dir = tempfile::tempdir().unwrap();
@@ -1312,13 +1313,15 @@ async fn new_terms_on_a_kept_session_keep_it() {
.mount(&server)
.await;
let mut client = client_for(&server, dir.path());
- let err = client.resume().await.unwrap_err();
- assert!(matches!(err, quince_auth::Error::TermsPending), "{err:?}");
+ assert!(client.resume().await.unwrap(), "the session holds");
+ assert!(client.session().terms_update_needed);
+ assert!(client.waits_on_icloud_com());
assert!(
client.session().session_token.is_some(),
"the session is kept"
);
assert_eq!(client.session().password.as_deref(), Some("hunter2"));
+ assert_eq!(client.session().consecutive_failures, 0);
let reqs = server.received_requests().await.unwrap();
assert!(
requests_to(&reqs, "/signin/init").is_empty(),
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 0915218..c6f7a3d 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -1332,6 +1332,8 @@ const NEEDS_SIGNIN: &str = "quince://needs-signin";
async fn keep_signed_in(app: &tauri::AppHandle, client: &Arc<Mutex<Client>>) {
// Said once per lapse, not on every pass after it.
static TOLD: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
+ // And once per wait at icloud.com, apart from a lapse: one never hides the other.
+ static TOLD_ICLOUD: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
let mut guard = client.lock().await;
if guard.session().webservices.is_none() {
return;
@@ -1367,30 +1369,38 @@ async fn keep_signed_in(app: &tauri::AppHandle, client: &Arc<Mutex<Client>>) {
}
Ok(true) => {
TOLD.store(false, std::sync::atomic::Ordering::Relaxed);
- // New iCloud terms waiting at icloud.com: asked again each pass, so the whole
- // session opens by itself once the person has agreed — one request every few
- // minutes, and only while they are waiting.
+ // New iCloud terms waiting at icloud.com (or the account to finish there): asked
+ // again each pass, so the whole session opens by itself once the person has agreed
+ // — one request every few minutes, and only while they are waiting. The session
+ // and password stay as they are: signing in again would meet the same terms.
if guard.waits_on_icloud_com() {
let _ = guard.refresh_account().await;
}
+ if guard.waits_on_icloud_com() {
+ // The window shows its own page for it; the desktop is told once, for someone
+ // with only the tray running. Never "Apple signed you out": it did not.
+ if !TOLD_ICLOUD.swap(true, std::sync::atomic::Ordering::Relaxed) {
+ let (title, body) = if guard.session().terms_update_needed {
+ (
+ "Agree to Apple's new iCloud terms",
+ "Sign in at icloud.com and agree to them. Your copy on this computer is still here.",
+ )
+ } else {
+ (
+ "Finish setting up iCloud",
+ "Sign in at icloud.com to finish. Your copy on this computer is still here.",
+ )
+ };
+ alerts::tell(app, title, body);
+ }
+ } else {
+ TOLD_ICLOUD.store(false, std::sync::atomic::Ordering::Relaxed);
+ }
// Keys that ran out while the approval still holds are attached again before the
// pass needs them — never a prompt on the person's phone from here.
drop(guard);
data_access::check(app, client, data_access::Ask::Background).await;
}
- // New iCloud terms to accept: nothing syncs until they are, and only icloud.com can
- // take them. Said with its reason, where "Apple signed you out" would be untrue.
- Err(e @ quince_auth::Error::TermsPending) => {
- LIVE.store(false, Ordering::SeqCst);
- app.emit(NEEDS_SIGNIN, e.to_string()).ok();
- if !TOLD.swap(true, std::sync::atomic::Ordering::Relaxed) {
- alerts::tell(
- app,
- "Accept Apple's new iCloud terms",
- "Sign in at icloud.com and accept them. Your copy on this computer is still here.",
- );
- }
- }
// Not reaching Apple says nothing about the session.
Err(_) => {}
}
diff --git a/src/App.tsx b/src/App.tsx
index 5a15454..665a2df 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -110,11 +110,7 @@ export default function App() {
// saying so, and the sign-in a click away rather than forced in its place.
const [lapsed, setLapsed] = useState(false);
useEffect(() => {
- // Its reason, when it has one (new iCloud terms to accept), is what the line says.
- const stop = listen<string | null>(NEEDS_SIGNIN, (event) => {
- if (typeof event.payload === "string" && event.payload) setWhy(event.payload);
- setLapsed(true);
- });
+ const stop = listen(NEEDS_SIGNIN, () => setLapsed(true));
return () => {
void stop.then((unlisten) => unlisten()).catch(() => {});
};