@dst-justin/relay 2.2.0 → 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 (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -0
  3. package/package.json +1 -1
  4. package/relay +14 -14
  5. package/relay.ps1 +3 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 darkstar1227
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -223,6 +223,16 @@ 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
+
229
+ ### v2.2.0 — 2026-06-28
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
231
+ - Pre-emptive refresh: tokens are refreshed 5 minutes before expiry, not just after
232
+ - Autoswitch daemon now refreshes tokens proactively every 30 minutes and on expiry detection, ensuring the daemon never switches to a dead account
233
+ - New `relay refresh-all` command: silently refreshes all accounts via OAuth in one go
234
+ - Windows (`relay.ps1`): token refresh wired into `Show-Table` usage loop
235
+
226
236
  ### v2.1.1 — 2026-06-24
227
237
  - Display current version and latest version at the end of `list`, `status`, `relay` (menu), `sessions`, and `help` commands
228
238
  - Background version check (24h cache) — non-blocking, never slows down output
@@ -243,3 +253,7 @@ Sessions live in `~/.claude/projects/` and are shared across all accounts — af
243
253
 
244
254
  ### v2.0.2 — 2026-06-23
245
255
  - Skip `npm install` during `relay update` when already on the latest version or when version check fails
256
+
257
+ ## License
258
+
259
+ MIT © [darkstar1227](https://github.com/darkstar1227)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dst-justin/relay",
3
- "version": "2.2.0",
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']
@@ -615,9 +615,9 @@ cmd_refresh_all() {
615
615
  local names=()
616
616
  while IFS= read -r f; do
617
617
  names+=("$(basename "${f%.json}")")
618
- done < <(find "${CREDS_DIR}" -maxdepth 1 -name '*.json' 2>/dev/null | sort)
618
+ done < <(find "${CREDS_STORE}" -maxdepth 1 -name '*.json' 2>/dev/null | sort)
619
619
  [[ ${#names[@]} -eq 0 ]] && { warn "No accounts found"; return 0; }
620
- "${PY}" - "${CREDS_DIR}" "${#names[@]}" "${names[@]}" <<'EOF'
620
+ "${PY}" - "${CREDS_STORE}" "${#names[@]}" "${names[@]}" <<'EOF'
621
621
  import json, sys, datetime, urllib.request, urllib.parse, os
622
622
 
623
623
  creds_dir, n = sys.argv[1], int(sys.argv[2])
@@ -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