{"_id":"@awelabs/tunnel","name":"@awelabs/tunnel","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@awelabs/tunnel","version":"0.1.0","description":"Cloudflare Named Tunnel and Quick Tunnel CLI for local development.","type":"module","sideEffects":false,"license":"MIT","author":{"name":"AWE"},"bin":{"tunnel":"dist/cli.js"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"dependencies":{"@clack/prompts":"^1.2.0","cloudflared":"^0.7.1","commander":"^14.0.3","picocolors":"^1.1.1","tree-kill":"^1.2.2"},"devDependencies":{"@types/node":"^22.9.0","tsup":"^8.3.0","typescript":"^5.6.3"},"scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_id":"@awelabs/tunnel@0.1.0","_integrity":"sha512-1Z6RUKxHCfFlZjRlYjgVIMbvGwzJiLQyEdzhQhIZq+6jbhBzkqx25EC7qbd0JQmExwwZNk74xV7Hb9uFJ4RQFw==","_resolved":"/tmp/b0242c3f95608a790e8c707af0d9a554/awelabs-tunnel-0.1.0.tgz","_from":"file:awelabs-tunnel-0.1.0.tgz","_nodeVersion":"22.23.2","_npmVersion":"10.9.8","dist":{"integrity":"sha512-1Z6RUKxHCfFlZjRlYjgVIMbvGwzJiLQyEdzhQhIZq+6jbhBzkqx25EC7qbd0JQmExwwZNk74xV7Hb9uFJ4RQFw==","shasum":"ef851ece36d862921efb10012136dc6cf5999264","tarball":"https://registry.npmjs.org/@awelabs/tunnel/-/tunnel-0.1.0.tgz","fileCount":12,"unpackedSize":120256,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAST7EmRYA24PGyJ0/862sNTl0KRrUNLaI6wShiT/uq+AiAEC+80gSB0IIPILKSKw7peO5f6JrhTPOEy0psU3I0SRA=="}]},"_npmUser":{"name":"awelabs","email":"vulq.dev@gmail.com"},"directories":{},"maintainers":[{"name":"awelabs","email":"vulq.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tunnel_0.1.0_1787076737523_0.29984564494339794"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-18T18:12:17.235Z","0.1.0":"2026-08-18T18:12:17.665Z","modified":"2026-08-18T18:12:17.958Z"},"maintainers":[{"name":"awelabs","email":"vulq.dev@gmail.com"}],"description":"Cloudflare Named Tunnel and Quick Tunnel CLI for local development.","author":{"name":"AWE"},"license":"MIT","readme":"# @awelabs/tunnel\n\nCloudflare tunnel CLI for local development. Exposes a local port over the\ninternet — either a **Quick Tunnel** (zero-config, random `*.trycloudflare.com`\nURL) or a **Named Tunnel** (stable hostname on your own domain).\n\n## CLI\n\n```bash\n# Quick tunnel (no account needed)\nPORT=3000 tunnel\n\n# Named tunnel on your domain, and run your app with the public URL injected\nPORT=3000 tunnel --host dev.example.com --exec \"npm run dev -- --url {TUNNEL_URL}\"\n```\n\nFlags: `--host`, `--port`, `--cert`, `--exec` (`{TUNNEL_URL}` is substituted).\n`PORT` and `TUNNEL_HOST` may also come from the environment or a local `.env`.\n\n## Mode detection\n\nThe mode is chosen by **`cert.pem` presence**, not by env flags:\n\n- **`cert.pem` found AND a host is set** → Named Tunnel.\n- **otherwise** → Quick Tunnel.\n\n## Named Tunnel auth — `cert.pem`, no API token\n\nA Named Tunnel authenticates with the account **origin certificate** produced by:\n\n```bash\ncloudflared tunnel login\n```\n\nThat writes `~/.cloudflared/cert.pem`. This cert *is* the account credential —\nit authorizes **creating tunnels** and **routing DNS** for your zones, so no\n`CF_API_TOKEN` / `CF_ACCOUNT_ID` is needed.\n\n`cert.pem` is resolved in priority order:\n\n1. `--cert <path>`\n2. `TUNNEL_ORIGIN_CERT` env var\n3. `<cwd>/cert.pem` (repo-local)\n4. `~/.cloudflared/cert.pem` (default)\n\nThe resolved path is exported as `TUNNEL_ORIGIN_CERT`, then the bundled\n`cloudflared` binary is driven to, idempotently:\n\n1. `cloudflared tunnel create <name>` — name derived from the host's first label.\n2. `cloudflared tunnel route dns <name> <host>` — CNAME → `<tunnel>.cfargotunnel.com`.\n3. `cloudflared tunnel run --url http://localhost:<port> <name>` — resolves once a\n   connection registers; returns `https://<host>`.\n\nIf no `cert.pem` is found, the CLI falls back to a Quick Tunnel automatically.\n\n## Library\n\n```ts\nimport { startQuickTunnel, startNamedTunnel, resolveCertPath } from \"@awelabs/tunnel\"\n\nconst cert = resolveCertPath()               // string | null\nconst url = cert\n  ? await startNamedTunnel(\"dev.example.com\", \"3000\", cert)\n  : await startQuickTunnel(\"3000\")\n```\n","readmeFilename":"README.md","_rev":"1-85ed25e1b6423a1b72b6721698d0a6cc"}