voicecc 1.1.17 → 1.1.18
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/dashboard/routes/auth.ts +12 -4
- package/package.json +1 -1
package/dashboard/routes/auth.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { Hono } from "hono";
|
|
16
|
-
import { execFile } from "child_process";
|
|
16
|
+
import { execFile, execFileSync } from "child_process";
|
|
17
17
|
import pty, { type IPty } from "node-pty";
|
|
18
18
|
import { writeEnvKey } from "../../server/services/env.js";
|
|
19
19
|
|
|
@@ -80,7 +80,6 @@ async function getAuthStatus(): Promise<AuthStatus> {
|
|
|
80
80
|
*/
|
|
81
81
|
function resolveClaudePath(): string {
|
|
82
82
|
try {
|
|
83
|
-
const { execFileSync } = require("child_process");
|
|
84
83
|
return execFileSync("which", [CLAUDE_BIN]).toString().trim();
|
|
85
84
|
} catch {
|
|
86
85
|
return CLAUDE_BIN;
|
|
@@ -123,6 +122,8 @@ function spawnLoginProcess(): Promise<string> {
|
|
|
123
122
|
|
|
124
123
|
child.onData((data: string) => {
|
|
125
124
|
output += data;
|
|
125
|
+
const clean = data.replace(/\x1b\[[^m]*m/g, "").replace(/\r/g, "").trim();
|
|
126
|
+
if (clean) console.debug(`[auth/login] step=${step} data: ${clean.slice(0, 200)}`);
|
|
126
127
|
|
|
127
128
|
// Step 0 → 1: Accept trust prompt
|
|
128
129
|
if (step === 0 && /enter to confirm/i.test(output)) {
|
|
@@ -131,7 +132,14 @@ function spawnLoginProcess(): Promise<string> {
|
|
|
131
132
|
setTimeout(() => child.write("\r"), 500);
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
// Step
|
|
135
|
+
// Step 0 alternative: no trust prompt, already trusted — look for version string
|
|
136
|
+
if (step === 0 && /v\d+\.\d+\.\d+/.test(output)) {
|
|
137
|
+
step = 2;
|
|
138
|
+
console.debug("[auth/login] step 2: no trust prompt, sending /login");
|
|
139
|
+
setTimeout(() => child.write("/login\r"), 1000);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Step 1 → 2: Wait for main prompt after trust, send /login
|
|
135
143
|
if (step === 1 && /v\d+\.\d+\.\d+/.test(output.slice(-2000))) {
|
|
136
144
|
step = 2;
|
|
137
145
|
console.debug("[auth/login] step 2: sending /login");
|
|
@@ -145,7 +153,7 @@ function spawnLoginProcess(): Promise<string> {
|
|
|
145
153
|
setTimeout(() => child.write("\r"), 1000);
|
|
146
154
|
}
|
|
147
155
|
|
|
148
|
-
//
|
|
156
|
+
// Capture OAuth URL (can happen at step 2 or 3)
|
|
149
157
|
if (step >= 2) {
|
|
150
158
|
const urlMatch = output.match(/(https:\/\/claude\.ai\/oauth\/authorize\S+)/);
|
|
151
159
|
if (urlMatch && !resolved) {
|