arisa 2.3.9 → 2.3.10
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/package.json +1 -1
- package/src/daemon/setup.ts +17 -14
package/package.json
CHANGED
package/src/daemon/setup.ts
CHANGED
|
@@ -276,34 +276,37 @@ async function runInteractiveLogin(cli: AgentCliName, vars: Record<string, strin
|
|
|
276
276
|
|
|
277
277
|
const exitCode = await proc.exited;
|
|
278
278
|
if (exitCode === 0) {
|
|
279
|
-
//
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
// Step 1: Strip ANSI escape sequences FIRST (their params contain digits/letters)
|
|
280
|
+
const clean = output
|
|
281
|
+
.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "") // CSI: ESC [ params final
|
|
282
|
+
.replace(/\x1b\][^\x07]*\x07/g, "") // OSC: ESC ] ... BEL
|
|
283
|
+
.replace(/\x1b[^[\]]/g, "") // Other ESC sequences (ESC + one char)
|
|
284
|
+
.replace(/[\x00-\x09\x0b-\x0c\x0e-\x1f]/g, ""); // Control chars (keep \n \r)
|
|
285
|
+
|
|
286
|
+
// Step 2: Find boundaries in clean text
|
|
287
|
+
const startIdx = clean.indexOf("sk-ant-");
|
|
282
288
|
let token = "";
|
|
283
289
|
|
|
284
290
|
if (startIdx >= 0) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
if (endIdx < 0) endIdx =
|
|
288
|
-
if (endIdx < 0) endIdx = startIdx + 300;
|
|
291
|
+
let endIdx = clean.indexOf("Store", startIdx);
|
|
292
|
+
if (endIdx < 0) endIdx = clean.indexOf("Use this", startIdx);
|
|
293
|
+
if (endIdx < 0) endIdx = startIdx + 200;
|
|
289
294
|
|
|
290
|
-
const tokenArea =
|
|
291
|
-
//
|
|
295
|
+
const tokenArea = clean.substring(startIdx, endIdx);
|
|
296
|
+
// Step 3: Strip whitespace and any remaining non-token chars
|
|
292
297
|
token = tokenArea.replace(/[^A-Za-z0-9_-]/g, "");
|
|
293
298
|
}
|
|
294
299
|
|
|
295
|
-
if (token && token.startsWith("sk-ant-") && token.length > 50) {
|
|
300
|
+
if (token && token.startsWith("sk-ant-") && token.length > 50 && token.length < 150) {
|
|
296
301
|
console.log(` [token] ${token.slice(0, 20)}...${token.slice(-6)} (${token.length} chars)`);
|
|
297
302
|
vars.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
298
303
|
saveEnv(vars);
|
|
299
304
|
console.log(" ✓ claude token saved to .env");
|
|
300
305
|
} else {
|
|
301
306
|
console.log(` ⚠ token extraction failed (indexOf=${startIdx}, len=${token.length})`);
|
|
302
|
-
//
|
|
307
|
+
// Show what the cleaned text looks like around the token
|
|
303
308
|
if (startIdx >= 0) {
|
|
304
|
-
|
|
305
|
-
const hex = [...raw].map(c => c.charCodeAt(0).toString(16).padStart(2, "0")).join(" ");
|
|
306
|
-
console.log(` [hex] ${hex.slice(0, 300)}`);
|
|
309
|
+
console.log(` [clean] ${clean.substring(startIdx, startIdx + 150).replace(/\n/g, "\\n")}`);
|
|
307
310
|
}
|
|
308
311
|
}
|
|
309
312
|
console.log(` ✓ claude login successful`);
|