@karpeleslab/teamclaude 1.0.2 → 1.0.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.js +14 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karpeleslab/teamclaude",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Multi-account Claude proxy with automatic quota-based rotation",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/server.js CHANGED
@@ -89,7 +89,20 @@ async function handleTokenRefresh(req, res, accountManager, hooks) {
89
89
  for await (const chunk of req) {
90
90
  bodyChunks.push(chunk);
91
91
  }
92
- const body = Buffer.concat(bodyChunks);
92
+ const rawBody = Buffer.concat(bodyChunks);
93
+
94
+ // Replace the refresh token in the request with the current account's refresh token
95
+ // so the renewal happens for the active account, not just the one the client knows about
96
+ let body = rawBody;
97
+ try {
98
+ const parsed = JSON.parse(rawBody.toString());
99
+ const currentAccount = accountManager.accounts[accountManager.currentIndex];
100
+ if (parsed.grant_type === 'refresh_token' && currentAccount?.type === 'oauth' && currentAccount.refreshToken) {
101
+ parsed.refresh_token = currentAccount.refreshToken;
102
+ body = JSON.stringify(parsed);
103
+ console.log(`[TeamClaude] Token refresh: substituted refresh token for account "${currentAccount.name}"`);
104
+ }
105
+ } catch {}
93
106
 
94
107
  try {
95
108
  // Forward to the real token endpoint