@stacksjs/rpx 0.11.19 → 0.11.21
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/acme-challenge.d.ts +13 -0
- package/dist/auth.d.ts +21 -0
- package/dist/bin/cli.js +252 -200
- package/dist/cert-inspect.d.ts +5 -3
- package/dist/{chunk-83dqq28c.js → chunk-1108y1dk.js} +1 -1
- package/dist/{chunk-0f32jmrb.js → chunk-c9brkawa.js} +1 -1
- package/dist/{chunk-w888yhnp.js → chunk-cqkz06bg.js} +1 -1
- package/dist/chunk-qs36t2rf.js +224 -0
- package/dist/daemon.d.ts +4 -1
- package/dist/https.d.ts +1 -0
- package/dist/index.d.ts +33 -1
- package/dist/index.js +7 -7
- package/dist/proxy-handler.d.ts +18 -1
- package/dist/proxy-pool.d.ts +5 -0
- package/dist/redirect.d.ts +40 -0
- package/dist/registry.d.ts +2 -1
- package/dist/site-resolver.d.ts +106 -0
- package/dist/site-splash.d.ts +19 -0
- package/dist/site-supervisor.d.ts +56 -0
- package/dist/start.d.ts +31 -8
- package/dist/types.d.ts +64 -0
- package/package.json +6 -7
- package/dist/chunk-rs8gqpax.js +0 -174
- package/src/cert-inspect.ts +0 -69
- package/src/colors.ts +0 -13
- package/src/config.ts +0 -45
- package/src/daemon-runner.ts +0 -180
- package/src/daemon.ts +0 -1209
- package/src/dns-state.ts +0 -116
- package/src/dns.ts +0 -568
- package/src/host-match.ts +0 -52
- package/src/host-routes.ts +0 -147
- package/src/hosts.ts +0 -283
- package/src/https.ts +0 -905
- package/src/index.ts +0 -161
- package/src/logger.ts +0 -19
- package/src/macos-trust.ts +0 -175
- package/src/on-demand.ts +0 -264
- package/src/origin-guard.ts +0 -127
- package/src/port-manager.ts +0 -183
- package/src/process-manager.ts +0 -164
- package/src/proxy-handler.ts +0 -387
- package/src/proxy-pool.ts +0 -1003
- package/src/registry.ts +0 -366
- package/src/sni.ts +0 -93
- package/src/start.ts +0 -1421
- package/src/static-files.ts +0 -201
- package/src/types.ts +0 -267
- package/src/utils.ts +0 -243
package/dist/start.d.ts
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
1
|
+
import { createOriginGuard } from './origin-guard';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import type { CleanupOptions, ProxyOption, ProxyOptions, ProxySetupOptions, SingleProxyConfig, SSLConfig } from './types';
|
|
4
|
+
import type { ProxyRoute } from './proxy-handler';
|
|
5
|
+
import type { SniTlsEntry } from './sni';
|
|
5
6
|
export declare function cleanup(options?: CleanupOptions): Promise<void>;
|
|
6
7
|
export declare function startServer(options: SingleProxyConfig): Promise<void>;
|
|
7
8
|
export declare function setupProxy(options: ProxySetupOptions): Promise<void>;
|
|
8
|
-
export declare function startHttpRedirectServer(verbose?: boolean): void;
|
|
9
|
+
export declare function startHttpRedirectServer(verbose?: boolean, httpPort?: number, httpsPort?: number, acmeChallengeWebroot?: string): void;
|
|
9
10
|
export declare function startProxy(options: ProxyOption): void;
|
|
10
11
|
export declare function startProxies(options?: ProxyOptions): Promise<void>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Build the `(host, path, route)` entries for a shared single-port listener from
|
|
14
|
+
* the resolved per-proxy options, and ensure an `/etc/hosts` entry exists for
|
|
15
|
+
* each non-localhost domain (once per domain). Several proxies can share one
|
|
16
|
+
* domain on different paths (e.g. `/api` → app, `/docs` → static dir, `/` →
|
|
17
|
+
* public) — `buildHostRoutes` groups + longest-prefix-sorts them later. Shared
|
|
18
|
+
* by the single-port HTTPS and HTTP paths so routing is identical regardless of
|
|
19
|
+
* whether TLS is terminated.
|
|
20
|
+
*/
|
|
21
|
+
export declare function collectRouteEntries(proxyOptions: ProxyOption[], hostsEnabled: boolean, verbose: boolean): Promise<Array<{ host: string, path?: string, route: ProxyRoute }>>;
|
|
22
|
+
/**
|
|
23
|
+
* Create a single shared `Bun.serve` listener that routes every request by
|
|
24
|
+
* `Host` header (and path) to the right upstream. When `sslConfig` is provided
|
|
25
|
+
* the listener terminates TLS; otherwise it serves plain HTTP (single-port HTTP
|
|
26
|
+
* mode). Registers the server for cleanup and returns it, or `null` if
|
|
27
|
+
* `Bun.serve` threw (e.g. the port could not be bound).
|
|
28
|
+
*/
|
|
29
|
+
export declare function createSharedProxyServer(opts: {
|
|
30
|
+
routeEntries: Array<{ host: string, path?: string, route: ProxyRoute }>
|
|
31
|
+
listenPort: number
|
|
32
|
+
sslConfig: SharedTlsConfig | null
|
|
33
|
+
originGuard: ReturnType<typeof createOriginGuard> | null
|
|
34
|
+
verbose: boolean
|
|
35
|
+
}): ReturnType<typeof Bun.serve> | null;
|
|
36
|
+
declare type SharedTlsConfig = SSLConfig | SniTlsEntry[];
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OriginGuardOptions } from './origin-guard';
|
|
2
|
+
import type { RedirectRouteConfig } from './redirect';
|
|
2
3
|
import type { TlsConfig, TlsOption } from '@stacksjs/tlsx';
|
|
3
4
|
export type { TlsConfig, TlsOption };
|
|
4
5
|
export declare interface StartOptions {
|
|
@@ -17,13 +18,28 @@ export declare interface StaticRouteConfig {
|
|
|
17
18
|
pathRewriteStyle?: PathRewriteStyle
|
|
18
19
|
maxAge?: number
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* HTTP Basic auth for a single route. When set, rpx challenges every request to
|
|
23
|
+
* the route with `401`/`WWW-Authenticate` until valid credentials are supplied
|
|
24
|
+
* (proxy, static, and WebSocket transports are all gated). Credentials may be
|
|
25
|
+
* given inline, as a `users[]` list, and/or via an Apache `htpasswd` file.
|
|
26
|
+
*/
|
|
27
|
+
export declare interface BasicAuthConfig {
|
|
28
|
+
realm?: string
|
|
29
|
+
username?: string
|
|
30
|
+
password?: string
|
|
31
|
+
users?: Array<{ username: string, password: string }>
|
|
32
|
+
htpasswdFile?: string
|
|
33
|
+
}
|
|
20
34
|
export declare interface BaseProxyConfig {
|
|
21
35
|
from?: string
|
|
22
36
|
to: string
|
|
37
|
+
auth?: BasicAuthConfig
|
|
23
38
|
path?: string
|
|
24
39
|
start?: StartOptions
|
|
25
40
|
pathRewrites?: PathRewrite[]
|
|
26
41
|
static?: string | StaticRouteConfig
|
|
42
|
+
redirect?: string | RedirectRouteConfig
|
|
27
43
|
id?: string
|
|
28
44
|
}
|
|
29
45
|
export declare interface CleanupConfig {
|
|
@@ -79,6 +95,49 @@ export declare interface OnDemandTlsConfig {
|
|
|
79
95
|
staging?: boolean
|
|
80
96
|
certsDir?: string
|
|
81
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* One backend a site exposes, mapped to a request path. rpx picks a free port,
|
|
100
|
+
* exports it to the dev command via {@link portEnv}, and proxies {@link path}
|
|
101
|
+
* (under the site host) to `localhost:<port>`.
|
|
102
|
+
*
|
|
103
|
+
* A Stacks app, for example, has three: the frontend at `/` (env `PORT`), the
|
|
104
|
+
* API at `/api` (env `PORT_API`), and the docs at `/docs` (env `PORT_DOCS`).
|
|
105
|
+
*/
|
|
106
|
+
export declare interface SiteRouteTemplate {
|
|
107
|
+
path?: string
|
|
108
|
+
portEnv: string
|
|
109
|
+
defaultPort?: number
|
|
110
|
+
stripPrefix?: boolean
|
|
111
|
+
readyGate?: boolean
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A lazily-booted project. The first request to {@link to} starts {@link command}
|
|
115
|
+
* in {@link dir}; rpx holds the request behind a "starting…" splash until the
|
|
116
|
+
* site's ready gate passes, then proxies it. After {@link idleTimeoutMs} with no
|
|
117
|
+
* traffic the process is stopped again — so a machine can "have" dozens of sites
|
|
118
|
+
* but only run the ones in active use.
|
|
119
|
+
*/
|
|
120
|
+
export declare interface SiteConfig {
|
|
121
|
+
to: string
|
|
122
|
+
dir: string
|
|
123
|
+
command: string
|
|
124
|
+
env?: Record<string, string>
|
|
125
|
+
routes?: SiteRouteTemplate[]
|
|
126
|
+
selfRegisters?: boolean
|
|
127
|
+
idleTimeoutMs?: number
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* On-demand sites: lazily boot a project's dev server the first time its host is
|
|
131
|
+
* visited, then proxy to it (Valet/puma-dev style). Opt-in via {@link enabled}.
|
|
132
|
+
*/
|
|
133
|
+
export declare interface OnDemandSitesConfig {
|
|
134
|
+
enabled?: boolean
|
|
135
|
+
sites?: SiteConfig[]
|
|
136
|
+
roots?: string[]
|
|
137
|
+
tlds?: string[]
|
|
138
|
+
idleTimeoutMs?: number
|
|
139
|
+
startupTimeoutMs?: number
|
|
140
|
+
}
|
|
82
141
|
export declare interface SharedProxyConfig {
|
|
83
142
|
https: boolean | TlsOption
|
|
84
143
|
cleanup: boolean | CleanupOptions
|
|
@@ -89,10 +148,15 @@ export declare interface SharedProxyConfig {
|
|
|
89
148
|
cleanUrls: boolean
|
|
90
149
|
changeOrigin?: boolean
|
|
91
150
|
regenerateUntrustedCerts?: boolean
|
|
151
|
+
singlePortMode?: boolean
|
|
152
|
+
httpPort?: number
|
|
153
|
+
httpsPort?: number
|
|
154
|
+
acmeChallengeWebroot?: string
|
|
92
155
|
viaDaemon?: boolean
|
|
93
156
|
hostsManagement?: boolean
|
|
94
157
|
productionCerts?: ProductionTlsConfig
|
|
95
158
|
onDemandTls?: OnDemandTlsConfig
|
|
159
|
+
onDemand?: OnDemandSitesConfig
|
|
96
160
|
originGuard?: OriginGuardOptions
|
|
97
161
|
}
|
|
98
162
|
export declare interface SingleProxyConfig extends BaseProxyConfig, SharedProxyConfig {}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/rpx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.21",
|
|
5
5
|
"description": "A modern and smart reverse proxy.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
|
-
"bun": "./
|
|
31
|
-
"import": "./dist/
|
|
30
|
+
"bun": "./dist/index.js",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
"module": "./dist/
|
|
34
|
+
"module": "./dist/index.js",
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
36
36
|
"bin": {
|
|
37
37
|
"rpx": "./dist/bin/cli.js",
|
|
@@ -39,8 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"README.md",
|
|
42
|
-
"dist"
|
|
43
|
-
"src"
|
|
42
|
+
"dist"
|
|
44
43
|
],
|
|
45
44
|
"scripts": {
|
|
46
45
|
"build": "bun build.ts && bun build ./bin/cli.ts --compile --minify --outfile bin/rpx",
|
|
@@ -73,7 +72,7 @@
|
|
|
73
72
|
},
|
|
74
73
|
"dependencies": {
|
|
75
74
|
"@stacksjs/clapp": "^0.2.10",
|
|
76
|
-
"@stacksjs/tlsx": "^0.13.
|
|
75
|
+
"@stacksjs/tlsx": "^0.13.9"
|
|
77
76
|
},
|
|
78
77
|
"devDependencies": {
|
|
79
78
|
"bunfig": "^0.15.6",
|