void 0.27.0 → 0.28.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.
Files changed (283) hide show
  1. package/README.md +3 -1
  2. package/dist/{account-cmd-l-FM7Ioq.mjs → account-cmd-Ci00cncT.mjs} +5 -5
  3. package/dist/{agents-B_pX_HmQ.mjs → agents-CuNtT0D_.mjs} +5 -2
  4. package/dist/{application-analysis-DKy02UY0.mjs → application-analysis-D72ZQfMZ.mjs} +118 -135
  5. package/dist/{application-routing-DQyUh_5S.mjs → application-routing-Dy589Vgn.mjs} +1 -2
  6. package/dist/atomic-write-Dq6R0BPN.mjs +18 -0
  7. package/dist/{auth-Dn2vw-SG.mjs → auth-B6iOCjKI.mjs} +23 -56
  8. package/dist/{auth-link-vz9Z2kmG.mjs → auth-link-DWr6Afao.mjs} +10 -10
  9. package/dist/{auth-migrations-BwHgeEsD.mjs → auth-migrations-Cgs0k6lS.mjs} +28 -5
  10. package/dist/{auth-router-DvsCUVw4.mjs → auth-router-DP14wVkZ.mjs} +4 -4
  11. package/dist/auth-wn6F8dB8.mjs +2 -0
  12. package/dist/base64-DVrOndmI.mjs +16 -0
  13. package/dist/{better-auth-shared-CPvWD3nG.d.mts → better-auth-shared-B74NJIus.d.mts} +8 -13
  14. package/dist/{better-auth-shared-DPpj8zxc.mjs → better-auth-shared-CMXlZG7W.mjs} +56 -68
  15. package/dist/{build-cmd-D6we0VjO.mjs → build-cmd-Cr3FJxv0.mjs} +5 -5
  16. package/dist/{cache-CZRdzKx1.mjs → cache-D0Tt28cn.mjs} +5 -5
  17. package/dist/{cancel-deploy-CQ3NnMvf.mjs → cancel-deploy-CJKvk7AN.mjs} +4 -4
  18. package/dist/{cf-access-TWNzXltp.mjs → cf-access-BM9G0lhO.mjs} +4 -3
  19. package/dist/{cf-access-BcIBSKqG.mjs → cf-access-CWP4avfP.mjs} +3 -7
  20. package/dist/cf-build-output-2u583yJK.mjs +2 -0
  21. package/dist/{cf-build-output-DjvB_872.mjs → cf-build-output-Bc8i3dzE.mjs} +2 -2
  22. package/dist/cf-user-agent-ChjQp2MU.mjs +33 -0
  23. package/dist/cli/cli.mjs +198 -311
  24. package/dist/cli/cloudflare-operation-process.mjs +41 -15
  25. package/dist/cli/env-schema-probe.d.mts +5 -43
  26. package/dist/cli/env-schema-probe.mjs +14 -80
  27. package/dist/client-C1BjRn3g.mjs +2 -0
  28. package/dist/{client-DlDJuY0s.mjs → client-DM9Kcf4e.mjs} +161 -415
  29. package/dist/{cloudflare-auth-CuxfF6OA.mjs → cloudflare-auth-CqFBDo52.mjs} +12 -39
  30. package/dist/{cloudflare-cmd-lHqNlJGW.mjs → cloudflare-cmd-CTrn-lXJ.mjs} +6 -5
  31. package/dist/{cloudflare-config-BmhBv3HV.mjs → cloudflare-config-DV60XFFK.mjs} +16 -28
  32. package/dist/{cloudflare-connect-2G3rL2rP.mjs → cloudflare-connect-BosmCNlq.mjs} +3 -3
  33. package/dist/{cloudflare-operations-CwI1bChl.mjs → cloudflare-operations-BKdSfNBN.mjs} +26 -34
  34. package/dist/{cloudflare-operations-BlYLlowZ.mjs → cloudflare-operations-Ds-lX3Ts.mjs} +1 -1
  35. package/dist/{cloudflare-process-2-TfIEzB.mjs → cloudflare-process-CeDWJRhj.mjs} +12 -7
  36. package/dist/collect-NUlJMpLY.mjs +2 -0
  37. package/dist/{collect-DiTn9yr6.mjs → collect-xjffdCdk.mjs} +1 -1
  38. package/dist/{config-CSa15FvD.d.mts → config-7qoq2p9v.d.mts} +2 -2
  39. package/dist/{config-CLYAosnQ.mjs → config-BEm9vRvS.mjs} +11 -5
  40. package/dist/{config-DiowPT80.mjs → config-Bx_1SpnO.mjs} +87 -177
  41. package/dist/config-CNnrSMYm.mjs +2 -0
  42. package/dist/{config-DPByhVck.mjs → config-D0GY5ItR.mjs} +1 -1
  43. package/dist/config-entry.d.mts +1 -1
  44. package/dist/{connect-BfPBHHm-.mjs → connect-nukQSoEO.mjs} +8 -8
  45. package/dist/{create-project-BdXEFKal.mjs → create-project-D4APeBwX.mjs} +7 -7
  46. package/dist/{create-project-qFDC45zg.mjs → create-project-DL7YXpjj.mjs} +1 -1
  47. package/dist/{db-Xs80hcaA.mjs → db-27RztQLy.mjs} +173 -263
  48. package/dist/{delete-d2vuou3j.mjs → delete-BbsZFZIw.mjs} +5 -5
  49. package/dist/deploy-B06EQq4t.mjs +6009 -0
  50. package/dist/deploy-Db2ALnQP.mjs +3 -0
  51. package/dist/deploy-managed-static-CGswbcay.mjs +2277 -0
  52. package/dist/deploy-transport-BiicfoQW.mjs +180 -0
  53. package/dist/deploy.d.mts +10 -0
  54. package/dist/deploy.mjs +82 -0
  55. package/dist/dev-inbox-Rd6j_8vM.mjs +217 -0
  56. package/dist/discover-CTUiSsfG.mjs +2 -0
  57. package/dist/{discover-CkCYv9T_.mjs → discover-D2PGT63u.mjs} +2 -2
  58. package/dist/{dist-BVqXeR_h.mjs → dist-ipQi0Q8y.mjs} +2 -3
  59. package/dist/{domain-BsDUBAvt.mjs → domain-Bfq9n03H.mjs} +7 -22
  60. package/dist/{dotenv-BfU6eqFt.mjs → dotenv-CNazY3-w.mjs} +4 -16
  61. package/dist/{email-d_Aux1vM.mjs → email-BcjSyAL0.mjs} +4 -20
  62. package/dist/{email-_lGAHOhp.mjs → email-DIwaQU4P.mjs} +99 -191
  63. package/dist/email-cloudflare-CH053RxK.mjs +1096 -0
  64. package/dist/email-protocol-D9nTvhCp.mjs +82 -0
  65. package/dist/{entry-CMAkqBmU.mjs → entry-ehmBvs5w.mjs} +2 -2
  66. package/dist/{env-BxocywBB.mjs → env-BJjULvL0.mjs} +2 -2
  67. package/dist/{env-DMA3cXZt.mjs → env-BhdWMrNy.mjs} +2 -13
  68. package/dist/{env-C74QepDE.mjs → env-C6ipBLp3.mjs} +8 -8
  69. package/dist/{env-public-DR7ZM6d-.d.mts → env-public-CCdykygU.d.mts} +6 -23
  70. package/dist/{env-raw-jZpP5n47.mjs → env-raw-Cklzcde3.mjs} +3 -20
  71. package/dist/{env-types-CwXgeMgL.mjs → env-types-DS2_y4X8.mjs} +2 -2
  72. package/dist/{env-validation-CrVNjsPm.mjs → env-validation-CTn-HhG1.mjs} +1 -1
  73. package/dist/env-validation-cE0zcmzO.mjs +486 -0
  74. package/dist/{gen-DtkQhvQg.mjs → gen-CnN1Xidx.mjs} +131 -253
  75. package/dist/gen-F8pSZnhc.mjs +2 -0
  76. package/dist/{generate-GDbL7sUr.mjs → generate-Dat0UTry.mjs} +38 -4
  77. package/dist/generate-Rii9klHB.mjs +2 -0
  78. package/dist/generated-wrangler-config-DeWj5F9Y.mjs +18 -0
  79. package/dist/{github-cmd-DaDdBbSS.mjs → github-cmd-BdkU4Nhe.mjs} +27 -71
  80. package/dist/{handler-BHAn2fZJ.mjs → handler-BZ1t7-Rv.mjs} +2 -2
  81. package/dist/{handler-CNAwjRcW.d.mts → handler-_PqY82xe.d.mts} +1 -1
  82. package/dist/{headers-DlfR78Nu.mjs → headers-Di1FsD3e.mjs} +26 -81
  83. package/dist/{help-0bTe_lID.mjs → help-Bug7pyK_.mjs} +18 -10
  84. package/dist/help-s9q7LTcu.mjs +2 -0
  85. package/dist/{inbound-PfQDLXc5.mjs → inbound-DmkTQeWp.mjs} +71 -222
  86. package/dist/{inbound-CH5Mksyy.d.mts → inbound-brj2-TM5.d.mts} +19 -58
  87. package/dist/index.d.mts +2 -18
  88. package/dist/index.mjs +200 -496
  89. package/dist/{info-PYWwkWyt.mjs → info-CujPwtMe.mjs} +5 -5
  90. package/dist/{init-DaBGmaXC.mjs → init-ZWOJvc-Z.mjs} +179 -388
  91. package/dist/isr-config-DPjXM8J2.mjs +194 -0
  92. package/dist/{link-C6fjafep.mjs → link-UEc7bnF4.mjs} +8 -8
  93. package/dist/{list-BTFBlqKl.mjs → list-CuWeOnzk.mjs} +6 -17
  94. package/dist/{live-CgQuTpqD.mjs → live-BxLX-JqJ.mjs} +19 -17
  95. package/dist/{live-Du8jXwOW.d.mts → live-DJONVlQK.d.mts} +1 -1
  96. package/dist/load-user-env-DD5qveNU.mjs +49 -0
  97. package/dist/{local-d1-ga5O_idV.mjs → local-d1-BM3p74mm.mjs} +6 -6
  98. package/dist/{login-GKcNUmtI.mjs → login-CZ2Cqa-D.mjs} +11 -11
  99. package/dist/login-DhK7o1oJ.mjs +2 -0
  100. package/dist/{logs-BiMSULmc.mjs → logs-TihRcLTk.mjs} +5 -5
  101. package/dist/migrate-BgT-hmu8.mjs +2 -0
  102. package/dist/{migrate-NLsjBbuM.mjs → migrate-uFwojusJ.mjs} +69 -21
  103. package/dist/migration-handler-Cg0Y4EPu.mjs +470 -0
  104. package/dist/{migration-handler-DM4clYj5.d.mts → migration-handler-CwlEQUoo.d.mts} +17 -26
  105. package/dist/{mime-DxCznlJq.mjs → mime-srOklVVv.mjs} +92 -395
  106. package/dist/{node-DJicPvPj.mjs → node-DoKbo1SZ.mjs} +8 -24
  107. package/dist/{operator-args-DOBhIaIg.mjs → operator-args-UnE8Y2eK.mjs} +27 -26
  108. package/dist/{operator-auth-BEZ_u0Cz.mjs → operator-auth-Cr2zCc-J.mjs} +2 -2
  109. package/dist/{operator-client-DbDv4vtE.mjs → operator-client-C-ROjk1I.mjs} +4 -4
  110. package/dist/{operator-cmd-BT4hgavL.mjs → operator-cmd-C5lCctnc.mjs} +8 -8
  111. package/dist/operator-cmd-Cjk5DiRx.mjs +2 -0
  112. package/dist/{output-C50ag2r3.mjs → output-FNHKw5Ac.mjs} +36 -5
  113. package/dist/{package-json-DXfiT1jV.mjs → package-json-BjYqR-So.mjs} +1 -1
  114. package/dist/pages/client.d.mts +1 -1
  115. package/dist/pages/client.mjs +91 -5
  116. package/dist/pages/index.d.mts +1 -2
  117. package/dist/pages/index.mjs +6 -6
  118. package/dist/pages/islands-plugin.mjs +5 -83
  119. package/dist/pages/protocol.d.mts +2 -2
  120. package/dist/pages/protocol.mjs +1 -1
  121. package/dist/pages/serialize.mjs +1 -1
  122. package/dist/{platform-args-DUeXY9Om.mjs → platform-args-C6Mb_I3a.mjs} +34 -58
  123. package/dist/platform-args-Cm7x-fot.mjs +2 -0
  124. package/dist/{platform-auth-config-CkSx3usH.mjs → platform-auth-config-CJmNkFT2.mjs} +10 -11
  125. package/dist/{platform-auth-protection-BJimB_p9.mjs → platform-auth-protection-D5wvsI-Y.mjs} +36 -26
  126. package/dist/{platform-auth-recovery-BU6izFAU.mjs → platform-auth-recovery-D_0I3n-1.mjs} +8 -9
  127. package/dist/{platform-cmd-BbmJiq5O.mjs → platform-cmd-Cuj4oUVo.mjs} +1 -1
  128. package/dist/{platform-cmd-BbY1dWiM.mjs → platform-cmd-DxxZO6e5.mjs} +15 -15
  129. package/dist/{platform-discovery-DIYz8V63.mjs → platform-discovery-CHhNs8Nn.mjs} +1 -1
  130. package/dist/{platform-domain-CHVS6cV0.mjs → platform-domain-zLXnW1G_.mjs} +5 -5
  131. package/dist/{platform-lifecycle-DzCwqhFq.mjs → platform-lifecycle-DOW-wLfx.mjs} +1398 -2043
  132. package/dist/{platform-lifecycle-ByAlpkhV.mjs → platform-lifecycle-_gfnjUBr.mjs} +1 -1
  133. package/dist/{platform-management-CBOT4BSM.mjs → platform-management-CYrLvTGH.mjs} +1 -1
  134. package/dist/{platform-management-CuuVDhyt.mjs → platform-management-t7HKy4-U.mjs} +632 -124
  135. package/dist/{platform-plans-config-CN-heS4q.mjs → platform-plans-config-CNH6zbPX.mjs} +15 -11
  136. package/dist/{platform-recovery-CskSJgLh.mjs → platform-recovery-DeucI7A9.mjs} +6 -9
  137. package/dist/{platform-registry-Cjv2Qf0r.mjs → platform-registry-B9mWX9LO.mjs} +13 -18
  138. package/dist/{platform-setup-BBxRxmFC.mjs → platform-setup-CTf6MMT9.mjs} +19 -26
  139. package/dist/{plugin-inference-BlQbOL0P.mjs → plugin-inference-DsARdQKE.mjs} +18 -33
  140. package/dist/{prepare-Dq9hTIbo.mjs → prepare-C4zfwks4.mjs} +3 -3
  141. package/dist/{prepare-Do96654b.mjs → prepare-CSH9dKTI.mjs} +11 -13
  142. package/dist/prepare-dr9uxQSV.mjs +2 -0
  143. package/dist/{prerender-render-Ct20jftc.mjs → prerender-render-Bfsumdkv.mjs} +8 -2
  144. package/dist/prerender-render.d.mts +2 -0
  145. package/dist/prerender-render.mjs +2 -2
  146. package/dist/project-DiiOBZPF.mjs +2 -0
  147. package/dist/{project-cmd-DaoRrn-8.mjs → project-cmd-Dq75AXzy.mjs} +19 -19
  148. package/dist/{project-paths-GgcMozYz.mjs → project-paths-DMvEeSau.mjs} +9 -14
  149. package/dist/{project-BAm2aB6Q.mjs → project-rqDnVsJN.mjs} +8 -4
  150. package/dist/{project-team-Q_lCA7Io.mjs → project-team-B3_QcStG.mjs} +6 -6
  151. package/dist/{project-token-BArgK9o1.mjs → project-token-CvsRvv2I.mjs} +5 -5
  152. package/dist/{project-tsconfig-CVJhNMxs.mjs → project-tsconfig-bveqhlYA.mjs} +3 -5
  153. package/dist/{project-zero-trust-KO9Hu2Pq.mjs → project-zero-trust-D1ICiwN_.mjs} +5 -5
  154. package/dist/{protocol-BPZaNqBo.d.mts → protocol-4H7V_3Os.d.mts} +1 -1
  155. package/dist/{protocol-CfaUwNs8.mjs → protocol-RNP0u7UY.mjs} +9 -3
  156. package/dist/{provision-BfaLiWbj.mjs → provision-DDh7ITVS.mjs} +118 -865
  157. package/dist/{requests-C7Oeoh5u.mjs → requests-3CL3BuZh.mjs} +4 -4
  158. package/dist/resolve-project-B9Hr0D3n.mjs +2 -0
  159. package/dist/resolve-project-C_Cu7E8a.mjs +48 -0
  160. package/dist/{rollback-DVAtrLAl.mjs → rollback-Ce1d_0J9.mjs} +7 -17
  161. package/dist/{route-types-CbtsIeFn.mjs → route-types-IrBuwJ7u.mjs} +35 -70
  162. package/dist/routing-assets-VkrKIbxE.mjs +139 -0
  163. package/dist/{runner-9wjsSZx-.mjs → runner-B5huK2eC.mjs} +1 -1
  164. package/dist/{runner-DMBKSrRk.mjs → runner-DcVDrzuR.mjs} +7 -28
  165. package/dist/{runner-mysql-CEzKtmFb.mjs → runner-mysql-CCtyI0p6.mjs} +4 -3
  166. package/dist/runner-mysql-CaJq-hd6.mjs +2 -0
  167. package/dist/runner-pg-BJhFZZG4.mjs +2 -0
  168. package/dist/{runner-pg-DV8p_zjA.mjs → runner-pg-CPd-CB_F.mjs} +1 -1
  169. package/dist/runtime/ai.mjs +9 -22
  170. package/dist/runtime/better-auth-mysql.d.mts +2 -5
  171. package/dist/runtime/better-auth-mysql.mjs +6 -31
  172. package/dist/runtime/better-auth-pg.d.mts +2 -5
  173. package/dist/runtime/better-auth-pg.mjs +6 -32
  174. package/dist/runtime/better-auth.d.mts +2 -4
  175. package/dist/runtime/better-auth.mjs +9 -19
  176. package/dist/runtime/db.mjs +1 -1
  177. package/dist/runtime/durable.d.mts +16 -0
  178. package/dist/runtime/durable.mjs +26 -2
  179. package/dist/runtime/email/testing.d.mts +1 -1
  180. package/dist/runtime/email/testing.mjs +9 -23
  181. package/dist/runtime/email-protocol.d.mts +12 -0
  182. package/dist/runtime/email-protocol.mjs +2 -70
  183. package/dist/runtime/email.d.mts +1 -1
  184. package/dist/runtime/email.mjs +79 -221
  185. package/dist/runtime/env-public.d.mts +1 -1
  186. package/dist/runtime/env-public.mjs +12 -38
  187. package/dist/runtime/env.d.mts +1 -12
  188. package/dist/runtime/env.mjs +1 -1
  189. package/dist/runtime/handler.d.mts +1 -1
  190. package/dist/runtime/handler.mjs +1 -1
  191. package/dist/runtime/isr.mjs +1 -1
  192. package/dist/runtime/kv.mjs +1 -1
  193. package/dist/runtime/live-client.d.mts +1 -1
  194. package/dist/runtime/live-server.mjs +1 -16
  195. package/dist/runtime/live.d.mts +1 -1
  196. package/dist/runtime/live.mjs +1 -1
  197. package/dist/runtime/migration-handler-mysql.d.mts +2 -2
  198. package/dist/runtime/migration-handler-mysql.mjs +3 -2
  199. package/dist/runtime/migration-handler-pg.d.mts +2 -2
  200. package/dist/runtime/migration-handler-pg.mjs +1 -1
  201. package/dist/runtime/migration-handler.d.mts +2 -2
  202. package/dist/runtime/migration-handler.mjs +2 -470
  203. package/dist/runtime/queues.mjs +1 -1
  204. package/dist/runtime/remote/binding-handler.mjs +62 -62
  205. package/dist/runtime/remote/index.mjs +16 -77
  206. package/dist/runtime/routing.d.mts +1 -4
  207. package/dist/runtime/routing.mjs +82 -218
  208. package/dist/runtime/sandbox-container.d.mts +2 -2
  209. package/dist/runtime/sandbox-container.mjs +2 -2
  210. package/dist/runtime/sandbox.d.mts +2 -2
  211. package/dist/runtime/sandbox.mjs +13 -6
  212. package/dist/runtime/storage.mjs +1 -1
  213. package/dist/runtime/validator.d.mts +1 -1
  214. package/dist/runtime/ws-server.d.mts +2 -3
  215. package/dist/runtime/ws-server.mjs +6 -28
  216. package/dist/runtime/ws.d.mts +1 -1
  217. package/dist/{sandbox-container-Bo0eiFKz.d.mts → sandbox-container-ChQRum-j.d.mts} +3 -1
  218. package/dist/{sandbox-container-C6ItmVuN.mjs → sandbox-container-DBKIqDEK.mjs} +12 -1
  219. package/dist/{sandbox-C5LFoJMf.d.mts → sandbox-q3waMc2T.d.mts} +1 -1
  220. package/dist/{scan-C3uDzz6J.mjs → scan-C0BMdmEd.mjs} +84 -7
  221. package/dist/{secret-BvtB7IjY.mjs → secret-B5J8bBsI.mjs} +62 -80
  222. package/dist/{serialize-BPvnNQuA.mjs → serialize-BtQyaYoC.mjs} +10 -4
  223. package/dist/{skills-BgVMvQdy.mjs → skills-BJsan98C.mjs} +2 -2
  224. package/dist/{subcommand-prompt-BSlnD1fI.mjs → subcommand-prompt-gQ-NDA-u.mjs} +38 -43
  225. package/dist/sveltekit.mjs +1 -1
  226. package/dist/validate-C9xtFOYR.mjs +2 -0
  227. package/dist/{validate-C9qJArv7.mjs → validate-CheZGRE7.mjs} +4 -8
  228. package/dist/version-metadata-DIrqEHQo.mjs +73 -0
  229. package/dist/{wrangler-D9KTuqnv.mjs → wrangler-BYs07Rxy.mjs} +119 -378
  230. package/dist/{ws-CChrrAU-.d.mts → ws-aKVYB-fA.d.mts} +1 -1
  231. package/dist/yarn-pnp-DLbEFMT0.mjs +92 -0
  232. package/docs/guide/auth.md +2 -0
  233. package/docs/guide/database/postgresql.md +2 -0
  234. package/docs/guide/database.md +2 -0
  235. package/docs/guide/durable-state.md +24 -0
  236. package/docs/guide/platform/administration/access.md +4 -0
  237. package/docs/guide/platform/administration/connected-apps.md +55 -0
  238. package/docs/guide/platform/installation/credentials.md +3 -1
  239. package/docs/guide/quickstart.md +2 -0
  240. package/docs/guide/sandboxes.md +2 -0
  241. package/docs/reference/api/deploy.md +23 -0
  242. package/docs/reference/api/pages.md +2 -0
  243. package/docs/reference/api.md +2 -1
  244. package/docs/reference/cli/database.md +9 -3
  245. package/docs/reference/cli/platform-installation.md +1 -1
  246. package/docs/reference/cli/setup.md +2 -0
  247. package/package.json +13 -16
  248. package/skills/void/SKILL.md +1 -0
  249. package/dist/auth-LMJcNESe.mjs +0 -2
  250. package/dist/cf-build-output-H9a97vME.mjs +0 -2
  251. package/dist/cf-user-agent-lKblH3zU.mjs +0 -17
  252. package/dist/client-tso2OfcG.mjs +0 -2
  253. package/dist/collect-DLyFDiKW.mjs +0 -2
  254. package/dist/config-5r-YpMC-.mjs +0 -2
  255. package/dist/config-B_ggY-IO.mjs +0 -89
  256. package/dist/config-BtSFvXZx.mjs +0 -2
  257. package/dist/config-write-AHGesphx.mjs +0 -61
  258. package/dist/deploy-Bqe1PYBw.mjs +0 -10458
  259. package/dist/deploy-VsWsVQkw.mjs +0 -2
  260. package/dist/dev-inbox-CK-UuPob.mjs +0 -297
  261. package/dist/discover-EDUf6JJw.mjs +0 -2
  262. package/dist/dist-_UUlL6bg.mjs +0 -2
  263. package/dist/env-validation-Dxdx_5wo.mjs +0 -951
  264. package/dist/gen-dA9hW7AV.mjs +0 -2
  265. package/dist/head-client-DzmJGN4C.mjs +0 -90
  266. package/dist/help-DfQYVfGY.mjs +0 -2
  267. package/dist/login-mx_ydhmp.mjs +0 -2
  268. package/dist/migrate-BHp07yJE.mjs +0 -2
  269. package/dist/operator-cmd-CwBB-1yb.mjs +0 -2
  270. package/dist/pages/head-client.d.mts +0 -13
  271. package/dist/pages/head-client.mjs +0 -2
  272. package/dist/platform-args-D4E1PjVw.mjs +0 -2
  273. package/dist/prepare-DRUV-g3X.mjs +0 -2
  274. package/dist/project-DedqCp59.mjs +0 -2
  275. package/dist/provision-Wu9ZBk9L.mjs +0 -2
  276. package/dist/resolve-project-BIeYs9Cw.mjs +0 -2
  277. package/dist/resolve-project-CP8rZs_p.mjs +0 -28
  278. package/dist/runner-mysql-CkFqZ6CE.mjs +0 -2
  279. package/dist/runner-pg-BGYRFdRp.mjs +0 -2
  280. package/dist/runtime/env-helpers.d.mts +0 -2
  281. package/dist/runtime/env-helpers.mjs +0 -2
  282. package/dist/validate-BJr9LfXy.mjs +0 -2
  283. package/dist/yarn-pnp-CUX_iTPA.mjs +0 -188
@@ -1,951 +0,0 @@
1
- import { a as join, n as dirname, u as resolve } from "./dist-BVqXeR_h.mjs";
2
- import { i as voidWarn } from "./log-vqY3pqwI.mjs";
3
- import { n as scanWranglerDotenvKeys } from "./dotenv-BfU6eqFt.mjs";
4
- import { a as isClientEnvKey, i as findReservedEnvKeys, n as LOCAL_ENV_FILE, o as loadLocalEnv, r as findLegacyEnvFiles, s as reservedEnvKeysMessage } from "./env-BxocywBB.mjs";
5
- import { t as findEnvFile } from "./env-types-CwXgeMgL.mjs";
6
- import { l as resolveCloudflareOperationArgv, n as decodeCloudflareOperationResult, r as encodeCloudflareOperation } from "./cloudflare-process-2-TfIEzB.mjs";
7
- import { existsSync, readFileSync } from "node:fs";
8
- import { pathToFileURL } from "node:url";
9
- import { parse } from "jsonc-parser";
10
- import { spawn } from "node:child_process";
11
- //#region src/host/load-user-env.ts
12
- /**
13
- * Loader for the user's `env.ts`.
14
- *
15
- * Uses Node's native `import()` (type-stripping is on by default in the
16
- * supported Node version), so only relative imports and bare package
17
- * specifiers resolve. tsconfig path aliases (`@/foo`, `~/foo`) are NOT
18
- * supported — if the user writes one, we detect the resulting resolution
19
- * error and re-throw with guidance pointing at the offending specifier.
20
- *
21
- * Used by:
22
- * - `plugin-env-schema.ts` (dev plugin, HMR re-imports)
23
- * - `cli/env-validation.ts` (deploy + `void env check`)
24
- *
25
- * Side-effect contract: loading the file evaluates the user's `defineEnv`
26
- * call, which registers the schema in the singleton state in
27
- * `runtime/env-public.ts`. Callers read the result from there.
28
- *
29
- * Node-only (lives under `host/`). Must not be imported from anything
30
- * that ships in worker bundles.
31
- */
32
- let loadCounter = 0;
33
- /** Returns the failed specifier from a Node module-resolution error, or `null`. */
34
- function extractFailedSpecifier(err) {
35
- if (!(err instanceof Error)) return null;
36
- const code = err.code;
37
- if (code !== "ERR_MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") return null;
38
- const match = /Cannot find (?:package|module) '([^']+)'/.exec(err.message);
39
- return match ? match[1] ?? null : null;
40
- }
41
- /** A specifier is alias-shaped if it isn't relative, absolute, a node: URL, or a valid bare package name. */
42
- function looksLikeAlias(specifier) {
43
- if (specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("node:") || specifier.startsWith("file:")) return false;
44
- if (specifier.startsWith("@")) return !/^@[^/]+\/[^/]+/.test(specifier);
45
- return specifier.startsWith("~") || specifier.startsWith("#");
46
- }
47
- /**
48
- * Load the user's env.ts via native `import()`. The URL gets a cache-busting
49
- * query param so HMR re-imports re-evaluate the file.
50
- *
51
- * On resolution failures, wraps the error with the source file path, and if
52
- * the failed specifier looks like a tsconfig path alias, appends guidance
53
- * explaining that env.ts doesn't resolve aliases.
54
- */
55
- async function loadUserEnvFile(envFile) {
56
- const url = pathToFileURL(envFile).href + `?t=${Date.now()}-${++loadCounter}`;
57
- try {
58
- await import(
59
- /* @vite-ignore */
60
- url
61
- );
62
- } catch (err) {
63
- const specifier = extractFailedSpecifier(err);
64
- const base = `env: Failed to load '${envFile}': '${err.message}'.`;
65
- if (specifier && looksLikeAlias(specifier)) throw new Error(`${base}\n\nHint: '${specifier}' looks like a tsconfig path alias. env.ts is loaded directly by Node and does not resolve tsconfig "paths" — use a relative import (e.g. "./shared/...") instead.`);
66
- throw new Error(base);
67
- }
68
- }
69
- //#endregion
70
- //#region src/cli/generated-wrangler-config.ts
71
- /** Parse a generated Wrangler JSON/JSONC config without accepting a partial parse. */
72
- function readGeneratedWranglerConfigFile(path) {
73
- const raw = readFileSync(path, "utf8");
74
- const content = raw.startsWith("") ? raw.slice(1) : raw;
75
- const errors = [];
76
- const parsed = parse(content, errors, { allowTrailingComma: true });
77
- if (errors.length > 0 || parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("Invalid Wrangler JSON/JSONC config.");
78
- return parsed;
79
- }
80
- //#endregion
81
- //#region src/cli/env-validation.ts
82
- /**
83
- * Shared env-schema validation for CLI commands.
84
- *
85
- * Loads the user's `env.ts` (which calls `defineEnv` as a side effect),
86
- * validates the local `.env` or remote production-secret state, and
87
- * validates each declared key against the registered schema.
88
- *
89
- * Used by both `void deploy` (hard error on missing prod env) and
90
- * `void env check` (CI/pre-push validation).
91
- */
92
- /**
93
- * Validate plaintext while it is still available to `void secret put/sync`.
94
- * Existing remote values remain unreadable and are validated again at worker boot.
95
- */
96
- async function validateSecretValues(root, entries) {
97
- const envFile = findEnvFile(root);
98
- if (!envFile) throw new Error("secret: env.ts is required before setting production values.");
99
- const schema = (await loadSchema(envFile))?._getRegisteredSchema();
100
- if (!schema) throw new Error("secret: env.ts did not register a schema with defineEnv().");
101
- for (const { name, value } of entries) {
102
- if (isClientEnvKey(name)) throw new Error(`secret: ${name} is client-exposed. Set it in the build shell or give it a schema default.`);
103
- const validator = schema[name];
104
- if (!validator) throw new Error(`secret: ${name} is not declared in env.ts.`);
105
- const result = validator["~standard"].validate(value);
106
- if ((result instanceof Promise ? await result : result).issues) throw new Error(`secret: ${name} failed env.ts validation.`);
107
- }
108
- }
109
- /** Load the registered schema by importing the user's env.ts. */
110
- async function loadSchema(envFile) {
111
- await loadUserEnvFile(envFile);
112
- const mod = await import("./runtime/env-public.mjs");
113
- if (!mod._hasRegisteredSchema()) return null;
114
- return mod;
115
- }
116
- function emptyReport() {
117
- return {
118
- valid: true,
119
- missing: [],
120
- invalid: [],
121
- values: /* @__PURE__ */ new Map()
122
- };
123
- }
124
- /**
125
- * Validate local development against `.env` + the shell, or production
126
- * against the build shell + remote secret names. `.env` is never a
127
- * production source.
128
- */
129
- async function validateProdEnv(root, options) {
130
- const legacyFiles = findLegacyEnvFiles(root);
131
- if (legacyFiles.length > 0) throw new Error(`env: only .env is supported for local development. Remove ${legacyFiles.join(", ")} and follow the env migration guide.`);
132
- const reservedInDotenv = options.productionOnly ? [] : findReservedEnvKeys(scanWranglerDotenvKeys(join(root, LOCAL_ENV_FILE)));
133
- if (reservedInDotenv.length > 0) throw new Error(`env: ${reservedEnvKeysMessage(".env", reservedInDotenv)}`);
134
- const envFile = findEnvFile(root);
135
- if (!envFile) return {
136
- hasSchema: false,
137
- report: emptyReport()
138
- };
139
- const mod = await loadSchema(envFile);
140
- if (!mod) return {
141
- hasSchema: false,
142
- report: emptyReport()
143
- };
144
- const reservedInSchema = findReservedEnvKeys(Object.keys(mod._getRegisteredSchema() ?? {}));
145
- if (reservedInSchema.length > 0) throw new Error(`env: ${reservedEnvKeysMessage("env.ts", reservedInSchema)}`);
146
- const local = options.productionOnly ? {} : loadLocalEnv(root, { onWarn: (message) => voidWarn(message) });
147
- const shell = options.productionOnly ? Object.fromEntries(Object.entries(process.env).filter(([key]) => isClientEnvKey(key))) : process.env;
148
- const merged = {
149
- ...local,
150
- ...shell
151
- };
152
- const report = await mod.validateAllEnv(merged);
153
- const remoteSet = new Set(options.remoteSecrets ?? []);
154
- if (remoteSet.size > 0 && report.missing.length > 0) {
155
- report.missing = report.missing.filter((key) => isClientEnvKey(key) || !remoteSet.has(key));
156
- if (report.missing.length === 0 && report.invalid.length === 0) report.valid = true;
157
- }
158
- return {
159
- hasSchema: true,
160
- report
161
- };
162
- }
163
- /** Format an EnvValidationReport into a human-readable multi-line string. */
164
- function formatEnvReport(report) {
165
- const lines = [];
166
- if (report.missing.length > 0) {
167
- lines.push("Missing required env vars:");
168
- for (const key of report.missing) lines.push(` • ${key}`);
169
- }
170
- if (report.invalid.length > 0) {
171
- if (lines.length > 0) lines.push("");
172
- lines.push("Invalid env vars:");
173
- for (const { key, messages } of report.invalid) lines.push(` • ${key}: ${messages.join("; ")}`);
174
- }
175
- return lines.join("\n");
176
- }
177
- /** Convenience: fetch remote secret names from the platform. */
178
- async function fetchRemoteSecretNames(client, projectId) {
179
- try {
180
- return (await client.listSecrets(projectId)).map((s) => s.name);
181
- } catch {
182
- return [];
183
- }
184
- }
185
- /**
186
- * The required-key set, derived independently of how any validator treats
187
- * the empty string. A key is required iff its validator REJECTS the ABSENT
188
- * value (probe with `undefined`) — the SAME notion of "required" the managed
189
- * gate uses (a key lands in `validateAllEnv().missing` when its absent value
190
- * yields issues; `_getSchemaDefaults` probes `undefined` the exact same way).
191
- * Requiredness is NEVER inferred from whether `""` validates, so a schema that
192
- * ACCEPTS `""` (e.g. a bare Zod `z.string()`) is still correctly required.
193
- *
194
- * Runs the user's validators (arbitrary code), so callers MUST invoke this
195
- * inside {@link withSchemaBoundary}: a validator that THROWS synchronously or
196
- * REJECTS (async) on the probe surfaces as a values-free structural error, and
197
- * the awaited async probe can never float as an unhandled rejection carrying a
198
- * value. A NORMAL rejection (an `{ issues }` Result, not a thrown/rejected
199
- * error) simply marks the key required.
200
- */
201
- async function requiredSchemaKeys(schema) {
202
- const required = /* @__PURE__ */ new Set();
203
- for (const [key, validator] of Object.entries(schema)) {
204
- const resultMaybe = validator["~standard"].validate(void 0);
205
- if ((resultMaybe instanceof Promise ? await resultMaybe : resultMaybe).issues) required.add(key);
206
- }
207
- return required;
208
- }
209
- /**
210
- * Hard failure fetching the remote secret list (spawn error, signal, nonzero
211
- * exit, timeout, or malformed output). DISTINCT from
212
- * {@link SelfHostEnvValidationError}: this means "we could not learn what
213
- * secrets exist" (fail closed), never "a required secret is missing".
214
- *
215
- * The message and attached fields are values-free by construction: only
216
- * the structural {@link SecretListFailureReason} code and safe scalars
217
- * ({@link SecretListFailureDetail}) are exposed. Raw wrangler output (stderr,
218
- * stdout, rejection/spawn-error text) is NEVER stored here, so no env value the
219
- * child may have echoed can reach `Error.message`, the `reason`/`detail`
220
- * fields, or their JSON serialization — even under `VOID_ENV_UNMASK`.
221
- */
222
- var SelfHostSecretListError = class extends Error {
223
- name = "SelfHostSecretListError";
224
- /** Stable, values-free failure classification. */
225
- reason;
226
- /** Safe scalars (exit code / signal name) — never contain wrangler output. */
227
- detail;
228
- constructor(message, reason, detail = {}) {
229
- super(message);
230
- this.reason = reason;
231
- this.detail = detail;
232
- }
233
- };
234
- /**
235
- * FIRST-DEPLOY specialization of {@link SelfHostSecretListError}: the remote
236
- * secret list could not be fetched because the worker has NOT been deployed
237
- * yet. wrangler 4.131's `secret list` catches the API worker-not-found error
238
- * (codes 10007 / 10090 — `WORKER_NOT_FOUND` / `WORKER_LEGACY_ENVIRONMENT_NOT_FOUND`,
239
- * per `isWorkerNotFoundError` in wrangler-dist/cli.js) and rethrows a `UserError`
240
- * ("… not found. If this is a new Worker, run `wrangler deploy` first to create
241
- * it."), exiting nonzero. Rather than surface that circular "deploy first" dead
242
- * end, this carries the still-unsatisfied required key NAMES plus a
243
- * worker-not-found flag so the deploy orchestrator can render actionable
244
- * `wrangler secret put <NAME>` bootstrap guidance (wrangler can `secret put` to
245
- * a draft worker). Still a HARD, fail-closed error — subclassing keeps existing
246
- * `instanceof SelfHostSecretListError` fail-closed handling intact.
247
- */
248
- var SelfHostFirstDeployError = class extends SelfHostSecretListError {
249
- name = "SelfHostFirstDeployError";
250
- /** Always true — distinguishes this from a generic list failure structurally. */
251
- workerNotFound = true;
252
- /** Required schema key NAMES still unsatisfied locally (values-free). */
253
- missingKeys;
254
- constructor(message, missingKeys, exitCode) {
255
- super(message, "nonzero-exit", { exitCode });
256
- this.missingKeys = missingKeys;
257
- }
258
- };
259
- /**
260
- * The env schema is not satisfied for a self-host production deploy: required
261
- * keys are missing from remote worker secrets, values are invalid, or an EMPTY
262
- * plaintext assignment would
263
- * shadow a remote secret. The message and the attached `report` carry the
264
- * offending key NAMES plus stable, values-free reason codes only — never raw
265
- * input, never resolved values — so nothing on this path can echo a secret
266
- * (see {@link selfHostEnvError}), even under `VOID_ENV_UNMASK`.
267
- */
268
- var SelfHostEnvValidationError = class extends Error {
269
- name = "SelfHostEnvValidationError";
270
- report;
271
- constructor(message, report) {
272
- super(message);
273
- this.report = report;
274
- }
275
- };
276
- /**
277
- * A self-host schema evaluation/validation step threw. DISTINCT from
278
- * {@link SelfHostEnvValidationError} (which means "a required value is missing
279
- * or invalid", carrying key names): this means the schema machinery itself
280
- * raised — env.ts failed to evaluate, or a validator threw/rejected rather than
281
- * returning issues. Values-free by construction: the original error's
282
- * message/stack/cause are DROPPED at the boundary and only the structural
283
- * {@link SelfHostSchemaFailureReason} code + fixed guidance survive, so no env
284
- * value the user's code may have embedded can reach the thrown error, even
285
- * under `VOID_ENV_UNMASK`.
286
- */
287
- var SelfHostSchemaError = class extends Error {
288
- name = "SelfHostSchemaError";
289
- /** Stable, values-free failure classification. */
290
- reason;
291
- constructor(message, reason) {
292
- super(message);
293
- this.reason = reason;
294
- }
295
- };
296
- /** The fixed, values-free message for each schema-failure reason. */
297
- function selfHostSchemaFailureMessage(reason) {
298
- switch (reason) {
299
- case "schema-load-failed": return "env: the project env schema could not be loaded (reason: schema-load-failed). Check that env.ts evaluates without error, then run the deploy again.";
300
- case "schema-validation-error": return "env: an env schema validator raised an error while checking production values (reason: schema-validation-error). Re-run the validator locally to see its own diagnostics.";
301
- }
302
- }
303
- /**
304
- * Values-free boundary around EVERY self-host schema evaluation +
305
- * validation step. `loadSchema` evaluates the user's env.ts and each
306
- * `validateProdEnv` / `validateAllEnv` pass runs the registered validators —
307
- * all arbitrary code that can throw/reject an error EMBEDDING an env value in
308
- * its message, stack, or cause (and `VOID_ENV_UNMASK` disables redaction). Any
309
- * throw/reject from `fn` is caught, its original message/stack/cause DROPPED,
310
- * and a fixed structural {@link SelfHostSchemaError} rethrown in its place. The
311
- * managed `validateProdEnv` itself is NEVER wrapped — only the self-host call
312
- * sites pass through here.
313
- */
314
- async function withSchemaBoundary(reason, fn) {
315
- try {
316
- return await fn();
317
- } catch {
318
- throw new SelfHostSchemaError(selfHostSchemaFailureMessage(reason), reason);
319
- }
320
- }
321
- /** A no-schema {@link SelfHostEnvContext} — nothing to gate. */
322
- function emptyEnvContext() {
323
- return {
324
- hasSchema: false,
325
- presentEmptyRequired: [],
326
- presentEmptySources: {},
327
- absentRequired: [],
328
- invalidKeys: []
329
- };
330
- }
331
- /**
332
- * Derive the {@link SelfHostSchemaFacts} by importing the user's env.ts. Runs
333
- * ARBITRARY project code (env.ts evaluation) + the registered validators' probes,
334
- * so the caller MUST run this in an ISOLATED SUBPROCESS ({@link
335
- * ../cli/env-schema-probe.ts}) under a scrubbed env. Throws only a values-free
336
- * {@link SelfHostSchemaError} (via {@link withSchemaBoundary}) when the schema
337
- * machinery itself fails; the derived names/flags are returned as values-free data.
338
- */
339
- async function deriveSelfHostSchemaFacts(root) {
340
- const envFile = findEnvFile(root);
341
- if (envFile == null) return {
342
- hasSchema: false,
343
- serverKeys: [],
344
- requiredKeys: []
345
- };
346
- const mod = await withSchemaBoundary("schema-load-failed", () => loadSchema(envFile));
347
- if (!mod) return {
348
- hasSchema: false,
349
- serverKeys: [],
350
- requiredKeys: []
351
- };
352
- const schema = mod._getRegisteredSchema() ?? {};
353
- return {
354
- hasSchema: true,
355
- serverKeys: Object.keys(schema).filter((key) => !isClientEnvKey(key)),
356
- requiredKeys: [...await withSchemaBoundary("schema-validation-error", () => requiredSchemaKeys(schema))].filter((key) => !isClientEnvKey(key))
357
- };
358
- }
359
- /**
360
- * Build the values-free {@link SelfHostEnvContext} from the REAL worker `vars` the
361
- * build emitted into `dist/ssr/wrangler.json` (ground truth — never a facsimile)
362
- * plus the env-insensitive {@link SelfHostSchemaFacts}. PURE (no project code, no
363
- * I/O): the parent runs this AFTER the build with the real emitted map, so the
364
- * gate reads exactly what the worker ships.
365
- * - a required key present with an EMPTY value (`K=""` or `K=null`) → SHADOWS a
366
- * same-named remote secret with an unusable value → fail closed ALWAYS
367
- * (`presentEmptyRequired`). Both spellings are treated the same because the
368
- * schema validators classify `null` and `""` as "missing" (not "invalid"), so
369
- * they would otherwise slip past both the invalid-value probe and the absent
370
- * fence while still shadowing the remote secret.
371
- * - a required key ABSENT from the emitted vars → the only state a remote secret
372
- * can discharge (`absentRequired`).
373
- * `invalidKeys` is populated separately from the value-validation probe (the parent
374
- * folds it in); a PRESENT, NON-EMPTY value that fails the schema validator lands there.
375
- */
376
- function deriveSelfHostEnvContextFromVars(emittedVars, facts) {
377
- if (!facts.hasSchema) return emptyEnvContext();
378
- const isEmptyShadow = (value) => value === "" || value === null;
379
- const presentEmptyRequired = facts.requiredKeys.filter((key) => Object.hasOwn(emittedVars, key) && isEmptyShadow(emittedVars[key]));
380
- const absentRequired = facts.requiredKeys.filter((key) => !Object.hasOwn(emittedVars, key));
381
- const presentEmptySources = {};
382
- for (const key of presentEmptyRequired) presentEmptySources[key] = { kind: "emitted" };
383
- return {
384
- hasSchema: true,
385
- presentEmptyRequired,
386
- presentEmptySources,
387
- absentRequired,
388
- invalidKeys: []
389
- };
390
- }
391
- /**
392
- * Follow the CF plugin's deploy pointer (`.wrangler/deploy/config.json` →
393
- * `configPath`) to the generated wrangler config the build emitted, and return it
394
- * parsed. Shared by the parent's ground-truth reads and the isolated
395
- * `validate-emitted` probe child, so both resolve the SAME artifact. Returns a
396
- * fail-closed reason (never throws) when the pointer/config is missing or malformed.
397
- */
398
- function readGeneratedWranglerConfig(root) {
399
- const deployConfigPath = join(root, ".wrangler", "deploy", "config.json");
400
- if (!existsSync(deployConfigPath)) return {
401
- ok: false,
402
- reason: `the CF plugin's deploy pointer at ${deployConfigPath} was not written by the build.`
403
- };
404
- let redirectedPath;
405
- try {
406
- const parsed = JSON.parse(readFileSync(deployConfigPath, "utf-8"));
407
- if (typeof parsed.configPath !== "string" || parsed.configPath.length === 0) return {
408
- ok: false,
409
- reason: `${deployConfigPath} has no "configPath" pointer.`
410
- };
411
- redirectedPath = resolve(dirname(deployConfigPath), parsed.configPath);
412
- } catch {
413
- return {
414
- ok: false,
415
- reason: `${deployConfigPath} is not valid JSON.`
416
- };
417
- }
418
- if (!existsSync(redirectedPath)) return {
419
- ok: false,
420
- reason: `generated wrangler config ${redirectedPath} does not exist.`
421
- };
422
- try {
423
- return {
424
- ok: true,
425
- config: readGeneratedWranglerConfigFile(redirectedPath)
426
- };
427
- } catch {
428
- return {
429
- ok: false,
430
- reason: `generated wrangler config ${redirectedPath} is not valid JSON/JSONC.`
431
- };
432
- }
433
- }
434
- /**
435
- * Read the REAL `vars` map the build baked into `dist/ssr/wrangler.json` (ground
436
- * truth — the exact plaintext the worker ships). A missing `vars` field is an empty
437
- * map (a worker with no vars), not a failure; a missing/malformed artifact fails
438
- * closed. The self-host orchestrator reads this in the parent; the `validate-emitted`
439
- * probe reads it in the child to run the schema validators against those exact
440
- * values in isolation.
441
- */
442
- function readEmittedWorkerVars(root) {
443
- const resolved = readGeneratedWranglerConfig(root);
444
- if (!resolved.ok) return resolved;
445
- const vars = resolved.config.vars;
446
- if (vars === void 0) return {
447
- ok: true,
448
- vars: {}
449
- };
450
- if (vars === null || typeof vars !== "object" || Array.isArray(vars)) return {
451
- ok: false,
452
- reason: "the generated wrangler config has a malformed \"vars\" field (expected an object)."
453
- };
454
- return {
455
- ok: true,
456
- vars
457
- };
458
- }
459
- /**
460
- * Validate the REAL emitted worker `vars` against the registered schema's
461
- * validators and return the FAILING key NAMES only (values-free). A key FAILS iff
462
- * the validator REJECTS the value it was SHIPPED WITH — the UNION of:
463
- * - `report.invalid` (a PRESENT, NON-EMPTY value the validator rejected), plus
464
- * - the `report.missing` keys that are STILL PRESENT in `emittedVars` (the key
465
- * exists in the emitted map with value `null`/`""`). `validateAllEnv` buckets a
466
- * REJECTED `undefined`/`null`/`""` as "missing", not "invalid" (see
467
- * `runtime/env-public.ts` — `isMissing = raw === undefined || raw === null || raw
468
- * === ''`), so an OPTIONAL-with-validator key shipped as `""`/`null` (e.g.
469
- * `z.url().optional()`, which rejects those but the required-empty fence in
470
- * `deriveSelfHostEnvContextFromVars` — `requiredKeys` only — never covers) would
471
- * otherwise slip EVERY gate and boot-reject the deployed worker.
472
- * A `report.missing` key ABSENT from `emittedVars` is NEVER counted: it is a
473
- * genuinely-unset REQUIRED secret that a same-named remote `wrangler secret list`
474
- * secret can still discharge, so it stays with the context's absent fence rather than
475
- * becoming a hard invalid. Runs the user's validators (arbitrary code), so the caller
476
- * MUST run this in the isolated {@link ../cli/env-schema-probe.ts} subprocess; a
477
- * validator that THROWS/REJECTS surfaces as a values-free {@link SelfHostSchemaError}
478
- * via {@link withSchemaBoundary}. NEVER reads `report.invalid[].messages` (which can
479
- * embed the offending value) — only the key names leave here.
480
- */
481
- async function computeInvalidEmittedKeys(root, emittedVars) {
482
- const envFile = findEnvFile(root);
483
- if (envFile == null) return [];
484
- const mod = await withSchemaBoundary("schema-load-failed", () => loadSchema(envFile));
485
- if (!mod) return [];
486
- const report = await withSchemaBoundary("schema-validation-error", () => mod.validateAllEnv(emittedVars));
487
- const invalid = new Set(report.invalid.map((entry) => entry.key));
488
- for (const key of report.missing) if (Object.hasOwn(emittedVars, key)) invalid.add(key);
489
- return Array.from(invalid).sort((a, b) => a.localeCompare(b));
490
- }
491
- /** Build a values-free invalid {@link EnvValidationReport} from key names only. */
492
- function invalidEnvReport(missing, invalidKeys) {
493
- return {
494
- valid: false,
495
- missing,
496
- invalid: invalidKeys.map((key) => ({
497
- key,
498
- messages: [SELF_HOST_INVALID_REASON]
499
- })),
500
- values: /* @__PURE__ */ new Map()
501
- };
502
- }
503
- /**
504
- * DISCHARGE half of the self-host gate — PURE parent work over the values-free
505
- * {@link SelfHostEnvContext}, plus at most one `wrangler secret list`. Runs NO
506
- * project code, NO `loadEnv`, and imports NO env.ts, so the parent never
507
- * evaluates arbitrary code with live credentials in scope. Applies three fences:
508
- * - a PRESENT-EMPTY required key fails closed ALWAYS, before any wrangler spawn;
509
- * - the pinned worker `name` is reconciled against the config's `name`, and the
510
- * target account against the config's `account_id`, BOTH BEFORE `secret list`
511
- * is spawned;
512
- * - an ABSENT required key is discharged only by a same-named remote secret,
513
- * else fails closed ({@link SelfHostFirstDeployError} on a not-yet-deployed
514
- * worker, carrying the missing names + `wrangler secret put` guidance).
515
- */
516
- async function dischargeSelfHostEnvContext(context, options) {
517
- if (!context.hasSchema) return {
518
- hasSchema: false,
519
- remoteSecretNames: null
520
- };
521
- if (context.presentEmptyRequired.length > 0) throw emptyAssignmentError(context.presentEmptyRequired, context.presentEmptySources);
522
- const invalidKeys = context.invalidKeys;
523
- if (context.absentRequired.length === 0) {
524
- if (invalidKeys.length > 0) throw selfHostEnvError(invalidEnvReport([], invalidKeys));
525
- return {
526
- hasSchema: true,
527
- remoteSecretNames: null
528
- };
529
- }
530
- const remoteSecretNames = await listSelfHostSecretNames(options, context.absentRequired);
531
- const remoteSet = new Set(remoteSecretNames);
532
- const stillMissing = context.absentRequired.filter((key) => !remoteSet.has(key));
533
- if (stillMissing.length > 0 || invalidKeys.length > 0) throw selfHostEnvError(invalidEnvReport(stillMissing, invalidKeys));
534
- return {
535
- hasSchema: true,
536
- remoteSecretNames
537
- };
538
- }
539
- /**
540
- * Read the pinned config's top-level `account_id` and reconcile it with
541
- * the caller's requested account, mirroring the provisioner's account gate
542
- * (provision.ts `provisionCloudflareResourcesLocked`). wrangler 4.131 gives the
543
- * config's `account_id` PRECEDENCE over `CLOUDFLARE_ACCOUNT_ID`, so a real
544
- * config-vs-requested mismatch is a fail-closed error (thrown BEFORE any spawn).
545
- * Returns the ONE effective account to pin (config wins, else requested), or
546
- * undefined when neither is set (wrangler then resolves it as it normally would).
547
- */
548
- function reconcileSelfHostAccount(configPath, requestedAccountId) {
549
- const configAccountId = readConfigAccountId(configPath);
550
- if (configAccountId && requestedAccountId && configAccountId !== requestedAccountId) throw new SelfHostSecretListError(`env: Cloudflare account mismatch — "${configPath}" pins account_id ${JSON.stringify(configAccountId)} but the deploy targets ${JSON.stringify(requestedAccountId)}. wrangler resolves the config's account_id before CLOUDFLARE_ACCOUNT_ID, so \`wrangler secret list\` would consult ${JSON.stringify(configAccountId)} while the deploy expects ${JSON.stringify(requestedAccountId)} — a same-named secret there could falsely pass this preflight. Reconcile them (correct or remove the config's account_id, or deploy to the pinned account) and retry.`, "account-mismatch");
551
- return configAccountId ?? requestedAccountId;
552
- }
553
- /**
554
- * Reconcile the config's top-level worker `name` against the name the deploy PINNED
555
- * (deploy.ts step 5 writes `name: workerName` into the root config before the build).
556
- * `wrangler secret list` resolves the worker from the config's `name`
557
- * (`getLegacyScriptName`: `args.name ?? config.name` — we pass no `--name`), so a
558
- * config whose `name` was CHANGED after it was pinned would make the gate list secrets
559
- * for a DIFFERENT worker than the deploy ships — and a same-named secret there could
560
- * falsely pass this preflight while the pinned worker deploys WITHOUT it.
561
- *
562
- * Fires ONLY when the config actually declares a `name` that DIFFERS from a passed
563
- * pinned name (the same "both set and differ" guard as {@link reconcileSelfHostAccount})
564
- * — post-pin the config's `name` IS `workerName`, so a later divergence is exactly the
565
- * laundering signal, while an undefined pinned name or an undeclared config `name` never
566
- * trips a legitimate deploy. Thrown BEFORE any spawn (its message names worker names,
567
- * which are caller/config identifiers, never wrangler output).
568
- */
569
- function reconcileSelfHostWorkerName(configPath, pinnedWorkerName) {
570
- const configName = readConfigName(configPath);
571
- if (configName && pinnedWorkerName && configName !== pinnedWorkerName) throw new SelfHostSecretListError(`env: Cloudflare worker name mismatch — "${configPath}" declares name ${JSON.stringify(configName)} but the deploy pinned ${JSON.stringify(pinnedWorkerName)}. wrangler resolves the worker name from the config's \`name\`, so \`wrangler secret list\` would consult ${JSON.stringify(configName)} while the deploy ships ${JSON.stringify(pinnedWorkerName)} — a same-named secret there could falsely pass this preflight. The config's name was changed after it was pinned; rebuild from a clean checkout, then rerun.`, "name-mismatch");
572
- }
573
- /** UTF-8 BOM, stripped before JSONC parsing (matches provision.ts readRootConfig). */
574
- const UTF8_BOM = "";
575
- /** True when `value` is a non-array object (JSONC-parsed config record). */
576
- function isConfigRecord(value) {
577
- return typeof value === "object" && value !== null && !Array.isArray(value);
578
- }
579
- /**
580
- * Parse the resolved root wrangler config (`-c` target) into a top-level record,
581
- * mirroring the provisioner's `readRootConfig` (jsonc-parser, BOM-stripped,
582
- * trailing commas allowed). We read the SAME file the deploy pins via `-c` and
583
- * force top-level via `--env=`, so its top-level fields are exactly what
584
- * wrangler's `secret list` and the build both resolve. An unreadable/malformed
585
- * config yields undefined — callers then fall back safely (no account gate / no
586
- * root-wrangler var layer), and wrangler itself later fails on a truly broken
587
- * config with a distinct fail-closed {@link SelfHostSecretListError}.
588
- */
589
- function parseRootConfig(configPath) {
590
- if (!existsSync(configPath)) return;
591
- let raw;
592
- try {
593
- raw = readFileSync(configPath, "utf-8");
594
- } catch {
595
- return;
596
- }
597
- const content = raw.startsWith(UTF8_BOM) ? raw.slice(1) : raw;
598
- const errors = [];
599
- const parsed = parse(content, errors, { allowTrailingComma: true });
600
- if (errors.length > 0 || !isConfigRecord(parsed)) return;
601
- return parsed;
602
- }
603
- /**
604
- * Read the top-level `account_id` string from the resolved wrangler config
605
- * (`-c` target). Same file/parse as {@link parseRootConfig}; this is exactly the
606
- * account wrangler's `secret list` will resolve. An unreadable/malformed config
607
- * yields undefined (no reconciliation gate).
608
- */
609
- function readConfigAccountId(configPath) {
610
- const parsed = parseRootConfig(configPath);
611
- if (!parsed) return;
612
- const accountId = parsed.account_id;
613
- return typeof accountId === "string" && accountId.length > 0 ? accountId : void 0;
614
- }
615
- /**
616
- * Read the top-level `name` string from the resolved wrangler config (`-c` target).
617
- * Same file/parse as {@link parseRootConfig}; this is exactly the worker name
618
- * wrangler's `secret list` will resolve. An unreadable/malformed config or an
619
- * absent/empty `name` yields undefined (no reconciliation gate).
620
- */
621
- function readConfigName(configPath) {
622
- const parsed = parseRootConfig(configPath);
623
- if (!parsed) return;
624
- const name = parsed.name;
625
- return typeof name === "string" && name.length > 0 ? name : void 0;
626
- }
627
- /**
628
- * Stable, values-free reason code stamped on every invalid key on the
629
- * self-host path. The raw validator message (e.g. `Expected a number, got
630
- * "not-a-number"`) can EMBED the offending input, and redaction preserves
631
- * benign values / can be disabled via `VOID_ENV_UNMASK`, so the message text is
632
- * never surfaced here — only the key name and this fixed code.
633
- */
634
- const SELF_HOST_INVALID_REASON = "failed schema validation";
635
- /**
636
- * Build the hard error for an unsatisfied schema from KEY NAMES + the
637
- * stable {@link SELF_HOST_INVALID_REASON} code ONLY. It never reads
638
- * `report.invalid[].messages` (which can embed raw input) and never resolved
639
- * `report.values`, and it attaches a freshly-sanitized report of the same
640
- * shape — so neither the thrown message, the attached report, nor its JSON
641
- * serialization can echo a value, even with `VOID_ENV_UNMASK` set.
642
- */
643
- function selfHostEnvError(report) {
644
- const sortNames = (names) => [...names].sort((a, b) => a.localeCompare(b));
645
- const missing = sortNames(report.missing);
646
- const invalidKeys = sortNames(report.invalid.map((i) => i.key));
647
- const lines = [];
648
- if (missing.length > 0) {
649
- lines.push("Missing required env vars:");
650
- for (const key of missing) lines.push(` • ${key}`);
651
- }
652
- if (invalidKeys.length > 0) {
653
- if (lines.length > 0) lines.push("");
654
- lines.push("Invalid env vars:");
655
- for (const key of invalidKeys) lines.push(` • ${key} (${SELF_HOST_INVALID_REASON})`);
656
- }
657
- if (missing.length > 0) lines.push("", "Set each missing production secret with `void secret put <NAME>`.");
658
- const safeReport = {
659
- valid: report.valid,
660
- missing: report.missing,
661
- invalid: report.invalid.map((i) => ({
662
- key: i.key,
663
- messages: [SELF_HOST_INVALID_REASON]
664
- })),
665
- values: /* @__PURE__ */ new Map()
666
- };
667
- return new SelfHostEnvValidationError(lines.join("\n"), safeReport);
668
- }
669
- /**
670
- * The values-free description of a var's WINNING source, used to name the
671
- * ACTUAL origin of a configured-empty key in the remediation. Only the source
672
- * KIND is ever surfaced — never a value. The self-host gate reads ground truth
673
- * (`dist/ssr/wrangler.json` `vars`), so every present key's source is `emitted`.
674
- */
675
- function describeVarSource(source) {
676
- switch (source?.kind) {
677
- case "emitted": return "the built worker config (`dist/ssr/wrangler.json` `vars`)";
678
- default: return "your build env configuration";
679
- }
680
- }
681
- /**
682
- * The hard error for a REQUIRED key set to an EMPTY value (`FOO=""`) in
683
- * the effective build map. Values-free (key names + source KIND/filename only),
684
- * thrown ALWAYS — independent of whether the key exists as a remote secret. The
685
- * build bakes the empty string into plaintext `vars`, and wrangler 4.131 gives a
686
- * config var precedence over a same-named remote secret (`checkRemoteSecretsOverride`
687
- * in wrangler-dist/cli.js warns "… will replace these remote secrets with the
688
- * configuration values"), so shipping this would ship an empty value for a
689
- * required secret (overwriting a remote one if it exists). The remedy is to
690
- * REMOVE the empty assignment, not `secret put`. The remediation names each
691
- * key's source (its {@link VarSource} provenance).
692
- */
693
- function emptyAssignmentError(keys, sources) {
694
- const sorted = [...keys].sort((a, b) => a.localeCompare(b));
695
- const lines = [
696
- "Empty value for a required env var:",
697
- ...sorted.map((key) => ` • ${key} (from ${describeVarSource(sources[key])})`),
698
- "",
699
- "These keys are REQUIRED by your env schema but assigned an EMPTY value in the source noted above. The build bakes the empty value into the worker config as a plaintext var, and Cloudflare gives a config var precedence over any same-named remote secret — so the deploy would ship an empty value for a required secret (overwriting a remote secret if one exists).",
700
- "",
701
- "Remove the empty assignment (so a remote secret can take effect), or set a real value:",
702
- ...sorted.map((key) => ` • ${key} — from ${describeVarSource(sources[key])}`)
703
- ];
704
- const safeReport = {
705
- valid: false,
706
- missing: sorted,
707
- invalid: [],
708
- values: /* @__PURE__ */ new Map()
709
- };
710
- return new SelfHostEnvValidationError(lines.join("\n"), safeReport);
711
- }
712
- /**
713
- * Actionable, values-free bootstrap guidance for the FIRST-DEPLOY case:
714
- * the worker does not exist yet, so its remote secrets can't be listed. Lists
715
- * the still-unsatisfied required key NAMES and the `wrangler secret put <NAME>`
716
- * command that bootstraps each on the draft worker (wrangler can `secret put`
717
- * before a worker's first deploy). Key names only — no values.
718
- */
719
- function firstDeployMessage(missingKeys) {
720
- const sorted = [...missingKeys].sort((a, b) => a.localeCompare(b));
721
- const names = sorted.length > 0 ? sorted : ["<NAME>"];
722
- return [
723
- "This Worker has not been deployed yet, so its remote secrets could not be listed.",
724
- "",
725
- "Required production secrets still unset locally:",
726
- ...sorted.map((key) => ` • ${key}`),
727
- "",
728
- "Bootstrap them on the draft Worker before deploying:",
729
- ...names.map((key) => ` void secret put ${key}`)
730
- ].join("\n");
731
- }
732
- /** Select the generated top-level Worker config for structured secret discovery. */
733
- function secretListOperation(configPath) {
734
- return {
735
- type: "secret.list",
736
- configPath
737
- };
738
- }
739
- /**
740
- * Build the THROWN message for a wrangler-run failure from the structural
741
- * reason code + safe scalars ONLY. It NEVER interpolates `result.stderr`,
742
- * `result.stdout`, a spawn-error string, or a rejection message — those are
743
- * unconstrained (the child inherits `process.env`) and could embed an env
744
- * value. Where wrangler's own diagnostics would help, the message tells the
745
- * user to retry through Void rather than echoing its output here.
746
- */
747
- function secretListFailureMessage(reason, detail) {
748
- const base = "env: `wrangler secret list` could not confirm the remote secrets";
749
- switch (reason) {
750
- case "spawn-error": return `${base} (reason: spawn-error) — the wrangler process could not be started. Check that wrangler is installed and the pinned config path is valid.`;
751
- case "signal": return `${base} (reason: signal) — the process was terminated by ${detail.signal ?? "a signal"} before completing.`;
752
- case "nonzero-exit": return `${base} (reason: nonzero-exit, status ${detail.exitCode ?? "unknown"}). Run \`void secret list\` to retry through Void and see the Cloudflare diagnostics.`;
753
- case "malformed-output": return `${base} (reason: malformed-output) — \`wrangler secret list --format=json\` did not return the expected JSON array of secret objects.`;
754
- }
755
- }
756
- /** Construct a values-free {@link SelfHostSecretListError} for a run failure. */
757
- function secretListError(reason, detail = {}) {
758
- return new SelfHostSecretListError(secretListFailureMessage(reason, detail), reason, detail);
759
- }
760
- /**
761
- * Run `wrangler secret list` through the seam and parse STRICTLY, failing
762
- * CLOSED: any signal, spawn error, nonzero exit, unparseable stdout, or
763
- * malformed list member throws {@link SelfHostSecretListError}. A failure here
764
- * is never interpreted as "no secrets exist" — that would let a deploy proceed
765
- * with required secrets actually missing on the worker.
766
- *
767
- * A completed failure with a typed missing-Worker code is a
768
- * DISTINCT, structured {@link SelfHostFirstDeployError} carrying the still
769
- * unsatisfied required `missingKeys` + `void secret put` bootstrap guidance,
770
- * instead of the generic "list exited nonzero" dead end.
771
- *
772
- * Raw child output (stderr/stdout, spawn-error text, rejection messages)
773
- * does not participate in missing-Worker classification. Every THROWN
774
- * error carries only a structural {@link SecretListFailureReason} code and safe
775
- * scalars (exit code / signal name), so no env value the child may have echoed
776
- * can reach the error's message, fields, or JSON — even under `VOID_ENV_UNMASK`.
777
- */
778
- async function fetchSelfHostSecretNames(run, configPath, missingKeys) {
779
- let result;
780
- try {
781
- result = await Promise.resolve(run(secretListOperation(configPath)));
782
- } catch {
783
- throw secretListError("spawn-error");
784
- }
785
- if (result.error != null && result.error !== "") throw secretListError("spawn-error");
786
- if (result.signal != null) throw secretListError("signal", { signal: String(result.signal) });
787
- if (typeof result.status !== "number" || result.status !== 0) {
788
- const exitCode = typeof result.status === "number" ? result.status : void 0;
789
- if (Number.isSafeInteger(result.status) && result.status > 0 && ([10007, 10090].includes(result.errorCode ?? 0) || result.failure === "not-found")) throw new SelfHostFirstDeployError(firstDeployMessage(missingKeys), missingKeys, exitCode);
790
- throw secretListError("nonzero-exit", { exitCode });
791
- }
792
- const parsed = result.data;
793
- if (!Array.isArray(parsed)) throw secretListError("malformed-output");
794
- const names = [];
795
- for (const member of parsed) {
796
- const name = member !== null && typeof member === "object" && !Array.isArray(member) ? member.name : void 0;
797
- if (typeof name !== "string" || name.length === 0) throw secretListError("malformed-output");
798
- names.push(name);
799
- }
800
- return names;
801
- }
802
- /**
803
- * List one pinned self-host Worker's remote secret names. Reconciles the root
804
- * config's worker/account identity before spawning wrangler, then delegates to
805
- * the same strict, values-free parser used by the production env gate.
806
- *
807
- * Exported so deploy-owned secret provisioning can share the exact same
808
- * first-deploy and malformed-output classification without duplicating it.
809
- */
810
- async function listSelfHostSecretNames(options, missingKeys = []) {
811
- reconcileSelfHostWorkerName(options.configPath, options.workerName);
812
- const effectiveAccountId = reconcileSelfHostAccount(options.configPath, options.accountId);
813
- return fetchSelfHostSecretNames(options.runWrangler ?? createDefaultSecretListRunner(options.root, {
814
- accountId: effectiveAccountId,
815
- timeoutMs: options.timeoutMs
816
- }), options.configPath, missingKeys);
817
- }
818
- /**
819
- * Hard timeout for one `wrangler secret list` invocation — same bound as the
820
- * provisioner's per-command timeout. A hung wrangler must never hang the
821
- * whole deploy preflight.
822
- */
823
- const SECRET_LIST_TIMEOUT_MS = 12e4;
824
- /**
825
- * Default {@link RunSecretList}: resolves wrangler's REAL CLI entry
826
- * (`wrangler-dist/cli.js`, not the signal-swallowing `bin` wrapper) via
827
- * {@link resolveCloudflareOperationArgv} and spawns it ASYNC with `shell: false`, so every
828
- * argv element is passed literally (no shell → no metacharacter injection) and
829
- * the event loop stays free. A hard timeout SIGKILLs a hung child; the result
830
- * carries `{status, signal, error}` provenance so the caller fails closed on
831
- * anything but a clean exit 0.
832
- *
833
- * Deliberately simpler than the provisioner's runner: this is a ONE-SHOT
834
- * READ-ONLY query outside the provision lock — no lock heartbeat to protect,
835
- * nothing a lingering child could mutate — so the group-kill/quarantine
836
- * machinery is unnecessary. If the SIGKILL cannot be confirmed (close never
837
- * fires), a bounded fallback settles the call as a HARD failure anyway.
838
- */
839
- function createDefaultSecretListRunner(root, options) {
840
- const launcher = options?.launcher ?? resolveCloudflareOperationArgv(root);
841
- const timeoutMs = options?.timeoutMs ?? SECRET_LIST_TIMEOUT_MS;
842
- const [command, ...prefix] = launcher;
843
- return (args) => new Promise((resolvePromise) => {
844
- const child = spawn(command, [...prefix, ...encodeCloudflareOperation(args)], {
845
- cwd: root,
846
- shell: false,
847
- env: secretListEnv(options?.accountId),
848
- stdio: [
849
- "ignore",
850
- "pipe",
851
- "pipe"
852
- ],
853
- windowsHide: true
854
- });
855
- let stdout = "";
856
- let stderr = "";
857
- let settled = false;
858
- let timedOut = false;
859
- let killFallbackTimer;
860
- child.stdout?.setEncoding("utf-8");
861
- child.stderr?.setEncoding("utf-8");
862
- child.stdout?.on("data", (chunk) => {
863
- stdout += chunk;
864
- });
865
- child.stderr?.on("data", (chunk) => {
866
- stderr += chunk;
867
- });
868
- const settle = (result) => {
869
- if (settled) return;
870
- settled = true;
871
- clearTimeout(commandTimer);
872
- clearTimeout(killFallbackTimer);
873
- resolvePromise(decodeCloudflareOperationResult(result));
874
- };
875
- const timeoutNote = `env: wrangler secret list exceeded the ${timeoutMs}ms timeout`;
876
- const commandTimer = setTimeout(() => {
877
- timedOut = true;
878
- try {
879
- child.kill("SIGKILL");
880
- } catch {}
881
- killFallbackTimer = setTimeout(() => {
882
- settle({
883
- stdout,
884
- stderr: [stderr, timeoutNote].filter(Boolean).join("\n"),
885
- status: -1,
886
- signal: "SIGKILL",
887
- error: "timed out and termination could not be confirmed"
888
- });
889
- }, 5e3);
890
- }, timeoutMs);
891
- child.on("error", (error) => {
892
- settle({
893
- stdout,
894
- stderr,
895
- status: -1,
896
- signal: null,
897
- error: error.message
898
- });
899
- });
900
- child.on("close", (code, signal) => {
901
- settle({
902
- stdout,
903
- stderr: timedOut ? [stderr, timeoutNote].filter(Boolean).join("\n") : stderr,
904
- status: typeof code === "number" ? code : -1,
905
- signal: signal ?? (timedOut ? "SIGKILL" : null)
906
- });
907
- });
908
- });
909
- }
910
- /**
911
- * Child env for the spawned `wrangler secret list`. Mirrors deploy.ts's
912
- * `buildEnv` (not imported — deploy.ts imports this module): the CF Access
913
- * service-token pair is for the Void platform API client only and must never
914
- * leak into a spawned wrangler. Pins `WRANGLER_LOG_SANITIZE=true` (same as the
915
- * provisioner) and the caller's account id when provided. Unlike the
916
- * provisioner's `provisionEnv`, ambient transport env (`CLOUDFLARE_API_BASE_URL`
917
- * etc.) is left untouched: this preflight has no second transport to keep in
918
- * lockstep, and scrubbing would silently redirect a staging/FedRAMP user's
919
- * `secret list` at the production endpoint.
920
- *
921
- * Windows environment keys are CASE-INSENSITIVE (same hazard `provisionEnv`
922
- * guards): an ambient mixed-case spelling (`Cloudflare_Account_Id`) could
923
- * shadow an exact-case pin, so on win32 every case-variant of a scrubbed or
924
- * pinned key is removed first. Exported (with a platform seam) for direct
925
- * unit testing of that case rule; production callers pass no platform.
926
- */
927
- function secretListEnv(accountId, platform) {
928
- const env = { ...process.env };
929
- const caseInsensitive = (platform ?? process.platform) === "win32";
930
- const scrub = (name) => {
931
- if (!caseInsensitive) {
932
- delete env[name];
933
- return;
934
- }
935
- const lower = name.toLowerCase();
936
- for (const key of Object.keys(env)) if (key.toLowerCase() === lower) delete env[key];
937
- };
938
- scrub("CF_ACCESS_CLIENT_ID");
939
- scrub("CF_ACCESS_CLIENT_SECRET");
940
- scrub("VOID_ACCESS_CREDENTIALS");
941
- scrub("VOID_ACCESS_ORIGIN");
942
- scrub("WRANGLER_LOG_SANITIZE");
943
- env.WRANGLER_LOG_SANITIZE = "true";
944
- if (accountId) {
945
- scrub("CLOUDFLARE_ACCOUNT_ID");
946
- env.CLOUDFLARE_ACCOUNT_ID = accountId;
947
- }
948
- return env;
949
- }
950
- //#endregion
951
- export { validateSecretValues as _, computeInvalidEmittedKeys as a, deriveSelfHostSchemaFacts as c, formatEnvReport as d, listSelfHostSecretNames as f, validateProdEnv as g, selfHostSchemaFailureMessage as h, SelfHostSecretListError as i, dischargeSelfHostEnvContext as l, secretListEnv as m, SelfHostFirstDeployError as n, createDefaultSecretListRunner as o, readEmittedWorkerVars as p, SelfHostSchemaError as r, deriveSelfHostEnvContextFromVars as s, SelfHostEnvValidationError as t, fetchRemoteSecretNames as u, readGeneratedWranglerConfigFile as v, loadUserEnvFile as y };