pennyrouter 0.1.8 → 0.1.9

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/cli.js +18 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pennyrouter",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Install and manage PennyRouter local coding-agent integrations.",
5
5
  "homepage": "https://pennyrouter.com",
6
6
  "bugs": {
package/src/cli.js CHANGED
@@ -170,7 +170,7 @@ async function authProvider(flags) {
170
170
  }
171
171
 
172
172
  function readAnthropicOAuthToken(flags = {}) {
173
- if (flags.token) return { token: flags.token.trim(), source: "flag" };
173
+ if (flags.token) return { token: normalizeAnthropicToken(flags.token), source: "flag" };
174
174
  if (flags.tokenCommand) {
175
175
  const result = spawnSync(flags.tokenCommand, {
176
176
  encoding: "utf8",
@@ -178,19 +178,32 @@ function readAnthropicOAuthToken(flags = {}) {
178
178
  stdio: ["ignore", "pipe", "pipe"],
179
179
  });
180
180
  if (result.status === 0) {
181
- return { token: String(result.stdout || "").trim(), source: "token-command" };
181
+ return { token: normalizeAnthropicToken(result.stdout), source: "token-command" };
182
182
  }
183
183
  return { token: "", source: "token-command" };
184
184
  }
185
185
  if (process.env.ANTHROPIC_AUTH_TOKEN) {
186
- return { token: process.env.ANTHROPIC_AUTH_TOKEN.trim(), source: "env" };
186
+ return { token: normalizeAnthropicToken(process.env.ANTHROPIC_AUTH_TOKEN), source: "env" };
187
187
  }
188
188
  const result = spawnSync("ant", ["auth", "print-credentials", "--access-token"], {
189
189
  encoding: "utf8",
190
190
  stdio: ["ignore", "pipe", "pipe"],
191
191
  });
192
192
  if (result.status !== 0) return { token: "", source: "none" };
193
- return { token: String(result.stdout || "").trim(), source: "ant" };
193
+ return { token: normalizeAnthropicToken(result.stdout), source: "ant" };
194
+ }
195
+
196
+ function normalizeAnthropicToken(value) {
197
+ let text = String(value || "").trim();
198
+ if (!text) return "";
199
+ const line = text.split(/\r?\n/).map((part) => part.trim()).find(Boolean) || "";
200
+ text = line.replace(/^export\s+/, "");
201
+ const match = text.match(/^ANTHROPIC_AUTH_TOKEN=(.*)$/);
202
+ if (match) text = match[1].trim();
203
+ if ((text.startsWith('"') && text.endsWith('"')) || (text.startsWith("'") && text.endsWith("'"))) {
204
+ text = text.slice(1, -1);
205
+ }
206
+ return text.trim();
194
207
  }
195
208
 
196
209
  async function install(flags) {
@@ -318,7 +331,7 @@ async function maybeConfigureClaudeAnthropicAuth(flags, selected) {
318
331
  } else {
319
332
  console.log("Claude Code was not found on PATH. Paste an Anthropic bearer token, or leave blank to skip.");
320
333
  }
321
- const token = await promptSecretish("Anthropic token (blank to skip): ");
334
+ const token = normalizeAnthropicToken(await promptSecretish("Anthropic token (blank to skip): "));
322
335
  if (!token) {
323
336
  console.log("Skipped Claude subscription auth. Enable later with `@penny auth` or `pennyrouter auth anthropic`.");
324
337
  console.log("");