Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
.DS_Store
*.log
.worktrees/
spec/v4.new.json
spec/.issue-title.txt
spec/.issue-body.md
7 changes: 4 additions & 3 deletions src/auth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createHash, randomBytes } from 'node:crypto';
import { createServer } from 'node:http';
import { exec } from 'node:child_process';
import { execFile } from 'node:child_process';
import { setTokens, getOAuthClientId, getRefreshToken, getOAuthRedirectUri } from './config.js';

const REDIRECT_PORT = 9876;
Expand All @@ -26,7 +26,7 @@ function openBrowser(url) {
process.platform === 'win32' ? 'start' :
process.platform === 'darwin' ? 'open' :
'xdg-open';
exec(`${cmd} "${url}"`);
execFile(cmd, [url]);
}

function waitForCallback() {
Expand All @@ -42,8 +42,9 @@ function waitForCallback() {
server.close();
resolve(code);
} else {
const safeError = (error || 'Unknown error').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
res.writeHead(400, { 'Content-Type': 'text/html' });
res.end(`<html><body style="font-family:sans-serif;padding:2rem"><h2>Authorization failed</h2><p>${error || 'Unknown error'}</p></body></html>`);
res.end(`<html><body style="font-family:sans-serif;padding:2rem"><h2>Authorization failed</h2><p>${safeError}</p></body></html>`);
server.close();
reject(new Error(`Authorization failed: ${error || 'unknown error'}`));
}
Expand Down
Loading