posthive-cli 0.1.4 → 0.1.7
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 -1
- package/dist/login.js +20 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -133,7 +133,10 @@ if (command === "login") {
|
|
|
133
133
|
const loginUrl = (str(flags, "api-url") ?? process.env.POSTHIVE_API_URL ?? DEFAULT_API_URL).replace(/\/$/, "");
|
|
134
134
|
try {
|
|
135
135
|
await runLogin(loginUrl);
|
|
136
|
-
|
|
136
|
+
// Delay exit by a tick so libuv finishes closing the local callback
|
|
137
|
+
// server's handles first — calling process.exit() synchronously here
|
|
138
|
+
// can race with that cleanup and crash on Windows.
|
|
139
|
+
setImmediate(() => process.exit(0));
|
|
137
140
|
}
|
|
138
141
|
catch (err) {
|
|
139
142
|
fail(err instanceof Error ? err.message : String(err));
|
package/dist/login.js
CHANGED
|
@@ -88,16 +88,26 @@ export async function runLogin(apiUrl) {
|
|
|
88
88
|
timer.unref();
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
let tokenRes;
|
|
92
|
+
try {
|
|
93
|
+
tokenRes = await fetch(`${apiUrl}/oauth/token`, {
|
|
94
|
+
method: "POST",
|
|
95
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
96
|
+
body: new URLSearchParams({
|
|
97
|
+
grant_type: "authorization_code",
|
|
98
|
+
code,
|
|
99
|
+
code_verifier: verifier,
|
|
100
|
+
redirect_uri: redirectUri,
|
|
101
|
+
}),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
const cause = err instanceof Error && err.cause instanceof Error ? `: ${err.cause.message}` : "";
|
|
106
|
+
throw new Error(`Could not reach ${apiUrl}${cause}. This is usually a network/firewall/proxy issue on your machine ` +
|
|
107
|
+
`blocking Node.js from making HTTPS requests (even if your browser can reach the site fine). ` +
|
|
108
|
+
`If you're behind a corporate proxy or antivirus with TLS inspection, try setting NODE_EXTRA_CA_CERTS ` +
|
|
109
|
+
`to your organization's root CA, or run from a different network.`);
|
|
110
|
+
}
|
|
101
111
|
if (!tokenRes.ok) {
|
|
102
112
|
const text = await tokenRes.text();
|
|
103
113
|
throw new Error(`Token exchange failed: ${text}`);
|
package/package.json
CHANGED