archbyte 0.2.0 → 0.2.1
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/bin/archbyte.js +1 -1
- package/dist/cli/auth.js +9 -4
- package/package.json +1 -1
package/bin/archbyte.js
CHANGED
package/dist/cli/auth.js
CHANGED
|
@@ -51,8 +51,8 @@ export async function handleLogin(provider) {
|
|
|
51
51
|
console.error(chalk.red(`Login failed: ${err instanceof Error ? err.message : "Unknown error"}`));
|
|
52
52
|
console.log();
|
|
53
53
|
console.log(chalk.gray("You can also log in manually:"));
|
|
54
|
-
console.log(chalk.gray(
|
|
55
|
-
console.log(chalk.gray(" 2.
|
|
54
|
+
console.log(chalk.gray(" 1. Visit https://archbyte.heartbyte.io"));
|
|
55
|
+
console.log(chalk.gray(" 2. Sign in and copy your token from the dashboard"));
|
|
56
56
|
console.log(chalk.gray(" 3. Run: archbyte login --token <your-token>"));
|
|
57
57
|
process.exit(1);
|
|
58
58
|
}
|
|
@@ -326,7 +326,11 @@ function startOAuthFlow(provider = "github") {
|
|
|
326
326
|
const server = http.createServer(async (req, res) => {
|
|
327
327
|
const url = new URL(req.url ?? "/", `http://localhost:${CLI_CALLBACK_PORT}`);
|
|
328
328
|
if (url.pathname === "/callback") {
|
|
329
|
-
|
|
329
|
+
// Extract token from raw query string, not URLSearchParams
|
|
330
|
+
// (URLSearchParams decodes '+' as space per x-www-form-urlencoded, corrupting JWT signatures)
|
|
331
|
+
const rawQuery = (req.url ?? "").split("?")[1] ?? "";
|
|
332
|
+
const tokenMatch = rawQuery.match(/(?:^|&)token=([^&]+)/);
|
|
333
|
+
const token = tokenMatch ? decodeURIComponent(tokenMatch[1]) : null;
|
|
330
334
|
if (!token) {
|
|
331
335
|
res.writeHead(400, { "Content-Type": "text/html" });
|
|
332
336
|
res.end("<h1>Login failed</h1><p>No token received. Close this window and try again.</p>");
|
|
@@ -342,7 +346,8 @@ function startOAuthFlow(provider = "github") {
|
|
|
342
346
|
headers: { Authorization: `Bearer ${token}` },
|
|
343
347
|
});
|
|
344
348
|
if (!meRes.ok) {
|
|
345
|
-
|
|
349
|
+
const errBody = await meRes.text().catch(() => "");
|
|
350
|
+
reject(new Error(`Failed to fetch user info (${meRes.status}: ${errBody})`));
|
|
346
351
|
return;
|
|
347
352
|
}
|
|
348
353
|
const { user } = (await meRes.json());
|