nport 2.1.1 โ 2.1.3
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/dist/bin-manager.js +1 -209
- package/dist/index.js +69 -91
- package/package.json +7 -7
- package/CHANGELOG.md +0 -449
- package/dist/analytics.d.ts +0 -59
- package/dist/analytics.js +0 -193
- package/dist/analytics.js.map +0 -1
- package/dist/api.d.ts +0 -20
- package/dist/api.js +0 -85
- package/dist/api.js.map +0 -1
- package/dist/args.d.ts +0 -44
- package/dist/args.js +0 -127
- package/dist/args.js.map +0 -1
- package/dist/bin-manager.d.ts +0 -1
- package/dist/bin-manager.js.map +0 -1
- package/dist/binary.d.ts +0 -42
- package/dist/binary.js +0 -119
- package/dist/binary.js.map +0 -1
- package/dist/config-manager.d.ts +0 -54
- package/dist/config-manager.js +0 -129
- package/dist/config-manager.js.map +0 -1
- package/dist/config.d.ts +0 -25
- package/dist/config.js +0 -59
- package/dist/config.js.map +0 -1
- package/dist/constants.d.ts +0 -61
- package/dist/constants.js +0 -86
- package/dist/constants.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.js.map +0 -1
- package/dist/lang.d.ts +0 -38
- package/dist/lang.js +0 -217
- package/dist/lang.js.map +0 -1
- package/dist/state.d.ts +0 -82
- package/dist/state.js +0 -139
- package/dist/state.js.map +0 -1
- package/dist/tunnel.d.ts +0 -16
- package/dist/tunnel.js +0 -101
- package/dist/tunnel.js.map +0 -1
- package/dist/types/analytics.d.ts +0 -91
- package/dist/types/analytics.js +0 -8
- package/dist/types/analytics.js.map +0 -1
- package/dist/types/config.d.ts +0 -89
- package/dist/types/config.js +0 -8
- package/dist/types/config.js.map +0 -1
- package/dist/types/i18n.d.ts +0 -75
- package/dist/types/i18n.js +0 -5
- package/dist/types/i18n.js.map +0 -1
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.js +0 -7
- package/dist/types/index.js.map +0 -1
- package/dist/types/tunnel.d.ts +0 -74
- package/dist/types/tunnel.js +0 -8
- package/dist/types/tunnel.js.map +0 -1
- package/dist/types/version.d.ts +0 -25
- package/dist/types/version.js +0 -5
- package/dist/types/version.js.map +0 -1
- package/dist/ui.d.ts +0 -54
- package/dist/ui.js +0 -120
- package/dist/ui.js.map +0 -1
- package/dist/version.d.ts +0 -16
- package/dist/version.js +0 -49
- package/dist/version.js.map +0 -1
package/CHANGELOG.md
DELETED
|
@@ -1,449 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to NPort will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [2.1.1] - 2026-01-27
|
|
9
|
-
|
|
10
|
-
### Fixed
|
|
11
|
-
- ๐ **NPM Package Build**: Fixed missing `dist/` folder in published package
|
|
12
|
-
- Added build step to npm-publish workflow before publishing
|
|
13
|
-
- Package now includes compiled JavaScript files correctly
|
|
14
|
-
|
|
15
|
-
### Added
|
|
16
|
-
- ๐ **CI/CD Workflows**: Added GitHub Actions for automated deployments
|
|
17
|
-
- `ci.yml`: Runs tests on push to main and pull requests
|
|
18
|
-
- `deploy-server.yml`: Auto-deploys Cloudflare Worker on server changes
|
|
19
|
-
- `deploy-website.yml`: Auto-deploys website to Cloudflare Pages on changes
|
|
20
|
-
- ๐งช **Server Test Configuration**: Fixed Vitest config for CI environment
|
|
21
|
-
- Added miniflare bindings for test environment variables
|
|
22
|
-
- Tests now pass in CI without `.dev.vars` file
|
|
23
|
-
- โ๏ธ **Wrangler Configuration**: Added `preview_urls` setting to suppress warnings
|
|
24
|
-
|
|
25
|
-
## [2.1.0] - 2026-01-27
|
|
26
|
-
|
|
27
|
-
### Added
|
|
28
|
-
- ๐ท **Full TypeScript Migration**: Complete rewrite of CLI and Server in TypeScript
|
|
29
|
-
- Strict type checking enabled across the entire codebase
|
|
30
|
-
- All modules converted from JavaScript to TypeScript
|
|
31
|
-
- Type-safe interfaces for configuration, tunnels, analytics, and i18n
|
|
32
|
-
- Better IDE support with IntelliSense and autocompletion
|
|
33
|
-
- ๐ **Comprehensive Documentation**: New docs folder with detailed guides
|
|
34
|
-
- `docs/ARCHITECTURE.md`: System overview, component diagrams, and data flow
|
|
35
|
-
- `docs/API.md`: Complete API reference with endpoints and examples
|
|
36
|
-
- `docs/CONTRIBUTING.md`: Contribution guidelines and development setup
|
|
37
|
-
- ๐ค **AI Context Support**: Added `.ai/context.md` for AI-assisted development
|
|
38
|
-
- Project structure and key patterns documented
|
|
39
|
-
- Coding conventions and architecture decisions
|
|
40
|
-
- Makes AI pair programming more effective
|
|
41
|
-
- ๐งช **Unit Testing with Vitest**: Comprehensive test suite for CLI
|
|
42
|
-
- Tests for argument parsing (`tests/args.test.ts`)
|
|
43
|
-
- Tests for version comparison (`tests/version.test.ts`)
|
|
44
|
-
- Tests for state management (`tests/state.test.ts`)
|
|
45
|
-
- Easy to run with `npm test`
|
|
46
|
-
- ๐ **Code Ownership**: Added `.github/CODEOWNERS` file
|
|
47
|
-
- Clear ownership for code review assignments
|
|
48
|
-
- Faster PR reviews with automatic reviewer assignment
|
|
49
|
-
- ๐ **Cursor Rules**: Added `.cursorrules` for consistent AI assistance
|
|
50
|
-
- Project-specific coding conventions
|
|
51
|
-
- TypeScript and naming guidelines
|
|
52
|
-
- Common patterns and anti-patterns
|
|
53
|
-
- ๐ **Auto-download Cloudflared**: Binary downloads automatically on first run
|
|
54
|
-
- No need to run separate install commands
|
|
55
|
-
- Seamless first-time user experience
|
|
56
|
-
- Progress indicator during download
|
|
57
|
-
- ๐ **Protected Subdomain Support**: Enhanced error handling for reserved subdomains
|
|
58
|
-
- User-friendly error message when trying to create protected subdomains (like `api`)
|
|
59
|
-
- Formatted error output matching existing error style
|
|
60
|
-
- Helpful suggestions to use alternative subdomain names
|
|
61
|
-
- Prevents accidental use of backend service subdomains
|
|
62
|
-
- ๐ **TODO Management**: Added `TODO.md` for tracking planned features
|
|
63
|
-
- Move time limit enforcement to backend
|
|
64
|
-
- Update README powered-by section
|
|
65
|
-
- Track terminal link clicks
|
|
66
|
-
|
|
67
|
-
### Changed
|
|
68
|
-
- ๐๏ธ **Project Structure**: Reorganized for better maintainability
|
|
69
|
-
- All source code in `src/` directory
|
|
70
|
-
- Type definitions in `src/types/`
|
|
71
|
-
- Shared constants in `src/constants.ts`
|
|
72
|
-
- Tests in `tests/` directory
|
|
73
|
-
- ๐ฆ **Build System**: Updated to TypeScript compilation
|
|
74
|
-
- Uses `tsc` for compilation
|
|
75
|
-
- Output to `dist/` directory
|
|
76
|
-
- Source maps for debugging
|
|
77
|
-
- ๐ง **Development Workflow**: Improved developer experience
|
|
78
|
-
- `npm run dev` for watch mode
|
|
79
|
-
- `npm run build` for production
|
|
80
|
-
- `npm test` for running tests
|
|
81
|
-
- `npm run lint` for type checking
|
|
82
|
-
- โ๏ธ **System Requirements**: Updated to Node.js 20+
|
|
83
|
-
- Minimum Node.js version: 20.0.0
|
|
84
|
-
- Minimum npm version: 10.0.0
|
|
85
|
-
- Better security and performance with latest LTS
|
|
86
|
-
|
|
87
|
-
### Improved
|
|
88
|
-
- โจ **Better Error Messages**: Enhanced user feedback for protected subdomains
|
|
89
|
-
- Catches `SUBDOMAIN_PROTECTED` errors from backend
|
|
90
|
-
- Formats error messages consistently with other error types
|
|
91
|
-
- Shows actionable options when subdomain is reserved
|
|
92
|
-
|
|
93
|
-
### Fixed
|
|
94
|
-
- ๐ **Intel Mac Binary Download**: Fixed cloudflared binary download on Intel Macs
|
|
95
|
-
- Node.js reports architecture as `x64`, not `amd64` - now correctly mapped
|
|
96
|
-
- Fixed ARM64 Macs to download the correct `cloudflared-darwin-arm64.tgz` binary
|
|
97
|
-
- Previously ARM64 Macs were incorrectly downloading the AMD64 binary
|
|
98
|
-
|
|
99
|
-
### Server (v1.1.0)
|
|
100
|
-
- ๐ท **TypeScript Migration**: Server fully converted to TypeScript
|
|
101
|
-
- Type-safe Cloudflare Worker handlers
|
|
102
|
-
- Properly typed API responses
|
|
103
|
-
- Full type coverage for Cloudflare API interactions
|
|
104
|
-
- ๐งช **Server Tests**: Updated test suite for TypeScript
|
|
105
|
-
- Vitest with Cloudflare Workers pool
|
|
106
|
-
- Tests for all API endpoints
|
|
107
|
-
- Scheduled task testing
|
|
108
|
-
- ๐ **Protected Subdomains**: Infrastructure to protect critical subdomains from deletion or overwriting
|
|
109
|
-
- New `PROTECTED_SUBDOMAINS` constant array for easy management of reserved subdomains
|
|
110
|
-
- Default protected subdomain: `api` (reserved for NPort backend service)
|
|
111
|
-
- Easy to add more protected subdomains by updating the array
|
|
112
|
-
- Protected subdomains are blocked at both creation and cleanup stages
|
|
113
|
-
- ๐ก๏ธ **Backend Service Protection**: Prevents accidental deletion or overwriting of production services
|
|
114
|
-
- `api` subdomain is now protected from user creation attempts
|
|
115
|
-
- Scheduled cleanup job skips protected subdomains
|
|
116
|
-
- Returns clear error message when users try to use protected names
|
|
117
|
-
- ๐ง **Manual Cleanup Endpoint**: Added `GET /scheduled` endpoint to manually trigger cleanup
|
|
118
|
-
- Useful for testing and on-demand cleanup
|
|
119
|
-
- Respects protected subdomains configuration
|
|
120
|
-
- Returns JSON response with cleanup results
|
|
121
|
-
|
|
122
|
-
### Technical Details
|
|
123
|
-
- **Type System**:
|
|
124
|
-
- `TunnelConfig`, `TunnelState`, `ConnectionInfo` interfaces
|
|
125
|
-
- `AnalyticsParams`, `VersionInfo`, `I18nStrings` types
|
|
126
|
-
- `LogPatterns` with readonly arrays for constants
|
|
127
|
-
- **ESM Compliance**: All imports use `.js` extensions as required
|
|
128
|
-
- **Constants**: Centralized in `src/constants.ts` with `as const` assertions
|
|
129
|
-
- **Error Handling**: Type-safe error boundaries throughout
|
|
130
|
-
|
|
131
|
-
### Migration
|
|
132
|
-
- Automatic migration - no manual steps required
|
|
133
|
-
- Existing configuration in `~/.nport/config.json` remains compatible
|
|
134
|
-
- All CLI flags and options unchanged
|
|
135
|
-
|
|
136
|
-
### Breaking Changes
|
|
137
|
-
- None - fully backward compatible!
|
|
138
|
-
|
|
139
|
-
## [2.0.7] - 2026-01-14
|
|
140
|
-
|
|
141
|
-
### Added
|
|
142
|
-
- ๐ **Smart Network Warning System**: Intelligent handling of QUIC/network connectivity issues
|
|
143
|
-
- Automatic detection and filtering of QUIC protocol errors
|
|
144
|
-
- User-friendly warning messages instead of scary red error spam
|
|
145
|
-
- Bilingual support (English & Vietnamese)
|
|
146
|
-
- Smart throttling: Shows warning only after 5 errors, max once per 30 seconds
|
|
147
|
-
- Clear explanations of what's happening and how to fix it
|
|
148
|
-
- Automatic reset when connection is restored
|
|
149
|
-
- ๐ **Protected Subdomain Support**: Enhanced error handling for reserved subdomains
|
|
150
|
-
- User-friendly error message when trying to create protected subdomains (like `api`)
|
|
151
|
-
- Formatted error output matching existing error style
|
|
152
|
-
- Helpful suggestions to use alternative subdomain names
|
|
153
|
-
- Prevents accidental use of backend service subdomains
|
|
154
|
-
|
|
155
|
-
### Improved
|
|
156
|
-
- ๐ **Cleaner Terminal Output**: No more error spam from cloudflared
|
|
157
|
-
- QUIC timeout errors are now silently tracked instead of displayed
|
|
158
|
-
- Network warnings filtered: "failed to accept QUIC stream", "timeout: no recent network activity", etc.
|
|
159
|
-
- Only shows meaningful warnings when there's an actual persistent issue
|
|
160
|
-
- Terminal stays clean and readable during normal operation
|
|
161
|
-
- ๐ก **Better User Communication**: Context-aware network issue reporting
|
|
162
|
-
- Explains that QUIC failures are usually not critical
|
|
163
|
-
- Tunnel continues working via HTTP/2 fallback
|
|
164
|
-
- Provides actionable troubleshooting steps
|
|
165
|
-
- Reassures users that the tunnel is still functional
|
|
166
|
-
- โจ **Better Error Messages**: Enhanced user feedback for protected subdomains
|
|
167
|
-
- Catches `SUBDOMAIN_PROTECTED` errors from backend
|
|
168
|
-
- Formats error messages consistently with other error types
|
|
169
|
-
- Shows actionable options when subdomain is reserved
|
|
170
|
-
|
|
171
|
-
### Technical Details
|
|
172
|
-
- **Network Error Patterns**: Added detection for 7 common QUIC/network error patterns
|
|
173
|
-
- **State Management**: New network issue tracking in application state
|
|
174
|
-
- `networkIssueCount`: Counter for network errors
|
|
175
|
-
- `lastNetworkWarningTime`: Timestamp tracking for cooldown
|
|
176
|
-
- `shouldShowNetworkWarning()`: Smart decision logic
|
|
177
|
-
- **Configuration**: New `NETWORK_CONFIG` with threshold and cooldown settings
|
|
178
|
-
- **Bilingual Messages**: Complete translations for all network warning messages
|
|
179
|
-
- **Protected Subdomain Handling**: Enhanced error handling in `src/api.js`
|
|
180
|
-
- Added check for `SUBDOMAIN_PROTECTED` error type
|
|
181
|
-
- Consistent formatting with existing error messages
|
|
182
|
-
- Clear user guidance for alternative subdomain choices
|
|
183
|
-
|
|
184
|
-
### User Experience
|
|
185
|
-
**Before:**
|
|
186
|
-
```
|
|
187
|
-
[Cloudflared] 2026-01-14T04:33:02Z ERR failed to accept QUIC stream...
|
|
188
|
-
[Cloudflared] 2026-01-14T04:33:03Z ERR failed to accept QUIC stream...
|
|
189
|
-
[Cloudflared] 2026-01-14T04:33:04Z ERR failed to accept QUIC stream...
|
|
190
|
-
[Cloudflared] 2026-01-14T04:33:05Z ERR failed to accept QUIC stream...
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
**After:**
|
|
194
|
-
```
|
|
195
|
-
โ [1/2] Connection established...
|
|
196
|
-
โ [2/2] Compression enabled...
|
|
197
|
-
|
|
198
|
-
โ ๏ธ NETWORK CONNECTIVITY ISSUE DETECTED
|
|
199
|
-
Cloudflared is having trouble maintaining a stable connection...
|
|
200
|
-
๐ก Your tunnel is still working, but connection quality may be affected.
|
|
201
|
-
|
|
202
|
-
๐ก Possible reasons:
|
|
203
|
-
โข Unstable internet connection or high packet loss
|
|
204
|
-
โข Firewall/Router blocking UDP traffic (QUIC protocol)
|
|
205
|
-
โข ISP throttling or network congestion
|
|
206
|
-
|
|
207
|
-
๐ง What to try:
|
|
208
|
-
โข Check your internet connection stability
|
|
209
|
-
โข Try connecting from a different network
|
|
210
|
-
โข Disable VPN/Proxy if you're using one
|
|
211
|
-
|
|
212
|
-
โน๏ธ This is usually not critical - your tunnel should continue working normally.
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## [2.0.6] - 2026-01-13
|
|
216
|
-
|
|
217
|
-
### Added
|
|
218
|
-
- ๐ง **Backend URL Configuration**: Full control over backend server
|
|
219
|
-
- `--backend` / `-b` flag for temporary backend override
|
|
220
|
-
- `--set-backend` command to save backend URL permanently
|
|
221
|
-
- `NPORT_BACKEND_URL` environment variable support
|
|
222
|
-
- Saved backend configuration persists across sessions
|
|
223
|
-
- Priority system: CLI flag > Saved config > Env var > Default
|
|
224
|
-
- ๐๏ธ **Unified Configuration System**: All settings in one place
|
|
225
|
-
- New centralized `config-manager.js` module
|
|
226
|
-
- All preferences stored in `~/.nport/config.json`
|
|
227
|
-
- Automatic migration from old format (v2.0.5)
|
|
228
|
-
- Easy to read and manually edit JSON format
|
|
229
|
-
- ๐ **New Default Backend**: Updated to `api.nport.link`
|
|
230
|
-
- Professional domain structure
|
|
231
|
-
- Better branding alignment
|
|
232
|
-
- Shorter and easier to remember
|
|
233
|
-
|
|
234
|
-
### Changed
|
|
235
|
-
- ๐ **Language Configuration**: Now uses unified config system
|
|
236
|
-
- Language setting moved from `~/.nport/lang` to `~/.nport/config.json`
|
|
237
|
-
- Automatic migration from old file format
|
|
238
|
-
- Consistent configuration approach across all settings
|
|
239
|
-
- ๐ **Documentation Updates**: Complete overhaul
|
|
240
|
-
- Updated `README.md` with backend configuration options
|
|
241
|
-
- New `CLIENT_SETUP.md` focused on npm installation and backend setup
|
|
242
|
-
- Comprehensive backend URL documentation
|
|
243
|
-
- Clear priority order explanation
|
|
244
|
-
|
|
245
|
-
### Improved
|
|
246
|
-
- ๐ฏ **Consistency**: Unified approach to all configuration
|
|
247
|
-
- Backend URL and language now use same storage system
|
|
248
|
-
- Single config file for all preferences
|
|
249
|
-
- Cleaner architecture and code organization
|
|
250
|
-
- ๐พ **Configuration File Structure**:
|
|
251
|
-
```json
|
|
252
|
-
{
|
|
253
|
-
"backendUrl": "https://api.nport.link",
|
|
254
|
-
"language": "en"
|
|
255
|
-
}
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
### Migration
|
|
259
|
-
- Automatic migration from v2.0.5 configuration files
|
|
260
|
-
- Old `~/.nport/lang` file automatically migrated to `config.json`
|
|
261
|
-
- No manual steps required
|
|
262
|
-
- Old files removed after successful migration
|
|
263
|
-
|
|
264
|
-
## [2.0.5] - 2026-01-13
|
|
265
|
-
|
|
266
|
-
### Added
|
|
267
|
-
- ๐ **Multilingual Support**: Full internationalization with English and Vietnamese
|
|
268
|
-
- Interactive language selection on first run
|
|
269
|
-
- `--language` / `-l` flag to change language anytime
|
|
270
|
-
- Language preference saved to `~/.nport/lang`
|
|
271
|
-
- ๐จ **Enhanced UI**: Complete redesign with better visual hierarchy
|
|
272
|
-
- New header design with Vietnamese pride
|
|
273
|
-
- Improved connection status messages
|
|
274
|
-
- Better formatted output with consistent spacing
|
|
275
|
-
- Language change hint in goodbye message
|
|
276
|
-
- ๐ **Modular Architecture**: Refactored codebase into organized modules
|
|
277
|
-
- Split code into `/src` directory with clear separation of concerns
|
|
278
|
-
- Better maintainability and testability
|
|
279
|
-
- Modules: config, state, args, binary, api, version, ui, tunnel, lang, analytics
|
|
280
|
-
- โ
**Version Command**: Added `-v` / `--version` flag
|
|
281
|
-
- Shows current version
|
|
282
|
-
- Checks for updates automatically
|
|
283
|
-
- Displays update instructions if available
|
|
284
|
-
- ๐ **Configuration Directory**: Organized config files under `~/.nport/`
|
|
285
|
-
- Language preference: `~/.nport/lang`
|
|
286
|
-
- Analytics ID: `~/.nport/analytics-id`
|
|
287
|
-
|
|
288
|
-
### Changed
|
|
289
|
-
- ๐ฏ **Improved Console Output**: Better formatting and spacing throughout
|
|
290
|
-
- Connection messages now properly indented
|
|
291
|
-
- Time remaining display updated
|
|
292
|
-
- Footer redesigned with clearer calls-to-action
|
|
293
|
-
- ๐ง **Better Argument Parsing**: Enhanced CLI argument handling
|
|
294
|
-
- Support for multiple language flag formats
|
|
295
|
-
- Interactive prompt when using `--language` without value
|
|
296
|
-
- ๐ **Updated Documentation**: Complete README overhaul
|
|
297
|
-
- Added multilingual feature documentation
|
|
298
|
-
- New CLI options table
|
|
299
|
-
- Project structure documentation
|
|
300
|
-
- Cleaner examples and better organization
|
|
301
|
-
|
|
302
|
-
### Fixed
|
|
303
|
-
- ๐ **Terminal Compatibility**: Removed problematic emoji flags
|
|
304
|
-
- Vietnamese flag emoji replaced with text
|
|
305
|
-
- Better compatibility across different terminals
|
|
306
|
-
|
|
307
|
-
## [2.0.4] - Previous Release
|
|
308
|
-
|
|
309
|
-
### Features
|
|
310
|
-
- Basic tunnel functionality
|
|
311
|
-
- Custom subdomain support
|
|
312
|
-
- Cloudflare integration
|
|
313
|
-
- Auto-cleanup on exit
|
|
314
|
-
- 4-hour tunnel timeout
|
|
315
|
-
|
|
316
|
-
---
|
|
317
|
-
|
|
318
|
-
## Version Upgrade Guide
|
|
319
|
-
|
|
320
|
-
### From 2.0.7 to 2.1.0
|
|
321
|
-
|
|
322
|
-
```bash
|
|
323
|
-
npm install -g nport@latest
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
**What's New:**
|
|
327
|
-
|
|
328
|
-
1. **Full TypeScript Rewrite**
|
|
329
|
-
- Both CLI and Server now fully typed
|
|
330
|
-
- Better IDE support and autocompletion
|
|
331
|
-
- Catches errors at compile time
|
|
332
|
-
|
|
333
|
-
2. **Comprehensive Documentation**
|
|
334
|
-
- Architecture guide in `docs/ARCHITECTURE.md`
|
|
335
|
-
- API reference in `docs/API.md`
|
|
336
|
-
- Contributing guide in `docs/CONTRIBUTING.md`
|
|
337
|
-
|
|
338
|
-
3. **Unit Testing**
|
|
339
|
-
- Run tests with `npm test`
|
|
340
|
-
- Covers argument parsing, version checks, state management
|
|
341
|
-
|
|
342
|
-
4. **Auto-download Cloudflared**
|
|
343
|
-
- Binary downloads automatically on first `nport` run
|
|
344
|
-
- No separate install step needed
|
|
345
|
-
|
|
346
|
-
5. **AI-Friendly Codebase**
|
|
347
|
-
- `.ai/context.md` for AI assistants
|
|
348
|
-
- `.cursorrules` for consistent AI suggestions
|
|
349
|
-
- JSDoc comments throughout
|
|
350
|
-
|
|
351
|
-
**For Contributors:**
|
|
352
|
-
```bash
|
|
353
|
-
git clone https://github.com/tuanngocptn/nport
|
|
354
|
-
cd nport
|
|
355
|
-
npm install
|
|
356
|
-
npm run build
|
|
357
|
-
npm run dev # Watch mode
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
**Breaking Changes:** None - fully backward compatible!
|
|
361
|
-
|
|
362
|
-
### From 2.0.6 to 2.0.7
|
|
363
|
-
|
|
364
|
-
```bash
|
|
365
|
-
npm install -g nport@latest
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
**What's New:**
|
|
369
|
-
|
|
370
|
-
1. **Cleaner Terminal Experience**
|
|
371
|
-
- No more scary red QUIC error spam
|
|
372
|
-
- Smart network warnings when needed
|
|
373
|
-
- Automatic fallback to HTTP/2 when QUIC fails
|
|
374
|
-
|
|
375
|
-
2. **Better Error Communication**
|
|
376
|
-
- Understand what's happening with your connection
|
|
377
|
-
- Clear explanations in your language (EN/VI)
|
|
378
|
-
- Actionable troubleshooting steps
|
|
379
|
-
|
|
380
|
-
3. **When You'll See Warnings**
|
|
381
|
-
- Only after multiple network issues (not just one)
|
|
382
|
-
- Maximum once every 30 seconds (no spam)
|
|
383
|
-
- Automatically disappears when connection improves
|
|
384
|
-
|
|
385
|
-
**Breaking Changes:** None - fully backward compatible!
|
|
386
|
-
|
|
387
|
-
### From 2.0.5 to 2.0.6
|
|
388
|
-
|
|
389
|
-
```bash
|
|
390
|
-
npm install -g nport@latest
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
**New Features to Try:**
|
|
394
|
-
|
|
395
|
-
1. **Set Your Backend Permanently**
|
|
396
|
-
```bash
|
|
397
|
-
nport --set-backend https://api.nport.link
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
2. **Use Custom Backend Temporarily**
|
|
401
|
-
```bash
|
|
402
|
-
nport 3000 -b https://your-backend.com
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
3. **Check Current Configuration**
|
|
406
|
-
```bash
|
|
407
|
-
cat ~/.nport/config.json
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
4. **Use Environment Variable**
|
|
411
|
-
```bash
|
|
412
|
-
export NPORT_BACKEND_URL=https://your-backend.com
|
|
413
|
-
nport 3000
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
**Breaking Changes:** None - fully backward compatible!
|
|
417
|
-
|
|
418
|
-
**Migration:** Your language preference from v2.0.5 will be automatically migrated to the new unified config format.
|
|
419
|
-
|
|
420
|
-
### From 2.0.4 to 2.0.5
|
|
421
|
-
|
|
422
|
-
```bash
|
|
423
|
-
npm install -g nport@latest
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
**New Features to Try:**
|
|
427
|
-
|
|
428
|
-
1. **Change Language**
|
|
429
|
-
```bash
|
|
430
|
-
nport --language
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
2. **Check Version**
|
|
434
|
-
```bash
|
|
435
|
-
nport -v
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
3. **Direct Language Selection**
|
|
439
|
-
```bash
|
|
440
|
-
nport 3000 -l vi # Vietnamese
|
|
441
|
-
nport 3000 -l en # English
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
**Breaking Changes:** None - fully backward compatible!
|
|
445
|
-
|
|
446
|
-
---
|
|
447
|
-
|
|
448
|
-
Made with โค๏ธ in Vietnam by [Nick Pham](https://github.com/tuanngocptn)
|
|
449
|
-
|
package/dist/analytics.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Analytics Manager
|
|
3
|
-
*/
|
|
4
|
-
declare class AnalyticsManager {
|
|
5
|
-
private userId;
|
|
6
|
-
private sessionId;
|
|
7
|
-
private disabled;
|
|
8
|
-
constructor();
|
|
9
|
-
/**
|
|
10
|
-
* Initializes analytics.
|
|
11
|
-
*/
|
|
12
|
-
initialize(): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Gets or creates a persistent user ID.
|
|
15
|
-
*/
|
|
16
|
-
private getUserId;
|
|
17
|
-
/**
|
|
18
|
-
* Generates an anonymous user ID.
|
|
19
|
-
*/
|
|
20
|
-
private generateAnonymousId;
|
|
21
|
-
/**
|
|
22
|
-
* Generates a session ID.
|
|
23
|
-
*/
|
|
24
|
-
private generateSessionId;
|
|
25
|
-
/**
|
|
26
|
-
* Tracks an event.
|
|
27
|
-
*/
|
|
28
|
-
private trackEvent;
|
|
29
|
-
/**
|
|
30
|
-
* Builds GA4 payload.
|
|
31
|
-
*/
|
|
32
|
-
private buildPayload;
|
|
33
|
-
/**
|
|
34
|
-
* Gets system information.
|
|
35
|
-
*/
|
|
36
|
-
private getSystemInfo;
|
|
37
|
-
/**
|
|
38
|
-
* Tracks CLI start.
|
|
39
|
-
*/
|
|
40
|
-
trackCliStart(port: number, subdomain: string, version: string): void;
|
|
41
|
-
/**
|
|
42
|
-
* Tracks tunnel creation.
|
|
43
|
-
*/
|
|
44
|
-
trackTunnelCreated(subdomain: string, port: number): void;
|
|
45
|
-
/**
|
|
46
|
-
* Tracks tunnel error.
|
|
47
|
-
*/
|
|
48
|
-
trackTunnelError(errorType: string, errorMessage: string): void;
|
|
49
|
-
/**
|
|
50
|
-
* Tracks tunnel shutdown.
|
|
51
|
-
*/
|
|
52
|
-
trackTunnelShutdown(reason: string, durationSeconds: number): void;
|
|
53
|
-
/**
|
|
54
|
-
* Tracks update available.
|
|
55
|
-
*/
|
|
56
|
-
trackUpdateAvailable(currentVersion: string, latestVersion: string): void;
|
|
57
|
-
}
|
|
58
|
-
export declare const analytics: AnalyticsManager;
|
|
59
|
-
export {};
|
package/dist/analytics.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { createHash, randomUUID } from 'crypto';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { ANALYTICS_TIMEOUT } from './constants.js';
|
|
7
|
-
/**
|
|
8
|
-
* Firebase/GA4 Configuration
|
|
9
|
-
*/
|
|
10
|
-
const FIREBASE_CONFIG = {
|
|
11
|
-
measurementId: 'G-8MYXZL6PGD',
|
|
12
|
-
apiSecret: process.env.NPORT_ANALYTICS_SECRET || 'YOUR_API_SECRET_HERE',
|
|
13
|
-
};
|
|
14
|
-
const ANALYTICS_CONFIG = {
|
|
15
|
-
enabled: true,
|
|
16
|
-
debug: process.env.NPORT_DEBUG === 'true',
|
|
17
|
-
timeout: ANALYTICS_TIMEOUT,
|
|
18
|
-
userIdFile: path.join(os.homedir(), '.nport', 'analytics-id'),
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Analytics Manager
|
|
22
|
-
*/
|
|
23
|
-
class AnalyticsManager {
|
|
24
|
-
userId = null;
|
|
25
|
-
sessionId = null;
|
|
26
|
-
disabled = false;
|
|
27
|
-
constructor() {
|
|
28
|
-
if (process.env.NPORT_ANALYTICS === 'false') {
|
|
29
|
-
this.disabled = true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Initializes analytics.
|
|
34
|
-
*/
|
|
35
|
-
async initialize() {
|
|
36
|
-
if (this.disabled)
|
|
37
|
-
return;
|
|
38
|
-
if (!FIREBASE_CONFIG.apiSecret || FIREBASE_CONFIG.apiSecret === 'YOUR_API_SECRET_HERE') {
|
|
39
|
-
if (ANALYTICS_CONFIG.debug) {
|
|
40
|
-
console.warn('[Analytics] API secret not configured. Analytics disabled.');
|
|
41
|
-
}
|
|
42
|
-
this.disabled = true;
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
this.userId = await this.getUserId();
|
|
47
|
-
this.sessionId = this.generateSessionId();
|
|
48
|
-
if (ANALYTICS_CONFIG.debug) {
|
|
49
|
-
console.log('[Analytics] Initialized successfully');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
this.disabled = true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Gets or creates a persistent user ID.
|
|
58
|
-
*/
|
|
59
|
-
async getUserId() {
|
|
60
|
-
try {
|
|
61
|
-
const configDir = path.join(os.homedir(), '.nport');
|
|
62
|
-
if (!fs.existsSync(configDir)) {
|
|
63
|
-
fs.mkdirSync(configDir, { recursive: true });
|
|
64
|
-
}
|
|
65
|
-
if (fs.existsSync(ANALYTICS_CONFIG.userIdFile)) {
|
|
66
|
-
const userId = fs.readFileSync(ANALYTICS_CONFIG.userIdFile, 'utf8').trim();
|
|
67
|
-
if (userId)
|
|
68
|
-
return userId;
|
|
69
|
-
}
|
|
70
|
-
const userId = this.generateAnonymousId();
|
|
71
|
-
fs.writeFileSync(ANALYTICS_CONFIG.userIdFile, userId, 'utf8');
|
|
72
|
-
return userId;
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
return this.generateAnonymousId();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Generates an anonymous user ID.
|
|
80
|
-
*/
|
|
81
|
-
generateAnonymousId() {
|
|
82
|
-
const machineId = [
|
|
83
|
-
os.hostname(),
|
|
84
|
-
os.platform(),
|
|
85
|
-
os.arch(),
|
|
86
|
-
os.homedir(),
|
|
87
|
-
].join('-');
|
|
88
|
-
return createHash('sha256').update(machineId).digest('hex').substring(0, 32);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Generates a session ID.
|
|
92
|
-
*/
|
|
93
|
-
generateSessionId() {
|
|
94
|
-
return randomUUID();
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Tracks an event.
|
|
98
|
-
*/
|
|
99
|
-
async trackEvent(eventName, params = {}) {
|
|
100
|
-
if (this.disabled || !ANALYTICS_CONFIG.enabled || !this.userId)
|
|
101
|
-
return;
|
|
102
|
-
try {
|
|
103
|
-
const payload = this.buildPayload(eventName, params);
|
|
104
|
-
axios.post(`https://www.google-analytics.com/mp/collect?measurement_id=${FIREBASE_CONFIG.measurementId}&api_secret=${FIREBASE_CONFIG.apiSecret}`, payload, {
|
|
105
|
-
timeout: ANALYTICS_CONFIG.timeout,
|
|
106
|
-
headers: { 'Content-Type': 'application/json' },
|
|
107
|
-
}).catch(() => {
|
|
108
|
-
// Silently fail
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
// Silently fail
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Builds GA4 payload.
|
|
117
|
-
*/
|
|
118
|
-
buildPayload(eventName, params) {
|
|
119
|
-
return {
|
|
120
|
-
client_id: this.userId,
|
|
121
|
-
events: [
|
|
122
|
-
{
|
|
123
|
-
name: eventName,
|
|
124
|
-
params: {
|
|
125
|
-
session_id: this.sessionId,
|
|
126
|
-
engagement_time_msec: '100',
|
|
127
|
-
...this.getSystemInfo(),
|
|
128
|
-
...params,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Gets system information.
|
|
136
|
-
*/
|
|
137
|
-
getSystemInfo() {
|
|
138
|
-
return {
|
|
139
|
-
os_platform: os.platform(),
|
|
140
|
-
os_version: os.release(),
|
|
141
|
-
os_arch: os.arch(),
|
|
142
|
-
node_version: process.version,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Tracks CLI start.
|
|
147
|
-
*/
|
|
148
|
-
trackCliStart(port, subdomain, version) {
|
|
149
|
-
this.trackEvent('cli_start', {
|
|
150
|
-
port: String(port),
|
|
151
|
-
has_custom_subdomain: subdomain && !subdomain.startsWith('user-'),
|
|
152
|
-
cli_version: version,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Tracks tunnel creation.
|
|
157
|
-
*/
|
|
158
|
-
trackTunnelCreated(subdomain, port) {
|
|
159
|
-
this.trackEvent('tunnel_created', {
|
|
160
|
-
subdomain_type: subdomain.startsWith('user-') ? 'random' : 'custom',
|
|
161
|
-
port: String(port),
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Tracks tunnel error.
|
|
166
|
-
*/
|
|
167
|
-
trackTunnelError(errorType, errorMessage) {
|
|
168
|
-
this.trackEvent('tunnel_error', {
|
|
169
|
-
error_type: errorType,
|
|
170
|
-
error_message: errorMessage.substring(0, 100),
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Tracks tunnel shutdown.
|
|
175
|
-
*/
|
|
176
|
-
trackTunnelShutdown(reason, durationSeconds) {
|
|
177
|
-
this.trackEvent('tunnel_shutdown', {
|
|
178
|
-
shutdown_reason: reason,
|
|
179
|
-
duration_seconds: String(Math.floor(durationSeconds)),
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Tracks update available.
|
|
184
|
-
*/
|
|
185
|
-
trackUpdateAvailable(currentVersion, latestVersion) {
|
|
186
|
-
this.trackEvent('update_available', {
|
|
187
|
-
current_version: currentVersion,
|
|
188
|
-
latest_version: latestVersion,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
export const analytics = new AnalyticsManager();
|
|
193
|
-
//# sourceMappingURL=analytics.js.map
|