@videan/cli 0.5.0 → 0.5.1

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 CHANGED
@@ -880,7 +880,7 @@ var LANDING = (title, sub) => `<!doctype html>
880
880
  <meta charset="utf-8"><title>${title}</title>
881
881
  <body style="font-family:system-ui;background:#101014;color:#e8e8ea;display:grid;place-items:center;min-height:90vh">
882
882
  <div style="text-align:center"><h1 style="font-weight:600">${title}</h1><p style="color:#9a9aa2">${sub}</p></div>`;
883
- function createCallbackServer(state, timeoutMs = 5 * 60 * 1e3) {
883
+ function createCallbackServer(state, timeoutMs = 5 * 60 * 1e3, redirectOrigin) {
884
884
  return new Promise((resolveServer, rejectServer) => {
885
885
  let settle;
886
886
  const waitForToken = new Promise((resolve, reject) => {
@@ -899,9 +899,17 @@ function createCallbackServer(state, timeoutMs = 5 * 60 * 1e3) {
899
899
  res.end(LANDING("Request refused", "This authorization was not started by this CLI."));
900
900
  return;
901
901
  }
902
+ const land = (done2, status, title, sub) => {
903
+ if (redirectOrigin) {
904
+ res.writeHead(302, { Location: `${redirectOrigin}/cli-auth?done=${done2}` });
905
+ res.end();
906
+ } else {
907
+ res.writeHead(status, { "Content-Type": "text/html" });
908
+ res.end(LANDING(title, sub));
909
+ }
910
+ };
902
911
  if (url.searchParams.get("error")) {
903
- res.writeHead(200, { "Content-Type": "text/html" });
904
- res.end(LANDING("Login cancelled", "You can close this tab."));
912
+ land("denied", 200, "Login cancelled", "You can close this tab.");
905
913
  finish(() => settle.reject(new Error("Authorization was declined in the browser.")));
906
914
  return;
907
915
  }
@@ -912,8 +920,7 @@ function createCallbackServer(state, timeoutMs = 5 * 60 * 1e3) {
912
920
  finish(() => settle.reject(new Error("The browser sent no token.")));
913
921
  return;
914
922
  }
915
- res.writeHead(200, { "Content-Type": "text/html" });
916
- res.end(LANDING("You're logged in", "Return to your terminal \u2014 you can close this tab."));
923
+ land("ok", 200, "You're logged in", "Return to your terminal \u2014 you can close this tab.");
917
924
  finish(() => settle.resolve(token));
918
925
  });
919
926
  const timer = setTimeout(() => {
@@ -1073,7 +1080,7 @@ async function finishWithToken(spinner, baseUrl, token, orgOpt) {
1073
1080
  }
1074
1081
  async function browserLogin(consoleOrigin) {
1075
1082
  const state = randomState();
1076
- const server = await createCallbackServer(state);
1083
+ const server = await createCallbackServer(state, void 0, consoleOrigin);
1077
1084
  const url = `${consoleOrigin}/cli-auth?port=${server.port}&state=${state}`;
1078
1085
  console.log("Opening your browser to sign in (password, Google or SSO all work):");
1079
1086
  console.log(chalk2.cyan(` ${url}`));
@@ -2520,7 +2527,7 @@ function period(start, end) {
2520
2527
  // src/index.ts
2521
2528
  installPromptCrashGuard();
2522
2529
  var program = new Command18();
2523
- program.name("videan").description("Videan CLI \u2014 deploy apps in seconds").version("0.5.0");
2530
+ program.name("videan").description("Videan CLI \u2014 deploy apps in seconds").version("0.5.1");
2524
2531
  program.addCommand(loginCommand);
2525
2532
  program.addCommand(logoutCommand);
2526
2533
  program.addCommand(initCommand);