@stacksjs/rpx 0.11.7 → 0.11.10

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.
@@ -26,4 +26,7 @@ export declare interface DaemonRunnerOptions {
26
26
  rpxDir?: string
27
27
  detached?: boolean
28
28
  spawnCommand?: string[]
29
+ startupTimeoutMs?: number
30
+ spawnEnv?: Record<string, string>
31
+ persistent?: boolean
29
32
  }
package/dist/daemon.d.ts CHANGED
@@ -55,6 +55,10 @@ export declare function ensureDaemonRunning(opts?: EnsureDaemonOptions): Promise
55
55
  * if we had to SIGKILL.
56
56
  */
57
57
  export declare function stopDaemon(opts?: StopDaemonOptions): Promise<StopDaemonResult>;
58
+ /**
59
+ * When the daemon is not running, ensure no stale macOS resolver overrides remain.
60
+ */
61
+ export declare function reconcileDevelopmentDnsOnIdle(opts?: { rpxDir?: string, verbose?: boolean }): Promise<void>;
58
62
  export declare interface DaemonOptions {
59
63
  verbose?: boolean
60
64
  rpxDir?: string
@@ -0,0 +1,27 @@
1
+ export declare function defaultRpxDir(): string;
2
+ export declare function getDnsStatePath(rpxDir?: string): string;
3
+ export declare function loadDnsState(rpxDir?: string): Promise<DnsState | null>;
4
+ export declare function saveDnsState(rpxDir: string, state: DnsState): Promise<void>;
5
+ export declare function clearDnsState(rpxDir: string): Promise<void>;
6
+ /**
7
+ * Normalize a dev hostname. Returns null for localhost / IPs — those use /etc/hosts only.
8
+ */
9
+ export declare function normalizeDevDomain(raw: string): string | null;
10
+ /**
11
+ * macOS resolver basename for a dev domain. Uses the registrable base (last two labels)
12
+ * so `api.postline.test` and `postline.test` share one `/etc/resolver/postline.test` file.
13
+ */
14
+ export declare function resolverBasenameForDomain(raw: string): string | null;
15
+ export declare function resolverBasenamesForDomains(domains: string[]): string[];
16
+ export declare function devDomainsFromHosts(hosts: string[]): string[];
17
+ export declare const DNS_STATE_VERSION: 1;
18
+ export declare const RPX_DNS_STATE_FILE: 'dns-state.json';
19
+ /** Single-label /etc/resolver files created by older rpx versions (whole-TLD hijack). */
20
+ export declare const LEGACY_TLD_RESOLVER_LABELS: readonly ['com', 'test', 'dev', 'app', 'page', 'local', 'localhost', 'example', 'invalid'];
21
+ export declare interface DnsState {
22
+ version: typeof DNS_STATE_VERSION
23
+ resolvers: string[]
24
+ domains: string[]
25
+ ownerPid: number | null
26
+ updatedAt: string
27
+ }
package/dist/dns.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ import type { RegistryEntry } from './registry';
2
+ export declare function startDnsServer(domains: string[], verbose?: boolean): Promise<boolean>;
3
+ export declare function stopDnsServer(verbose?: boolean): void;
4
+ export declare function isDnsServerRunning(): boolean;
5
+ export declare function resolverFilePath(basename: string): string;
6
+ /** True when a resolver file points at the rpx local DNS port. */
7
+ export declare function contentLooksLikeRpxResolver(content: string): boolean;
8
+ /**
9
+ * @deprecated Use {@link setupDevelopmentDns}. Domain-scoped resolver files only.
10
+ */
11
+ export declare function setupResolver(verbose?: boolean, domains?: string[]): Promise<boolean>;
12
+ /** Remove legacy whole-TLD resolver files (e.g. `/etc/resolver/com`). */
13
+ export declare function removeLegacyTldResolvers(verbose?: boolean): Promise<string[]>;
14
+ /**
15
+ * Start the local DNS server and install domain-scoped macOS resolver files.
16
+ */
17
+ export declare function setupDevelopmentDns(opts: DevelopmentDnsOptions): Promise<boolean>;
18
+ /**
19
+ * Sync resolver + DNS state to the current set of registry hosts (daemon mode).
20
+ */
21
+ export declare function syncDevelopmentDnsFromRegistry(entries: RegistryEntry[], opts?: { rpxDir?: string, verbose?: boolean, ownerPid?: number }): Promise<void>;
22
+ /**
23
+ * Stop DNS and remove all resolver files recorded in state (plus legacy TLD files).
24
+ */
25
+ export declare function tearDownDevelopmentDns(opts?: { rpxDir?: string, verbose?: boolean }): Promise<void>;
26
+ /**
27
+ * @deprecated Use {@link tearDownDevelopmentDns}.
28
+ */
29
+ export declare function removeResolver(verbose?: boolean): Promise<void>;
30
+ /**
31
+ * Remove stale DNS overrides left after a crashed dev session or legacy TLD hijacks.
32
+ * Safe to call before starting the daemon or `./buddy dev`.
33
+ */
34
+ export declare function reconcileStaleDevelopmentDns(opts?: { rpxDir?: string, verbose?: boolean }): Promise<void>;
35
+ /** High port — does not require root. */
36
+ export declare const DNS_PORT: 15353;
37
+ export declare const RPX_RESOLVER_MARKER: '# managed-by: rpx';
38
+ export declare interface DevelopmentDnsOptions {
39
+ domains: string[]
40
+ rpxDir?: string
41
+ verbose?: boolean
42
+ ownerPid?: number
43
+ }
package/dist/https.d.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  import { config } from './config';
2
+ import { MACOS_CA_TRUST_FLAGS, MACOS_SYSTEM_KEYCHAIN, getMacosLoginKeychainPath, isRootCaFingerprintInKeychains, isRootCaTrustedForSsl, pruneStaleRootCas, trustRootCaForBrowsers } from './macos-trust';
2
3
  import type { ProxyConfigs, ProxyOption, ProxyOptions, SSLConfig, TlsConfig } from './types';
3
4
  /**
4
5
  * Returns the canonical Root CA cert + key paths inside `basePath`.
5
6
  */
6
7
  export declare function getRootCAPaths(basePath: string): RootCAPaths;
8
+ /** Paths for the shared multi-host daemon cert under `~/.stacks/ssl`. */
9
+ export declare function getSharedDaemonCertPaths(sslDir: string): {
10
+ certPath: string
11
+ keyPath: string
12
+ caCertPath: string
13
+ rootCA: RootCAPaths
14
+ };
7
15
  /**
8
16
  * Resolves SSL paths based on configuration
9
17
  */
@@ -26,9 +34,11 @@ export declare function loadSSLConfig(options: ProxyOption): Promise<SSLConfig |
26
34
  /**
27
35
  * Force trust a certificate - exposing for direct use
28
36
  */
29
- export declare function forceTrustCertificate(certPath: string): Promise<boolean>;
37
+ export declare function forceTrustCertificate(certPath: string, options?: { serverName?: string, verbose?: boolean }): Promise<boolean>;
30
38
  export declare function generateCertificate(options: ProxyOptions): Promise<void>;
31
39
  export declare function getSSLConfig(): { key: string, cert: string, ca?: string } | null;
40
+ /** Clear in-process TLS cache so the next generate/load picks up new files on disk. */
41
+ export declare function clearSslConfigCache(): void;
32
42
  // needs to accept the options
33
43
  export declare function checkExistingCertificates(options?: ProxyOptions): Promise<SSLConfig | null>;
34
44
  export declare function httpsConfig(options: ProxyOption | ProxyOptions, verbose?: boolean): TlsConfig;
@@ -40,8 +50,28 @@ export declare function cleanupCertificates(domain: string, verbose?: boolean):
40
50
  * Checks if a certificate is trusted by the system (macOS only for now)
41
51
  * If options.regenerateUntrustedCerts is false, always returns true (skips trust check)
42
52
  */
43
- export declare function isCertTrusted(certPath: string, options?: { verbose?: boolean, regenerateUntrustedCerts?: boolean }): Promise<boolean>;
53
+ export declare function isCertTrusted(certPath: string, options?: { verbose?: boolean, regenerateUntrustedCerts?: boolean, serverName?: string }): Promise<boolean>;
44
54
  export declare interface RootCAPaths {
45
55
  caCertPath: string
46
56
  caKeyPath: string
47
57
  }
58
+ export {
59
+ MACOS_CA_TRUST_FLAGS,
60
+ MACOS_SYSTEM_KEYCHAIN,
61
+ RPX_ROOT_CA_COMMON_NAME,
62
+ getMacosLoginKeychainPath,
63
+ getMacosTrustKeychains,
64
+ isRootCaFingerprintInKeychains,
65
+ isRootCaTrustedForSsl,
66
+ listCertSha256HashesByCommonName,
67
+ pruneStaleRootCas,
68
+ trustRootCaForBrowsers,
69
+ } from './macos-trust';
70
+ export {
71
+ certIncludesSanHostnames,
72
+ normalizeSha256Fingerprint,
73
+ parseSha256HashesFromSecurityListing,
74
+ readCertCommonName,
75
+ readCertSha256Fingerprint,
76
+ verifyHttpsChain,
77
+ } from './cert-inspect';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { startProxies as startProxiesFunc } from './start';
2
2
  export type { RegistryEntry, WatchHandle, WatchOptions } from './registry';
3
+ export type { DevelopmentDnsOptions } from './dns';
3
4
  export type {
4
5
  DaemonHandle,
5
6
  DaemonOptions,
@@ -20,12 +21,35 @@ export {
20
21
  export {
21
22
  checkExistingCertificates,
22
23
  cleanupCertificates,
24
+ clearSslConfigCache,
23
25
  forceTrustCertificate,
24
26
  generateCertificate,
27
+ getRootCAPaths,
28
+ getSharedDaemonCertPaths,
25
29
  httpsConfig,
26
30
  isCertTrusted,
27
31
  loadSSLConfig,
28
32
  } from './https';
33
+ export {
34
+ MACOS_CA_TRUST_FLAGS,
35
+ MACOS_SYSTEM_KEYCHAIN,
36
+ RPX_ROOT_CA_COMMON_NAME,
37
+ getMacosLoginKeychainPath,
38
+ getMacosTrustKeychains,
39
+ isRootCaFingerprintInKeychains,
40
+ isRootCaTrustedForSsl,
41
+ listCertSha256HashesByCommonName,
42
+ pruneStaleRootCas,
43
+ trustRootCaForBrowsers,
44
+ } from './macos-trust';
45
+ export {
46
+ certIncludesSanHostnames,
47
+ normalizeSha256Fingerprint,
48
+ parseSha256HashesFromSecurityListing,
49
+ readCertCommonName,
50
+ readCertSha256Fingerprint,
51
+ verifyHttpsChain,
52
+ } from './cert-inspect';
29
53
  export { DefaultPortManager, findAvailablePort, isPortInUse, portManager } from './port-manager';
30
54
  export {
31
55
  gcStaleEntries,
@@ -38,6 +62,30 @@ export {
38
62
  watchRegistry,
39
63
  writeEntry,
40
64
  } from './registry';
65
+ export {
66
+ DNS_PORT,
67
+ RPX_RESOLVER_MARKER,
68
+ contentLooksLikeRpxResolver,
69
+ isDnsServerRunning,
70
+ reconcileStaleDevelopmentDns,
71
+ removeLegacyTldResolvers,
72
+ removeResolver,
73
+ resolverFilePath,
74
+ setupDevelopmentDns,
75
+ setupResolver,
76
+ startDnsServer,
77
+ stopDnsServer,
78
+ syncDevelopmentDnsFromRegistry,
79
+ tearDownDevelopmentDns,
80
+ } from './dns';
81
+ export {
82
+ DNS_STATE_VERSION,
83
+ LEGACY_TLD_RESOLVER_LABELS,
84
+ devDomainsFromHosts,
85
+ normalizeDevDomain,
86
+ resolverBasenameForDomain,
87
+ resolverBasenamesForDomains,
88
+ } from './dns-state';
41
89
  export {
42
90
  acquireDaemonLock,
43
91
  defaultDaemonSpawnCommand,
@@ -46,6 +94,7 @@ export {
46
94
  getDaemonRpxDir,
47
95
  isDaemonRunning,
48
96
  readDaemonPid,
97
+ reconcileDevelopmentDnsOnIdle,
49
98
  releaseDaemonLock,
50
99
  runDaemon,
51
100
  stopDaemon,