node-proxylens 1.3.4 → 1.4.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.
package/README.md CHANGED
@@ -1,13 +1,6 @@
1
1
  # ProxyLens CLI
2
2
 
3
- **[ProxyLens](https://proxylens.dev)** is an AI-powered traffic inspector for your local development environment. This package provides the CLI and Node.js SDK to connect your local applications to the ProxyLens dashboard.
4
-
5
- ## Features
6
-
7
- - **Traffic Inspection**: View and analyze HTTP/HTTPS requests in real-time.
8
- - **Tunneling**: Expose your local server to the internet with a secure tunnel.
9
- - **Request Replay**: Replay requests to test your backend.
10
- - **AI Analysis**: Get AI-driven insights into your API traffic (via dashboard).
3
+ Instant HTTP tunnels and local proxy with a live traffic inspector — no config, no signup required to get started.
11
4
 
12
5
  ## Installation
13
6
 
@@ -15,86 +8,237 @@
15
8
  npm install -g node-proxylens
16
9
  ```
17
10
 
18
- ## CLI Usage
19
-
20
- ### Start Proxying
11
+ ---
21
12
 
22
- To start proxying traffic to your local server:
13
+ ## Quick Start
23
14
 
24
15
  ```bash
25
- # Proxy to a local port (e.g., 3000)
16
+ # Expose localhost:3000 to the internet instantly (no login needed)
26
17
  proxylens 3000
27
-
28
- # Proxy to a specific URL
29
- proxylens http://localhost:8080
30
18
  ```
31
19
 
32
- Running this command will start a proxy server (default port 8000) and open the web dashboard.
20
+ A public URL like `https://happy-tiger.proxylens.dev` is printed. Requests hitting that URL are forwarded to your local server and shown in real time at [proxylens.dev/interceptor](https://proxylens.dev/interceptor).
21
+
22
+ ---
23
+
24
+ ## Modes
33
25
 
34
- ### Public Tunneling
26
+ ### Tunnel Mode (default)
35
27
 
36
- To expose your local server to the internet using a public subdomain:
28
+ Forwards public HTTPS traffic to your local server through ProxyLens's tunnel.
29
+
30
+ **Guest mode** — no login required. A random `adjective-animal.proxylens.dev` domain is assigned for the session.
31
+
32
+ **Authenticated mode** — log in to use a persistent domain from your account:
37
33
 
38
34
  ```bash
39
- # Expose port 3000 with a random or shared subdomain
40
- proxylens 3000 -d my-app
35
+ proxylens login <token>
36
+ proxylens 3000 -d my-app # → https://my-app.proxylens.dev
37
+ proxylens 3000 -d api.mysite.com # → https://api.mysite.com
41
38
  ```
42
39
 
43
- *Note: You may need to login to use custom subdomains.*
40
+ ### Local Proxy Mode (`--local`)
41
+
42
+ Runs a local HTTP proxy on a port instead of creating a tunnel. Point your HTTP client at `http://localhost:<port>` and ProxyLens intercepts everything.
43
+
44
+ ```bash
45
+ proxylens 3000 --local # Proxy on default port 4150
46
+ proxylens 3000 --local -i 5050 # Proxy on port 5050
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Usage
52
+
53
+ ```
54
+ proxylens <target> [flags]
55
+ proxylens <command>
56
+ ```
57
+
58
+ ### Target
59
+
60
+ | Format | Example | Description |
61
+ |---|---|---|
62
+ | Port number | `3000` | Shorthand for `http://localhost:3000` |
63
+ | Host:port | `localhost:3000` | Port is required when using `localhost` |
64
+ | Full URL | `http://192.168.1.5:8080` | Any reachable HTTP server |
65
+ | Domain | `myservice.internal` | Internal hostnames or other machines |
66
+
67
+ ---
44
68
 
45
- ### ProxyLens Dashboard
69
+ ## Flags
46
70
 
47
- Visit [proxylens.dev](https://proxylens.dev) to:
48
- - Get your authentication token for the CLI.
49
- - Manage your domains and tunnels.
50
- - View and analyze your traffic history.
51
- - Collaborate with your team.
71
+ | Flag | Short | Default | Description |
72
+ |---|---|---|---|
73
+ | `--domain <name>` | `-d` | auto-assigned | Subdomain or full custom domain to use for the tunnel. Pass just a name (`my-app`) for a `.proxylens.dev` subdomain, or a full domain (`api.mysite.com`). Requires login. |
74
+ | `--local` | `-l` | off | Run as a local proxy instead of a tunnel. Starts an HTTP proxy server on `--interceptor-port`. |
75
+ | `--interceptor-port <port>` | `-i` | `4150` | Port for the local inspector/proxy server. In tunnel mode this is opt-in; in `--local` mode it is the proxy port. |
76
+ | `--server <url>` | `-s` | `wss://tunnel.proxylens.dev` | Override the tunnel server WebSocket URL. Useful for self-hosted setups. |
77
+ | `--no-ui` | | off | Disable the local inspector UI server. Cannot be combined with `--local`. |
78
+ | `--help` | `-h` | | Print help and exit. |
52
79
 
53
- **View Live Traffic:** Go to [proxylens.dev/interceptor](https://proxylens.dev/interceptor) to see all your traffic in real-time.
80
+ ---
54
81
 
55
- ### Authentication
82
+ ## Commands
56
83
 
57
- Manage your ProxyLens account directly from the CLI.
84
+ ### `proxylens login <token>`
85
+
86
+ Save an API token to `~/.proxylens/config.json`. Get your token from [proxylens.dev/dashboard/tokens](https://proxylens.dev/dashboard/tokens).
58
87
 
59
88
  ```bash
60
- # Login with your authentication token
61
- proxylens login <your-token>
89
+ proxylens login plk_abc123...
90
+ ```
62
91
 
63
- # Check which account you are logged in as
64
- proxylens whoami
92
+ Running `proxylens login` with no token shows your current session if you are already logged in.
65
93
 
66
- # Logout from the CLI
94
+ ### `proxylens logout`
95
+
96
+ Remove the stored credentials.
97
+
98
+ ```bash
67
99
  proxylens logout
68
100
  ```
69
101
 
70
- ### Options
102
+ ### `proxylens whoami`
71
103
 
72
- | Flag | Description |
73
- |------|-------------|
74
- | `target` | The target URL or port to proxy to (e.g., `3000` or `http://localhost:3000`). |
75
- | `[port]` | Optional. The port for ProxyLens to listen on (default: `8000`). usage: `proxylens <target> <port>` |
76
- | `-d <subdomain>` | Request a specific subdomain for the public tunnel. |
77
- | `-u <url>` | Specify a custom server URL (for self-hosted ProxyLens instances, Enterprise option). |
78
- | `--domain <domain>` | Specify a custom root domain (advanced usage). |
104
+ Show the currently authenticated user and plan.
79
105
 
80
- ## Node.js SDK (COMING SOON)
81
- You can also use ProxyLens programmatically in your Node.js applications.
106
+ ```bash
107
+ proxylens whoami
108
+ # Logged in as: user@example.com (pro)
109
+ ```
82
110
 
83
- ```javascript
84
- const { ProxyLens } = require('node-proxylens');
111
+ ### `proxylens domains`
112
+
113
+ List all domains registered in your account with their type and status.
114
+
115
+ ```bash
116
+ proxylens domains
117
+
118
+ # Domain Type Status
119
+ # ──────────────────────────────────────────────────────────────────────
120
+ # my-app.proxylens.dev Free active
121
+ # api.mysite.com Custom active
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Examples
127
+
128
+ ```bash
129
+ # Instant public URL, no login required
130
+ proxylens 3000
131
+
132
+ # Use a persistent subdomain from your account
133
+ proxylens 3000 -d my-app
134
+
135
+ # Use a custom domain (must be registered in the dashboard first)
136
+ proxylens 3000 -d api.mycompany.com
137
+
138
+ # Local proxy on default port 4150 — point your client at http://localhost:4150
139
+ proxylens http://staging.internal --local
140
+
141
+ # Local proxy on a custom port
142
+ proxylens 3000 --local -i 8888
143
+
144
+ # Tunnel + open local inspector UI on port 5050
145
+ proxylens 3000 -i 5050
146
+
147
+ # Tunnel without any local UI server
148
+ proxylens 3000 --no-ui
149
+
150
+ # Use a custom tunnel server
151
+ proxylens 3000 -s wss://tunnel.mycompany.com
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Domain Conflict
157
+
158
+ If you connect with a domain that is already active in another session, ProxyLens will ask:
159
+
160
+ ```
161
+ ⚠ The domain 'my-app.proxylens.dev' is already in use.
162
+ Do you want to close the remote connection and take over? (y/N)
163
+ ```
164
+
165
+ Answering `y` disconnects the previous session and takes over the domain.
166
+
167
+ ---
168
+
169
+ ## Reconnection
170
+
171
+ In tunnel mode, if the connection drops unexpectedly (network error / code 1006), the CLI automatically retries every 3 seconds. It will not retry if the session was intentionally closed or replaced by another client.
172
+
173
+ ---
174
+
175
+ ## Programmatic Usage
176
+
177
+ Embed the ProxyLens inspector into your own Node.js HTTP server to stream traffic to the live UI.
178
+
179
+ ```js
85
180
  const http = require('http');
181
+ const { ProxyLens } = require('node-proxylens');
182
+
183
+ const server = http.createServer((req, res) => {
184
+ res.end('Hello');
185
+ });
86
186
 
87
- const uiServer = http.createServer();
88
- const lens = new ProxyLens(uiServer, {
89
- proxyTarget: 'http://localhost:3000'
187
+ const lens = new ProxyLens(server, {
188
+ historyLimit: 100, // requests kept in memory (default: 50)
189
+ proxyTarget: 'http://localhost:3000', // used when replaying from UI
90
190
  });
91
191
 
92
- // Start the UI server
93
- uiServer.listen(8000, () => {
94
- console.log('ProxyLens dashboard running at http://localhost:8000');
192
+ // Manually log a transaction
193
+ lens.logTransaction({
194
+ id: 'req-1',
195
+ timestamp: Date.now(),
196
+ duration: 42,
197
+ clientIp: '127.0.0.1',
198
+ request: { method: 'GET', path: '/api/users', headers: {}, body: null, queryParams: {} },
199
+ response: { status: 200, statusText: 'OK', headers: {}, body: '[]' },
200
+ pending: false,
95
201
  });
202
+
203
+ server.listen(3000);
96
204
  ```
97
205
 
206
+ The inspector UI connects to `/_proxylens` on your server via WebSocket and streams all logged transactions in real time.
207
+
208
+ ### `ProxyLens` options
209
+
210
+ | Option | Type | Default | Description |
211
+ |---|---|---|---|
212
+ | `historyLimit` | `number` | `50` | Max requests kept in memory and sent to new UI connections on connect |
213
+ | `proxyTarget` | `string` | — | Target URL used when replaying requests from the inspector UI |
214
+ | `domain` | `string` | — | Public domain associated with this instance |
215
+
216
+ ---
217
+
218
+ ## Configuration
219
+
220
+ Credentials are stored in `~/.proxylens/config.json`.
221
+
222
+ Set `PROXY_PORT` as an environment variable to change the default local proxy/inspector port (default: `4150`):
223
+
224
+ ```bash
225
+ PROXY_PORT=8080 proxylens 3000 --local
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Links
231
+
232
+ - Dashboard: [proxylens.dev/dashboard](https://proxylens.dev/dashboard)
233
+ - Live interceptor: [proxylens.dev/interceptor](https://proxylens.dev/interceptor)
234
+ - Docs: [proxylens.dev/docs](https://proxylens.dev/docs)
235
+
236
+ ---
237
+
98
238
  ## License
99
239
 
100
- Copyright (c) 2025 ProxyLens. All rights reserved.
240
+ Copyright © 2025 ProxyLens. All rights reserved.
241
+
242
+ This software is licensed, not sold. You may not copy, modify, distribute, sublicense, or reverse engineer this software except as explicitly permitted by ProxyLens.
243
+
244
+ See [LICENSE](./LICENSE) for the full terms.