From dfdc781d67d2553f912537758bdb491d8c240acb Mon Sep 17 00:00:00 2001 From: Daniel Tao Date: Thu, 21 May 2026 21:51:38 +0000 Subject: [PATCH] feat: accept `api_token` as an alias for `token` in `sf login` The CLI session polling endpoint returns the auth JWT under the `token` field today. Accept `api_token` as a fallback so the CLI stays compatible if the field is renamed server-side. --- src/lib/login.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/login.ts b/src/lib/login.ts index 3a9880e7..eab6a042 100644 --- a/src/lib/login.ts +++ b/src/lib/login.ts @@ -97,9 +97,17 @@ async function getSession({ token }: { token: string }) { }, }); - return response.data as { + // The auth JWT is returned as `token` today; accept `api_token` as a + // fallback so the CLI is forward-compatible with a server-side rename. + const data = response.data as { validation?: string; token?: string; + api_token?: string; + }; + + return { + validation: data.validation, + token: data.token ?? data.api_token, }; } catch (error) { console.error("Error getting session:", error);