From 7f06ba0ee93eebf4482a7eb5d5d25e9d8a072f9d Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Mon, 23 Mar 2026 09:33:04 -0700 Subject: chore: Refactor CLI auth flows and token storage (#3317) This PR eplaces the binary `is_hub_sync()` auth routing with an explicit `SyncAuth` enum that classifies the client's authentication state at runtime. This fixes a class of bugs where CLI session tokens were silently mis-stored or used with the wrong auth scheme during Hub migration. --- crates/atuin-common/src/api.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/atuin-common/src') diff --git a/crates/atuin-common/src/api.rs b/crates/atuin-common/src/api.rs index efc17163..1a9f348c 100644 --- a/crates/atuin-common/src/api.rs +++ b/crates/atuin-common/src/api.rs @@ -26,6 +26,10 @@ pub struct RegisterRequest { #[derive(Debug, Serialize, Deserialize)] pub struct RegisterResponse { pub session: String, + /// Auth type: "hub" for Hub API tokens, "cli" for legacy CLI session tokens. + /// Old servers that don't return this field will deserialize as None. + #[serde(default)] + pub auth: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -49,6 +53,10 @@ pub struct LoginRequest { #[derive(Debug, Serialize, Deserialize)] pub struct LoginResponse { pub session: String, + /// Auth type: "hub" for Hub API tokens, "cli" for legacy CLI session tokens. + /// Old servers that don't return this field will deserialize as None. + #[serde(default)] + pub auth: Option, } #[derive(Debug, Serialize, Deserialize)] -- cgit v1.3.1