@l4yercak3/cli 1.1.4 → 1.1.5
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
CHANGED
|
@@ -129,7 +129,8 @@ class BackendClient {
|
|
|
129
129
|
* @returns {string} The login URL
|
|
130
130
|
*/
|
|
131
131
|
getLoginUrl(state, provider = null) {
|
|
132
|
-
|
|
132
|
+
// Use port 3333 to avoid conflicts with Next.js dev server (port 3000)
|
|
133
|
+
const callbackUrl = 'http://localhost:3333/callback';
|
|
133
134
|
|
|
134
135
|
if (provider) {
|
|
135
136
|
// Direct OAuth provider URL
|
package/src/commands/login.js
CHANGED
|
@@ -39,6 +39,9 @@ function generateRetroPage({ title, icon, heading, headingColor, message, submes
|
|
|
39
39
|
</html>`;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
// CLI callback port - different from Next.js dev server (3000)
|
|
43
|
+
const CLI_CALLBACK_PORT = 3333;
|
|
44
|
+
|
|
42
45
|
/**
|
|
43
46
|
* Start local server to receive OAuth callback
|
|
44
47
|
* @param {string} expectedState - The state token to verify against
|
|
@@ -48,7 +51,7 @@ function startCallbackServer(expectedState) {
|
|
|
48
51
|
const http = require('http');
|
|
49
52
|
|
|
50
53
|
const server = http.createServer((req, res) => {
|
|
51
|
-
const url = new URL(req.url,
|
|
54
|
+
const url = new URL(req.url, `http://localhost:${CLI_CALLBACK_PORT}`);
|
|
52
55
|
|
|
53
56
|
if (url.pathname === '/callback') {
|
|
54
57
|
const token = url.searchParams.get('token');
|
|
@@ -104,7 +107,16 @@ function startCallbackServer(expectedState) {
|
|
|
104
107
|
}
|
|
105
108
|
});
|
|
106
109
|
|
|
107
|
-
server
|
|
110
|
+
// Handle server errors (e.g., port already in use)
|
|
111
|
+
server.on('error', (err) => {
|
|
112
|
+
if (err.code === 'EADDRINUSE') {
|
|
113
|
+
reject(new Error(`Port ${CLI_CALLBACK_PORT} is already in use. Please close any other l4yercak3 processes and try again.`));
|
|
114
|
+
} else {
|
|
115
|
+
reject(err);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
server.listen(CLI_CALLBACK_PORT, 'localhost', () => {
|
|
108
120
|
console.log(chalk.gray(' Waiting for authentication...'));
|
|
109
121
|
});
|
|
110
122
|
|
|
@@ -290,7 +290,7 @@ describe('BackendClient', () => {
|
|
|
290
290
|
const state = 'test-state-token';
|
|
291
291
|
const url = BackendClient.getLoginUrl(state, 'github');
|
|
292
292
|
|
|
293
|
-
expect(url).toContain(encodeURIComponent('http://localhost:
|
|
293
|
+
expect(url).toContain(encodeURIComponent('http://localhost:3333/callback'));
|
|
294
294
|
});
|
|
295
295
|
});
|
|
296
296
|
|