diff --git a/src/lib/auth/html/SuccessPage.html b/src/lib/auth/html/SuccessPage.html new file mode 100644 index 00000000..4c55b4db --- /dev/null +++ b/src/lib/auth/html/SuccessPage.html @@ -0,0 +1,92 @@ + + + + +
+ +
You're all set!
+
+ Your device is now connected. You can close this window and return to the + terminal. +
+
+ diff --git a/src/lib/auth/oauth-client.mjs b/src/lib/auth/oauth-client.mjs index fd706e09..9a3e885c 100644 --- a/src/lib/auth/oauth-client.mjs +++ b/src/lib/auth/oauth-client.mjs @@ -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"; 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 @@ -74,12 +86,8 @@ class OAuthClient { if (req.method === "GET") { const parsedUrl = url.parse(req.url || "", true); if (parsedUrl.pathname === "/success") { - res.write(` - -

Success

-

Authentication successful. You can close this window and return to the terminal.

- - `); + res.writeHead(200, { "Content-Type": "text/html" }); + res.write(SuccessPage); res.end(); this.closeServer(); } else if (parsedUrl.pathname !== "/") {