@persistmemory/cli 0.2.1 → 0.2.2

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/bin.js CHANGED
@@ -1527,7 +1527,7 @@ function shortDate(iso) {
1527
1527
  }
1528
1528
 
1529
1529
  // src/help.ts
1530
- var VERSION = true ? "0.2.1" : versionFromManifest();
1530
+ var VERSION = true ? "0.2.2" : versionFromManifest();
1531
1531
  var PACKAGE = "@persistmemory/cli";
1532
1532
  var HELP = `
1533
1533
  pm \u2014 PersistMemory from your terminal
@@ -1746,7 +1746,17 @@ async function startLoopback(options = {}) {
1746
1746
  // This page is one-use and holds a result; nothing should keep it.
1747
1747
  "cache-control": "no-store",
1748
1748
  // It never loads anything, so it is not allowed to.
1749
- "content-security-policy": "default-src 'none'; style-src 'unsafe-inline'"
1749
+ "content-security-policy": "default-src 'none'; style-src 'unsafe-inline'",
1750
+ /*
1751
+ Not kept alive, because a kept socket keeps the PROCESS alive.
1752
+
1753
+ `server.close()` stops new connections and leaves established ones
1754
+ open, and a browser holds this one open by default — so `pm auth login`
1755
+ printed "Signed in" and then sat there until somebody pressed Ctrl+C.
1756
+ The page is the last thing this server ever serves; there is nothing to
1757
+ reuse the connection for.
1758
+ */
1759
+ connection: "close"
1750
1760
  });
1751
1761
  response.end(donePage(callback));
1752
1762
  resolveCallback?.(callback);
@@ -1778,7 +1788,9 @@ async function startLoopback(options = {}) {
1778
1788
  },
1779
1789
  close() {
1780
1790
  clearTimeout(timer);
1791
+ server.closeAllConnections?.();
1781
1792
  server.close();
1793
+ server.unref();
1782
1794
  }
1783
1795
  };
1784
1796
  }
@@ -2064,7 +2076,7 @@ async function clientFor(resolved, deps) {
2064
2076
  });
2065
2077
  }
2066
2078
  async function currentCredential(resolved, deps) {
2067
- const credential = resolved.credential;
2079
+ const credential = resolved.fromEnvironment ? resolved.credential : readCredentials(deps.paths)[resolved.profile] ?? resolved.credential;
2068
2080
  if (!credential) throw new NotSignedIn();
2069
2081
  if (!isExpired(credential, deps.now?.() ?? Date.now())) return credential;
2070
2082
  if (!credential.refreshToken || !resolved.clientId) {