@dst-justin/relay 2.2.1 → 2.2.2

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.
Files changed (4) hide show
  1. package/README.md +3 -0
  2. package/package.json +1 -1
  3. package/relay +12 -12
  4. package/relay.ps1 +3 -3
package/README.md CHANGED
@@ -223,6 +223,9 @@ Sessions live in `~/.claude/projects/` and are shared across all accounts — af
223
223
 
224
224
  ## Changelog
225
225
 
226
+ ### v2.2.2 — 2026-06-28
227
+ - Fix OAuth token refresh: use correct endpoint (`/v1/oauth/token`), required `client_id`, and `anthropic-version: oauth-2025-04-20` header — `relay refresh-all` now works
228
+
226
229
  ### v2.2.0 — 2026-06-28
227
230
  - Silent OAuth auto-refresh: `relay list` and `relay status` now silently refresh expired tokens using the stored `refreshToken` — no browser login needed for routine expiry
228
231
  - Pre-emptive refresh: tokens are refreshed 5 minutes before expiry, not just after
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dst-justin/relay",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "Multi-account switcher for Claude Code — instant credential swap across macOS, Linux, and Windows",
5
5
  "bin": {
6
6
  "relay": "./relay.js"
package/relay CHANGED
@@ -187,11 +187,11 @@ def try_refresh(name, cred_path):
187
187
  refresh_tok = oauth.get('refreshToken', '')
188
188
  if not refresh_tok:
189
189
  return None
190
- params = urllib.parse.urlencode({'grant_type': 'refresh_token', 'refresh_token': refresh_tok}).encode()
190
+ params = urllib.parse.urlencode({'grant_type': 'refresh_token', 'refresh_token': refresh_tok, 'client_id': '9d1c250a-e61b-44d9-88ed-5944d1962f5e'}).encode()
191
191
  req = urllib.request.Request(
192
- 'https://api.anthropic.com/token',
192
+ 'https://api.anthropic.com/v1/oauth/token',
193
193
  data=params,
194
- headers={'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'relay/2.0'})
194
+ headers={'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'relay/2.0', 'anthropic-version': 'oauth-2025-04-20'})
195
195
  with urllib.request.urlopen(req, timeout=10) as r:
196
196
  resp = json.loads(r.read())
197
197
  oauth['accessToken'] = resp['access_token']
@@ -425,9 +425,9 @@ def _try_refresh(cred_path):
425
425
  rt = oauth2.get('refreshToken', '')
426
426
  if not rt:
427
427
  return None
428
- params = urllib.parse.urlencode({'grant_type': 'refresh_token', 'refresh_token': rt}).encode()
429
- req2 = urllib.request.Request('https://api.anthropic.com/token', data=params,
430
- headers={'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'relay/2.0'})
428
+ params = urllib.parse.urlencode({'grant_type': 'refresh_token', 'refresh_token': rt, 'client_id': '9d1c250a-e61b-44d9-88ed-5944d1962f5e'}).encode()
429
+ req2 = urllib.request.Request('https://api.anthropic.com/v1/oauth/token', data=params,
430
+ headers={'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'relay/2.0', 'anthropic-version': 'oauth-2025-04-20'})
431
431
  with urllib.request.urlopen(req2, timeout=10) as r2:
432
432
  resp = json.loads(r2.read())
433
433
  oauth2['accessToken'] = resp['access_token']
@@ -632,9 +632,9 @@ def try_refresh(name, cred_path):
632
632
  rt = oauth.get('refreshToken', '')
633
633
  if not rt:
634
634
  return None
635
- params = urllib.parse.urlencode({'grant_type': 'refresh_token', 'refresh_token': rt}).encode()
636
- req = urllib.request.Request('https://api.anthropic.com/token', data=params,
637
- headers={'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'relay/2.0'})
635
+ params = urllib.parse.urlencode({'grant_type': 'refresh_token', 'refresh_token': rt, 'client_id': '9d1c250a-e61b-44d9-88ed-5944d1962f5e'}).encode()
636
+ req = urllib.request.Request('https://api.anthropic.com/v1/oauth/token', data=params,
637
+ headers={'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'relay/2.0', 'anthropic-version': 'oauth-2025-04-20'})
638
638
  with urllib.request.urlopen(req, timeout=10) as r:
639
639
  resp = json.loads(r.read())
640
640
  oauth['accessToken'] = resp['access_token']
@@ -880,9 +880,9 @@ def try_refresh_daemon(name, cred_path):
880
880
  if not rt:
881
881
  return None
882
882
  import urllib.parse
883
- params = urllib.parse.urlencode({'grant_type': 'refresh_token', 'refresh_token': rt}).encode()
884
- req = urllib.request.Request('https://api.anthropic.com/token', data=params,
885
- headers={'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'relay/2.0'})
883
+ params = urllib.parse.urlencode({'grant_type': 'refresh_token', 'refresh_token': rt, 'client_id': '9d1c250a-e61b-44d9-88ed-5944d1962f5e'}).encode()
884
+ req = urllib.request.Request('https://api.anthropic.com/v1/oauth/token', data=params,
885
+ headers={'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'relay/2.0', 'anthropic-version': 'oauth-2025-04-20'})
886
886
  with urllib.request.urlopen(req, timeout=10) as r:
887
887
  resp = json.loads(r.read())
888
888
  oauth['accessToken'] = resp['access_token']
package/relay.ps1 CHANGED
@@ -127,10 +127,10 @@ function Invoke-TokenRefresh($credPath) {
127
127
  $oauth = $d.claudeAiOauth
128
128
  $rt = $oauth.refreshToken
129
129
  if (-not $rt) { return $null }
130
- $body = "grant_type=refresh_token&refresh_token=$([System.Uri]::EscapeDataString($rt))"
131
- $resp = Invoke-RestMethod "https://api.anthropic.com/token" -Method Post `
130
+ $body = "grant_type=refresh_token&refresh_token=$([System.Uri]::EscapeDataString($rt))&client_id=9d1c250a-e61b-44d9-88ed-5944d1962f5e"
131
+ $resp = Invoke-RestMethod "https://api.anthropic.com/v1/oauth/token" -Method Post `
132
132
  -Body $body -ContentType "application/x-www-form-urlencoded" `
133
- -Headers @{ "User-Agent" = "relay/2.0" } -TimeoutSec 10
133
+ -Headers @{ "User-Agent" = "relay/2.0"; "anthropic-version" = "oauth-2025-04-20" } -TimeoutSec 10
134
134
  $oauth.accessToken = $resp.access_token
135
135
  if ($resp.refresh_token) { $oauth.refreshToken = $resp.refresh_token }
136
136
  $expiresMs = [System.DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() + ($resp.expires_in ?? 3600) * 1000