dsh-zen-remote 2.2.9 → 2.3.2

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.
Files changed (149) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +2 -2
  3. package/docs/interface.md +1 -1
  4. package/docs/remote-access.md +20 -0
  5. package/lan-gate.mjs +11 -1
  6. package/lib/adapters/dsh-better-sidebar/index.js +6 -2
  7. package/lib/adapters/dsh-better-sidebar/index.js.map +1 -1
  8. package/lib/adapters/dsh-better-sidebar/methods.js +3 -0
  9. package/lib/adapters/dsh-better-sidebar/methods.js.map +1 -1
  10. package/lib/admin-routes.js +33 -2
  11. package/lib/admin-routes.js.map +1 -1
  12. package/lib/client.js +3293 -6
  13. package/lib/config.js +70 -0
  14. package/lib/config.js.map +1 -1
  15. package/lib/index.js +232 -2
  16. package/lib/index.js.map +1 -1
  17. package/lib/intercept.js +43 -3
  18. package/lib/intercept.js.map +1 -1
  19. package/lib/lan-gate-server.cjs +58 -3
  20. package/lib/merge-streams.js +42 -12
  21. package/lib/merge-streams.js.map +1 -1
  22. package/lib/types/adapters/dsh-better-sidebar/index.d.ts +1 -1
  23. package/lib/types/adapters/dsh-better-sidebar/index.d.ts.map +1 -1
  24. package/lib/types/adapters/dsh-better-sidebar/methods.d.ts.map +1 -1
  25. package/lib/types/admin-routes.d.ts +13 -0
  26. package/lib/types/admin-routes.d.ts.map +1 -1
  27. package/lib/types/client/index.d.ts.map +1 -1
  28. package/lib/types/client/locales.d.ts +204 -1
  29. package/lib/types/client/locales.d.ts.map +1 -1
  30. package/lib/types/client/wizard/GatewayWizard.d.ts +29 -0
  31. package/lib/types/client/wizard/GatewayWizard.d.ts.map +1 -0
  32. package/lib/types/client/wizard/WizardCard.d.ts +30 -0
  33. package/lib/types/client/wizard/WizardCard.d.ts.map +1 -0
  34. package/lib/types/client/wizard/cards/MigrateCard.d.ts +15 -0
  35. package/lib/types/client/wizard/cards/MigrateCard.d.ts.map +1 -0
  36. package/lib/types/client/wizard/cards/PortForwardCard.d.ts +15 -0
  37. package/lib/types/client/wizard/cards/PortForwardCard.d.ts.map +1 -0
  38. package/lib/types/client/wizard/cards/ProxyCard.d.ts +19 -0
  39. package/lib/types/client/wizard/cards/ProxyCard.d.ts.map +1 -0
  40. package/lib/types/client/wizard/cards/TokenCard.d.ts +20 -0
  41. package/lib/types/client/wizard/cards/TokenCard.d.ts.map +1 -0
  42. package/lib/types/client/wizard/register-wizard.d.ts +51 -0
  43. package/lib/types/client/wizard/register-wizard.d.ts.map +1 -0
  44. package/lib/types/client/wizard/wizard-css.d.ts +10 -0
  45. package/lib/types/client/wizard/wizard-css.d.ts.map +1 -0
  46. package/lib/types/client-data/qr.d.ts +20 -0
  47. package/lib/types/client-data/qr.d.ts.map +1 -0
  48. package/lib/types/client-data/settings-form.d.ts +7 -2
  49. package/lib/types/client-data/settings-form.d.ts.map +1 -1
  50. package/lib/types/client-data/wizard.d.ts +247 -0
  51. package/lib/types/client-data/wizard.d.ts.map +1 -0
  52. package/lib/types/config.d.ts +27 -0
  53. package/lib/types/config.d.ts.map +1 -1
  54. package/lib/types/index.d.ts.map +1 -1
  55. package/lib/types/intercept.d.ts.map +1 -1
  56. package/lib/types/merge-streams.d.ts.map +1 -1
  57. package/lib/types/wizard/binary-io.d.ts +111 -0
  58. package/lib/types/wizard/binary-io.d.ts.map +1 -0
  59. package/lib/types/wizard/binary.d.ts +118 -0
  60. package/lib/types/wizard/binary.d.ts.map +1 -0
  61. package/lib/types/wizard/caddy-process.d.ts +101 -0
  62. package/lib/types/wizard/caddy-process.d.ts.map +1 -0
  63. package/lib/types/wizard/caddy.d.ts +53 -0
  64. package/lib/types/wizard/caddy.d.ts.map +1 -0
  65. package/lib/types/wizard/cloudflare.d.ts +112 -0
  66. package/lib/types/wizard/cloudflare.d.ts.map +1 -0
  67. package/lib/types/wizard/cloudflared.d.ts +71 -0
  68. package/lib/types/wizard/cloudflared.d.ts.map +1 -0
  69. package/lib/types/wizard/probe.d.ts +66 -0
  70. package/lib/types/wizard/probe.d.ts.map +1 -0
  71. package/lib/types/wizard/proxy-snippets.d.ts +60 -0
  72. package/lib/types/wizard/proxy-snippets.d.ts.map +1 -0
  73. package/lib/types/wizard/routes.d.ts +152 -0
  74. package/lib/types/wizard/routes.d.ts.map +1 -0
  75. package/lib/types/wizard/source-detect.d.ts +53 -0
  76. package/lib/types/wizard/source-detect.d.ts.map +1 -0
  77. package/lib/types/wizard/status.d.ts +115 -0
  78. package/lib/types/wizard/status.d.ts.map +1 -0
  79. package/lib/types/wizard/token-store.d.ts +27 -0
  80. package/lib/types/wizard/token-store.d.ts.map +1 -0
  81. package/lib/types/wizard/tunnel-orchestrator.d.ts +90 -0
  82. package/lib/types/wizard/tunnel-orchestrator.d.ts.map +1 -0
  83. package/lib/types/wizard/verify.d.ts +97 -0
  84. package/lib/types/wizard/verify.d.ts.map +1 -0
  85. package/lib/wizard/binary-io.js +386 -0
  86. package/lib/wizard/binary-io.js.map +1 -0
  87. package/lib/wizard/binary.js +138 -0
  88. package/lib/wizard/binary.js.map +1 -0
  89. package/lib/wizard/caddy-process.js +162 -0
  90. package/lib/wizard/caddy-process.js.map +1 -0
  91. package/lib/wizard/caddy.js +80 -0
  92. package/lib/wizard/caddy.js.map +1 -0
  93. package/lib/wizard/cloudflare.js +334 -0
  94. package/lib/wizard/cloudflare.js.map +1 -0
  95. package/lib/wizard/cloudflared.js +158 -0
  96. package/lib/wizard/cloudflared.js.map +1 -0
  97. package/lib/wizard/probe.js +118 -0
  98. package/lib/wizard/probe.js.map +1 -0
  99. package/lib/wizard/proxy-snippets.js +112 -0
  100. package/lib/wizard/proxy-snippets.js.map +1 -0
  101. package/lib/wizard/routes.js +462 -0
  102. package/lib/wizard/routes.js.map +1 -0
  103. package/lib/wizard/source-detect.js +77 -0
  104. package/lib/wizard/source-detect.js.map +1 -0
  105. package/lib/wizard/status.js +94 -0
  106. package/lib/wizard/status.js.map +1 -0
  107. package/lib/wizard/token-store.js +71 -0
  108. package/lib/wizard/token-store.js.map +1 -0
  109. package/lib/wizard/tunnel-orchestrator.js +155 -0
  110. package/lib/wizard/tunnel-orchestrator.js.map +1 -0
  111. package/lib/wizard/verify.js +171 -0
  112. package/lib/wizard/verify.js.map +1 -0
  113. package/package.json +37 -37
  114. package/scripts/check-settings-form.mjs +5 -4
  115. package/scripts/check-wizard-ui.mjs +690 -0
  116. package/src/adapters/dsh-better-sidebar/index.ts +6 -2
  117. package/src/adapters/dsh-better-sidebar/methods.ts +3 -0
  118. package/src/admin-routes.ts +44 -2
  119. package/src/client/index.tsx +9 -0
  120. package/src/client/locales.ts +410 -2
  121. package/src/client/wizard/GatewayWizard.tsx +2224 -0
  122. package/src/client/wizard/WizardCard.tsx +81 -0
  123. package/src/client/wizard/cards/MigrateCard.tsx +42 -0
  124. package/src/client/wizard/cards/PortForwardCard.tsx +37 -0
  125. package/src/client/wizard/cards/ProxyCard.tsx +56 -0
  126. package/src/client/wizard/cards/TokenCard.tsx +81 -0
  127. package/src/client/wizard/register-wizard.ts +99 -0
  128. package/src/client/wizard/wizard-css.ts +948 -0
  129. package/src/client-data/qr.ts +284 -0
  130. package/src/client-data/settings-form.ts +12 -3
  131. package/src/client-data/wizard.ts +432 -0
  132. package/src/config.ts +87 -0
  133. package/src/index.ts +227 -2
  134. package/src/intercept.ts +43 -3
  135. package/src/merge-streams.ts +41 -12
  136. package/src/wizard/binary-io.ts +449 -0
  137. package/src/wizard/binary.ts +177 -0
  138. package/src/wizard/caddy-process.ts +228 -0
  139. package/src/wizard/caddy.ts +97 -0
  140. package/src/wizard/cloudflare.ts +413 -0
  141. package/src/wizard/cloudflared.ts +196 -0
  142. package/src/wizard/probe.ts +161 -0
  143. package/src/wizard/proxy-snippets.ts +128 -0
  144. package/src/wizard/routes.ts +537 -0
  145. package/src/wizard/source-detect.ts +87 -0
  146. package/src/wizard/status.ts +180 -0
  147. package/src/wizard/token-store.ts +73 -0
  148. package/src/wizard/tunnel-orchestrator.ts +197 -0
  149. package/src/wizard/verify.ts +236 -0
@@ -74,6 +74,22 @@ export interface ZenRemoteConfig {
74
74
  * false means NO — default `{}` keeps every plugin unconsented. Volatile:
75
75
  * read at compare time, deliberately NOT in RESTART_FIELDS. */
76
76
  pluginBridgeConsent: Record<string, boolean>;
77
+ /** Which public-ingress setup the gateway wizard (GW-1) manages.
78
+ * `'off'` no public entry; `'caddy'` the plugin-managed Caddy reverse
79
+ * proxy; `'external'` a user-operated reverse proxy; `'cloudflared'` a
80
+ * Cloudflare Tunnel. Read live per request by the wizard routes; a mode
81
+ * change must NOT reload the row (the ingress processes outlive it). */
82
+ ingressMode: 'off' | 'caddy' | 'external' | 'cloudflared';
83
+ /** Public ingress domain, bare host (e.g. `dsh.example.com`), no scheme,
84
+ * no path. Empty means none yet. */
85
+ ingressDomain: string;
86
+ /** Port the managed Caddy listens for HTTPS on. [1, 65535]. */
87
+ ingressHttpsPort: number;
88
+ /** ACME account contact for certificate notices; empty means none. */
89
+ ingressAcmeEmail: string;
90
+ /** The public origin the final verification reached (scheme + host +
91
+ * optional port, root path only). Empty until verified. */
92
+ ingressPublicUrl: string;
77
93
  }
78
94
  /** Defaults, one per field — exactly what layer 4 hands back. */
79
95
  export declare const DEFAULTS: ZenRemoteConfig;
@@ -88,6 +104,7 @@ export declare const DEFAULTS: ZenRemoteConfig;
88
104
  * settings at operation time use this too.
89
105
  */
90
106
  export declare function unwrapVolatile(value: unknown): unknown;
107
+ export declare function hostOf(value: unknown): string | undefined;
91
108
  /**
92
109
  * The effective configuration: every field resolved through the four layers.
93
110
  * @param row - the plugin row config as `apply()` received it (loosely typed
@@ -172,6 +189,11 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
172
189
  idleHours: z<any, any, "volatile">;
173
190
  autoShareNewSessions: z<any, any, "volatile">;
174
191
  pluginBridgeConsent: z<any, any, "volatile">;
192
+ ingressMode: z<any, any, "volatile">;
193
+ ingressDomain: z<any, any, "volatile">;
194
+ ingressHttpsPort: z<any, any, "volatile">;
195
+ ingressAcmeEmail: z<any, any, "volatile">;
196
+ ingressPublicUrl: z<any, any, "volatile">;
175
197
  serverUrl: z<any, any, "volatile">;
176
198
  deviceToken: z<string, string, "volatile">;
177
199
  turnFoldDesktop: z<any, any, "volatile">;
@@ -197,6 +219,11 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
197
219
  idleHours: z<any, any, "volatile">;
198
220
  autoShareNewSessions: z<any, any, "volatile">;
199
221
  pluginBridgeConsent: z<any, any, "volatile">;
222
+ ingressMode: z<any, any, "volatile">;
223
+ ingressDomain: z<any, any, "volatile">;
224
+ ingressHttpsPort: z<any, any, "volatile">;
225
+ ingressAcmeEmail: z<any, any, "volatile">;
226
+ ingressPublicUrl: z<any, any, "volatile">;
200
227
  serverUrl: z<any, any, "volatile">;
201
228
  deviceToken: z<string, string, "volatile">;
202
229
  turnFoldDesktop: z<any, any, "volatile">;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAKH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,mEAAmE;AACnE,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAA;AAK7D,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B;oEACgE;IAChE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;IACvB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ;qEACiE;IACjE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAA;IACjB,sEAAsE;IACtE,cAAc,EAAE,MAAM,CAAA;IACtB,+EAA+E;IAC/E,YAAY,EAAE,MAAM,CAAA;IACpB,2EAA2E;IAC3E,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,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAC7C,gEAAgE;IAChE,eAAe,IAAI,OAAO,EAAE,CAAA;IAC5B,+CAA+C;IAC/C,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,EAAE,CAAA;IAC3D,uDAAuD;IACvD,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAA;CACzC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA2JhF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAqBvG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAwB/G;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAUvF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE,CAiBvF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,CAc5F"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Ingress binary I/O (GW-2, revised by GW-fix-1/H1): download, unpack,
3
+ * install and cache-probe for the two wizard-managed binaries. The
4
+ * arithmetic lives in binary.ts; this file is the only one allowed to touch
5
+ * the filesystem or the network for it.
6
+ *
7
+ * House rules the tasks pin down:
8
+ *
9
+ * - No shell, no `child_process` at all. Downloads ride `fetch`, the
10
+ * body streams straight to a `.part` file, and the install is a POSIX
11
+ * rename — a crash mid-download can never leave a half binary at the
12
+ * install path.
13
+ * - The archive wrapper comes from binary.ts's METADATA (`options.archive`,
14
+ * what binaryUrls() models per platform), never from sniffing the URL:
15
+ * the Caddy build API's URL is a query string whose ending says nothing
16
+ * about the tar.gz / zip payload it answers with (GW-fix-1/H1).
17
+ * - Windows' Caddy asset is a zip and there is no zip reader here yet:
18
+ * refused up front with the typed `windows-zip-unsupported` code, the
19
+ * manual-install link stays the fallback (GW-fix-1/H1 item 3).
20
+ * - After unpacking (or for a bare download), a unix image must carry an
21
+ * ELF or Mach-O magic; anything else is refused as `bad-binary-image`
22
+ * and leaves nothing on disk (GW-fix-1/H1 item 4). Windows keeps no
23
+ * magic check — PE inspection is not this module's job.
24
+ * - The darwin cloudflared asset is a `.tgz`; it is unpacked with
25
+ * `zlib.gunzipSync` plus a minimal ustar reader (the archive carries a
26
+ * single entry — no PAX/GNU long-name handling needed, but those
27
+ * header types are skipped correctly if an upstream rebuild adds one).
28
+ * - Installed images get 0755; `ensureBinary` is idempotent (an existing
29
+ * executable short-circuits before any network traffic).
30
+ *
31
+ * `fetch` is injectable so the tests drive real downloads against a local
32
+ * mock server without touching the network.
33
+ */
34
+ import { type BinaryArchive, type BinaryPlatform, type IngressBinary } from './binary.js';
35
+ /**
36
+ * One failed or refused download/install. `code` is the wire-stable marker
37
+ * the UI classifies on — `'download-failed'` for transport/shaping
38
+ * failures, `'windows-zip-unsupported'` for the zip refusal, and
39
+ * `'bad-binary-image'` when the payload did not carry an executable
40
+ * image's magic. `installUrl` is the official manual-install page the
41
+ * failure card links to. Fields are assigned in the constructor body rather
42
+ * than declared as parameter properties (the check scripts import modules
43
+ * through Node's strip-only type stripping, which rejects that syntax).
44
+ */
45
+ export declare class BinaryDownloadError extends Error {
46
+ readonly code: string;
47
+ readonly tool: IngressBinary;
48
+ readonly url: string;
49
+ readonly status: number | null;
50
+ readonly installUrl: string;
51
+ constructor(tool: IngressBinary, url: string, status: number | null, message: string, options?: {
52
+ cause?: unknown;
53
+ code?: string;
54
+ });
55
+ }
56
+ /**
57
+ * The installed binary's absolute path, or undefined when it is not (yet)
58
+ * on disk in executable shape — the read-only probe; see binary.ts's
59
+ * `binaryInstallPath` for the pure arithmetic.
60
+ */
61
+ export declare function binaryPath(dshHome: string, tool: IngressBinary, platform?: BinaryPlatform): string | undefined;
62
+ /** Progress callback: bytes on disk so far, and the declared total when the
63
+ * server sent one. */
64
+ export type DownloadProgress = (received: number, total: number | null) => void;
65
+ export interface DownloadBinaryOptions {
66
+ fetchImpl?: typeof fetch;
67
+ platform?: BinaryPlatform;
68
+ onProgress?: DownloadProgress;
69
+ /** The archive wrapper the URL delivers — metadata from binary.ts
70
+ * (`binaryUrls` / `caddyDownload` / `cloudflaredDownload`), NOT guessed
71
+ * from the URL shape. Default `'none'`: a bare executable. */
72
+ archive?: BinaryArchive;
73
+ }
74
+ /**
75
+ * Download one binary from an explicit URL and install it. The archive
76
+ * wrapper is the CALLER'S metadata (`options.archive`) — `ensureBinary`
77
+ * feeds it from binaryUrls(); tests pin it per fixture. `platform` only
78
+ * matters for the install name and the magic-check gate; it defaults to
79
+ * this process's.
80
+ * @returns the absolute install path.
81
+ */
82
+ export declare function downloadBinary(dshHome: string, tool: IngressBinary, url: string, options?: DownloadBinaryOptions): Promise<string>;
83
+ export interface EnsureBinaryOptions extends DownloadBinaryOptions {
84
+ /** Force the platform mapping (tests); defaults to this process's. */
85
+ platform?: BinaryPlatform;
86
+ }
87
+ /**
88
+ * Detect whether the current host is in mainland China:
89
+ * 1. Fast local check: system timezone is `Asia/Shanghai`, `Asia/Chongqing`,
90
+ * `Asia/Harbin`, or `Asia/Urumqi`, or `LANG`/`LC_ALL` carries `zh_CN`.
91
+ * 2. Quick 1.5s probe to Cloudflare's `/cdn-cgi/trace` (`loc=CN`), or if
92
+ * direct `github.com` HEAD fails/times out within 2s.
93
+ */
94
+ export declare function detectCnNetwork(fetchImpl?: typeof fetch): Promise<boolean>;
95
+ /**
96
+ * The idempotent front door: an already-installed executable short-circuits
97
+ * (no network), anything else downloads from the official distribution
98
+ * point for the tool, archive shape included.
99
+ *
100
+ * When using the default `fetch` transport, automatically detects mainland
101
+ * China network environments and tries prebuilt GitHub Release mirrors
102
+ * (`gh-proxy.com` / `ghfast.top`) + direct GitHub Release before falling back
103
+ * to `caddyserver.com/api/download`. When a custom `fetchImpl` is injected
104
+ * (unit tests), calls the canonical `binaryUrls(platform)` endpoint directly.
105
+ * @returns the absolute install path and whether THIS call downloaded.
106
+ */
107
+ export declare function ensureBinary(dshHome: string, tool: IngressBinary, options?: EnsureBinaryOptions): Promise<{
108
+ path: string;
109
+ downloaded: boolean;
110
+ }>;
111
+ //# sourceMappingURL=binary-io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-io.d.ts","sourceRoot":"","sources":["../../../src/wizard/binary-io.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAqBH,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAA;AAqCpB;;;;;;;;;GASG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;gBAEf,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAA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
3
+ * construction and install-path computation for the two binaries the
4
+ * gateway wizard manages — Caddy (custom build with the Cloudflare DNS
5
+ * module, for DNS-01 certificates) and cloudflared (the tunnel client).
6
+ *
7
+ * Pure by contract: URL strings, path strings and platform facts only —
8
+ * every touch of the filesystem or the network lives in binary-io.ts, and
9
+ * the routes layer reads both. `node:path`/`node:os` here are arithmetic,
10
+ * not I/O: the same discipline as virtual-id.ts's zero-dependency rule,
11
+ * relaxed one notch because path building is this module's whole job.
12
+ *
13
+ * Platform coverage mirrors what both upstream distribution points actually
14
+ * ship: darwin/linux/windows × amd64/arm64. macOS arm64's cloudflared asset
15
+ * is a `.tgz` (the only archive shape in the set) — binary-io unpacks it.
16
+ */
17
+ /** The two binaries the wizard downloads and runs. */
18
+ export type IngressBinary = 'caddy' | 'cloudflared';
19
+ /**
20
+ * The platform shapes both distribution points understand. Windows is
21
+ * deliberately amd64-only: that is all Caddy's build API and cloudflared's
22
+ * Releases publish a gateway-wizard-usable image for (a windows-arm64 host
23
+ * has no supported download either way, so pretending otherwise would only
24
+ * move the failure somewhere less explicable).
25
+ */
26
+ export type BinaryPlatform = {
27
+ os: 'darwin';
28
+ arch: 'amd64' | 'arm64';
29
+ } | {
30
+ os: 'linux';
31
+ arch: 'amd64' | 'arm64';
32
+ } | {
33
+ os: 'windows';
34
+ arch: 'amd64';
35
+ };
36
+ /**
37
+ * The wrapper an asset arrives in: `tgz` gzipped tar (needs unpacking),
38
+ * `zip` (no reader in this codebase yet — refused before download), `exe`
39
+ * Windows' own format, `none` a bare executable.
40
+ */
41
+ export type BinaryArchive = 'tgz' | 'zip' | 'exe' | 'none';
42
+ /** This process's platform, mapped into the download points' naming. */
43
+ export declare function currentPlatform(): BinaryPlatform;
44
+ /** Caddy's custom-build API, pinned to the Cloudflare DNS module the
45
+ * DNS-01 challenge needs (plain Caddy cannot write the TXT record). */
46
+ export declare function caddyDownloadUrl(platform: BinaryPlatform): string;
47
+ /**
48
+ * The Caddy asset the build API answers with, PLUS its archive shape —
49
+ * `caddyserver.com/api/download` returns a bare Mach-O/ELF binary on unix
50
+ * (`Content-Disposition: attachment; filename="caddy_<os>_<arch>_custom"`,
51
+ * `Content-Type: application/octet-stream`) and a bare `.exe` on Windows.
52
+ */
53
+ export declare function caddyDownload(platform: BinaryPlatform): {
54
+ url: string;
55
+ archive: BinaryArchive;
56
+ };
57
+ /** cloudflared's GitHub Releases asset for one platform, plus the archive
58
+ * shape the I/O half must unwrap (darwin assets are `.tgz`, windows ships
59
+ * a bare `.exe`, linux a bare binary). */
60
+ export declare function cloudflaredDownload(platform: BinaryPlatform): {
61
+ url: string;
62
+ archive: BinaryArchive;
63
+ };
64
+ /** Both download URLs for one platform WITH their archive shapes, defaults
65
+ * to the running process's. The archive metadata — not a URL suffix — is
66
+ * what tells the I/O half how to unpack. */
67
+ export declare function binaryUrls(platform?: BinaryPlatform): {
68
+ caddy: string;
69
+ caddyArchive: BinaryArchive;
70
+ cloudflared: string;
71
+ cloudflaredArchive: BinaryArchive;
72
+ };
73
+ /** Official manual-install pages, surfaced by the UI when a download fails. */
74
+ export declare const MANUAL_INSTALL_LINKS: Readonly<Record<IngressBinary, string>>;
75
+ /** Everything ingress lives under this one directory of DSH_HOME. */
76
+ export declare const INGRESS_DIR_NAME = "zen-remote-ingress";
77
+ /** `<DSH_HOME>` as the rest of the plugin resolves it (config.ts's convention). */
78
+ export declare function dshHomeDefault(env?: NodeJS.ProcessEnv): string;
79
+ /** `<DSH_HOME>/zen-remote-ingress` — Caddyfile, data dir and bin/ sit here. */
80
+ export declare function ingressDir(dshHome: string): string;
81
+ /** `<DSH_HOME>/zen-remote-ingress/bin` — both binaries install here. */
82
+ export declare function binDir(dshHome: string): string;
83
+ /** `<DSH_HOME>/zen-remote-ingress/Caddyfile` — generated, validated, then
84
+ * handed to `caddy run --config`. */
85
+ export declare function caddyfilePath(dshHome: string): string;
86
+ /** `<DSH_HOME>/zen-remote-ingress/caddy-data` — certificates and the ACME
87
+ * account live here, kept out of the default Caddy home. */
88
+ export declare function caddyDataDir(dshHome: string): string;
89
+ /** The installed file name. Windows cannot spawn an extension-less image,
90
+ * so the `.exe` suffix is part of the install name there. */
91
+ export declare function binaryFileName(tool: IngressBinary, platform?: BinaryPlatform): string;
92
+ /** The absolute install path for one binary (where downloadBinary puts it). */
93
+ export declare function binaryInstallPath(dshHome: string, tool: IngressBinary, platform?: BinaryPlatform): string;
94
+ /** Prebuilt Caddy + `github.com/caddy-dns/cloudflare` release assets hosted
95
+ * on this repository's `caddy-cloudflare` GitHub Release (built by
96
+ * `.github/workflows/caddy-assets.yml`). Unlike `caddyserver.com/api/download`
97
+ * — which compiles on the fly and throttles downloads to ~13 KB/s — these
98
+ * static GitHub Release assets download in seconds and work with mainland
99
+ * China GitHub acceleration mirrors (`gh-proxy.com` / `ghfast.top`). */
100
+ export declare function caddyPrebuiltDownload(platform: BinaryPlatform): {
101
+ url: string;
102
+ archive: BinaryArchive;
103
+ };
104
+ /** Mainland China GitHub release acceleration mirrors, tried first when the
105
+ * host environment is detected as mainland China (or tried as fallbacks if
106
+ * direct GitHub times out). */
107
+ export declare const GITHUB_MIRROR_PREFIXES: readonly ["https://gh-proxy.com/", "https://ghfast.top/"];
108
+ /** Ordered candidate downloads for one binary and platform:
109
+ * - When `preferCnMirror` is true, GitHub Release URLs through mainland
110
+ * mirrors come first, followed by direct GitHub Release URL, and finally
111
+ * (for Caddy) the upstream `caddyserver.com/api/download` fallback.
112
+ * - When `preferCnMirror` is false, direct GitHub Release comes first, then
113
+ * mainland mirrors, then the upstream build API fallback. */
114
+ export declare function binaryDownloadCandidates(tool: IngressBinary, platform?: BinaryPlatform, preferCnMirror?: boolean): Array<{
115
+ url: string;
116
+ archive: BinaryArchive;
117
+ }>;
118
+ //# sourceMappingURL=binary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../../../src/wizard/binary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,s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AAEpD,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAE3E;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wEAAwE;AACxE,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;qCACqC;AACrC,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;4DAC4D;AAC5D,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;6DAC6D;AAC7D,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,GAAE,cAAkC,GAAG,MAAM,CAGxG;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,GAAE,cAAkC,GAAG,MAAM,CAE5H;AAED;;;;;wEAKwE;AACxE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAIvG;AAED;;+BAE+B;AAC/B,eAAO,MAAM,sBAAsB,2DAGzB,CAAA;AAEV;;;;;+DAK+D;AAC/D,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,aAAa,EACnB,QAAQ,GAAE,cAAkC,EAC5C,cAAc,UAAQ,GACrB,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAAC,CAWhD"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Managed-Caddy process lifecycle (GW-3). The Caddyfile's content is
3
+ * caddy.ts's job; this module owns everything with a heartbeat:
4
+ *
5
+ * start: ensureBinary (GW-2, cached after the first download) →
6
+ * generateCaddyfile (typed refusals) → write the Caddyfile as a
7
+ * `.part` sibling → `caddy validate --config <part> --adapter
8
+ * caddyfile` → only on a clean validate rename it to the real
9
+ * path → `caddy run --config <Caddyfile>`. The ticket's "validate
10
+ * before write" is honored as validate-before-PUBLISH: the final
11
+ * Caddyfile on disk only ever holds bytes Caddy accepted, and a
12
+ * failed validate leaves neither a start nor a published file.
13
+ *
14
+ * The Cloudflare API token travels in the child's ENVIRONMENT
15
+ * (`CF_API_TOKEN`, what the generated `{env.CF_API_TOKEN}` placeholder
16
+ * reads) — never in argv, which other processes on the machine can see.
17
+ *
18
+ * Idempotency: start with a live process refuses (`already-running`) —
19
+ * switching configuration stops first (design: 切换路时先停旧进程再启新的).
20
+ * stop is idempotent; an exited child clears its own slot so a later
21
+ * start works. The host wiring hands stop to ctx.effect, so the row's
22
+ * disposal kills Caddy too.
23
+ *
24
+ * The subprocess service is structural (the tests feed a recorder), and
25
+ * `fetch` is injectable for the ensureBinary step.
26
+ */
27
+ import { type DownloadProgress } from './binary-io.js';
28
+ import { caddyDataDir, caddyfilePath, ingressDir, type BinaryPlatform } from './binary.js';
29
+ import { type CaddyfileInput } from './caddy.js';
30
+ /** The slice of DSH's subprocess service the manager drives (structural so
31
+ * tests record instead of exec). */
32
+ export interface SubprocessHandleLike {
33
+ terminate(): unknown;
34
+ done: Promise<{
35
+ exitCode?: number | null;
36
+ signal?: string | null;
37
+ }>;
38
+ }
39
+ export interface SubprocessServiceLike {
40
+ spawn(options: {
41
+ argv: string[];
42
+ cwd?: string;
43
+ env?: NodeJS.ProcessEnv;
44
+ stdio?: unknown;
45
+ graceMs?: number;
46
+ }): SubprocessHandleLike;
47
+ }
48
+ export interface CaddyManagerOptions {
49
+ /** The host's subprocess service (ctx.subprocess). */
50
+ subprocess: SubprocessServiceLike;
51
+ /** `<DSH_HOME>` — binaries, Caddyfile and caddy-data all live under it. */
52
+ dshHome: string;
53
+ /** Injected transport for the one-time binary download (tests point it
54
+ * at a mock server). */
55
+ fetchImpl?: typeof fetch;
56
+ /** Forced platform mapping (tests). */
57
+ platform?: BinaryPlatform;
58
+ /** Download progress relay (bytes, declared total or null). */
59
+ onProgress?: DownloadProgress;
60
+ /** Stdio byte caps for the child, both streams. Default 64 KiB — enough
61
+ * for the startup banner and an error or two. */
62
+ maxLogBytes?: number;
63
+ }
64
+ export type CaddyStartResult = {
65
+ ok: true;
66
+ binaryPath: string;
67
+ caddyfile: string;
68
+ alreadyRunning: false;
69
+ } | {
70
+ ok: false;
71
+ error: 'already-running' | 'missing-token' | 'bad-config' | 'download-failed' | 'validate-failed' | 'spawn-failed';
72
+ /** The generateCaddyfile error code for `bad-config`, or a short
73
+ * human-readable line for the transport/spawn failures. */
74
+ detail?: string;
75
+ /** Official manual-install link, present for `download-failed`. */
76
+ installUrl?: string;
77
+ };
78
+ export interface CaddyManager {
79
+ /**
80
+ * Idempotent front door: a live Caddy refuses a second start (stop
81
+ * first to switch configuration). Throws nothing — every failure is a
82
+ * value. The storage directory is this manager's own (under dshHome) —
83
+ * callers supply only the user-facing fields.
84
+ */
85
+ start(input: Omit<CaddyfileInput, 'storageDir'> & {
86
+ cfToken: unknown;
87
+ }): Promise<CaddyStartResult>;
88
+ /** Idempotent terminate; safe before any start. */
89
+ stop(): void;
90
+ /** Whether a child is currently held (true between spawn and exit). */
91
+ isRunning(): boolean;
92
+ /** The live child's Caddyfile path, or undefined. */
93
+ runningCaddyfile(): string | undefined;
94
+ /** Whether any start has succeeded in this manager's lifetime. */
95
+ hasStarted(): boolean;
96
+ }
97
+ export declare function createCaddyManager(options: CaddyManagerOptions): CaddyManager;
98
+ /** Re-exported so the wiring (and later the routes) need one import for
99
+ * the whole ingress-directory layout. */
100
+ export { caddyDataDir, caddyfilePath, ingressDir };
101
+ //# sourceMappingURL=caddy-process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caddy-process.d.ts","sourceRoot":"","sources":["../../../src/wizard/caddy-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyB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AAA;IACT,KAAK,EAAE,iBAAiB,GAAG,eAAe,GAAG,YAAY,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,cAAc,CAAA;IAClH;+DAC2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAEH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAClG,mDAAmD;IACnD,IAAI,IAAI,IAAI,CAAA;IACZ,uEAAuE;IACvE,SAAS,IAAI,OAAO,CAAA;IACpB,qDAAqD;IACrD,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAAA;IACtC,kEAAkE;IAClE,UAAU,IAAI,OAAO,CAAA;CACtB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CA+H7E;AAED;yCACyC;AACzC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,CAAA"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Caddyfile generation (GW-3), pure logic — every byte the managed Caddy
3
+ * will run comes out of {@link generateCaddyfile}, so the validation and
4
+ * the injection guards live HERE and the process half (caddy-process.ts)
5
+ * only writes, validates and spawns what this answered.
6
+ *
7
+ * Shape (design.md 路 A), with one deliberate correction to the design
8
+ * sketch: the global DNS-01 option in a real Caddyfile is `acme_dns
9
+ * <provider> <token-placeholder>` — the sketch's bare `dns cloudflare`
10
+ * line is site-block `tls` syntax and is not valid as a global option.
11
+ * The DNS-01 challenge itself is the point: the certificate is ordered
12
+ * through Cloudflare's API (the token rides the `CF_API_TOKEN`
13
+ * environment variable, never the file), so neither 80 nor 443 needs to
14
+ * be reachable from outside for issuance; only the HTTPS service port
15
+ * must be.
16
+ *
17
+ * Injection posture: every interpolated value passes a charset gate —
18
+ * the domain through config.ts's `hostOf` (the exact validator the row
19
+ * layer applies), the storage path free of control characters, quotes and
20
+ * braces (Caddyfile's block delimiters), the env-var name as a legal
21
+ * POSIX name. Nothing else from the outside world reaches the output.
22
+ */
23
+ /** The default environment variable the Cloudflare token rides in on. */
24
+ export declare const CF_TOKEN_ENV_DEFAULT = "CF_API_TOKEN";
25
+ export interface CaddyfileInput {
26
+ /** Public ingress domain, bare hostname (validated like the row field). */
27
+ domain: unknown;
28
+ /** HTTPS port the managed Caddy listens on. [1, 65535]. */
29
+ httpsPort: unknown;
30
+ /** The gateway's ACTUAL listening port — the caller reads it from the
31
+ * running gateway, never the configured one (it may have retried). */
32
+ gatewayPort: unknown;
33
+ /** Caddy storage directory (certificates + ACME account). */
34
+ storageDir: unknown;
35
+ /** Environment variable name the Cloudflare token arrives in. */
36
+ cfTokenEnvName?: unknown;
37
+ }
38
+ export type CaddyfileResult = {
39
+ ok: true;
40
+ caddyfile: string;
41
+ domain: string;
42
+ httpsPort: number;
43
+ gatewayPort: number;
44
+ } | {
45
+ ok: false;
46
+ error: 'bad-domain' | 'bad-https-port' | 'bad-gateway-port' | 'bad-storage' | 'bad-token-env';
47
+ };
48
+ /**
49
+ * Build the complete Caddyfile for the managed Caddy. Refuses (typed)
50
+ * instead of throwing so the caller can map each refusal to a form error.
51
+ */
52
+ export declare function generateCaddyfile(input: CaddyfileInput): CaddyfileResult;
53
+ //# sourceMappingURL=caddy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caddy.d.ts","sourceRoot":"","sources":["../../../src/wizard/caddy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,iBAAiB,CAAA;AAElD,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,MAAM,EAAE,OAAO,CAAA;IACf,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAA;IAClB;0EACsE;IACtE,WAAW,EAAE,OAAO,CAAA;IACpB,6DAA6D;IAC7D,UAAU,EAAE,OAAO,CAAA;IACnB,iEAAiE;IACjE,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACvF;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,YAAY,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,aAAa,GAAG,eAAe,CAAA;CAAE,CAAA;AAoBhH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CA4BxE"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Cloudflare API v4 client (GW-7) — the whole tunnel path (路 C) talks to
3
+ * this module: account lookup, zone lookup, tunnel create/list, ingress
4
+ * configuration, the CNAME that points the public hostname at the tunnel,
5
+ * and the composed "is this domain on Cloudflare already" check.
6
+ *
7
+ * Transport rules the ticket pins down:
8
+ *
9
+ * - Plain `fetch`, no third-party dependency; the token rides the
10
+ * `Authorization: Bearer` header and is NEVER logged, echoed into an
11
+ * error, or written into any returned structure.
12
+ * - Every failure is a typed {@link CloudflareError} whose `code` the UI
13
+ * classifies on (`cf-auth-failed`, `cf-zone-not-found`,
14
+ * `cf-tunnel-conflict`, `cf-dns-conflict`, `cf-network`, and the
15
+ * catch-all `cf-api`). Raw response bodies never pass through — the
16
+ * message carries only the API's short error summary, truncated,
17
+ * which is what the design's 「兜底显示原始错误码」 wants.
18
+ * - The client is stateless: a factory binds the token (plus injectable
19
+ * `fetchImpl` / `baseUrl` for the mock-server tests); every method
20
+ * takes the ids it needs. The module-level `cf*` wrappers are one-call
21
+ * conveniences over the factory.
22
+ *
23
+ * Conflict classification matches the well-known numeric codes where they
24
+ * exist and falls back to the API's error text (`already exists`
25
+ * wordings), so an upstream renumber degrades to the generic envelope
26
+ * instead of a wrong verdict.
27
+ */
28
+ export declare const CLOUDFLARE_API_BASE = "https://api.cloudflare.com/client/v4";
29
+ export type CloudflareErrorCode = 'cf-auth-failed' | 'cf-zone-not-found' | 'cf-tunnel-conflict' | 'cf-dns-conflict' | 'cf-network' | 'cf-api';
30
+ /**
31
+ * One refused API call. Fields are assigned in the constructor body (the
32
+ * check scripts' strip-only type stripping rejects parameter properties).
33
+ */
34
+ export declare class CloudflareError extends Error {
35
+ readonly code: CloudflareErrorCode;
36
+ readonly status: number | null;
37
+ /** The API's own numeric error code(s), when the envelope carried any. */
38
+ readonly apiCodes: readonly number[];
39
+ constructor(code: CloudflareErrorCode, message: string, status?: number | null, apiCodes?: readonly number[], options?: {
40
+ cause?: unknown;
41
+ });
42
+ }
43
+ export interface CloudflareApiOptions {
44
+ token: string;
45
+ fetchImpl?: typeof fetch;
46
+ baseUrl?: string;
47
+ }
48
+ export interface CloudflareTunnelSummary {
49
+ id: string;
50
+ name: string;
51
+ status: string;
52
+ }
53
+ /** One DNS record summary (the id/content the tunnel setup compares). */
54
+ export interface CloudflareDnsRecord {
55
+ id: string;
56
+ name: string;
57
+ content: string;
58
+ }
59
+ export interface CloudflareDomainCheck {
60
+ onCloudflare: boolean;
61
+ zoneId: string | null;
62
+ accountId: string | null;
63
+ }
64
+ export interface CloudflareApi {
65
+ /** Every account id the token can see. */
66
+ listAccounts(): Promise<string[]>;
67
+ /** The zone id whose name EXACTLY equals `domain`, within one account. */
68
+ getZone(accountId: string, domain: string): Promise<string>;
69
+ /** One new named tunnel; `token` is the connector secret cloudflared runs with. */
70
+ createTunnel(accountId: string, name: string): Promise<{
71
+ id: string;
72
+ token: string;
73
+ }>;
74
+ /** The account's live tunnels (deleted ones filtered server-side). */
75
+ listTunnels(accountId: string): Promise<CloudflareTunnelSummary[]>;
76
+ /** The connector token of an EXISTING tunnel (the re-use path of setup). */
77
+ getTunnelToken(accountId: string, tunnelId: string): Promise<string>;
78
+ /** Map `domain` → `serviceUrl` in the tunnel's ingress, 404 fallback last. */
79
+ configureIngress(accountId: string, tunnelId: string, domain: string, serviceUrl: string): Promise<void>;
80
+ /** One proxied CNAME `subdomain` → `target`; returns the record id. */
81
+ createDnsRecord(zoneId: string, subdomain: string, target: string): Promise<string>;
82
+ /** The CNAME records named `name` in one zone (id/name/content only). */
83
+ listDnsRecords(zoneId: string, name: string): Promise<CloudflareDnsRecord[]>;
84
+ /** Composed check: does any ancestor of `domain` name a zone on the
85
+ * token's accounts (zones are apexes — `dsh.example.com` lives in the
86
+ * `example.com` zone)? */
87
+ checkDomainOnCloudflare(domain: string): Promise<CloudflareDomainCheck>;
88
+ }
89
+ /**
90
+ * The ancestor chain of one hostname, itself first: `dsh.example.com` →
91
+ * `dsh.example.com`, `example.com`, `com`. Cloudflare zones are apex
92
+ * domains, so a wizard lookup for `dsh.example.com` must find the zone
93
+ * named `example.com` (GW-fix-2/H1) — exact-name matching walks this chain
94
+ * level by level.
95
+ */
96
+ export declare function ancestorHosts(domain: string): string[];
97
+ export declare function createCloudflareApi(options: CloudflareApiOptions): CloudflareApi;
98
+ type CfCallOptions = Partial<Pick<CloudflareApiOptions, 'fetchImpl' | 'baseUrl'>>;
99
+ export declare function cfListAccounts(token: string, opts?: CfCallOptions): Promise<string[]>;
100
+ export declare function cfGetZone(token: string, accountId: string, domain: string, opts?: CfCallOptions): Promise<string>;
101
+ export declare function cfCreateTunnel(token: string, accountId: string, name: string, opts?: CfCallOptions): Promise<{
102
+ id: string;
103
+ token: string;
104
+ }>;
105
+ export declare function cfListTunnels(token: string, accountId: string, opts?: CfCallOptions): Promise<CloudflareTunnelSummary[]>;
106
+ export declare function cfGetTunnelToken(token: string, accountId: string, tunnelId: string, opts?: CfCallOptions): Promise<string>;
107
+ export declare function cfConfigureIngress(token: string, accountId: string, tunnelId: string, domain: string, serviceUrl: string, opts?: CfCallOptions): Promise<void>;
108
+ export declare function cfCreateDnsRecord(token: string, zoneId: string, subdomain: string, target: string, opts?: CfCallOptions): Promise<string>;
109
+ export declare function cfListDnsRecords(token: string, zoneId: string, name: string, opts?: CfCallOptions): Promise<CloudflareDnsRecord[]>;
110
+ export declare function cfCheckDomainOnCloudflare(token: string, domain: string, opts?: CfCallOptions): Promise<CloudflareDomainCheck>;
111
+ export {};
112
+ //# sourceMappingURL=cloudflare.d.ts.map