@floomhq/floom 1.0.22 → 1.0.24
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/login.js +49 -2
- package/package.json +1 -1
package/dist/login.js
CHANGED
|
@@ -151,6 +151,11 @@ function waitForCallback(port, provider) {
|
|
|
151
151
|
});
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
|
+
if (req.method === "GET" && req.url?.startsWith("/cli-callback")) {
|
|
155
|
+
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
156
|
+
res.end(localCallbackBridgePage());
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
154
159
|
res.writeHead(404, { "content-type": "text/plain" });
|
|
155
160
|
res.end("Not found");
|
|
156
161
|
});
|
|
@@ -174,10 +179,11 @@ function waitForCallback(port, provider) {
|
|
|
174
179
|
});
|
|
175
180
|
server.listen(port, "127.0.0.1", () => {
|
|
176
181
|
const target = `${apiUrl}/auth/cli?port=${port}&provider=${provider}&state=${encodeURIComponent(state)}`;
|
|
182
|
+
process.stdout.write(c.dim("If the browser does not open, copy this URL:") +
|
|
183
|
+
`\n${c.cyan(target)}\n\n`);
|
|
177
184
|
open(target).catch((e) => {
|
|
178
185
|
const msg = e instanceof Error ? e.message : String(e);
|
|
179
|
-
process.stdout.write(c.yellow(`Could not auto-open browser (${msg}).\n`)
|
|
180
|
-
c.dim(`Open this URL manually: ${target}\n`));
|
|
186
|
+
process.stdout.write(c.yellow(`Could not auto-open browser (${msg}).\n`));
|
|
181
187
|
});
|
|
182
188
|
});
|
|
183
189
|
});
|
|
@@ -196,6 +202,47 @@ function parseCallbackBody(body, contentType) {
|
|
|
196
202
|
}
|
|
197
203
|
return JSON.parse(body);
|
|
198
204
|
}
|
|
205
|
+
function localCallbackBridgePage() {
|
|
206
|
+
return `<!doctype html>
|
|
207
|
+
<html lang="en">
|
|
208
|
+
<head>
|
|
209
|
+
<meta charset="utf-8">
|
|
210
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
211
|
+
<title>Floom CLI sign-in</title>
|
|
212
|
+
</head>
|
|
213
|
+
<body>
|
|
214
|
+
<p>Completing Floom CLI sign-in...</p>
|
|
215
|
+
<script>
|
|
216
|
+
(async function () {
|
|
217
|
+
try {
|
|
218
|
+
var params = new URLSearchParams(window.location.hash.slice(1));
|
|
219
|
+
if (!params.get("access_token") || !params.get("refresh_token")) {
|
|
220
|
+
document.body.textContent = "OAuth response missing tokens.";
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
var body = new URLSearchParams();
|
|
224
|
+
["access_token", "refresh_token", "expires_in", "token_type", "state"].forEach(function (key) {
|
|
225
|
+
var value = params.get(key);
|
|
226
|
+
if (value) body.set(key, value);
|
|
227
|
+
});
|
|
228
|
+
window.history.replaceState(null, "", window.location.pathname);
|
|
229
|
+
var res = await fetch("/cli-callback", {
|
|
230
|
+
method: "POST",
|
|
231
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
232
|
+
body: body.toString()
|
|
233
|
+
});
|
|
234
|
+
var html = await res.text();
|
|
235
|
+
document.open();
|
|
236
|
+
document.write(html);
|
|
237
|
+
document.close();
|
|
238
|
+
} catch (e) {
|
|
239
|
+
document.body.textContent = "Could not complete Floom CLI sign-in. Return to your terminal and run floom login again.";
|
|
240
|
+
}
|
|
241
|
+
})();
|
|
242
|
+
</script>
|
|
243
|
+
</body>
|
|
244
|
+
</html>`;
|
|
245
|
+
}
|
|
199
246
|
function localCallbackPage(message) {
|
|
200
247
|
const safeMessage = escapeHtml(message);
|
|
201
248
|
return `<!doctype html>
|