@lifeaitools/clauth 0.5.0 → 0.5.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.
@@ -897,43 +897,36 @@ function createServer(initPassword, whitelist, port) {
897
897
  tunnelError = null;
898
898
 
899
899
  try {
900
- // Named tunnel "clauth" ingress configured in ~/.cloudflared/config.yml
901
- // Falls back to quick tunnel if named tunnel fails
902
- const tunnelName = "clauth";
903
- const proc = spawnProc("cloudflared", ["tunnel", "run", tunnelName], {
900
+ // Quick tunnel — no DNS/config needed, new random URL each session
901
+ // Resolve cloudflared binary may not be on PATH in bash shells
902
+ let cfBin = "cloudflared";
903
+ if (os.platform() === "win32") {
904
+ const candidates = [
905
+ "cloudflared",
906
+ path.join(process.env.ProgramFiles || "", "cloudflared", "cloudflared.exe"),
907
+ path.join(process.env["ProgramFiles(x86)"] || "C:\\Program Files (x86)", "cloudflared", "cloudflared.exe"),
908
+ path.join(os.homedir(), "scoop", "shims", "cloudflared.exe"),
909
+ "C:\\ProgramData\\chocolatey\\bin\\cloudflared.exe",
910
+ ];
911
+ for (const c of candidates) {
912
+ try { if (fs.statSync(c).isFile()) { cfBin = c; break; } } catch {}
913
+ }
914
+ }
915
+
916
+ const proc = spawnProc(cfBin, ["tunnel", "--url", `http://127.0.0.1:${port}`], {
904
917
  stdio: ["ignore", "pipe", "pipe"],
905
918
  });
906
919
 
907
920
  tunnelProc = proc;
908
921
 
909
- // cloudflared logs to stderr parse for connection info
922
+ // cloudflared prints the quick tunnel URL to stderr
910
923
  let stderrBuf = "";
911
924
  proc.stderr.on("data", (chunk) => {
912
- const text = chunk.toString();
913
- stderrBuf += text;
914
-
915
- // Detect connection registered (named tunnel is live)
916
- if (!tunnelUrl && stderrBuf.includes("Registered tunnel connection")) {
917
- // Named tunnel URL comes from config, not stderr.
918
- // Read it from cloudflared config if available.
919
- try {
920
- const cfgPath = path.join(os.homedir(), ".cloudflared", "config.yml");
921
- const cfgText = fs.readFileSync(cfgPath, "utf8");
922
- const hostnameMatch = cfgText.match(/hostname:\s*(\S+)/);
923
- if (hostnameMatch) {
924
- tunnelUrl = hostnameMatch[1].startsWith("http") ? hostnameMatch[1] : `https://${hostnameMatch[1]}`;
925
- }
926
- } catch {}
927
- if (!tunnelUrl) tunnelUrl = `(named tunnel "${tunnelName}" connected — check DNS)`;
928
- const logLine = `[${new Date().toISOString()}] Tunnel started: ${tunnelUrl}\n`;
929
- try { fs.appendFileSync(LOG_FILE, logLine); } catch {}
930
- }
931
-
932
- // Quick tunnel fallback: trycloudflare.com URL
925
+ stderrBuf += chunk.toString();
933
926
  if (!tunnelUrl) {
934
- const quickMatch = stderrBuf.match(/https:\/\/[a-z0-9-]+\.trycloudflare\.com/);
935
- if (quickMatch) {
936
- tunnelUrl = quickMatch[0];
927
+ const match = stderrBuf.match(/https:\/\/[a-z0-9-]+\.trycloudflare\.com/);
928
+ if (match) {
929
+ tunnelUrl = match[0];
937
930
  const logLine = `[${new Date().toISOString()}] Tunnel started: ${tunnelUrl}\n`;
938
931
  try { fs.appendFileSync(LOG_FILE, logLine); } catch {}
939
932
  }
package/cli/index.js CHANGED
@@ -12,7 +12,7 @@ import * as api from "./api.js";
12
12
  import os from "os";
13
13
 
14
14
  const config = new Conf(getConfOptions());
15
- const VERSION = "0.5.0";
15
+ const VERSION = "0.5.2";
16
16
 
17
17
  // ============================================================
18
18
  // Password prompt helper
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifeaitools/clauth",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Hardware-bound credential vault for the LIFEAI infrastructure stack",
5
5
  "type": "module",
6
6
  "bin": {