@stacksjs/rpx 0.11.18 → 0.11.20
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/cli.js +225 -210
- package/dist/cert-inspect.d.ts +5 -3
- package/dist/chunk-0f32jmrb.js +1 -0
- package/dist/chunk-bs9e342s.js +1 -0
- package/dist/chunk-vxj1ckdm.js +176 -0
- package/dist/{chunk-rbgb5fyg.js → chunk-w888yhnp.js} +12 -12
- package/dist/daemon.d.ts +17 -8
- package/dist/dns.d.ts +2 -0
- package/dist/https.d.ts +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -7
- package/dist/logger.d.ts +8 -8
- package/dist/proxy-handler.d.ts +1 -1
- package/dist/proxy-pool.d.ts +82 -0
- package/dist/start.d.ts +31 -8
- package/dist/types.d.ts +13 -0
- package/dist/utils.d.ts +15 -0
- package/package.json +11 -7
- package/dist/chunk-9njrhbd4.js +0 -1
- package/dist/chunk-a0b9f9fs.js +0 -1
- package/dist/chunk-s4tdtq37.js +0 -161
- 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 -786
- package/src/dns-state.ts +0 -116
- package/src/dns.ts +0 -509
- package/src/host-match.ts +0 -52
- package/src/host-routes.ts +0 -147
- package/src/hosts.ts +0 -278
- package/src/https.ts +0 -862
- package/src/index.ts +0 -158
- 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 -105
- package/src/port-manager.ts +0 -183
- package/src/process-manager.ts +0 -164
- package/src/proxy-handler.ts +0 -315
- 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 -256
- package/src/utils.ts +0 -210
package/src/sni.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build a Bun.serve TLS array for per-domain SNI from real PEM files on disk.
|
|
3
|
-
*
|
|
4
|
-
* Production deployments (Let's Encrypt) have one cert+key per domain. Bun's
|
|
5
|
-
* `Bun.serve({ tls: [{ serverName, cert, key }, ...] })` selects the right cert
|
|
6
|
-
* by SNI server name at handshake time, so a single listener can front many
|
|
7
|
-
* domains with their own real certs.
|
|
8
|
-
*/
|
|
9
|
-
import type { DomainCert, ProductionTlsConfig } from './types'
|
|
10
|
-
import * as fsp from 'node:fs/promises'
|
|
11
|
-
import * as path from 'node:path'
|
|
12
|
-
import { debugLog } from './utils'
|
|
13
|
-
|
|
14
|
-
/** One entry of the Bun.serve `tls` array. */
|
|
15
|
-
export interface SniTlsEntry {
|
|
16
|
-
serverName: string
|
|
17
|
-
cert: string
|
|
18
|
-
key: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Map a PEM filename under a `certsDir` to its SNI server name. Returns `null`
|
|
23
|
-
* for files that aren't `<name>.crt`. The wildcard convention
|
|
24
|
-
* `_wildcard.<apex>.crt` maps to server name `*.<apex>`.
|
|
25
|
-
*/
|
|
26
|
-
export function serverNameFromCertFilename(filename: string): string | null {
|
|
27
|
-
if (!filename.endsWith('.crt'))
|
|
28
|
-
return null
|
|
29
|
-
const base = filename.slice(0, -'.crt'.length)
|
|
30
|
-
if (base.length === 0)
|
|
31
|
-
return null
|
|
32
|
-
if (base.startsWith('_wildcard.'))
|
|
33
|
-
return `*.${base.slice('_wildcard.'.length)}`
|
|
34
|
-
return base
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async function readPair(serverName: string, certPath: string, keyPath: string, verbose?: boolean): Promise<SniTlsEntry | null> {
|
|
38
|
-
try {
|
|
39
|
-
const [cert, key] = await Promise.all([
|
|
40
|
-
fsp.readFile(certPath, 'utf8'),
|
|
41
|
-
fsp.readFile(keyPath, 'utf8'),
|
|
42
|
-
])
|
|
43
|
-
return { serverName, cert, key }
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
debugLog('sni', `skipping ${serverName}: ${(err as Error).message}`, verbose)
|
|
47
|
-
return null
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Build the SNI TLS array from a {@link ProductionTlsConfig}. Reads PEM files
|
|
53
|
-
* from an explicit `domains` map and/or a `certsDir` convention. Files that
|
|
54
|
-
* can't be read are skipped (logged in verbose mode). Returns `[]` when nothing
|
|
55
|
-
* usable is found so the caller can fall back to the dev cert flow.
|
|
56
|
-
*/
|
|
57
|
-
export async function buildSniTlsConfig(cfg: ProductionTlsConfig, verbose?: boolean): Promise<SniTlsEntry[]> {
|
|
58
|
-
const bySrvName = new Map<string, DomainCert>()
|
|
59
|
-
|
|
60
|
-
if (cfg.certsDir) {
|
|
61
|
-
let names: string[] = []
|
|
62
|
-
try {
|
|
63
|
-
names = await fsp.readdir(cfg.certsDir)
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
debugLog('sni', `certsDir read failed (${cfg.certsDir}): ${(err as Error).message}`, verbose)
|
|
67
|
-
}
|
|
68
|
-
for (const name of names) {
|
|
69
|
-
const serverName = serverNameFromCertFilename(name)
|
|
70
|
-
if (!serverName)
|
|
71
|
-
continue
|
|
72
|
-
const base = name.slice(0, -'.crt'.length)
|
|
73
|
-
bySrvName.set(serverName, {
|
|
74
|
-
certPath: path.join(cfg.certsDir, name),
|
|
75
|
-
keyPath: path.join(cfg.certsDir, `${base}.key`),
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Explicit `domains` entries take precedence over `certsDir` discoveries.
|
|
81
|
-
if (cfg.domains) {
|
|
82
|
-
for (const [serverName, pair] of Object.entries(cfg.domains))
|
|
83
|
-
bySrvName.set(serverName, pair)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const entries: SniTlsEntry[] = []
|
|
87
|
-
for (const [serverName, pair] of bySrvName) {
|
|
88
|
-
const entry = await readPair(serverName, pair.certPath, pair.keyPath, verbose)
|
|
89
|
-
if (entry)
|
|
90
|
-
entries.push(entry)
|
|
91
|
-
}
|
|
92
|
-
return entries
|
|
93
|
-
}
|