Skip to content

Commit

Permalink
prettify auth page
Browse files Browse the repository at this point in the history
  • Loading branch information
henryfauna committed Dec 6, 2024
1 parent d52a149 commit 422b95a
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 6 deletions.
92 changes: 92 additions & 0 deletions src/lib/auth/html/SuccessPage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<head>
<style>
body {
margin: 0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: #f7f9fa;
font-family: proxima-nova, system-ui, sans-serif;
}

.success-container {
padding: 48px;
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 24px;
}

.logo {
display: flex;
align-items: center;
gap: 8px;
}

.title,
.description {
color: #363a3d;
}

.title {
font-size: 32px;
font-weight: 600;
}

.description {
font-size: 16px;
}
</style>
</head>
<body>
<div class="success-container">
<div class="logo">
<svg
width="40"
height="40"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M18.6453 5.03442C16.9971 5.53001 16.2035 6.4189 15.6627 7.80336C15.5232 8.17308 15.1744 8.58211 14.7819 8.85744L16.1337 10.1632L11.843 7.45724L0 0C0 0 0.854648 5.00296 1.15116 6.84368C1.36046 8.1416 1.71802 8.72371 2.85174 9.31369L3.30523 9.53394L5.25871 10.4622L4.09883 9.91938L9.45346 12.5546L9.41858 12.6254L3.65406 10.2183C3.9593 11.1623 4.55231 12.9794 4.80522 13.7817C5.07557 14.647 5.3808 14.9617 6.31394 15.2685L8.03196 15.8349L9.09591 15.4573L7.74416 16.2676L0.985462 24C5.47673 20.24 9.27904 18.9027 12.061 17.8093C15.6104 16.4248 17.7471 15.536 19.1424 12.3422C20.1366 10.1003 20.9127 7.22913 21.8982 6.11997L24 3.69716C24 3.69716 19.6481 4.73551 18.6453 5.03442Z"
fill="#3A1AB6"
/>
</svg>
<svg
width="77"
height="24"
viewBox="0 0 77 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M2.16243 7.2345V6.17988C2.16243 2.71196 5.08126 0.146667 8.51135 0.146667C9.19917 0.146667 9.887 0.251171 10.1937 0.355692L9.40371 3.45306C9.12479 3.34854 8.81807 3.31054 8.51135 3.31054C6.72662 3.31054 5.52753 4.6407 5.52753 6.18938V7.244H9.64526V9.83782H5.52753V23.0254H2.16243V9.82831H0.17334V7.2345H2.16243Z"
fill="#3A1AB6"
/>
<path
d="M10.3242 15.1297C10.3242 10.5691 13.5498 7.0632 17.807 7.0632C20.0007 7.0632 21.9249 8.26035 23.0589 10.0466V7.24374H26.4146V23.0252H23.0497V20.2223C21.8784 22.0085 19.9635 23.2056 17.7977 23.2056C13.5498 23.1962 10.3242 19.6522 10.3242 15.1297ZM13.6891 15.1297C13.6891 18.1796 15.7806 20.5644 18.3555 20.5644C20.5491 20.5644 23.0589 18.7021 23.0589 15.1297C23.0589 12.1178 21.0326 9.69502 18.3555 9.69502C15.7806 9.69502 13.6891 12.1463 13.6891 15.1297Z"
fill="#3A1AB6"
/>
<path
d="M28.5801 16.3926V7.24304H31.9078V16.6111C31.9078 18.6444 33.4136 20.402 35.5422 20.402C38.2565 20.402 39.7252 18.0553 39.7252 16.4021V7.25253H43.0529V23.0339H39.7252V20.8963C38.6655 22.2643 36.983 23.2144 35.0217 23.2144C30.9782 23.1955 28.5801 20.0696 28.5801 16.3926Z"
fill="#3A1AB6"
/>
<path
d="M44.9121 23.0163V7.23481H48.2398V9.37256C49.2716 8.0044 50.9541 7.05429 52.9432 7.05429C56.959 7.05429 59.3944 10.1802 59.3944 13.857V23.0067H56.0666V13.6386C56.0666 11.5008 54.4584 9.84762 52.3948 9.84762C49.6527 9.84762 48.2398 12.2989 48.2398 13.8476V22.9971H44.9121V23.0163Z"
fill="#3A1AB6"
/>
<path
d="M60.9004 15.1297C60.9004 10.5691 64.1259 7.0632 68.3832 7.0632C70.577 7.0632 72.5011 8.26035 73.6352 10.0466V7.24374H77.0002V23.0252H73.6352V20.2223C72.4639 22.0085 70.5491 23.2056 68.3832 23.2056C64.1259 23.1962 60.9004 19.6522 60.9004 15.1297ZM64.2653 15.1297C64.2653 18.1796 66.3569 20.5644 68.9317 20.5644C71.1255 20.5644 73.6352 18.7021 73.6352 15.1297C73.6352 12.1178 71.6088 9.69502 68.9317 9.69502C66.3569 9.69502 64.2653 12.1463 64.2653 15.1297Z"
fill="#3A1AB6"
/>
</svg>
</div>
<div class="title">You're all set!</div>
<div class="description">
Your device is now connected. You can close this window and return to the
terminal.
</div>
</div>
</body>
20 changes: 14 additions & 6 deletions src/lib/auth/oauth-client.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { createHash, randomBytes } from "crypto";
import http from "http";
import url from "url";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";

Check failure on line 6 in src/lib/auth/oauth-client.mjs

View workflow job for this annotation

GitHub Actions / lint

'url' import is duplicated

import { container } from "../../cli.mjs";

// Get current file's directory
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Read success page content
const SuccessPage = fs.readFileSync(
path.join(__dirname, "./html/SuccessPage.html"),
"utf8",
);

// Default to prod client id and secret
const clientId = process.env.FAUNA_CLIENT_ID ?? "Aq4_G0mOtm_F1fK3PuzE0k-i9F0";
// Native public clients are not confidential. The client secret is not used beyond
Expand Down Expand Up @@ -74,12 +86,8 @@ class OAuthClient {
if (req.method === "GET") {
const parsedUrl = url.parse(req.url || "", true);
if (parsedUrl.pathname === "/success") {
res.write(`
<body>
<h1>Success</h1>
<p>Authentication successful. You can close this window and return to the terminal.</p>
</body>
`);
res.writeHead(200, { "Content-Type": "text/html" });
res.write(SuccessPage);
res.end();
this.closeServer();
} else if (parsedUrl.pathname !== "/") {
Expand Down

0 comments on commit 422b95a

Please sign in to comment.