portless 0.5.2 → 0.7.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/LICENSE +201 -0
- package/README.md +104 -130
- package/dist/{chunk-P3DHZHEZ.js → chunk-Y6FWHU6F.js} +158 -39
- package/dist/cli.js +360 -95
- package/dist/index.d.ts +14 -10
- package/dist/index.js +3 -3
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ interface ProxyServerOptions {
|
|
|
12
12
|
getRoutes: () => RouteInfo[];
|
|
13
13
|
/** The port the proxy is listening on (used to build correct URLs). */
|
|
14
14
|
proxyPort: number;
|
|
15
|
+
/** TLD suffix used for hostnames (default: "localhost"). */
|
|
16
|
+
tld?: string;
|
|
15
17
|
/** Optional error logger; defaults to console.error. */
|
|
16
18
|
onError?: (message: string) => void;
|
|
17
19
|
/** When provided, enables HTTP/2 over TLS (HTTPS). */
|
|
@@ -99,7 +101,8 @@ declare class RouteStore {
|
|
|
99
101
|
|
|
100
102
|
/**
|
|
101
103
|
* When running under sudo, fix file ownership so the real user can
|
|
102
|
-
* read/write the file later without sudo. No-op
|
|
104
|
+
* read/write the file later without sudo. No-op on Windows or when not
|
|
105
|
+
* running as root.
|
|
103
106
|
*/
|
|
104
107
|
declare function fixOwnership(...paths: string[]): void;
|
|
105
108
|
/** Type guard for Node.js system errors with an error code. */
|
|
@@ -109,15 +112,16 @@ declare function isErrnoException(err: unknown): err is NodeJS.ErrnoException;
|
|
|
109
112
|
*/
|
|
110
113
|
declare function escapeHtml(str: string): string;
|
|
111
114
|
/**
|
|
112
|
-
* Format a
|
|
113
|
-
* (80 for HTTP, 443 for HTTPS).
|
|
115
|
+
* Format a URL for the given hostname. Omits the port when it matches the
|
|
116
|
+
* protocol default (80 for HTTP, 443 for HTTPS).
|
|
114
117
|
*/
|
|
115
118
|
declare function formatUrl(hostname: string, proxyPort: number, tls?: boolean): string;
|
|
116
119
|
/**
|
|
117
|
-
* Parse and normalize a hostname input for use as a
|
|
118
|
-
* Strips protocol prefixes, validates characters, and
|
|
120
|
+
* Parse and normalize a hostname input for use as a subdomain of the
|
|
121
|
+
* configured TLD. Strips protocol prefixes, validates characters, and
|
|
122
|
+
* appends the TLD suffix if needed.
|
|
119
123
|
*/
|
|
120
|
-
declare function parseHostname(input: string): string;
|
|
124
|
+
declare function parseHostname(input: string, tld?: string): string;
|
|
121
125
|
|
|
122
126
|
/**
|
|
123
127
|
* Extract the portless-managed block from /etc/hosts content.
|
|
@@ -150,9 +154,9 @@ declare function cleanHostsFile(): boolean;
|
|
|
150
154
|
*/
|
|
151
155
|
declare function getManagedHostnames(): string[];
|
|
152
156
|
/**
|
|
153
|
-
* Check whether a
|
|
154
|
-
*
|
|
157
|
+
* Check whether a hostname resolves to 127.0.0.1 via the system DNS resolver.
|
|
158
|
+
* Returns true if resolution works, false otherwise.
|
|
155
159
|
*/
|
|
156
|
-
declare function
|
|
160
|
+
declare function checkHostResolution(hostname: string): Promise<boolean>;
|
|
157
161
|
|
|
158
|
-
export { DIR_MODE, FILE_MODE, PORTLESS_HEADER, type ProxyServer, type ProxyServerOptions, RouteConflictError, type RouteInfo, type RouteMapping, RouteStore, SYSTEM_DIR_MODE, SYSTEM_FILE_MODE, buildBlock,
|
|
162
|
+
export { DIR_MODE, FILE_MODE, PORTLESS_HEADER, type ProxyServer, type ProxyServerOptions, RouteConflictError, type RouteInfo, type RouteMapping, RouteStore, SYSTEM_DIR_MODE, SYSTEM_FILE_MODE, buildBlock, checkHostResolution, cleanHostsFile, createProxyServer, escapeHtml, extractManagedBlock, fixOwnership, formatUrl, getManagedHostnames, isErrnoException, parseHostname, removeBlock, syncHostsFile };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SYSTEM_DIR_MODE,
|
|
8
8
|
SYSTEM_FILE_MODE,
|
|
9
9
|
buildBlock,
|
|
10
|
-
|
|
10
|
+
checkHostResolution,
|
|
11
11
|
cleanHostsFile,
|
|
12
12
|
createProxyServer,
|
|
13
13
|
escapeHtml,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
parseHostname,
|
|
20
20
|
removeBlock,
|
|
21
21
|
syncHostsFile
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-Y6FWHU6F.js";
|
|
23
23
|
export {
|
|
24
24
|
DIR_MODE,
|
|
25
25
|
FILE_MODE,
|
|
@@ -29,7 +29,7 @@ export {
|
|
|
29
29
|
SYSTEM_DIR_MODE,
|
|
30
30
|
SYSTEM_FILE_MODE,
|
|
31
31
|
buildBlock,
|
|
32
|
-
|
|
32
|
+
checkHostResolution,
|
|
33
33
|
cleanHostsFile,
|
|
34
34
|
createProxyServer,
|
|
35
35
|
escapeHtml,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "portless",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Replace port numbers with stable, named .localhost URLs. For humans and agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,19 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"os": [
|
|
24
24
|
"darwin",
|
|
25
|
-
"linux"
|
|
25
|
+
"linux",
|
|
26
|
+
"win32"
|
|
26
27
|
],
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "tsup",
|
|
29
|
-
"dev": "tsup --watch",
|
|
30
|
-
"lint": "eslint src/",
|
|
31
|
-
"lint:fix": "eslint src/ --fix",
|
|
32
|
-
"prepublishOnly": "cp ../../README.md . && pnpm build",
|
|
33
|
-
"test": "vitest run",
|
|
34
|
-
"test:coverage": "vitest run --coverage",
|
|
35
|
-
"test:watch": "vitest",
|
|
36
|
-
"typecheck": "tsc --noEmit"
|
|
37
|
-
},
|
|
38
28
|
"keywords": [
|
|
39
29
|
"local",
|
|
40
30
|
"development",
|
|
@@ -61,5 +51,15 @@
|
|
|
61
51
|
"tsup": "^8.0.1",
|
|
62
52
|
"typescript": "^5.3.3",
|
|
63
53
|
"vitest": "^4.0.18"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup",
|
|
57
|
+
"dev": "tsup --watch",
|
|
58
|
+
"lint": "eslint src/",
|
|
59
|
+
"lint:fix": "eslint src/ --fix",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"test:coverage": "vitest run --coverage",
|
|
62
|
+
"test:watch": "vitest",
|
|
63
|
+
"typecheck": "tsc --noEmit"
|
|
64
64
|
}
|
|
65
|
-
}
|
|
65
|
+
}
|