lazypush-cli 0.1.2 → 0.1.3
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/dist/commands/login.js +2 -2
- package/package.json +1 -1
- package/src/commands/login.ts +14 -11
package/dist/commands/login.js
CHANGED
|
@@ -34,7 +34,7 @@ async function handleLogin() {
|
|
|
34
34
|
try {
|
|
35
35
|
const jwtPayload = parseJwt(token);
|
|
36
36
|
if (!jwtPayload.userId) {
|
|
37
|
-
throw new Error(
|
|
37
|
+
throw new Error("Invalid token: missing userId");
|
|
38
38
|
}
|
|
39
39
|
const session = {
|
|
40
40
|
token,
|
|
@@ -100,7 +100,7 @@ async function waitForOAuthCallback() {
|
|
|
100
100
|
server.listen(port, () => {
|
|
101
101
|
(0, logger_1.info)("Opening browser for GitHub authentication...");
|
|
102
102
|
const apiUrl = process.env.LAZYPUSH_API || "https://lazypush.onrender.com";
|
|
103
|
-
const redirectUri = `http://localhost
|
|
103
|
+
const redirectUri = `http://localhost:8000/auth/callback`;
|
|
104
104
|
const loginUrl = `${apiUrl}/auth/github?redirect_uri=${encodeURIComponent(redirectUri)}`;
|
|
105
105
|
(0, open_1.default)(loginUrl);
|
|
106
106
|
(0, logger_1.info)("Browser opened. If it did not open, visit:");
|
package/package.json
CHANGED
package/src/commands/login.ts
CHANGED
|
@@ -21,7 +21,7 @@ export async function handleLogin() {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const token = await waitForOAuthCallback();
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
if (!token) {
|
|
26
26
|
error("Authentication cancelled");
|
|
27
27
|
process.exit(1);
|
|
@@ -31,9 +31,9 @@ export async function handleLogin() {
|
|
|
31
31
|
try {
|
|
32
32
|
const jwtPayload = parseJwt(token);
|
|
33
33
|
if (!jwtPayload.userId) {
|
|
34
|
-
throw new Error(
|
|
34
|
+
throw new Error("Invalid token: missing userId");
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
const session = {
|
|
38
38
|
token,
|
|
39
39
|
userId: jwtPayload.userId,
|
|
@@ -59,11 +59,14 @@ async function waitForOAuthCallback(): Promise<string | null> {
|
|
|
59
59
|
return new Promise((resolve) => {
|
|
60
60
|
let server: Server | null = null;
|
|
61
61
|
const port = 3001;
|
|
62
|
-
const timeout = setTimeout(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
const timeout = setTimeout(
|
|
63
|
+
() => {
|
|
64
|
+
if (server) server.close();
|
|
65
|
+
error("Login timeout - no response from GitHub");
|
|
66
|
+
resolve(null);
|
|
67
|
+
},
|
|
68
|
+
10 * 60 * 1000,
|
|
69
|
+
); // 10 minute timeout
|
|
67
70
|
|
|
68
71
|
server = createServer((req, res) => {
|
|
69
72
|
if (!req.url) {
|
|
@@ -72,7 +75,6 @@ async function waitForOAuthCallback(): Promise<string | null> {
|
|
|
72
75
|
return;
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
|
|
76
78
|
const urlObj = new URL(`http://localhost${req.url}`);
|
|
77
79
|
const token = urlObj.searchParams.get("token");
|
|
78
80
|
const errorParam = urlObj.searchParams.get("error");
|
|
@@ -101,8 +103,9 @@ async function waitForOAuthCallback(): Promise<string | null> {
|
|
|
101
103
|
|
|
102
104
|
server.listen(port, () => {
|
|
103
105
|
info("Opening browser for GitHub authentication...");
|
|
104
|
-
const apiUrl =
|
|
105
|
-
|
|
106
|
+
const apiUrl =
|
|
107
|
+
process.env.LAZYPUSH_API || "https://lazypush.onrender.com";
|
|
108
|
+
const redirectUri = `http://localhost:8000/auth/callback`;
|
|
106
109
|
const loginUrl = `${apiUrl}/auth/github?redirect_uri=${encodeURIComponent(redirectUri)}`;
|
|
107
110
|
|
|
108
111
|
open(loginUrl);
|