@floomhq/floom 1.0.23 → 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 +46 -0
- 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
|
});
|
|
@@ -197,6 +202,47 @@ function parseCallbackBody(body, contentType) {
|
|
|
197
202
|
}
|
|
198
203
|
return JSON.parse(body);
|
|
199
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
|
+
}
|
|
200
246
|
function localCallbackPage(message) {
|
|
201
247
|
const safeMessage = escapeHtml(message);
|
|
202
248
|
return `<!doctype html>
|