@cvasingh/httpsurl
v1.2.0
Published
Expose local servers to the internet via httpsurl.in tunnels
Maintainers
Readme
@cvasingh/httpsurl
CLI tool to expose local HTTP servers to the internet via secure HTTPS tunnels at httpsurl.in.
Published on npm as @cvasingh/httpsurl.
Installation
npm install -g @cvasingh/httpsurlBoth hsurl and httpsurl commands are available after install.
Command Reference
| Command | Aliases | Description |
|---------|---------|-------------|
| hsurl -v | -V, --version | Show version |
| hsurl -h | --help | Show help |
| hsurl login | signin, auth | Authenticate via browser |
| hsurl login --token <t> | | Set token directly |
| hsurl logout | signout | Remove saved credentials |
| hsurl http <port> | live, start, tunnel, expose, serve | Create a tunnel |
| hsurl http <port> -s <url> | | Custom server URL |
| hsurl status | info | Show authentication status |
| hsurl whoami | me | Print current user ID |
Quick Start
# 1. Login
hsurl login
# 2. Start a local server
npx http-server -p 8080
# 3. Expose it
hsurl live 8080Your server is now accessible at https://<tunnelId>.httpsurl.in.
Usage
Login
# Opens browser for Clerk authentication + CLI token exchange
hsurl login
# Or provide a CLI token directly
hsurl login --token <cli-token>
# Aliases
hsurl signin
hsurl authThe login flow:
- CLI starts a temporary localhost HTTP server
- Opens browser to
https://httpsurl.in/cli-auth?callback=http://localhost:PORT - You sign in via Clerk in the browser
- The browser exchanges the Clerk JWT for a long-lived CLI token via
POST /api/cli-token - The CLI token (
cli_<userId>_<hash>) is redirected back to the CLI callback - Token is saved to
~/.httpsurl/credentials.json(chmod 600)
Create a Tunnel
# Expose local port 3000
hsurl http 3000
hsurl live 3000
hsurl start 3000
hsurl tunnel 3000
hsurl expose 3000
hsurl serve 3000
# Custom server URL (for local development)
hsurl http 8080 --server ws://localhost:3000/connectOutput:
i Connecting to wss://httpsurl.in/connect...
i Connected, registering tunnel...
v Tunnel registered!
httpsurl.in
-----------------------------
> Forwarding: https://abc123def456.httpsurl.in
-----------------------------
> GET / 200 12ms
> POST /api/data 201 45ms
> GET /style.css 200 3msAccount
# Check auth status
hsurl status
hsurl info
# Print user ID
hsurl whoami
hsurl me
# Logout
hsurl logout
hsurl signoutModules
cli.js -- Commander CLI
Commands with aliases:
login(signin,auth) -- Opens browser to Clerk sign-in, exchanges JWT for CLI tokenhttp(live,start,tunnel,expose,serve) -- Creates tunnel with--serveroptionstatus(info) -- Shows authentication status and credentials pathwhoami(me) -- Prints current user IDlogout(signout) -- Removes saved credentials
tunnel-client.js -- WebSocket Client
- Connects to server, sends
registermessage with CLI token - Receives
registeredwith tunnel URL - Handles
requestmessages by proxying to local server vialocal-proxy.js - Sends
responseorresponse_errorback - Auto-reconnects with exponential backoff on disconnect
- Preserves tunnel ID across reconnections (within 60s grace period)
local-proxy.js -- HTTP Proxy
- Makes HTTP requests to
127.0.0.1:<port> - Strips
hostandx-tunnel-hostheaders - Base64 encodes/decodes request and response bodies
- 30s timeout per request
reconnect.js -- Exponential Backoff
- Initial delay: 1s
- Doubles each attempt: 1s -> 2s -> 4s -> 8s -> 16s -> 30s (max)
- Resets on successful reconnection
- Cancellable
logger.js -- Terminal Output
Colored output using chalk:
info-- bluesuccess-- greenwarn-- yellowerror-- redrequest-- method-colored badges with status code and latencybanner-- formatted tunnel URL display
protocol.js -- Message Constants
Shared message type constants (duplicated from server for simplicity):
MSG_REGISTER,MSG_RESPONSE,MSG_RESPONSE_ERRORMSG_REGISTERED,MSG_REQUEST,MSG_ERROR
Dependencies
| Package | Purpose | |---------|---------| | ws | WebSocket client | | commander | CLI argument parsing | | chalk (v4, CJS) | Terminal colors | | nanoid (v3, CJS) | Request ID generation | | open (v8) | Open browser for login |
