@seguelac/aca-cli 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to `aca-cli` are documented here. Format loosely follows [Keep a Changelog](https://keepachangelog.com/).
4
4
 
5
+ ## [0.6.0] - 2026-09-02
6
+
7
+ ### Fixed
8
+ - **API token auth was broken for every command that reads via PostgREST** (`org ls/switch/current`, `inbox`, `contact get`, `campaign`, `autopilot`, `leads`, `lists`, `signals`, `reply` lookups): `aca login --token` sent the raw `aca_` token straight to `/rest/v1/*`, which PostgREST rejects outright (`Expected 3 parts in JWT; got 1`) since it isn't a signed JWT — this affected every Google sign-in user, i.e. the CLI's own recommended login path.
9
+ - `getAccessToken()` now exchanges the `aca_` token for a short-lived real Supabase session via a new `cli-token-exchange` edge function, and caches it until it's near expiry. Everything downstream (PostgREST and edge-function calls alike) now gets a token it actually accepts.
10
+ - The 0.5.0 note that `aca sequence ls` couldn't exist because "listing goes through PostgREST, which only accepts JWTs" no longer applies — that limitation is what this fixes.
11
+
5
12
  ## [0.5.0] - 2026-08-07
6
13
 
7
14
  ### Added
@@ -11,7 +18,7 @@ All notable changes to `aca-cli` are documented here. Format loosely follows [Ke
11
18
  - Backed by a new `duplicate-email-sequence` edge function and a `sourceSequenceId` mode on `enroll-leads`, both shared with the app UI and the `duplicate_email_sequence` MCP tool.
12
19
 
13
20
  ### Note
14
- There is intentionally no `aca sequence ls` — listing goes through PostgREST, which only accepts JWTs, not the `aca_` API tokens this CLI recommends.
21
+ There was intentionally no `aca sequence ls` — listing went through PostgREST, which only accepted JWTs, not the `aca_` API tokens this CLI recommends. Fixed in 0.6.0.
15
22
 
16
23
  ## [0.4.0] - 2026-07-18
17
24
 
package/dist/session.js CHANGED
@@ -89,13 +89,38 @@ async function refreshJwt(session) {
89
89
  writeSession(next);
90
90
  return next;
91
91
  }
92
+ async function exchangeApiToken(apiToken) {
93
+ const res = await fetch(`${SUPABASE_URL}/functions/v1/cli-token-exchange`, {
94
+ method: 'POST',
95
+ headers: { apikey: SUPABASE_ANON_KEY, Authorization: `Bearer ${apiToken}` },
96
+ });
97
+ if (!res.ok) {
98
+ const body = await res.text();
99
+ throw new Error(`Token exchange failed (${res.status}): ${body}`);
100
+ }
101
+ const data = (await res.json());
102
+ if (!data.access_token) {
103
+ throw new Error('Token exchange returned no access token');
104
+ }
105
+ return { access_token: data.access_token, expires_in: data.expires_in ?? 3600 };
106
+ }
92
107
  export async function getAccessToken() {
93
108
  const session = readSession();
94
109
  if (!session?.access_token) {
95
110
  throw new Error('Not logged in. Run `aca login` first.');
96
111
  }
97
112
  if (session.auth_method === 'api_token') {
98
- return session.access_token;
113
+ const now = Math.floor(Date.now() / 1000);
114
+ if (session.derived_access_token && session.derived_expires_at && session.derived_expires_at - now > 60) {
115
+ return session.derived_access_token;
116
+ }
117
+ const derived = await exchangeApiToken(session.access_token);
118
+ writeSession({
119
+ ...session,
120
+ derived_access_token: derived.access_token,
121
+ derived_expires_at: Math.floor(Date.now() / 1000) + derived.expires_in,
122
+ });
123
+ return derived.access_token;
99
124
  }
100
125
  const now = Math.floor(Date.now() / 1000);
101
126
  if (session.expires_at && session.expires_at - now < 60) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seguelac/aca-cli",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Command-line interface for ACA (Automated Client Acquisition) — push leads to campaigns, triage replies, manage contacts, all from your terminal.",
5
5
  "type": "module",
6
6
  "bin": {