@promarketingstore/cli 0.1.0 → 0.1.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/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57,14 +57,14 @@ function requireSession() {
|
|
|
57
57
|
var loginCommand = new Command("login").description("Sign in with Google (opens browser)").action(async () => {
|
|
58
58
|
writeLine("Opening browser for Google sign-in...");
|
|
59
59
|
const port = await findFreePort();
|
|
60
|
-
const redirectUri = `http://
|
|
60
|
+
const redirectUri = `http://localhost:${port}/callback`;
|
|
61
61
|
const tokenPromise = new Promise((resolve, reject) => {
|
|
62
62
|
const timeout = setTimeout(() => {
|
|
63
63
|
server.close();
|
|
64
64
|
reject(new Error("Login timed out (60s)"));
|
|
65
65
|
}, 6e4);
|
|
66
66
|
const server = createServer(async (req, res) => {
|
|
67
|
-
const url = new URL(req.url || "/", `http://
|
|
67
|
+
const url = new URL(req.url || "/", `http://localhost:${port}`);
|
|
68
68
|
if (url.pathname !== "/callback") {
|
|
69
69
|
res.writeHead(404);
|
|
70
70
|
res.end();
|
|
@@ -105,7 +105,7 @@ var loginCommand = new Command("login").description("Sign in with Google (opens
|
|
|
105
105
|
reject(err);
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
|
-
server.listen(port, "
|
|
108
|
+
server.listen(port, "localhost");
|
|
109
109
|
});
|
|
110
110
|
const params = new URLSearchParams({
|
|
111
111
|
client_id: GOOGLE_CLIENT_ID,
|
|
@@ -146,7 +146,7 @@ var whoamiCommand = new Command("whoami").description("Show current signed-in us
|
|
|
146
146
|
async function findFreePort() {
|
|
147
147
|
return new Promise((resolve) => {
|
|
148
148
|
const server = createServer();
|
|
149
|
-
server.listen(0, "
|
|
149
|
+
server.listen(0, "localhost", () => {
|
|
150
150
|
const addr = server.address();
|
|
151
151
|
const port = typeof addr === "object" && addr ? addr.port : 0;
|
|
152
152
|
server.close(() => resolve(port));
|