@iamken/cloudtunnel 0.1.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/commands/login.ts","../src/ui/output.ts","../src/config/token-url.ts","../src/config/resolve-identity.ts","../src/commands/up.ts","../src/config/ensure-auth.ts","../src/connector/binary.ts","../src/connector/process.ts","../src/connector/registry.ts","../src/cloudflare/tunnels.ts","../src/connector/health.ts","../src/core/orchestrator-create.ts","../src/core/ingress.ts","../src/core/slug.ts","../src/core/orchestrator-manage.ts","../src/commands/ls.ts","../src/commands/rm.ts","../src/commands/update.ts","../src/commands/status.ts","../src/commands/down.ts","../src/commands/gc.ts","../src/commands/zones.ts","../src/core/profiles.ts","../src/commands/save.ts","../src/commands/run.ts","../src/commands/profiles.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { createRequire } from \"node:module\";\nimport pc from \"picocolors\";\nimport { reportError } from \"./ui/errors.js\";\n\nimport { registerLogin } from \"./commands/login.js\";\nimport { registerUp } from \"./commands/up.js\";\nimport { registerLs } from \"./commands/ls.js\";\nimport { registerRm } from \"./commands/rm.js\";\nimport { registerUpdate } from \"./commands/update.js\";\nimport { registerStatus } from \"./commands/status.js\";\nimport { registerDown } from \"./commands/down.js\";\nimport { registerGc } from \"./commands/gc.js\";\nimport { registerZones } from \"./commands/zones.js\";\nimport { registerSave } from \"./commands/save.js\";\nimport { registerRun } from \"./commands/run.js\";\nimport { registerProfiles } from \"./commands/profiles.js\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\") as { version: string };\n\nconst KNOWN_COMMANDS = new Set([\n \"login\", \"up\", \"ls\", \"rm\", \"update\", \"status\", \"down\", \"gc\", \"zones\",\n \"save\", \"run\", \"profiles\", \"help\",\n]);\n\n/**\n * Bare-port sugar: `cloudtunnel 3000` ≡ `cloudtunnel up 3000`.\n * If the first non-flag arg is a port-like number and not a known command,\n * splice `up` in front. Keeps commander's own parsing untouched.\n */\nfunction applyBarePortAlias(argv: string[]): string[] {\n const args = argv.slice(2);\n const first = args[0];\n // Only the leading token: `cloudtunnel 3000 …` → `up 3000 …`. Avoids mistaking\n // a flag value (e.g. `--proto 3000`) for the port.\n if (first && /^\\d{1,5}$/.test(first) && !KNOWN_COMMANDS.has(first)) {\n args.unshift(\"up\");\n }\n return [argv[0]!, argv[1]!, ...args];\n}\n\nfunction buildProgram(): Command {\n const program = new Command();\n program\n .name(\"cloudtunnel\")\n .description(\"Manage Cloudflare Tunnels and subdomains account-wide, nport-style.\")\n .version(pkg.version, \"-v, --version\")\n .showHelpAfterError();\n\n program.addHelpText(\n \"before\",\n [\n pc.bold(\"Quickstart:\"),\n ` ${pc.cyan(\"cloudtunnel login\")} once — paste a token (or set CLOUDFLARE_API_TOKEN)`,\n ` ${pc.cyan(\"cloudtunnel 3000\")} → your local :3000 goes live at an HTTPS URL`,\n \"\",\n ].join(\"\\n\"),\n );\n\n for (const register of [\n registerLogin, registerUp, registerLs, registerRm, registerUpdate,\n registerStatus, registerDown, registerGc, registerZones,\n registerSave, registerRun, registerProfiles,\n ]) {\n register(program);\n }\n return program;\n}\n\nasync function main(): Promise<void> {\n const program = buildProgram();\n try {\n await program.parseAsync(applyBarePortAlias(process.argv));\n } catch (err) {\n process.exitCode = reportError(err);\n }\n}\n\nvoid main();\n","import type { Command } from \"commander\";\nimport * as clack from \"@clack/prompts\";\nimport { CliError } from \"../ui/errors.js\";\nimport { redactToken, say, selectOne } from \"../ui/output.js\";\nimport { configFile } from \"../config/paths.js\";\nimport { loadConfig, saveConfig } from \"../config/store.js\";\nimport { REQUIRED_SCOPES, openBrowser, tokenCreateUrl } from \"../config/token-url.js\";\nimport { listAccounts, listZones } from \"../config/resolve-identity.js\";\n\ninterface LoginOptions {\n tokenStdin?: boolean;\n token?: string; // deprecated: leaks into shell history\n account?: string;\n zone?: string;\n status?: boolean;\n}\n\n/** Read the whole stdin pipe (for `--token-stdin`). */\nasync function readStdin(): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) chunks.push(chunk as Buffer);\n return Buffer.concat(chunks).toString(\"utf8\").trim();\n}\n\n/** Acquire the API token: env (silent) → stdin → deprecated flag → masked prompt.\n * Env tokens are NOT persisted (the env stays the source of truth). */\nasync function acquireToken(opts: LoginOptions): Promise<{ token: string; fromEnv: boolean }> {\n const envToken = process.env.CLOUDFLARE_API_TOKEN;\n if (envToken) {\n say.dim(\"Using token from CLOUDFLARE_API_TOKEN.\");\n return { token: envToken, fromEnv: true };\n }\n if (opts.tokenStdin) return { token: await readStdin(), fromEnv: false };\n if (opts.token) {\n say.warn(\"--token puts the token in your shell history — prefer --token-stdin or the prompt. Rotate it if this is a shared host.\");\n return { token: opts.token, fromEnv: false };\n }\n if (!process.stdin.isTTY) {\n throw new CliError(\"No token provided and no interactive terminal.\", {\n hint: \"pipe it: `printf %s $TOKEN | cloudtunnel login --token-stdin`\",\n });\n }\n clack.note(REQUIRED_SCOPES.map((s) => `• ${s}`).join(\"\\n\"), \"Create a token with these scopes\");\n openBrowser(tokenCreateUrl());\n say.dim(`(opened ${tokenCreateUrl()})`);\n const token = await clack.password({ message: \"Paste your Cloudflare API token\", mask: \"•\" });\n if (clack.isCancel(token) || !token) {\n clack.cancel(\"Cancelled.\");\n throw new CliError(\"Cancelled.\", { exitCode: 130 });\n }\n return { token, fromEnv: false };\n}\n\nasync function runLoginFlow(opts: LoginOptions = {}): Promise<void> {\n if (process.stdout.isTTY) clack.intro(\"cloudtunnel · connect to Cloudflare\");\n const { token, fromEnv } = await acquireToken(opts);\n\n const spin = clack.spinner();\n spin.start(\"Verifying token…\");\n const [accounts, zones] = await Promise.all([listAccounts(token), listZones(token)]).catch((err: unknown) => {\n spin.stop(\"Token check failed\");\n throw err;\n });\n spin.stop(\"Token verified\");\n\n if (accounts.length === 0) throw new CliError(\"Token can't see any Cloudflare account.\");\n let account = opts.account ? accounts.find((a) => a.id === opts.account) : undefined;\n if (opts.account && !account) throw new CliError(`Account ${opts.account} not visible to this token.`);\n if (!account) {\n account = accounts.length === 1 || !process.stdin.isTTY\n ? accounts[0]!\n : await selectOne(\"Select an account\", accounts, (a) => `${a.name} (${a.id})`);\n }\n\n let defaultZone = opts.zone;\n if (!defaultZone) {\n if (zones.length === 1) defaultZone = zones[0]!.name;\n else if (zones.length > 1 && process.stdin.isTTY) {\n defaultZone = (await selectOne(\"Select a default domain\", zones, (z) => z.name)).name;\n }\n }\n\n saveConfig({ apiToken: fromEnv ? undefined : token, accountId: account.id, defaultZone });\n const summary = `Logged in as ${account.name}${defaultZone ? ` · default domain ${defaultZone}` : \"\"}`;\n if (process.stdout.isTTY) clack.outro(summary);\n else say.ok(summary);\n if (!defaultZone) say.dim(\"No default domain set — pass -d <domain> on `up`, or re-run `login --zone <domain>`.\");\n}\n\nfunction showStatus(): void {\n const config = loadConfig();\n const token = process.env.CLOUDFLARE_API_TOKEN ?? config.apiToken;\n if (!token) {\n say.warn(\"Not logged in. Run `cloudtunnel login`.\");\n return;\n }\n const source = process.env.CLOUDFLARE_API_TOKEN ? \"env\" : \"config\";\n say.info(`Token: ${redactToken(token)} (${source})`);\n say.info(`Account: ${config.accountId ?? \"(from env / unresolved)\"}`);\n say.info(`Domain: ${config.defaultZone ?? \"(none)\"}`);\n say.dim(`Config: ${configFile}`);\n}\n\nexport function registerLogin(program: Command): void {\n program\n .command(\"login\")\n .description(\"Authenticate with Cloudflare (paste a token once; account + domain auto-resolved)\")\n .option(\"--token-stdin\", \"read the API token from stdin (scriptable, avoids shell history)\")\n .option(\"--token <token>\", \"[discouraged] token as an argument (leaks into shell history)\")\n .option(\"--account <id>\", \"Cloudflare account id (auto-resolved when you have one account)\")\n .option(\"--zone <domain>\", \"default domain for new tunnels (auto-resolved when you have one)\")\n .option(\"--status\", \"show current identity (redacted) and exit\")\n .action(async (opts: LoginOptions) => {\n if (opts.status) return showStatus();\n await runLoginFlow(opts);\n });\n}\n\nexport { runLoginFlow };\n","import pc from \"picocolors\";\nimport Table from \"cli-table3\";\nimport { cancel, intro, isCancel, note, outro, select, spinner } from \"@clack/prompts\";\nimport { CliError } from \"./errors.js\";\n\n// Re-export the clack primitives used to build modern multi-step flows.\nexport { intro, note, outro, spinner };\n\n/** Redact a secret to `••••{last4}` so tokens never appear in output/logs. */\nexport function redactToken(token: string): string {\n if (!token) return \"\";\n const last4 = token.length > 4 ? token.slice(-4) : token;\n return `••••${last4}`;\n}\n\n// Lightweight one-off lines for non-flow commands (ls, zones, status, …).\nexport const say = {\n info: (msg: string) => console.log(msg),\n ok: (msg: string) => console.log(pc.green(`✓ ${msg}`)),\n warn: (msg: string) => console.warn(pc.yellow(`! ${msg}`)),\n dim: (msg: string) => console.log(pc.dim(msg)),\n step: (msg: string) => console.log(pc.cyan(`→ ${msg}`)),\n};\n\nexport const dim = (s: string): string => pc.dim(s);\n\n/** Format a live tunnel as `https://host → proto://localhost:port`. */\nexport function formatRoute(host: string, target: string): string {\n return `${pc.green(pc.bold(`https://${host}`))} ${pc.dim(\"→\")} ${pc.cyan(target)}`;\n}\n\n/** Render a simple table. `head` = column titles, `rows` = string cells. */\nexport function printTable(head: string[], rows: string[][]): void {\n const table = new Table({\n head: head.map((h) => pc.bold(h)),\n style: { head: [], border: [] },\n });\n for (const row of rows) table.push(row);\n console.log(table.toString());\n}\n\n/**\n * Modern arrow-key single-select (↑/↓ to move, Enter to choose). Callers must\n * guard non-TTY before calling. Ctrl-C cancels cleanly (exit 130).\n */\nexport async function selectOne<T>(\n message: string,\n items: T[],\n label: (item: T) => string,\n): Promise<T> {\n // Use the item index as the (primitive) option value to avoid clack's\n // conditional Option<T> type fighting the generic, then map back.\n const value = await select({\n message,\n options: items.map((item, i) => ({ value: String(i), label: label(item) })),\n });\n if (isCancel(value)) {\n cancel(\"Cancelled.\");\n throw new CliError(\"Cancelled.\", { exitCode: 130 });\n }\n return items[Number(value)]!;\n}\n","import { spawn } from \"node:child_process\";\n\n/** The exact scopes cloudtunnel needs. Printed so the user selects them when\n * minting a token — least-privilege, account-wide only where required. */\nexport const REQUIRED_SCOPES = [\n \"Account · Cloudflare Tunnel · Edit\",\n \"Account · Account Settings · Read\",\n \"Zone · DNS · Edit\",\n \"Zone · Zone · Read\",\n] as const;\n\n/** Cloudflare \"Create Custom Token\" page. `name` is pre-filled best-effort;\n * the user still selects the scopes above (dashboard pre-fill params are not a\n * versioned API, so we rely on the printed scope list, not URL params). */\nexport function tokenCreateUrl(): string {\n return \"https://dash.cloudflare.com/profile/api-tokens?name=cloudtunnel\";\n}\n\n/** Best-effort open a URL in the default browser. Never throws — if no opener\n * exists (headless/CI), the caller still prints the URL. */\nexport function openBrowser(url: string): void {\n const cmd =\n process.platform === \"darwin\" ? \"open\"\n : process.platform === \"win32\" ? \"cmd\"\n : \"xdg-open\";\n const args = process.platform === \"win32\" ? [\"/c\", \"start\", \"\", url] : [url];\n try {\n const child = spawn(cmd, args, { stdio: \"ignore\", detached: true });\n child.on(\"error\", () => {}); // swallow: opener may not exist\n child.unref();\n } catch {\n // ignore — printing the URL is the fallback\n }\n}\n","import { CliError } from \"../ui/errors.js\";\nimport { REQUIRED_SCOPES, tokenCreateUrl } from \"./token-url.js\";\n\nconst API_BASE = \"https://api.cloudflare.com/client/v4\";\n\nexport interface CfAccount { id: string; name: string }\nexport interface CfZone { id: string; name: string; account?: { id: string } }\n\n/**\n * Raw Cloudflare GET used only for login-time validation (the typed SDK client\n * is wired in Phase 3). Errors are sanitized: the token never appears in any\n * thrown message. A 403 is mapped to a missing-scope hint.\n */\nasync function cfGet<T>(path: string, token: string): Promise<T[]> {\n let res: Response;\n try {\n res = await fetch(`${API_BASE}${path}`, {\n headers: { Authorization: `Bearer ${token}`, \"Content-Type\": \"application/json\" },\n });\n } catch {\n throw new CliError(\"Could not reach the Cloudflare API (network error).\");\n }\n if (res.status === 401) {\n throw new CliError(\"Cloudflare rejected the token (invalid or expired).\", {\n hint: `mint a new token: ${tokenCreateUrl()}`,\n });\n }\n if (res.status === 403) {\n throw new CliError(`Token is missing a required scope for ${path}.`, {\n hint: `token needs: ${REQUIRED_SCOPES.join(\", \")}`,\n });\n }\n const body = (await res.json().catch(() => ({}))) as { success?: boolean; result?: T[] };\n if (!res.ok || !body.success) {\n throw new CliError(`Cloudflare API error (${res.status}) on ${path}.`);\n }\n return body.result ?? [];\n}\n\nexport function listAccounts(token: string): Promise<CfAccount[]> {\n return cfGet<CfAccount>(\"/accounts?per_page=50\", token);\n}\n\nexport function listZones(token: string): Promise<CfZone[]> {\n return cfGet<CfZone>(\"/zones?per_page=50\", token);\n}\n","import type { Command } from \"commander\";\nimport { join } from \"node:path\";\nimport { readFileSync } from \"node:fs\";\nimport * as clack from \"@clack/prompts\";\nimport { CliError, reportError } from \"../ui/errors.js\";\nimport { dim, formatRoute, say, selectOne } from \"../ui/output.js\";\nimport { ensureAuth } from \"../config/ensure-auth.js\";\nimport { loadConfig, saveConfig } from \"../config/store.js\";\nimport { resolveCf } from \"../cloudflare/client.js\";\nimport { listZones } from \"../cloudflare/zones.js\";\nimport { logDir } from \"../config/paths.js\";\nimport { ensureCloudflared } from \"../connector/binary.js\";\nimport { startConnector, stopConnector } from \"../connector/process.js\";\nimport { waitHealthy } from \"../connector/health.js\";\nimport { currentBootId, getEntry, patchEntry } from \"../connector/registry.js\";\nimport { createTunnelSubdomain } from \"../core/orchestrator-create.js\";\nimport { removeTunnelSubdomain } from \"../core/orchestrator-manage.js\";\n\ninterface UpOptions {\n subdomain?: string;\n domain?: string;\n name?: string; // alias of --subdomain\n zone?: string; // alias of --domain\n hostname?: string;\n detach?: boolean;\n ephemeral?: boolean;\n proto: \"http\" | \"https\";\n force?: boolean;\n}\n\nfunction parsePort(port: string): number {\n const n = Number(port);\n if (!Number.isInteger(n) || n < 1 || n > 65535) {\n throw new CliError(`Invalid port: ${port}`, { hint: \"use a number 1–65535, e.g. `cloudtunnel 3000`\" });\n }\n return n;\n}\n\n/** Resolve which domain (zone) to use: explicit `-d` → saved default → auto\n * (single zone) → interactive pick (multiple + TTY, remembered) → error (non-TTY). */\nexport async function resolveDomain(token: string, explicit?: string, saved?: string): Promise<string> {\n if (explicit) return explicit;\n if (saved) return saved;\n const zones = await listZones(token);\n if (zones.length === 0) throw new CliError(\"No domains found in this Cloudflare account.\");\n if (zones.length === 1) return zones[0]!.name;\n if (!process.stdin.isTTY) {\n throw new CliError(\"Multiple domains in this account — pick one.\", { hint: \"pass -d <domain>, e.g. -d example.com\" });\n }\n const chosen = await selectOne(\"Choose a domain\", zones, (z) => z.name);\n saveConfig({ ...loadConfig(), defaultZone: chosen.name });\n say.dim(`Saved ${chosen.name} as your default domain (change it with \\`cloudtunnel login --zone <domain>\\`).`);\n return chosen.name;\n}\n\n/** Print the last few lines of a connector logfile (shown when it crashes). */\nfunction showLogTail(logFile: string): void {\n try {\n const tail = readFileSync(logFile, \"utf8\").trim().split(\"\\n\").slice(-8).join(\"\\n\");\n if (tail) say.dim(tail);\n } catch {\n /* no log yet */\n }\n}\n\nasync function runUp(portArg: string, opts: UpOptions): Promise<void> {\n const port = parsePort(portArg);\n const creds = await ensureAuth();\n const cf = resolveCf();\n const bin = await ensureCloudflared(); // before any CF create: unsupported platform fails clean\n\n const subdomain = opts.subdomain ?? opts.name;\n const domain = opts.hostname ? undefined : await resolveDomain(cf.token, opts.domain ?? opts.zone, creds.defaultZone);\n\n if (process.stdout.isTTY) clack.intro(\"cloudtunnel\");\n const spin = clack.spinner();\n let spinnerActive = true;\n const stopSpin = (msg: string) => {\n if (spinnerActive) {\n spinnerActive = false;\n spin.stop(msg);\n }\n };\n\n spin.start(\"Creating tunnel…\");\n const result = await createTunnelSubdomain(cf, {\n port, proto: opts.proto, name: subdomain, zone: domain,\n hostname: opts.hostname, defaultZone: creds.defaultZone, force: opts.force,\n }).catch((err: unknown) => {\n stopSpin(\"Failed to create the tunnel\");\n throw err;\n });\n const fqdn = result.host.hostname;\n const logFile = join(logDir, `${result.host.subdomain}.log`);\n const target = `${opts.proto}://localhost:${port}`;\n\n if (opts.detach) {\n const started = startConnector({ bin, token: result.token, detach: true, logFile });\n await patchEntry(fqdn, { pid: started.pid, bootId: currentBootId(), logFile });\n stopSpin(\"Started in the background\");\n clack.note(formatRoute(fqdn, target), `pid ${started.pid}`);\n if (process.stdout.isTTY) clack.outro(`Stop it with: cloudtunnel down ${result.host.subdomain}`);\n return;\n }\n\n spin.message(\"Connecting to the Cloudflare edge…\");\n const controller = new AbortController();\n let tornDown = false;\n const teardown = async (exitCode: number): Promise<void> => {\n if (tornDown) return;\n tornDown = true;\n controller.abort();\n stopSpin(\"Stopping…\");\n try {\n const entry = getEntry(fqdn);\n if (entry) await stopConnector(entry);\n if (opts.ephemeral) {\n await removeTunnelSubdomain(cf, fqdn, { force: true });\n clack.outro(`Stopped · ${fqdn} deleted`);\n } else {\n clack.outro(`Stopped · ${fqdn} kept — re-attach: cloudtunnel ${port} -s ${result.host.subdomain}`);\n }\n } catch (err) {\n reportError(err); // never let teardown become an unhandled rejection\n } finally {\n process.exit(exitCode);\n }\n };\n\n const started = startConnector({\n bin, token: result.token, detach: false, logFile,\n onExit: (code) => {\n if (!tornDown) {\n stopSpin(\"cloudflared exited\");\n showLogTail(logFile);\n void teardown(code ?? 1);\n }\n },\n });\n await patchEntry(fqdn, { pid: started.pid, bootId: currentBootId(), logFile });\n for (const sig of [\"SIGINT\", \"SIGHUP\", \"SIGTERM\"] as const) {\n process.on(sig, () => void teardown(0));\n }\n\n const health = await waitHealthy(cf, result.tunnelId, { signal: controller.signal });\n if (health === \"healthy\") {\n stopSpin(\"Connected\");\n clack.note(`${formatRoute(fqdn, target)}\\n${dim(\"Ctrl-C stops the connector — the subdomain is kept\")}`, \"Live\");\n } else if (health === \"provisioning\") {\n stopSpin(\"Provisioning\");\n say.warn(`${fqdn} is not healthy yet — it should be live shortly.`);\n }\n // health === \"dead\" → onExit already handled teardown.\n}\n\nexport function registerUp(program: Command): void {\n program\n .command(\"up\")\n .argument(\"<port>\", \"local port to expose (e.g. 3000)\")\n .description(\"Expose a local port at an HTTPS subdomain (also: `cloudtunnel <port>`)\")\n .option(\"-s, --subdomain <name>\", \"subdomain label (default: a friendly random slug)\")\n .option(\"-d, --domain <domain>\", \"domain to create the subdomain under (default: your default; picks interactively if unset)\")\n .option(\"--name <name>\", \"alias of --subdomain\")\n .option(\"--zone <domain>\", \"alias of --domain\")\n .option(\"--hostname <fqdn>\", \"full hostname override (instead of --subdomain + --domain)\")\n .option(\"--detach\", \"run the connector in the background\")\n .option(\"--ephemeral\", \"delete the tunnel + DNS on exit (nport-style; default keeps them)\")\n .option(\"-f, --force\", \"take over a subdomain already occupied by another record\")\n .option(\"--proto <proto>\", \"local service protocol: http | https\", \"http\")\n .action((port: string, opts: UpOptions) => runUp(port, opts));\n}\n","import { CliError } from \"../ui/errors.js\";\nimport { say } from \"../ui/output.js\";\nimport { getCredentials, type Credentials } from \"./store.js\";\nimport { runLoginFlow } from \"../commands/login.js\";\n\n/**\n * Single auth entry point for every command. Returns credentials if present;\n * on a fresh machine with a TTY it runs onboarding inline and continues, so\n * `cloudtunnel 3000` on a new box just works. Non-TTY (CI) → actionable error.\n */\nexport async function ensureAuth(): Promise<Credentials> {\n try {\n return getCredentials();\n } catch (err) {\n if (err instanceof CliError && process.stdin.isTTY) {\n say.info(\"Welcome to cloudtunnel — let's get you connected to Cloudflare first.\");\n await runLoginFlow();\n return getCredentials();\n }\n throw err;\n }\n}\n","import { execFileSync } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { chmodSync, existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { CliError } from \"../ui/errors.js\";\nimport { say } from \"../ui/output.js\";\nimport { binDir, ensureDirs } from \"../config/paths.js\";\n\n// Pinned release for reproducible, checksum-verified auto-install. Bump both the\n// version and the checksums together (values from the release's sha256 sums).\nconst PINNED_VERSION = \"2025.1.0\";\nconst RELEASE_BASE = `https://github.com/cloudflare/cloudflared/releases/download/${PINNED_VERSION}`;\n\ninterface Asset { file: string; archive: boolean; sha256: string }\n\n// Fill sha256 from the pinned release before shipping auto-install for a target.\n// Empty string ⇒ fail closed (never run an unverified binary).\nconst ASSETS: Record<string, Asset | undefined> = {\n \"linux-x64\": { file: \"cloudflared-linux-amd64\", archive: false, sha256: \"\" },\n \"linux-arm64\": { file: \"cloudflared-linux-arm64\", archive: false, sha256: \"\" },\n \"darwin-x64\": { file: \"cloudflared-darwin-amd64.tgz\", archive: true, sha256: \"\" },\n \"darwin-arm64\": { file: \"cloudflared-darwin-arm64.tgz\", archive: true, sha256: \"\" },\n \"win32-x64\": { file: \"cloudflared-windows-amd64.exe\", archive: false, sha256: \"\" },\n};\n\nfunction binaryWorks(bin: string): boolean {\n try {\n execFileSync(bin, [\"--version\"], { stdio: \"ignore\" });\n return true;\n } catch {\n return false;\n }\n}\n\nfunction cachedPath(): string {\n return join(binDir, process.platform === \"win32\" ? \"cloudflared.exe\" : \"cloudflared\");\n}\n\n/** True on Alpine/musl, where cloudflared has no prebuilt binary. */\nfunction isMusl(): boolean {\n try {\n return process.platform === \"linux\" && readFileSync(\"/usr/bin/ldd\", \"utf8\").includes(\"musl\");\n } catch {\n return false;\n }\n}\n\n/**\n * Return a runnable `cloudflared` with zero user action: PATH → cached download\n * → verified auto-download. Fails closed (never runs an unverified binary).\n */\nexport async function ensureCloudflared(): Promise<string> {\n if (binaryWorks(\"cloudflared\")) return \"cloudflared\";\n const cached = cachedPath();\n if (existsSync(cached) && binaryWorks(cached)) return cached;\n return downloadCloudflared(cached);\n}\n\nasync function downloadCloudflared(dest: string): Promise<string> {\n if (isMusl()) {\n throw new CliError(\"cloudflared has no musl (Alpine) build.\", {\n hint: \"install it manually: https://github.com/cloudflare/cloudflared/releases\",\n });\n }\n const key = `${process.platform}-${process.arch}`;\n const asset = ASSETS[key];\n if (!asset || !asset.sha256) {\n throw new CliError(`Auto-install unavailable for ${key} (no pinned checksum).`, {\n hint: \"install cloudflared manually: https://github.com/cloudflare/cloudflared/releases\",\n });\n }\n\n say.step(`cloudflared not found — downloading v${PINNED_VERSION} (checksum-verified)…`);\n const res = await fetch(`${RELEASE_BASE}/${asset.file}`);\n if (!res.ok) throw new CliError(`Download failed (HTTP ${res.status}).`);\n const bytes = Buffer.from(await res.arrayBuffer());\n\n const digest = createHash(\"sha256\").update(bytes).digest(\"hex\");\n if (digest !== asset.sha256) {\n throw new CliError(\"cloudflared checksum mismatch — refusing to run the download.\", {\n hint: \"network tampering or an outdated pin; install manually instead\",\n });\n }\n\n ensureDirs();\n const binary = asset.archive ? extractTgz(bytes) : bytes;\n writeFileSync(dest, binary, { mode: 0o755 });\n chmodSync(dest, 0o755);\n if (!binaryWorks(dest)) throw new CliError(\"Downloaded cloudflared is not runnable.\");\n return dest;\n}\n\n/** Extract the single `cloudflared` entry from a .tgz (darwin assets). */\nfunction extractTgz(_bytes: Buffer): Buffer {\n // gunzip + untar of a single-file archive; implemented when a darwin\n // checksum is pinned (dormant until then — see ASSETS).\n throw new CliError(\"darwin .tgz extraction not yet wired.\", {\n hint: \"install cloudflared via `brew install cloudflared`\",\n });\n}\n","import { type ChildProcess, execFileSync, spawn } from \"node:child_process\";\nimport { openSync } from \"node:fs\";\nimport { CliError } from \"../ui/errors.js\";\nimport { isOurConnector, type RegistryEntry } from \"./registry.js\";\n\nexport interface StartOptions {\n bin: string;\n token: string;\n detach: boolean;\n logFile: string;\n /** Foreground only: fired when the connector exits for ANY reason (crash,\n * bad token, or a signal) so the caller can tear down / report. */\n onExit?: (code: number | null) => void;\n}\n\nexport interface StartedConnector {\n pid: number;\n child?: ChildProcess;\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\n/**\n * Spawn `cloudflared tunnel run`. The token is passed via the TUNNEL_TOKEN env\n * var — NEVER as an argv arg (argv is world-readable via `ps`/proc). Output goes\n * to a 0600 logfile (both foreground and detached) so the CLI can render its own\n * clean status instead of cloudflared's raw logs.\n */\nexport function startConnector(opts: StartOptions): StartedConnector {\n const args = [\"tunnel\", \"run\"];\n const env = { ...process.env, TUNNEL_TOKEN: opts.token };\n const fd = openSync(opts.logFile, \"a\", 0o600);\n const child = spawn(opts.bin, args, { env, detached: opts.detach, stdio: [\"ignore\", fd, fd] });\n if (!child.pid) throw new CliError(\"Failed to start the cloudflared connector.\");\n\n if (opts.detach) {\n child.unref();\n return { pid: child.pid };\n }\n child.on(\"exit\", (code) => opts.onExit?.(code));\n child.on(\"error\", () => opts.onExit?.(1));\n return { pid: child.pid, child };\n}\n\n/**\n * Stop a connector by registry entry. Verifies the pid is still OUR cloudflared\n * (alive, same boot, right cmdline) BEFORE signalling, so a reused pid held by\n * an unrelated process is never killed. Returns true if a stop was issued.\n */\nexport async function stopConnector(entry: RegistryEntry): Promise<boolean> {\n if (!entry.pid || !(await isOurConnector(entry))) return false;\n const pid = entry.pid;\n\n if (process.platform === \"win32\") {\n try {\n execFileSync(\"taskkill\", [\"/pid\", String(pid), \"/T\", \"/F\"], { stdio: \"ignore\" });\n } catch {\n return false;\n }\n return true;\n }\n\n try {\n process.kill(pid, \"SIGTERM\");\n } catch {\n return false;\n }\n await sleep(3000);\n if (await isOurConnector(entry)) {\n try {\n process.kill(pid, \"SIGKILL\");\n } catch {\n // already gone\n }\n }\n return true;\n}\n","import { existsSync, readFileSync, renameSync, writeFileSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport os from \"node:os\";\nimport lockfile from \"proper-lockfile\";\nimport { ensureDirs, registryFile } from \"../config/paths.js\";\n\nexport type EntryState = \"provisioning\" | \"running\" | \"stopped\" | \"orphaned\";\n\nexport interface RegistryEntry {\n subdomain: string;\n zone: string;\n zoneId: string;\n tunnelId?: string;\n dnsRecordId?: string;\n port: number;\n proto: \"http\" | \"https\";\n pid?: number;\n bootId?: string;\n logFile?: string;\n createdAt: string;\n state: EntryState;\n}\n\ntype Registry = Record<string, RegistryEntry>;\n\n/** Stable per-boot id so a pid reused after a reboot is never mistaken for ours. */\nexport function currentBootId(): string {\n try {\n return readFileSync(\"/proc/sys/kernel/random/boot_id\", \"utf8\").trim();\n } catch {\n return `uptime-${Math.round(os.uptime())}-${os.hostname()}`;\n }\n}\n\nfunction readRegistry(): Registry {\n try {\n return JSON.parse(readFileSync(registryFile, \"utf8\")) as Registry;\n } catch {\n return {};\n }\n}\n\nfunction writeRegistry(reg: Registry): void {\n ensureDirs();\n const tmp = `${registryFile}.tmp`;\n writeFileSync(tmp, JSON.stringify(reg, null, 2), { mode: 0o600 });\n renameSync(tmp, registryFile); // atomic on the same filesystem\n}\n\n/** Lock-guarded read-modify-write (prevents lost updates across concurrent runs). */\nexport async function mutateRegistry<T>(fn: (reg: Registry) => T): Promise<T> {\n ensureDirs();\n if (!existsSync(registryFile)) writeFileSync(registryFile, \"{}\", { mode: 0o600 });\n const release = await lockfile.lock(registryFile, { retries: { retries: 10, minTimeout: 50 } });\n try {\n const reg = readRegistry();\n const result = fn(reg);\n writeRegistry(reg);\n return result;\n } finally {\n await release();\n }\n}\n\nexport function listEntries(): RegistryEntry[] {\n return Object.values(readRegistry());\n}\n\nexport function getEntry(fqdn: string): RegistryEntry | undefined {\n return readRegistry()[fqdn];\n}\n\nexport function upsertEntry(fqdn: string, patch: Partial<RegistryEntry> & Pick<RegistryEntry, \"subdomain\" | \"zone\" | \"zoneId\" | \"port\" | \"proto\">): Promise<void> {\n return mutateRegistry((reg) => {\n const prev = reg[fqdn];\n reg[fqdn] = {\n createdAt: prev?.createdAt ?? new Date().toISOString(),\n state: \"provisioning\",\n ...prev,\n ...patch,\n };\n });\n}\n\n/** Merge changed fields onto an existing entry under the lock (no stale\n * full-snapshot read outside the lock — avoids lost updates). No-op if absent. */\nexport function patchEntry(fqdn: string, patch: Partial<RegistryEntry>): Promise<void> {\n return mutateRegistry((reg) => {\n const prev = reg[fqdn];\n if (prev) reg[fqdn] = { ...prev, ...patch };\n });\n}\n\nexport function removeEntry(fqdn: string): Promise<void> {\n return mutateRegistry((reg) => {\n delete reg[fqdn];\n });\n}\n\nfunction pidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Verify a pid is still OUR cloudflared: alive, same boot, and (Linux) its\n * cmdline is cloudflared — so we never signal a reused pid. */\nexport async function isOurConnector(entry: RegistryEntry): Promise<boolean> {\n if (!entry.pid || entry.bootId !== currentBootId()) return false;\n if (!pidAlive(entry.pid)) return false;\n if (process.platform === \"linux\") {\n try {\n const cmdline = await readFile(`/proc/${entry.pid}/cmdline`, \"utf8\");\n return cmdline.includes(\"cloudflared\");\n } catch {\n return false;\n }\n }\n return true; // non-Linux: bootId + liveness (best effort)\n}\n\n/** Mark entries whose connector is no longer alive as `stopped`. */\nexport async function reconcile(): Promise<RegistryEntry[]> {\n const entries = listEntries();\n for (const entry of entries) {\n if (entry.state === \"running\" && !(await isOurConnector(entry))) {\n const fqdn = `${entry.subdomain}.${entry.zone}`;\n await mutateRegistry((reg) => {\n const e = reg[fqdn];\n if (e) {\n e.state = \"stopped\";\n delete e.pid;\n }\n });\n }\n }\n return listEntries();\n}\n","import { cfPaginate, cfRequest, type Cf } from \"./client.js\";\nimport type { Connection, IngressRule, Tunnel } from \"./types.js\";\n\n/** Tunnels created by cloudtunnel carry this name prefix (ownership marker). */\nexport const MANAGED_TUNNEL_PREFIX = \"ct-\";\n\nexport function isManagedTunnel(tunnel: Tunnel): boolean {\n return tunnel.name.startsWith(MANAGED_TUNNEL_PREFIX);\n}\n\nexport async function createTunnel(cf: Cf, name: string): Promise<Tunnel> {\n const env = await cfRequest<Tunnel>(cf.token, \"POST\", `/accounts/${cf.accountId}/cfd_tunnel`, {\n name,\n config_src: \"cloudflare\",\n });\n return env.result;\n}\n\nexport function listTunnels(cf: Cf): Promise<Tunnel[]> {\n return cfPaginate<Tunnel>(cf.token, `/accounts/${cf.accountId}/cfd_tunnel?is_deleted=false`);\n}\n\nexport async function getTunnel(cf: Cf, id: string): Promise<Tunnel> {\n return (await cfRequest<Tunnel>(cf.token, \"GET\", `/accounts/${cf.accountId}/cfd_tunnel/${id}`)).result;\n}\n\nexport async function deleteTunnel(cf: Cf, id: string): Promise<void> {\n await cfRequest<unknown>(cf.token, \"DELETE\", `/accounts/${cf.accountId}/cfd_tunnel/${id}`);\n}\n\n/** The connector token (encodes tunnelId + secret) passed to `cloudflared`. */\nexport async function getTunnelToken(cf: Cf, id: string): Promise<string> {\n return (await cfRequest<string>(cf.token, \"GET\", `/accounts/${cf.accountId}/cfd_tunnel/${id}/token`)).result;\n}\n\n/** Full-replace ingress config (safe: one hostname + catch-all per tunnel). */\nexport async function putIngress(cf: Cf, id: string, ingress: IngressRule[]): Promise<void> {\n await cfRequest<unknown>(cf.token, \"PUT\", `/accounts/${cf.accountId}/cfd_tunnel/${id}/configurations`, {\n config: { ingress },\n });\n}\n\n/** Active connector instances (≥1 ⇒ tunnel is serving). */\nexport async function getConnections(cf: Cf, id: string): Promise<Connection[]> {\n const env = await cfRequest<Connection[]>(\n cf.token,\n \"GET\",\n `/accounts/${cf.accountId}/cfd_tunnel/${id}/connections`,\n );\n return env.result ?? [];\n}\n","import { getConnections } from \"../cloudflare/tunnels.js\";\nimport type { Cf } from \"../cloudflare/client.js\";\n\nexport type HealthResult = \"healthy\" | \"provisioning\" | \"dead\";\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\n/**\n * Poll the tunnel's connections until it's serving. `signal` is fired by the\n * caller when the connector process exits, so a dead connector returns `dead`\n * immediately instead of waiting out the timeout. `provisioning` is only\n * returned if the process is still alive at the deadline (never a false\n * \"healthy\"). Note: this measures connector↔edge, not local-origin, health.\n */\nexport async function waitHealthy(\n cf: Cf,\n tunnelId: string,\n opts: { signal?: AbortSignal; timeoutMs?: number } = {},\n): Promise<HealthResult> {\n const deadline = Date.now() + (opts.timeoutMs ?? 30_000);\n while (Date.now() < deadline) {\n if (opts.signal?.aborted) return \"dead\";\n try {\n const connections = await getConnections(cf, tunnelId);\n if (connections.length > 0) return \"healthy\";\n } catch {\n // transient API error — keep polling until the deadline\n }\n await sleep(2000);\n }\n return opts.signal?.aborted ? \"dead\" : \"provisioning\";\n}\n","import { randomInt } from \"node:crypto\";\nimport type { Cf } from \"../cloudflare/client.js\";\nimport { resolveZone } from \"../cloudflare/zones.js\";\nimport {\n MANAGED_TUNNEL_PREFIX,\n createTunnel,\n deleteTunnel,\n getTunnel,\n getTunnelToken,\n isManagedTunnel,\n putIngress,\n} from \"../cloudflare/tunnels.js\";\nimport { createCname, deleteDnsRecord, findCname, isManagedDns } from \"../cloudflare/dns.js\";\nimport type { DnsRecord } from \"../cloudflare/types.js\";\nimport { buildIngress } from \"./ingress.js\";\nimport { resolveHostSpec, type HostSpec } from \"./slug.js\";\nimport { currentBootId, patchEntry, removeEntry, upsertEntry } from \"../connector/registry.js\";\nimport { CliError } from \"../ui/errors.js\";\nimport { say } from \"../ui/output.js\";\n\nexport interface CreateOptions {\n port: number;\n proto: \"http\" | \"https\";\n name?: string;\n zone?: string;\n hostname?: string;\n defaultZone?: string;\n force?: boolean;\n}\n\nexport interface CreateResult {\n host: HostSpec;\n tunnelId: string;\n token: string;\n adopted: boolean;\n}\n\nconst tunnelIdFromCname = (content: string): string => content.replace(/\\.cfargotunnel\\.com\\.?$/, \"\");\n\n/**\n * Create (or adopt) a tunnel subdomain transactionally. A `provisioning`\n * registry entry is written BEFORE any Cloudflare resource, so a crash leaves a\n * tracked orphan (recoverable via `gc`). On failure, resources are unwound in\n * reverse; the original error is always surfaced.\n */\nexport async function createTunnelSubdomain(cf: Cf, opts: CreateOptions): Promise<CreateResult> {\n const host = resolveHostSpec(opts, opts.defaultZone);\n const zone = await resolveZone(cf.token, host.zone);\n\n const existing = await findCname(cf.token, zone.id, host.hostname);\n if (existing) {\n // Re-running our own subdomain (no --force) → adopt: reuse the tunnel, update the port.\n if (isManagedDns(existing) && !opts.force) {\n const tunnelId = tunnelIdFromCname(existing.content);\n const token = await getTunnelToken(cf, tunnelId);\n await putIngress(cf, tunnelId, buildIngress({ hostname: host.hostname, port: opts.port, proto: opts.proto }));\n await recordRunning(host, zone.id, tunnelId, existing.id, opts);\n say.dim(`Re-attaching to existing tunnel for ${host.hostname}.`);\n return { host, tunnelId, token, adopted: true };\n }\n // Occupied (someone else's record, or a --force reset) → require --force, then release it.\n if (!opts.force) {\n throw new CliError(`${host.hostname} is already taken by a record not managed by cloudtunnel.`, {\n hint: \"pick another --subdomain/--hostname, or pass -f/--force to take it over\",\n });\n }\n await releaseHostname(cf, zone.id, existing);\n say.dim(`Released ${host.hostname} (--force) — recreating.`);\n }\n\n // Track provisioning BEFORE creating anything irreversible.\n await upsertEntry(host.hostname, {\n subdomain: host.subdomain, zone: host.zone, zoneId: zone.id,\n port: opts.port, proto: opts.proto, state: \"provisioning\",\n });\n\n let tunnelId: string | undefined;\n let dnsRecordId: string | undefined;\n try {\n const suffix = randomInt(0x10000).toString(16).padStart(4, \"0\");\n const tunnel = await createTunnel(cf, `${MANAGED_TUNNEL_PREFIX}${host.subdomain}-${suffix}`);\n tunnelId = tunnel.id;\n const token = await getTunnelToken(cf, tunnelId);\n await putIngress(cf, tunnelId, buildIngress({ hostname: host.hostname, port: opts.port, proto: opts.proto }));\n const record = await createCname(cf.token, zone.id, host.hostname, tunnelId);\n dnsRecordId = record.id;\n await recordRunning(host, zone.id, tunnelId, dnsRecordId, opts);\n return { host, tunnelId, token, adopted: false };\n } catch (err) {\n const clean = await rollback(cf, zone.id, tunnelId, dnsRecordId, host.hostname);\n // Clean unwind ⇒ drop the provisioning entry; a failed unwind ⇒ mark it\n // `orphaned` so `ls`/`gc` flag it for manual cleanup.\n if (clean) await removeEntry(host.hostname);\n else await patchEntry(host.hostname, { state: \"orphaned\" });\n throw err;\n }\n}\n\nasync function recordRunning(host: HostSpec, zoneId: string, tunnelId: string, dnsRecordId: string, opts: CreateOptions): Promise<void> {\n await upsertEntry(host.hostname, {\n subdomain: host.subdomain, zone: host.zone, zoneId,\n tunnelId, dnsRecordId, port: opts.port, proto: opts.proto,\n bootId: currentBootId(), state: \"running\",\n });\n}\n\n/** Free an occupied hostname (for --force): delete its DNS record, and if it\n * pointed at a cloudtunnel-managed tunnel, delete that tunnel too. A foreign\n * tunnel is left alone — we only free the DNS name so our CNAME can be created. */\nasync function releaseHostname(cf: Cf, zoneId: string, record: DnsRecord): Promise<void> {\n if (record.content.endsWith(\".cfargotunnel.com\")) {\n const oldTunnelId = tunnelIdFromCname(record.content);\n try {\n const tunnel = await getTunnel(cf, oldTunnelId);\n if (isManagedTunnel(tunnel)) await deleteTunnel(cf, oldTunnelId);\n } catch {\n /* tunnel already gone or not accessible — freeing the DNS name is enough */\n }\n }\n await deleteDnsRecord(cf.token, zoneId, record.id);\n}\n\n/** Unwind created resources in reverse. Never masks the original error; if a\n * step fails, report the leaked id and return false so the caller marks the\n * entry `orphaned`. */\nasync function rollback(cf: Cf, zoneId: string, tunnelId?: string, dnsRecordId?: string, hostname?: string): Promise<boolean> {\n let clean = true;\n if (dnsRecordId) {\n try { await deleteDnsRecord(cf.token, zoneId, dnsRecordId); }\n catch { clean = false; say.warn(`Left a DNS record behind for ${hostname} (${dnsRecordId}) — run \\`cloudtunnel rm --force ${hostname}\\`.`); }\n }\n if (tunnelId) {\n try { await deleteTunnel(cf, tunnelId); }\n catch { clean = false; say.warn(`Left tunnel ${tunnelId} behind — run \\`cloudtunnel gc\\`.`); }\n }\n return clean;\n}\n","import type { IngressRule } from \"../cloudflare/types.js\";\n\n/**\n * Build the ingress config for a single-hostname tunnel. The mandatory\n * catch-all `http_status:404` rule must come last (Cloudflare rejects configs\n * without it). One-tunnel-per-subdomain keeps this a fixed two-rule list, so\n * the full-replace PUT is always safe (no merge with other hostnames).\n */\nexport function buildIngress(opts: {\n hostname: string;\n port: number;\n proto: \"http\" | \"https\";\n}): IngressRule[] {\n return [\n { hostname: opts.hostname, service: `${opts.proto}://localhost:${opts.port}` },\n { service: \"http_status:404\" },\n ];\n}\n","import { randomInt } from \"node:crypto\";\nimport { CliError } from \"../ui/errors.js\";\n\nconst ADJECTIVES = [\n \"brave\", \"calm\", \"clever\", \"eager\", \"gentle\", \"happy\", \"jolly\", \"kind\",\n \"lively\", \"mighty\", \"nimble\", \"proud\", \"quick\", \"royal\", \"swift\", \"witty\",\n];\nconst NOUNS = [\n \"otter\", \"falcon\", \"maple\", \"comet\", \"harbor\", \"lynx\", \"willow\", \"cedar\",\n \"raven\", \"meadow\", \"pixel\", \"quartz\", \"river\", \"sparrow\", \"tiger\", \"walnut\",\n];\n\nconst pick = <T>(arr: T[]): T => arr[randomInt(arr.length)]!;\n\n/** A friendly random subdomain, e.g. `brave-otter-1a2b` (nport-style default). */\nexport function randomSlug(): string {\n const suffix = randomInt(0x10000).toString(16).padStart(4, \"0\");\n return `${pick(ADJECTIVES)}-${pick(NOUNS)}-${suffix}`;\n}\n\nexport interface HostSpec {\n subdomain: string;\n zone: string;\n hostname: string;\n}\n\n/**\n * Resolve the target hostname from flags. Precedence: --hostname > --name+zone >\n * random-slug+zone. Zone comes from --zone or the saved default; missing zone is\n * an actionable error. (--hostname assumes `label.zone`; deeper subdomains need\n * the zone to be an actual Cloudflare zone.)\n */\nexport function resolveHostSpec(\n opts: { name?: string; zone?: string; hostname?: string },\n defaultZone?: string,\n): HostSpec {\n if (opts.hostname) {\n const dot = opts.hostname.indexOf(\".\");\n if (dot <= 0) throw new CliError(`Invalid hostname: ${opts.hostname}`);\n return {\n subdomain: opts.hostname.slice(0, dot),\n zone: opts.hostname.slice(dot + 1),\n hostname: opts.hostname,\n };\n }\n const zone = opts.zone ?? defaultZone;\n if (!zone) {\n throw new CliError(\"No zone specified and no default zone set.\", {\n hint: \"pass --zone <domain>, or run `cloudtunnel login --zone <domain>`\",\n });\n }\n const subdomain = opts.name ?? randomSlug();\n return { subdomain, zone, hostname: `${subdomain}.${zone}` };\n}\n","import type { Cf } from \"../cloudflare/client.js\";\nimport { resolveZone } from \"../cloudflare/zones.js\";\nimport { deleteTunnel, getTunnel, isManagedTunnel, listTunnels, putIngress } from \"../cloudflare/tunnels.js\";\nimport { deleteDnsRecord, findCname, isManagedDns } from \"../cloudflare/dns.js\";\nimport type { Tunnel } from \"../cloudflare/types.js\";\nimport { buildIngress } from \"./ingress.js\";\nimport { CliError } from \"../ui/errors.js\";\nimport { say } from \"../ui/output.js\";\nimport { getEntry, listEntries, patchEntry, reconcile, removeEntry, type RegistryEntry } from \"../connector/registry.js\";\nimport { stopConnector } from \"../connector/process.js\";\n\nconst tunnelIdFromCname = (content: string): string => content.replace(/\\.cfargotunnel\\.com\\.?$/, \"\");\nconst isNotFound = (err: unknown): boolean => err instanceof CliError && err.status === 404;\nconst zoneFromFqdn = (fqdn: string): string => fqdn.slice(fqdn.indexOf(\".\") + 1);\n\n/** Resolve a `<name|fqdn>` target to its registry entry / fqdn. Refuses an\n * ambiguous bare name that matches multiple zones. */\nexport function resolveTarget(target: string): { fqdn: string; entry?: RegistryEntry } {\n if (target.includes(\".\")) return { fqdn: target, entry: getEntry(target) };\n const matches = listEntries().filter((e) => e.subdomain === target);\n if (matches.length > 1) {\n throw new CliError(`\"${target}\" matches multiple zones.`, {\n hint: `use the full hostname: ${matches.map((m) => `${m.subdomain}.${m.zone}`).join(\", \")}`,\n });\n }\n const entry = matches[0];\n if (!entry) throw new CliError(`No tracked subdomain named \"${target}\".`, { hint: \"pass a full hostname\" });\n return { fqdn: `${entry.subdomain}.${entry.zone}`, entry };\n}\n\nexport interface RemoveOptions { force?: boolean; dryRun?: boolean; keepDns?: boolean }\n\n/** Delete a tunnel subdomain. Re-verifies fresh Cloudflare state (cached ids are\n * hints), ownership-gates unmanaged resources, and tolerates already-deleted parts. */\nexport async function removeTunnelSubdomain(cf: Cf, target: string, opts: RemoveOptions = {}): Promise<void> {\n const { fqdn, entry } = resolveTarget(target);\n if (!entry && !opts.force) {\n throw new CliError(`${fqdn} is not managed by cloudtunnel.`, { hint: \"pass --force to delete it anyway\" });\n }\n const zoneId = entry?.zoneId ?? (await resolveZone(cf.token, zoneFromFqdn(fqdn))).id;\n\n const record = await findCname(cf.token, zoneId, fqdn); // fresh, authoritative\n if (record && !isManagedDns(record) && !opts.force) {\n throw new CliError(`${fqdn} points to a record not managed by cloudtunnel.`, { hint: \"pass --force to delete it\" });\n }\n const tunnelId = record ? tunnelIdFromCname(record.content) : entry?.tunnelId;\n\n if (opts.dryRun) {\n say.info(`Would delete: tunnel ${tunnelId ?? \"(none)\"}${record && !opts.keepDns ? `, DNS ${record.id}` : \"\"}`);\n return;\n }\n\n if (entry) await stopConnector(entry);\n if (tunnelId) {\n let tunnel: Tunnel | undefined;\n try {\n tunnel = await getTunnel(cf, tunnelId);\n } catch (err) {\n if (!isNotFound(err)) throw err; // transient error → don't silently orphan\n }\n if (tunnel && !isManagedTunnel(tunnel) && !opts.force) {\n throw new CliError(`Tunnel ${tunnelId} is not managed by cloudtunnel.`, { hint: \"pass --force\" });\n }\n if (tunnel) {\n try {\n await deleteTunnel(cf, tunnelId);\n } catch (err) {\n if (!isNotFound(err)) throw err;\n }\n }\n }\n if (record && !opts.keepDns) {\n try {\n await deleteDnsRecord(cf.token, zoneId, record.id);\n } catch (err) {\n if (!isNotFound(err)) throw err;\n }\n }\n await removeEntry(fqdn);\n say.ok(`Removed ${fqdn}`);\n}\n\n/** Change the served port/proto. PUT-only — the connector hot-reloads ingress\n * over its edge RPC, so no restart (and no downtime) is needed. */\nexport async function updateIngress(cf: Cf, target: string, port: number, proto?: \"http\" | \"https\"): Promise<void> {\n const { fqdn, entry } = resolveTarget(target);\n if (!entry?.tunnelId) throw new CliError(`No tracked tunnel for ${fqdn}.`);\n const nextProto = proto ?? entry.proto;\n await putIngress(cf, entry.tunnelId, buildIngress({ hostname: fqdn, port, proto: nextProto }));\n await patchEntry(fqdn, { port, proto: nextProto });\n say.ok(`${fqdn} now points to ${nextProto}://localhost:${port} (no restart needed)`);\n}\n\nexport interface LsRow { hostname: string; zone: string; port: string; state: string; managed: boolean }\n\n/** Reconcile + list tracked subdomains (with connector state). `all` also scans\n * every zone for cfargotunnel CNAMEs created outside cloudtunnel. */\nexport async function listAll(cf: Cf, opts: { all?: boolean } = {}): Promise<LsRow[]> {\n const entries = await reconcile();\n const tunnels = new Map((await listTunnels(cf)).map((t) => [t.id, t]));\n const rows: LsRow[] = entries.map((e) => ({\n hostname: `${e.subdomain}.${e.zone}`,\n zone: e.zone,\n port: `${e.proto}://localhost:${e.port}`,\n state: e.tunnelId && !tunnels.has(e.tunnelId) ? \"dangling\" : e.state,\n managed: true,\n }));\n if (opts.all) {\n const { listCargoCnames } = await import(\"../cloudflare/dns.js\");\n const { listZones } = await import(\"../cloudflare/zones.js\");\n const tracked = new Set(entries.map((e) => `${e.subdomain}.${e.zone}`));\n for (const zone of await listZones(cf.token)) {\n for (const rec of await listCargoCnames(cf.token, zone.id)) {\n if (!tracked.has(rec.name)) {\n rows.push({ hostname: rec.name, zone: zone.name, port: \"-\", state: \"unmanaged\", managed: false });\n }\n }\n }\n }\n return rows;\n}\n","import type { Command } from \"commander\";\nimport { printTable, say } from \"../ui/output.js\";\nimport { ensureAuth } from \"../config/ensure-auth.js\";\nimport { resolveCf } from \"../cloudflare/client.js\";\nimport { listAll } from \"../core/orchestrator-manage.js\";\n\nexport function registerLs(program: Command): void {\n program\n .command(\"ls\")\n .description(\"List tunnel subdomains (managed by default; --all scans the whole account)\")\n .option(\"--all\", \"scan every zone in the account (slower; shows unmanaged tunnels too)\")\n .action(async (opts: { all?: boolean }) => {\n await ensureAuth();\n const cf = resolveCf();\n const rows = await listAll(cf, { all: opts.all });\n if (rows.length === 0) {\n say.info(\"No tunnel subdomains yet. Create one: `cloudtunnel 3000`\");\n return;\n }\n printTable(\n [\"SUBDOMAIN\", \"ZONE\", \"TARGET\", \"STATE\"],\n rows.map((r) => [r.hostname, r.zone, r.port, r.state]),\n );\n });\n}\n","import type { Command } from \"commander\";\nimport { ensureAuth } from \"../config/ensure-auth.js\";\nimport { resolveCf } from \"../cloudflare/client.js\";\nimport { removeTunnelSubdomain } from \"../core/orchestrator-manage.js\";\n\ninterface RmOptions { force?: boolean; dryRun?: boolean; keepDns?: boolean }\n\nexport function registerRm(program: Command): void {\n program\n .command(\"rm\")\n .argument(\"<target>\", \"subdomain name or full hostname to delete\")\n .description(\"Delete a tunnel subdomain (stops connector, removes tunnel + DNS)\")\n .option(\"--force\", \"allow deleting a resource not created by cloudtunnel\")\n .option(\"--dry-run\", \"show what would be deleted without deleting\")\n .option(\"--keep-dns\", \"delete the tunnel but leave the DNS record\")\n .action(async (target: string, opts: RmOptions) => {\n await ensureAuth();\n const cf = resolveCf();\n await removeTunnelSubdomain(cf, target, opts);\n });\n}\n","import type { Command } from \"commander\";\nimport { CliError } from \"../ui/errors.js\";\nimport { ensureAuth } from \"../config/ensure-auth.js\";\nimport { resolveCf } from \"../cloudflare/client.js\";\nimport { updateIngress } from \"../core/orchestrator-manage.js\";\n\ninterface UpdateOptions { port?: string; proto?: \"http\" | \"https\" }\n\nexport function registerUpdate(program: Command): void {\n program\n .command(\"update\")\n .argument(\"<name>\", \"subdomain name or full hostname to update\")\n .description(\"Change the local port/protocol a subdomain points to (zero-downtime)\")\n .option(\"--port <port>\", \"new local port\")\n .option(\"--proto <proto>\", \"new local protocol: http | https\")\n .action(async (name: string, opts: UpdateOptions) => {\n if (!opts.port) throw new CliError(\"--port is required\", { hint: \"e.g. `cloudtunnel update myapp --port 8080`\" });\n const port = Number(opts.port);\n if (!Number.isInteger(port) || port < 1 || port > 65535) throw new CliError(`Invalid port: ${opts.port}`);\n await ensureAuth();\n const cf = resolveCf();\n await updateIngress(cf, name, port, opts.proto);\n });\n}\n","import type { Command } from \"commander\";\nimport { CliError } from \"../ui/errors.js\";\nimport { say } from \"../ui/output.js\";\nimport { ensureAuth } from \"../config/ensure-auth.js\";\nimport { resolveCf } from \"../cloudflare/client.js\";\nimport { getConnections } from \"../cloudflare/tunnels.js\";\nimport { isOurConnector } from \"../connector/registry.js\";\nimport { resolveTarget } from \"../core/orchestrator-manage.js\";\n\nexport function registerStatus(program: Command): void {\n program\n .command(\"status\")\n .argument(\"<name>\", \"subdomain name or full hostname\")\n .description(\"Show tunnel health and connector state for a subdomain\")\n .action(async (name: string) => {\n await ensureAuth();\n const cf = resolveCf();\n const { fqdn, entry } = resolveTarget(name);\n if (!entry?.tunnelId) throw new CliError(`No tracked tunnel for ${fqdn}.`);\n const connections = await getConnections(cf, entry.tunnelId);\n const connectorAlive = await isOurConnector(entry);\n say.info(`Host: https://${fqdn}`);\n say.info(`Tunnel: ${entry.tunnelId} — ${connections.length} edge connection(s)`);\n say.info(`Connector: ${connectorAlive ? `running (pid ${entry.pid})` : \"stopped\"}`);\n say.info(`Target: ${entry.proto}://localhost:${entry.port}`);\n });\n}\n","import type { Command } from \"commander\";\nimport { CliError } from \"../ui/errors.js\";\nimport { say } from \"../ui/output.js\";\nimport { listEntries, mutateRegistry, type RegistryEntry } from \"../connector/registry.js\";\nimport { stopConnector } from \"../connector/process.js\";\nimport { resolveTarget } from \"../core/orchestrator-manage.js\";\n\nasync function stopEntry(entry: RegistryEntry): Promise<boolean> {\n const stopped = await stopConnector(entry);\n await mutateRegistry((reg) => {\n const e = reg[`${entry.subdomain}.${entry.zone}`];\n if (e) {\n e.state = \"stopped\";\n delete e.pid;\n }\n });\n return stopped;\n}\n\nexport function registerDown(program: Command): void {\n program\n .command(\"down\")\n .argument(\"[name]\", \"subdomain to stop (omit with --all to stop everything)\")\n .description(\"Stop a running connector, leaving the tunnel + DNS intact\")\n .option(\"--all\", \"stop all running connectors\")\n .action(async (name: string | undefined, opts: { all?: boolean }) => {\n // Purely local — no Cloudflare auth needed to stop a connector process.\n if (opts.all) {\n const running = listEntries().filter((e) => e.pid);\n let stopped = 0;\n for (const entry of running) if (await stopEntry(entry)) stopped++;\n say.ok(`Stopped ${stopped} connector(s).`);\n return;\n }\n if (!name) throw new CliError(\"Pass a subdomain name or --all.\");\n const { fqdn, entry } = resolveTarget(name);\n if (!entry) throw new CliError(`No tracked subdomain for ${fqdn}.`);\n await stopEntry(entry);\n say.ok(`Stopped ${fqdn}.`);\n });\n}\n","import type { Command } from \"commander\";\nimport { say } from \"../ui/output.js\";\nimport { ensureAuth } from \"../config/ensure-auth.js\";\nimport { resolveCf } from \"../cloudflare/client.js\";\nimport { listEntries, reconcile } from \"../connector/registry.js\";\nimport { removeTunnelSubdomain } from \"../core/orchestrator-manage.js\";\n\nexport function registerGc(program: Command): void {\n program\n .command(\"gc\")\n .description(\"Prune crash orphans (provisioning/orphaned entries) after confirmation\")\n .option(\"--yes\", \"skip the confirmation prompt\")\n .action(async (opts: { yes?: boolean }) => {\n await ensureAuth();\n const cf = resolveCf();\n await reconcile();\n const orphans = listEntries().filter((e) => e.state === \"provisioning\" || e.state === \"orphaned\");\n if (orphans.length === 0) {\n say.info(\"Nothing to clean up.\");\n return;\n }\n say.info(`Found ${orphans.length} orphaned entr${orphans.length === 1 ? \"y\" : \"ies\"}:`);\n for (const o of orphans) say.dim(` ${o.subdomain}.${o.zone} (${o.state})`);\n if (!opts.yes) {\n say.warn(\"Re-run with --yes to delete these tunnels/records.\");\n return;\n }\n for (const o of orphans) {\n try {\n await removeTunnelSubdomain(cf, `${o.subdomain}.${o.zone}`, { force: true });\n } catch {\n say.warn(`Could not fully clean ${o.subdomain}.${o.zone} — check the dashboard.`);\n }\n }\n });\n}\n","import type { Command } from \"commander\";\nimport { printTable, say } from \"../ui/output.js\";\nimport { ensureAuth } from \"../config/ensure-auth.js\";\nimport { resolveCf } from \"../cloudflare/client.js\";\nimport { listZones } from \"../cloudflare/zones.js\";\n\nexport function registerZones(program: Command): void {\n program\n .command(\"zones\")\n .description(\"List the zones (domains) available in your Cloudflare account\")\n .action(async () => {\n await ensureAuth();\n const cf = resolveCf();\n const zones = await listZones(cf.token);\n if (zones.length === 0) {\n say.info(\"No zones in this account.\");\n return;\n }\n printTable(\n [\"ZONE\", \"STATUS\", \"ID\"],\n zones.map((z) => [z.name, z.status ?? \"-\", z.id]),\n );\n });\n}\n","import { readFileSync, writeFileSync } from \"node:fs\";\nimport { ensureDirs, profilesFile } from \"../config/paths.js\";\nimport { CliError } from \"../ui/errors.js\";\n\n/** One service in a profile — e.g. `{ name: \"api\", port: 3000 }`. */\nexport interface ProfileService {\n name: string;\n port: number;\n proto: \"http\" | \"https\";\n domain?: string; // overrides the profile/default domain\n}\n\nexport interface Profile {\n services: ProfileService[];\n domain?: string; // default domain for the whole profile\n}\n\ntype Profiles = Record<string, Profile>;\n\nfunction readProfiles(): Profiles {\n try {\n return JSON.parse(readFileSync(profilesFile, \"utf8\")) as Profiles;\n } catch {\n return {};\n }\n}\n\nfunction writeProfiles(profiles: Profiles): void {\n ensureDirs();\n writeFileSync(profilesFile, JSON.stringify(profiles, null, 2), { mode: 0o600 });\n}\n\nexport function listProfiles(): Array<{ name: string; profile: Profile }> {\n return Object.entries(readProfiles()).map(([name, profile]) => ({ name, profile }));\n}\n\nexport function getProfile(name: string): Profile {\n const profile = readProfiles()[name];\n if (!profile) {\n throw new CliError(`No profile named \"${name}\".`, { hint: \"list them with `cloudtunnel profiles`\" });\n }\n return profile;\n}\n\nexport function saveProfile(name: string, profile: Profile): void {\n const profiles = readProfiles();\n profiles[name] = profile;\n writeProfiles(profiles);\n}\n\nexport function removeProfile(name: string): void {\n const profiles = readProfiles();\n if (!profiles[name]) throw new CliError(`No profile named \"${name}\".`);\n delete profiles[name];\n writeProfiles(profiles);\n}\n\n/**\n * Parse a `name:port[:proto]` service spec, e.g. `api:3000` or `web:5173:https`.\n */\nexport function parseServiceSpec(spec: string): ProfileService {\n const [name, portStr, proto] = spec.split(\":\");\n const port = Number(portStr);\n if (!name || !Number.isInteger(port) || port < 1 || port > 65535) {\n throw new CliError(`Invalid service \"${spec}\".`, { hint: \"use name:port, e.g. api:3000 or web:5173:https\" });\n }\n if (proto && proto !== \"http\" && proto !== \"https\") {\n throw new CliError(`Invalid protocol \"${proto}\" in \"${spec}\".`, { hint: \"proto must be http or https\" });\n }\n return { name, port, proto: (proto as \"http\" | \"https\") ?? \"http\" };\n}\n","import type { Command } from \"commander\";\nimport { CliError } from \"../ui/errors.js\";\nimport { say } from \"../ui/output.js\";\nimport { listEntries } from \"../connector/registry.js\";\nimport { parseServiceSpec, saveProfile, type ProfileService } from \"../core/profiles.js\";\n\ninterface SaveOptions { fromRunning?: boolean; domain?: string }\n\nexport function registerSave(program: Command): void {\n program\n .command(\"save\")\n .argument(\"<profile>\", \"profile name, e.g. mb\")\n .argument(\"[services...]\", \"services as name:port[:proto], e.g. api:3000 web:5173\")\n .description(\"Save a group of services as a profile you can `run` together\")\n .option(\"--from-running\", \"snapshot the currently tracked tunnels instead of listing services\")\n .option(\"-d, --domain <domain>\", \"default domain for this profile\")\n .action((profile: string, specs: string[], opts: SaveOptions) => {\n let services: ProfileService[];\n if (opts.fromRunning) {\n const entries = listEntries().filter((e) => e.tunnelId);\n if (entries.length === 0) {\n throw new CliError(\"No tunnels to snapshot.\", { hint: \"start some with `cloudtunnel up`, or pass services like api:3000\" });\n }\n services = entries.map((e) => ({ name: e.subdomain, port: e.port, proto: e.proto, domain: e.zone }));\n } else {\n if (specs.length === 0) {\n throw new CliError(\"No services given.\", { hint: \"e.g. `cloudtunnel save mb api:3000 web:5173`\" });\n }\n services = specs.map(parseServiceSpec);\n }\n saveProfile(profile, { services, domain: opts.domain });\n say.ok(`Saved profile \"${profile}\" (${services.length} service${services.length === 1 ? \"\" : \"s\"}). Run it: cloudtunnel run ${profile}`);\n });\n}\n","import type { Command } from \"commander\";\nimport { join } from \"node:path\";\nimport * as clack from \"@clack/prompts\";\nimport { reportError } from \"../ui/errors.js\";\nimport { dim, formatRoute, say } from \"../ui/output.js\";\nimport { ensureAuth } from \"../config/ensure-auth.js\";\nimport { resolveCf } from \"../cloudflare/client.js\";\nimport { logDir } from \"../config/paths.js\";\nimport { ensureCloudflared } from \"../connector/binary.js\";\nimport { startConnector, stopConnector } from \"../connector/process.js\";\nimport { waitHealthy, type HealthResult } from \"../connector/health.js\";\nimport { currentBootId, getEntry, patchEntry } from \"../connector/registry.js\";\nimport { createTunnelSubdomain } from \"../core/orchestrator-create.js\";\nimport { getProfile } from \"../core/profiles.js\";\n\n/**\n * Run every service in a saved profile at once (e.g. `cloudtunnel run mb` →\n * backend + frontend live together). All connectors run in the foreground;\n * Ctrl-C stops them all (subdomains are kept).\n */\ninterface RunOptions { force?: boolean; domain?: string }\n\nasync function runProfile(name: string, opts: RunOptions): Promise<void> {\n const creds = await ensureAuth();\n const cf = resolveCf();\n const bin = await ensureCloudflared();\n const profile = getProfile(name);\n\n if (process.stdout.isTTY) clack.intro(`cloudtunnel · profile \"${name}\"`);\n const spin = clack.spinner();\n spin.start(\"Creating tunnels…\");\n\n const started: Array<{ fqdn: string; subdomain: string; tunnelId: string; target: string }> = [];\n for (const svc of profile.services) {\n spin.message(`Creating ${svc.name} (:${svc.port})…`);\n const result = await createTunnelSubdomain(cf, {\n port: svc.port, proto: svc.proto, name: svc.name,\n zone: svc.domain ?? opts.domain ?? profile.domain, defaultZone: creds.defaultZone,\n force: opts.force,\n });\n const fqdn = result.host.hostname;\n const logFile = join(logDir, `${result.host.subdomain}.log`);\n const conn = startConnector({\n bin, token: result.token, detach: false, logFile,\n onExit: () => say.warn(`Connector for ${fqdn} exited — check \\`cloudtunnel status ${result.host.subdomain}\\`.`),\n });\n await patchEntry(fqdn, { pid: conn.pid, bootId: currentBootId(), logFile });\n started.push({ fqdn, subdomain: result.host.subdomain, tunnelId: result.tunnelId, target: `${svc.proto}://localhost:${svc.port}` });\n }\n\n spin.message(\"Connecting to the Cloudflare edge…\");\n const healths = await Promise.all(started.map((s) => waitHealthy(cf, s.tunnelId, { timeoutMs: 30_000 })));\n const live = healths.filter((h: HealthResult) => h === \"healthy\").length;\n spin.stop(`${started.length} service(s) started`);\n\n const lines = started.map((s, i) => `${formatRoute(s.fqdn, s.target)}${healths[i] === \"healthy\" ? \"\" : dim(` (${healths[i]})`)}`);\n clack.note(lines.join(\"\\n\"), `profile \"${name}\" — ${live}/${started.length} live`);\n say.dim(\"Ctrl-C stops all connectors (subdomains are kept).\");\n\n let tornDown = false;\n const teardownAll = async (code: number): Promise<void> => {\n if (tornDown) return;\n tornDown = true;\n try {\n for (const s of started) {\n const entry = getEntry(s.fqdn);\n if (entry) await stopConnector(entry);\n }\n if (process.stdout.isTTY) clack.outro(`Stopped ${started.length} connector(s) · subdomains kept`);\n } catch (err) {\n reportError(err);\n } finally {\n process.exit(code);\n }\n };\n for (const sig of [\"SIGINT\", \"SIGHUP\", \"SIGTERM\"] as const) {\n process.on(sig, () => void teardownAll(0));\n }\n}\n\nexport function registerRun(program: Command): void {\n program\n .command(\"run\")\n .argument(\"<profile>\", \"name of a saved profile (see `cloudtunnel profiles`)\")\n .description(\"Start every service in a saved profile at once\")\n .option(\"-f, --force\", \"take over subdomains already occupied by another record\")\n .option(\"-d, --domain <domain>\", \"override the profile's domain for this run\")\n .action((name: string, opts: RunOptions) => runProfile(name, opts));\n}\n","import type { Command } from \"commander\";\nimport { printTable, say } from \"../ui/output.js\";\nimport { listProfiles, removeProfile } from \"../core/profiles.js\";\n\nexport function registerProfiles(program: Command): void {\n program\n .command(\"profiles\")\n .description(\"List saved profiles (or delete one with --rm)\")\n .option(\"--rm <name>\", \"delete a profile\")\n .action((opts: { rm?: string }) => {\n if (opts.rm) {\n removeProfile(opts.rm);\n say.ok(`Deleted profile \"${opts.rm}\".`);\n return;\n }\n const profiles = listProfiles();\n if (profiles.length === 0) {\n say.info(\"No profiles yet. Create one: `cloudtunnel save mb api:3000 web:5173`\");\n return;\n }\n printTable(\n [\"PROFILE\", \"SERVICES\", \"DOMAIN\"],\n profiles.map(({ name, profile }) => [\n name,\n profile.services.map((s) => `${s.name}:${s.port}`).join(\", \"),\n profile.domain ?? \"(default)\",\n ]),\n );\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,OAAOA,SAAQ;;;ACDf,YAAY,WAAW;;;ACDvB,OAAO,QAAQ;AACf,OAAO,WAAW;AA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existsSync","readFileSync","writeFileSync","readFileSync","writeFileSync","existsSync","spawn","execFileSync","sleep","randomInt","tunnelId","randomInt","tunnelIdFromCname","listZones","readFileSync","join","started","entry","readFileSync","writeFileSync","readFileSync","writeFileSync","join","clack","join","require","pc"]}
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ listZones,
4
+ resolveZone
5
+ } from "./chunk-2TCFCMJS.js";
6
+ import "./chunk-UPBVRXLF.js";
7
+ export {
8
+ listZones,
9
+ resolveZone
10
+ };
11
+ //# sourceMappingURL=zones-YNGQYXAF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@iamken/cloudtunnel",
3
+ "version": "0.1.0",
4
+ "description": "Manage Cloudflare Tunnels and subdomains account-wide from the CLI — nport-style instant share.",
5
+ "type": "module",
6
+ "bin": {
7
+ "cloudtunnel": "dist/index.js",
8
+ "ct": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
16
+ "scripts": {
17
+ "build": "tsup",
18
+ "dev": "tsup --watch",
19
+ "typecheck": "tsc --noEmit",
20
+ "lint": "eslint \"src/**/*.ts\"",
21
+ "test": "vitest run",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "cloudflare",
26
+ "tunnel",
27
+ "cloudflared",
28
+ "cli",
29
+ "ngrok",
30
+ "nport",
31
+ "subdomain"
32
+ ],
33
+ "license": "MIT",
34
+ "author": "thanhken <admin@iamken.work>",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/thanhken/cloudtunnel.git"
38
+ },
39
+ "homepage": "https://github.com/thanhken/cloudtunnel#readme",
40
+ "bugs": {
41
+ "url": "https://github.com/thanhken/cloudtunnel/issues"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "dependencies": {
47
+ "@clack/prompts": "^1.7.0",
48
+ "cli-table3": "^0.6.5",
49
+ "commander": "^12.1.0",
50
+ "env-paths": "^3.0.0",
51
+ "picocolors": "^1.1.1",
52
+ "proper-lockfile": "^4.1.2"
53
+ },
54
+ "devDependencies": {
55
+ "@types/node": "^20.14.0",
56
+ "@types/proper-lockfile": "^4.1.4",
57
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
58
+ "@typescript-eslint/parser": "^8.0.0",
59
+ "eslint": "^8.57.0",
60
+ "tsup": "^8.2.0",
61
+ "typescript": "^5.5.0",
62
+ "vitest": "^2.0.0"
63
+ }
64
+ }