@geekmidas/cli 10.0.0-alpha.17 → 10.0.0-alpha.170

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 (452) hide show
  1. package/README.md +323 -380
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-C1h_wExz.cjs +1098 -0
  7. package/dist/EndpointGenerator-C1h_wExz.cjs.map +1 -0
  8. package/dist/EndpointGenerator-CSKhAD6W.mjs +1039 -0
  9. package/dist/EndpointGenerator-CSKhAD6W.mjs.map +1 -0
  10. package/dist/GoDaddyProvider-Cf4MIuaD.mjs +412 -0
  11. package/dist/GoDaddyProvider-Cf4MIuaD.mjs.map +1 -0
  12. package/dist/GoDaddyProvider-DK9_Jw9d.cjs +412 -0
  13. package/dist/GoDaddyProvider-DK9_Jw9d.cjs.map +1 -0
  14. package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-CQebZrz3.mjs} +23 -9
  15. package/dist/HostingerProvider-CQebZrz3.mjs.map +1 -0
  16. package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-qQzo4MYp.cjs} +23 -9
  17. package/dist/HostingerProvider-qQzo4MYp.cjs.map +1 -0
  18. package/dist/LegacyStateStore-BeMRGXRi.cjs +124 -0
  19. package/dist/LegacyStateStore-BeMRGXRi.cjs.map +1 -0
  20. package/dist/LegacyStateStore-DXPHKdMk.mjs +124 -0
  21. package/dist/LegacyStateStore-DXPHKdMk.mjs.map +1 -0
  22. package/dist/LocalStateStore-BYQ9lPje.mjs +167 -0
  23. package/dist/LocalStateStore-BYQ9lPje.mjs.map +1 -0
  24. package/dist/LocalStateStore-E_sa5GR2.cjs +178 -0
  25. package/dist/LocalStateStore-E_sa5GR2.cjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-5xPn-p65.mjs +534 -0
  27. package/dist/OpenApiTsGenerator-5xPn-p65.mjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-CzrLGzC0.cjs +539 -0
  29. package/dist/OpenApiTsGenerator-CzrLGzC0.cjs.map +1 -0
  30. package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-Di_SD9CF.mjs} +3 -3
  31. package/dist/Route53Provider-Di_SD9CF.mjs.map +1 -0
  32. package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-emLuQHVw.cjs} +3 -3
  33. package/dist/Route53Provider-emLuQHVw.cjs.map +1 -0
  34. package/dist/S3StateStore-BQaGVNRf.mjs +223 -0
  35. package/dist/S3StateStore-BQaGVNRf.mjs.map +1 -0
  36. package/dist/S3StateStore-Cjr4Rtsf.cjs +222 -0
  37. package/dist/S3StateStore-Cjr4Rtsf.cjs.map +1 -0
  38. package/dist/SSMStateStore-Bq_S7x5_.mjs +205 -0
  39. package/dist/SSMStateStore-Bq_S7x5_.mjs.map +1 -0
  40. package/dist/SSMStateStore-Cnfwdlme.cjs +204 -0
  41. package/dist/SSMStateStore-Cnfwdlme.cjs.map +1 -0
  42. package/dist/SubscriberGenerator-CfZWX0lT.mjs +783 -0
  43. package/dist/SubscriberGenerator-CfZWX0lT.mjs.map +1 -0
  44. package/dist/SubscriberGenerator-DMi4siph.cjs +848 -0
  45. package/dist/SubscriberGenerator-DMi4siph.cjs.map +1 -0
  46. package/dist/add-3_IHpF5F.cjs +713 -0
  47. package/dist/add-3_IHpF5F.cjs.map +1 -0
  48. package/dist/add-CNQFnG0C.mjs +711 -0
  49. package/dist/add-CNQFnG0C.mjs.map +1 -0
  50. package/dist/appPorts-BoXMwolc.mjs +249 -0
  51. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  52. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  53. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  54. package/dist/apps-BGu47YRF.cjs +6404 -0
  55. package/dist/apps-BGu47YRF.cjs.map +1 -0
  56. package/dist/apps-DGod3aS9.mjs +5765 -0
  57. package/dist/apps-DGod3aS9.mjs.map +1 -0
  58. package/dist/aws-C5LAU_Ii.mjs +97 -0
  59. package/dist/aws-C5LAU_Ii.mjs.map +1 -0
  60. package/dist/aws-DKC2m3sT.cjs +108 -0
  61. package/dist/aws-DKC2m3sT.cjs.map +1 -0
  62. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  63. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  64. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  65. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  66. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  67. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  68. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  69. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  70. package/dist/backups/runner.cjs +519 -0
  71. package/dist/backups/runner.cjs.map +1 -0
  72. package/dist/backups/runner.d.cts +102 -0
  73. package/dist/backups/runner.d.cts.map +1 -0
  74. package/dist/backups/runner.d.mts +102 -0
  75. package/dist/backups/runner.d.mts.map +1 -0
  76. package/dist/backups/runner.mjs +506 -0
  77. package/dist/backups/runner.mjs.map +1 -0
  78. package/dist/{bundler-mjqGAvu1.cjs → bundler-DWGxNGSB.cjs} +59 -14
  79. package/dist/bundler-DWGxNGSB.cjs.map +1 -0
  80. package/dist/{bundler-mwH7WOb1.mjs → bundler-Dm0mB7EK.mjs} +59 -14
  81. package/dist/bundler-Dm0mB7EK.mjs.map +1 -0
  82. package/dist/cli-CYeZF85I.cjs +80 -0
  83. package/dist/cli-CYeZF85I.cjs.map +1 -0
  84. package/dist/cli-Qm-8tG46.mjs +80 -0
  85. package/dist/cli-Qm-8tG46.mjs.map +1 -0
  86. package/dist/compose-BVeevJO_.mjs +3139 -0
  87. package/dist/compose-BVeevJO_.mjs.map +1 -0
  88. package/dist/compose-CXgwCuqv.mjs +1560 -0
  89. package/dist/compose-CXgwCuqv.mjs.map +1 -0
  90. package/dist/compose-CshnO-Th.cjs +1919 -0
  91. package/dist/compose-CshnO-Th.cjs.map +1 -0
  92. package/dist/compose-IsvqY6iX.cjs +3240 -0
  93. package/dist/compose-IsvqY6iX.cjs.map +1 -0
  94. package/dist/config-B8gSu59v.d.mts +291 -0
  95. package/dist/config-B8gSu59v.d.mts.map +1 -0
  96. package/dist/config-u5XdE1Cq.d.cts +291 -0
  97. package/dist/config-u5XdE1Cq.d.cts.map +1 -0
  98. package/dist/config.cjs +457 -9
  99. package/dist/config.cjs.map +1 -0
  100. package/dist/config.d.cts +4 -117
  101. package/dist/config.d.mts +4 -117
  102. package/dist/config.mjs +441 -3
  103. package/dist/config.mjs.map +1 -0
  104. package/dist/credentialSchemas-BzJiK1nQ.mjs +236 -0
  105. package/dist/credentialSchemas-BzJiK1nQ.mjs.map +1 -0
  106. package/dist/credentialSchemas-OVXofU-r.cjs +271 -0
  107. package/dist/credentialSchemas-OVXofU-r.cjs.map +1 -0
  108. package/dist/credentials-CKIeLL7T.mjs +1838 -0
  109. package/dist/credentials-CKIeLL7T.mjs.map +1 -0
  110. package/dist/credentials-DzR2j8h1.cjs +2293 -0
  111. package/dist/credentials-DzR2j8h1.cjs.map +1 -0
  112. package/dist/databases-CuTL1e7s.cjs +703 -0
  113. package/dist/databases-CuTL1e7s.cjs.map +1 -0
  114. package/dist/databases-zN-gEox0.mjs +588 -0
  115. package/dist/databases-zN-gEox0.mjs.map +1 -0
  116. package/dist/define-6poNqm5O.mjs +106 -0
  117. package/dist/define-6poNqm5O.mjs.map +1 -0
  118. package/dist/define-crmMcXFS.cjs +153 -0
  119. package/dist/define-crmMcXFS.cjs.map +1 -0
  120. package/dist/deploy/public.cjs +211 -0
  121. package/dist/deploy/public.cjs.map +1 -0
  122. package/dist/deploy/public.d.cts +658 -0
  123. package/dist/deploy/public.d.cts.map +1 -0
  124. package/dist/deploy/public.d.mts +658 -0
  125. package/dist/deploy/public.d.mts.map +1 -0
  126. package/dist/deploy/public.mjs +144 -0
  127. package/dist/deploy/public.mjs.map +1 -0
  128. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  129. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  130. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  131. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  132. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  133. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  134. package/dist/deploy/sniffer-hooks.cjs +1 -1
  135. package/dist/deploy/sniffer-hooks.mjs +1 -1
  136. package/dist/deploy/sniffer-loader.cjs +2 -2
  137. package/dist/deploy/sniffer-loader.mjs +1 -1
  138. package/dist/deploy/sniffer-routes-worker.cjs +2 -2
  139. package/dist/deploy/sniffer-routes-worker.mjs +1 -1
  140. package/dist/deploy-CjubyZlP.mjs +3848 -0
  141. package/dist/deploy-CjubyZlP.mjs.map +1 -0
  142. package/dist/deploy-DQjEjUfB.cjs +3904 -0
  143. package/dist/deploy-DQjEjUfB.cjs.map +1 -0
  144. package/dist/destroy-D1375m8C.cjs +789 -0
  145. package/dist/destroy-D1375m8C.cjs.map +1 -0
  146. package/dist/destroy-D4m5aO9k.mjs +788 -0
  147. package/dist/destroy-D4m5aO9k.mjs.map +1 -0
  148. package/dist/discover-39VKSE2i.cjs +1085 -0
  149. package/dist/discover-39VKSE2i.cjs.map +1 -0
  150. package/dist/discover-B_PDDaVj.mjs +940 -0
  151. package/dist/discover-B_PDDaVj.mjs.map +1 -0
  152. package/dist/docker-C27YUUMQ.mjs +1413 -0
  153. package/dist/docker-C27YUUMQ.mjs.map +1 -0
  154. package/dist/docker-CSEAKwFr.cjs +1520 -0
  155. package/dist/docker-CSEAKwFr.cjs.map +1 -0
  156. package/dist/dokploy-CSqDsvY-.mjs +38 -0
  157. package/dist/dokploy-CSqDsvY-.mjs.map +1 -0
  158. package/dist/dokploy-DJDdiFz6.cjs +38 -0
  159. package/dist/dokploy-DJDdiFz6.cjs.map +1 -0
  160. package/dist/drivers-BhdC9Efj.cjs +248 -0
  161. package/dist/drivers-BhdC9Efj.cjs.map +1 -0
  162. package/dist/drivers-wcDnzf7l.mjs +213 -0
  163. package/dist/drivers-wcDnzf7l.mjs.map +1 -0
  164. package/dist/eas-DC3F8cy0.mjs +334 -0
  165. package/dist/eas-DC3F8cy0.mjs.map +1 -0
  166. package/dist/eas-DryGYjFk.cjs +337 -0
  167. package/dist/eas-DryGYjFk.cjs.map +1 -0
  168. package/dist/emit-C4KSXOeS.mjs +153 -0
  169. package/dist/emit-C4KSXOeS.mjs.map +1 -0
  170. package/dist/emit-DiW0kbue.cjs +164 -0
  171. package/dist/emit-DiW0kbue.cjs.map +1 -0
  172. package/dist/encryption-8qZGm15p.cjs +90 -0
  173. package/dist/encryption-8qZGm15p.cjs.map +1 -0
  174. package/dist/encryption-C8Y8Ly6n.mjs +89 -0
  175. package/dist/encryption-C8Y8Ly6n.mjs.map +1 -0
  176. package/dist/engine-C9E0MeLm.mjs +3216 -0
  177. package/dist/engine-C9E0MeLm.mjs.map +1 -0
  178. package/dist/engine-DI7JAyiD.cjs +3329 -0
  179. package/dist/engine-DI7JAyiD.cjs.map +1 -0
  180. package/dist/errors-D8Gwp5kU.mjs +23 -0
  181. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  182. package/dist/errors-DMC4Umsb.cjs +34 -0
  183. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  184. package/dist/github-DdaV-Gll.mjs +977 -0
  185. package/dist/github-DdaV-Gll.mjs.map +1 -0
  186. package/dist/github-g3nRZlli.cjs +978 -0
  187. package/dist/github-g3nRZlli.cjs.map +1 -0
  188. package/dist/googlePlay-BHJ_iThq.cjs +931 -0
  189. package/dist/googlePlay-BHJ_iThq.cjs.map +1 -0
  190. package/dist/googlePlay-BmeR1kY4.mjs +931 -0
  191. package/dist/googlePlay-BmeR1kY4.mjs.map +1 -0
  192. package/dist/iam-BoYPPNdM.cjs +521 -0
  193. package/dist/iam-BoYPPNdM.cjs.map +1 -0
  194. package/dist/iam-ra1_Y405.mjs +442 -0
  195. package/dist/iam-ra1_Y405.mjs.map +1 -0
  196. package/dist/{index-RCUizGxL.d.cts → index-1H93w_H6.d.cts} +38 -14
  197. package/dist/index-1H93w_H6.d.cts.map +1 -0
  198. package/dist/{index-B4H4XF7A.d.mts → index-DFZ0SMwN.d.mts} +38 -14
  199. package/dist/index-DFZ0SMwN.d.mts.map +1 -0
  200. package/dist/index.cjs +15142 -13470
  201. package/dist/index.cjs.map +1 -1
  202. package/dist/index.mjs +14959 -13285
  203. package/dist/index.mjs.map +1 -1
  204. package/dist/local-Bkv-e8uM.mjs +224 -0
  205. package/dist/local-Bkv-e8uM.mjs.map +1 -0
  206. package/dist/local-DTidpa-a.cjs +241 -0
  207. package/dist/local-DTidpa-a.cjs.map +1 -0
  208. package/dist/migrate-BZRsJwni.mjs +181 -0
  209. package/dist/migrate-BZRsJwni.mjs.map +1 -0
  210. package/dist/migrate-CXLhrHwu.cjs +272 -0
  211. package/dist/migrate-CXLhrHwu.cjs.map +1 -0
  212. package/dist/migrate-DNOI23QA.mjs +267 -0
  213. package/dist/migrate-DNOI23QA.mjs.map +1 -0
  214. package/dist/migrate-DU4MtKxz.cjs +181 -0
  215. package/dist/migrate-DU4MtKxz.cjs.map +1 -0
  216. package/dist/next.cjs +59 -0
  217. package/dist/next.cjs.map +1 -0
  218. package/dist/next.d.cts +44 -0
  219. package/dist/next.d.cts.map +1 -0
  220. package/dist/next.d.mts +44 -0
  221. package/dist/next.d.mts.map +1 -0
  222. package/dist/next.mjs +58 -0
  223. package/dist/next.mjs.map +1 -0
  224. package/dist/notes-1TM_Vzi7.mjs +408 -0
  225. package/dist/notes-1TM_Vzi7.mjs.map +1 -0
  226. package/dist/notes-BpaXOAkA.cjs +509 -0
  227. package/dist/notes-BpaXOAkA.cjs.map +1 -0
  228. package/dist/openapi.cjs +213 -7
  229. package/dist/openapi.cjs.map +1 -0
  230. package/dist/openapi.d.cts +32 -8
  231. package/dist/openapi.d.cts.map +1 -1
  232. package/dist/openapi.d.mts +32 -8
  233. package/dist/openapi.d.mts.map +1 -1
  234. package/dist/openapi.mjs +208 -2
  235. package/dist/openapi.mjs.map +1 -0
  236. package/dist/projectBucket-BRgsSv2P.mjs +222 -0
  237. package/dist/projectBucket-BRgsSv2P.mjs.map +1 -0
  238. package/dist/projectBucket-DbEWuLGX.cjs +263 -0
  239. package/dist/projectBucket-DbEWuLGX.cjs.map +1 -0
  240. package/dist/provider-BqpjG9QM.cjs +57 -0
  241. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  242. package/dist/provider-CEOKk8NS.mjs +46 -0
  243. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  244. package/dist/publish-BN1l3tPF.cjs +124 -0
  245. package/dist/publish-BN1l3tPF.cjs.map +1 -0
  246. package/dist/publish-DjFgxu2v.mjs +123 -0
  247. package/dist/publish-DjFgxu2v.mjs.map +1 -0
  248. package/dist/ready-COJHr1Yi.mjs +375 -0
  249. package/dist/ready-COJHr1Yi.mjs.map +1 -0
  250. package/dist/ready-DcD0SCnV.cjs +404 -0
  251. package/dist/ready-DcD0SCnV.cjs.map +1 -0
  252. package/dist/reconcile/public.cjs +3 -5
  253. package/dist/reconcile/public.d.cts +33 -89
  254. package/dist/reconcile/public.d.cts.map +1 -1
  255. package/dist/reconcile/public.d.mts +33 -89
  256. package/dist/reconcile/public.d.mts.map +1 -1
  257. package/dist/reconcile/public.mjs +3 -3
  258. package/dist/reconcile--I7V4Klj.mjs +34 -0
  259. package/dist/reconcile--I7V4Klj.mjs.map +1 -0
  260. package/dist/reconcile-CuCQBa5-.cjs +34 -0
  261. package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
  262. package/dist/resolve-BHVyg4Hg.cjs +316 -0
  263. package/dist/resolve-BHVyg4Hg.cjs.map +1 -0
  264. package/dist/resolve-NEKsqNAw.mjs +263 -0
  265. package/dist/resolve-NEKsqNAw.mjs.map +1 -0
  266. package/dist/rollback-BVgyLE7B.mjs +136 -0
  267. package/dist/rollback-BVgyLE7B.mjs.map +1 -0
  268. package/dist/rollback-CUjvOIDE.cjs +165 -0
  269. package/dist/rollback-CUjvOIDE.cjs.map +1 -0
  270. package/dist/runtime-CKOkIrw0.d.cts +82 -0
  271. package/dist/runtime-CKOkIrw0.d.cts.map +1 -0
  272. package/dist/runtime-Cdvv8SfU.d.mts +82 -0
  273. package/dist/runtime-Cdvv8SfU.d.mts.map +1 -0
  274. package/dist/s3-BO4yr61G.mjs +240 -0
  275. package/dist/s3-BO4yr61G.mjs.map +1 -0
  276. package/dist/s3-DnPbDfQN.cjs +240 -0
  277. package/dist/s3-DnPbDfQN.cjs.map +1 -0
  278. package/dist/sandbox/config-worker.cjs +43 -0
  279. package/dist/sandbox/config-worker.cjs.map +1 -0
  280. package/dist/sandbox/config-worker.d.cts +1 -0
  281. package/dist/sandbox/config-worker.d.mts +1 -0
  282. package/dist/sandbox/config-worker.mjs +44 -0
  283. package/dist/sandbox/config-worker.mjs.map +1 -0
  284. package/dist/sandbox/credentials-worker.cjs +53 -0
  285. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  286. package/dist/sandbox/credentials-worker.d.cts +1 -0
  287. package/dist/sandbox/credentials-worker.d.mts +1 -0
  288. package/dist/sandbox/credentials-worker.mjs +54 -0
  289. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  290. package/dist/sandbox/discover-worker.cjs +47 -0
  291. package/dist/sandbox/discover-worker.cjs.map +1 -0
  292. package/dist/sandbox/discover-worker.d.cts +1 -0
  293. package/dist/sandbox/discover-worker.d.mts +1 -0
  294. package/dist/sandbox/discover-worker.mjs +48 -0
  295. package/dist/sandbox/discover-worker.mjs.map +1 -0
  296. package/dist/sandbox/migrate-worker.cjs +75 -0
  297. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  298. package/dist/sandbox/migrate-worker.d.cts +1 -0
  299. package/dist/sandbox/migrate-worker.d.mts +1 -0
  300. package/dist/sandbox/migrate-worker.mjs +76 -0
  301. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  302. package/dist/{workspace-B8NLb54N.cjs → schemas-BCwKKA42.mjs} +399 -1173
  303. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  304. package/dist/{workspace-DI-M3BnN.mjs → schemas-BQ_v0lEX.cjs} +487 -982
  305. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  306. package/dist/secretsManager-CJyxFcBH.mjs +113 -0
  307. package/dist/secretsManager-CJyxFcBH.mjs.map +1 -0
  308. package/dist/secretsManager-D8on44WI.cjs +124 -0
  309. package/dist/secretsManager-D8on44WI.cjs.map +1 -0
  310. package/dist/seeds-Bc3niNVb.cjs +382 -0
  311. package/dist/seeds-Bc3niNVb.cjs.map +1 -0
  312. package/dist/seeds-Ccn0Ru2T.mjs +299 -0
  313. package/dist/seeds-Ccn0Ru2T.mjs.map +1 -0
  314. package/dist/serverSetup-BxnCM11A.mjs +685 -0
  315. package/dist/serverSetup-BxnCM11A.mjs.map +1 -0
  316. package/dist/serverSetup-DScJ7tQs.cjs +685 -0
  317. package/dist/serverSetup-DScJ7tQs.cjs.map +1 -0
  318. package/dist/sniffer-9smKtb86.mjs +1824 -0
  319. package/dist/sniffer-9smKtb86.mjs.map +1 -0
  320. package/dist/sniffer-DHcxlSJF.cjs +1997 -0
  321. package/dist/sniffer-DHcxlSJF.cjs.map +1 -0
  322. package/dist/snsSubscriptions-B8TYeAM-.cjs +1184 -0
  323. package/dist/snsSubscriptions-B8TYeAM-.cjs.map +1 -0
  324. package/dist/snsSubscriptions-CygsiXhb.mjs +1053 -0
  325. package/dist/snsSubscriptions-CygsiXhb.mjs.map +1 -0
  326. package/dist/sst-Bgb3WWEl.mjs +478 -0
  327. package/dist/sst-Bgb3WWEl.mjs.map +1 -0
  328. package/dist/sst-DiHVSku5.cjs +501 -0
  329. package/dist/sst-DiHVSku5.cjs.map +1 -0
  330. package/dist/stack-A3evQgbk.cjs +2512 -0
  331. package/dist/stack-A3evQgbk.cjs.map +1 -0
  332. package/dist/stack-Cy2FwO3Z.mjs +2331 -0
  333. package/dist/stack-Cy2FwO3Z.mjs.map +1 -0
  334. package/dist/stage-Bm1x9Anp.cjs +313 -0
  335. package/dist/stage-Bm1x9Anp.cjs.map +1 -0
  336. package/dist/stage-Dgy08WVL.mjs +302 -0
  337. package/dist/stage-Dgy08WVL.mjs.map +1 -0
  338. package/dist/stages-BWg3NU3J.cjs +190 -0
  339. package/dist/stages-BWg3NU3J.cjs.map +1 -0
  340. package/dist/stages-COiipV8N.mjs +190 -0
  341. package/dist/stages-COiipV8N.mjs.map +1 -0
  342. package/dist/target/public.cjs +15 -0
  343. package/dist/target/public.d.cts +28 -0
  344. package/dist/target/public.d.cts.map +1 -0
  345. package/dist/target/public.d.mts +28 -0
  346. package/dist/target/public.d.mts.map +1 -0
  347. package/dist/target/public.mjs +4 -0
  348. package/dist/terminal-BDRxzEZD.cjs +85 -0
  349. package/dist/terminal-BDRxzEZD.cjs.map +1 -0
  350. package/dist/terminal-BRAIvH83.mjs +85 -0
  351. package/dist/terminal-BRAIvH83.mjs.map +1 -0
  352. package/dist/types-Bl_CwZC9.cjs +90 -0
  353. package/dist/types-Bl_CwZC9.cjs.map +1 -0
  354. package/dist/{types-7R81hu0i.d.mts → types-DEmuMHsS.d.cts} +2147 -428
  355. package/dist/types-DEmuMHsS.d.cts.map +1 -0
  356. package/dist/types-Y1NfWlyG.mjs +61 -0
  357. package/dist/types-Y1NfWlyG.mjs.map +1 -0
  358. package/dist/{types-N7c2O2m7.d.cts → types-g_S0_RAi.d.mts} +2145 -428
  359. package/dist/types-g_S0_RAi.d.mts.map +1 -0
  360. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  361. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  362. package/dist/utils-D_fxUqvU.mjs +156 -0
  363. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  364. package/dist/vitest.cjs +65 -0
  365. package/dist/vitest.cjs.map +1 -0
  366. package/dist/vitest.d.cts +29 -0
  367. package/dist/vitest.d.cts.map +1 -0
  368. package/dist/vitest.d.mts +29 -0
  369. package/dist/vitest.d.mts.map +1 -0
  370. package/dist/vitest.mjs +65 -0
  371. package/dist/vitest.mjs.map +1 -0
  372. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  373. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  374. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  375. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  376. package/dist/workspace/index.cjs +6 -2
  377. package/dist/workspace/index.d.cts +3 -3
  378. package/dist/workspace/index.d.mts +3 -3
  379. package/dist/workspace/index.mjs +2 -2
  380. package/dist/workspace-CEpojAus.cjs +3528 -0
  381. package/dist/workspace-CEpojAus.cjs.map +1 -0
  382. package/dist/workspace-_aoe8v6u.mjs +2990 -0
  383. package/dist/workspace-_aoe8v6u.mjs.map +1 -0
  384. package/package.json +75 -13
  385. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  386. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  387. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  388. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  389. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  390. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  391. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  392. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  393. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  394. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  395. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  396. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  397. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  398. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  399. package/dist/bundler-mjqGAvu1.cjs.map +0 -1
  400. package/dist/bundler-mwH7WOb1.mjs.map +0 -1
  401. package/dist/config-CdTMeMU_.cjs +0 -467
  402. package/dist/config-CdTMeMU_.cjs.map +0 -1
  403. package/dist/config-DPnPkWyH.mjs +0 -414
  404. package/dist/config-DPnPkWyH.mjs.map +0 -1
  405. package/dist/config.d.cts.map +0 -1
  406. package/dist/config.d.mts.map +0 -1
  407. package/dist/credentials-fJP5-fa1.mjs +0 -2780
  408. package/dist/credentials-fJP5-fa1.mjs.map +0 -1
  409. package/dist/credentials-tvyReUAd.cjs +0 -2917
  410. package/dist/credentials-tvyReUAd.cjs.map +0 -1
  411. package/dist/discover-BERGFg8v.cjs +0 -288
  412. package/dist/discover-BERGFg8v.cjs.map +0 -1
  413. package/dist/discover-CK-n3w6b.mjs +0 -244
  414. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  415. package/dist/emit-BdoPFjZf.cjs +0 -253
  416. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  417. package/dist/emit-Bzq7JsMP.mjs +0 -224
  418. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  419. package/dist/generator-LfZU7NlU.mjs +0 -247
  420. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  421. package/dist/generator-Wdfp0jCS.cjs +0 -282
  422. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  423. package/dist/github-CAfKyYPN.mjs +0 -216
  424. package/dist/github-CAfKyYPN.mjs.map +0 -1
  425. package/dist/github-DVE8Gg_F.cjs +0 -216
  426. package/dist/github-DVE8Gg_F.cjs.map +0 -1
  427. package/dist/index-B4H4XF7A.d.mts.map +0 -1
  428. package/dist/index-RCUizGxL.d.cts.map +0 -1
  429. package/dist/openapi-BeckoaP9.cjs +0 -2038
  430. package/dist/openapi-BeckoaP9.cjs.map +0 -1
  431. package/dist/openapi-DolhBm6r.mjs +0 -1991
  432. package/dist/openapi-DolhBm6r.mjs.map +0 -1
  433. package/dist/reconcile-Cq4cO83R.cjs +0 -136
  434. package/dist/reconcile-Cq4cO83R.cjs.map +0 -1
  435. package/dist/reconcile-fmoluZmZ.mjs +0 -113
  436. package/dist/reconcile-fmoluZmZ.mjs.map +0 -1
  437. package/dist/ssm-BKN1Cg4z.mjs +0 -60
  438. package/dist/ssm-BKN1Cg4z.mjs.map +0 -1
  439. package/dist/ssm-FxeSAt35.cjs +0 -60
  440. package/dist/ssm-FxeSAt35.cjs.map +0 -1
  441. package/dist/storage-DgypfSD6.cjs +0 -351
  442. package/dist/storage-DgypfSD6.cjs.map +0 -1
  443. package/dist/storage-TP0x118M.mjs +0 -304
  444. package/dist/storage-TP0x118M.mjs.map +0 -1
  445. package/dist/transfer-4A4S2hcw.mjs +0 -122
  446. package/dist/transfer-4A4S2hcw.mjs.map +0 -1
  447. package/dist/transfer-DdmtKLzi.cjs +0 -151
  448. package/dist/transfer-DdmtKLzi.cjs.map +0 -1
  449. package/dist/types-7R81hu0i.d.mts.map +0 -1
  450. package/dist/types-N7c2O2m7.d.cts.map +0 -1
  451. package/dist/workspace-B8NLb54N.cjs.map +0 -1
  452. package/dist/workspace-DI-M3BnN.mjs.map +0 -1
@@ -0,0 +1,977 @@
1
+ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
+ import { J as readKey, K as keystoreProject, O as isRemoteStore, U as getKeyPath, X as deployIdentity, k as secretsStoreFor } from "./credentials-CKIeLL7T.mjs";
3
+ import { At as s3SecretsKey, J as inboxBucketId, N as assertDeployedStage, U as stageProvider, Y as inboxTopicName, jt as s3SecretsLocation, nt as bucketName, q as emailUserName, rt as iamUserName, tt as IAM_USER_PATH } from "./workspace-_aoe8v6u.mjs";
4
+ import { Zt as stageBackups, f as constructGlobs } from "./apps-DGod3aS9.mjs";
5
+ import { i as discover } from "./discover-B_PDDaVj.mjs";
6
+ import { loadWorkspaceConfig } from "./config.mjs";
7
+ import { v as stageDnsDomains } from "./snsSubscriptions-CygsiXhb.mjs";
8
+ import { l as backupsUserName } from "./deploy-CjubyZlP.mjs";
9
+ import { n as PROJECT_BUCKET_LIFECYCLE_ACTIONS, o as projectBucketName, t as PROJECT_BUCKET_CREATE_ACTIONS } from "./projectBucket-BRgsSv2P.mjs";
10
+ import { n as secretsParameterName } from "./aws-C5LAU_Ii.mjs";
11
+ import { t as secretsManagerSecretName } from "./secretsManager-CJyxFcBH.mjs";
12
+ import { execFileSync } from "node:child_process";
13
+ import { AttachRolePolicyCommand, CreateOpenIDConnectProviderCommand, CreateRoleCommand, DeleteRolePolicyCommand, DetachRolePolicyCommand, GetRoleCommand, IAMClient, ListAttachedRolePoliciesCommand, ListOpenIDConnectProvidersCommand, ListRoleTagsCommand, PutRolePolicyCommand, TagRoleCommand, UntagRoleCommand, UpdateAssumeRolePolicyCommand } from "@aws-sdk/client-iam";
14
+ //#region src/deploy/githubOidc.ts
15
+ /**
16
+ * The `sub` GitHub puts in a deploy job's OIDC token — what the deploy role's
17
+ * trust policy has to match exactly.
18
+ *
19
+ * It is not always `repo:<owner>/<name>:environment:<stage>`. A repository
20
+ * (or its organisation) decides the format, and says which through
21
+ * `GET /repos/{owner}/{repo}/actions/oidc/customization/sub`:
22
+ *
23
+ * - the default: `repo:<owner>/<name>:environment:<stage>`;
24
+ * - the immutable subject — the default for repositories created after
25
+ * 15 July 2026, opt-in before — puts the owner's and the repository's ids in
26
+ * the `repo` segment: `repo:<owner>@<ownerId>/<name>@<repoId>:environment:<stage>`.
27
+ * The API hands that segment back as `sub_claim_prefix`;
28
+ * - a custom template (`use_default: false`) builds the `sub` from
29
+ * `include_claim_keys`, in order, each as `<key>:<value>` joined by `:`,
30
+ * where `context` is `environment:<stage>` in an environment job.
31
+ *
32
+ * A `:` inside a value is sent as `%3A`.
33
+ *
34
+ * See https://docs.github.com/en/actions/reference/security/oidc.
35
+ */
36
+ /**
37
+ * Template keys whose values are known for a repository's environment job
38
+ * before the job runs. Anything else — `job_workflow_ref`, `ref`, `sha`,
39
+ * `run_id`, `workflow`, `actor`, a custom property — depends on the run.
40
+ */
41
+ const SUPPORTED_CLAIM_KEYS = [
42
+ "repo",
43
+ "context",
44
+ "environment",
45
+ "repository",
46
+ "repository_owner",
47
+ "repository_owner_id",
48
+ "repository_id",
49
+ "repository_visibility"
50
+ ];
51
+ const NEEDS_FACTS = /* @__PURE__ */ new Set([
52
+ "repository_owner_id",
53
+ "repository_id",
54
+ "repository_visibility"
55
+ ]);
56
+ /** A `:` inside a claim value is sent as `%3A`. */
57
+ function claim(value) {
58
+ return value.replaceAll(":", "%3A");
59
+ }
60
+ /** Whether {@link oidcSubject} needs the repository's ids or visibility. */
61
+ function needsRepoFacts(customization) {
62
+ const immutableWithoutPrefix = customization.use_immutable_subject === true && !customization.sub_claim_prefix;
63
+ if (customization.use_default) return immutableWithoutPrefix;
64
+ return (customization.include_claim_keys ?? []).some((key) => NEEDS_FACTS.has(key) || key === "repo" && immutableWithoutPrefix);
65
+ }
66
+ /**
67
+ * The exact `sub` of a job in `repo`'s `stage` environment.
68
+ *
69
+ * @throws OidcSubjectNotSupported when a custom template includes a claim
70
+ * whose value depends on the run, so no one subject can be trusted.
71
+ */
72
+ function oidcSubject(repo, stage, customization, facts) {
73
+ const [owner = "", name = ""] = repo.split("/");
74
+ const environment = `environment:${claim(stage)}`;
75
+ const repoSegment = () => {
76
+ if (customization.sub_claim_prefix) return customization.sub_claim_prefix;
77
+ if (customization.use_immutable_subject) {
78
+ if (!facts) throw new RepoFactsRequired(repo);
79
+ return `repo:${owner}@${facts.ownerId}/${name}@${facts.repoId}`;
80
+ }
81
+ return `repo:${repo}`;
82
+ };
83
+ const immutable = customization.use_immutable_subject === true || customization.sub_claim_prefix !== void 0;
84
+ if (customization.use_default) return {
85
+ subject: `${repoSegment()}:${environment}`,
86
+ kind: immutable ? "immutable" : "default"
87
+ };
88
+ const keys = customization.include_claim_keys ?? [];
89
+ const unsupported = keys.filter((key) => !SUPPORTED_CLAIM_KEYS.includes(key));
90
+ if (keys.length === 0 || unsupported.length > 0) throw new OidcSubjectNotSupported(repo, keys, unsupported);
91
+ if (keys.some((key) => NEEDS_FACTS.has(key)) && !facts) throw new RepoFactsRequired(repo);
92
+ return {
93
+ subject: keys.map((key) => {
94
+ switch (key) {
95
+ case "repo": return repoSegment();
96
+ case "context":
97
+ case "environment": return environment;
98
+ case "repository": return `repository:${claim(repo)}`;
99
+ case "repository_owner": return `repository_owner:${claim(owner)}`;
100
+ case "repository_owner_id": return `repository_owner_id:${facts.ownerId}`;
101
+ case "repository_id": return `repository_id:${facts.repoId}`;
102
+ default: return `repository_visibility:${claim(facts.visibility)}`;
103
+ }
104
+ }).join(":"),
105
+ kind: "custom"
106
+ };
107
+ }
108
+ /** The endpoint a repository's subject format is read from. */
109
+ function customizationEndpoint(repo) {
110
+ return `repos/${repo}/actions/oidc/customization/sub`;
111
+ }
112
+ /**
113
+ * The `sub` GitHub will send for `repo`'s `stage` environment, read from the
114
+ * repository's OIDC settings through `gh`.
115
+ *
116
+ * A repository on a custom template that names no keys of its own uses its
117
+ * organisation's, read from `orgs/{owner}/actions/oidc/customization/sub`.
118
+ * When the settings cannot be read at all — no permission, or a GitHub
119
+ * Enterprise Server without the endpoint — the default format is assumed, with
120
+ * a warning saying where to check it.
121
+ */
122
+ function resolveOidcSubject(gh, repo, stage) {
123
+ const endpoint = customizationEndpoint(repo);
124
+ let customization;
125
+ try {
126
+ customization = JSON.parse(gh(["api", endpoint]));
127
+ } catch {
128
+ return {
129
+ subject: `repo:${repo}:environment:${claim(stage)}`,
130
+ kind: "assumed",
131
+ warning: `Could not read ${endpoint}, so the default subject format is assumed. Check it with: gh api ${endpoint} — a repository on the immutable subject or a custom template sends a different sub, and the role would not be assumable.`
132
+ };
133
+ }
134
+ if (!customization.use_default && (customization.include_claim_keys ?? []).length === 0) {
135
+ const [owner = ""] = repo.split("/");
136
+ const orgEndpoint = `orgs/${owner}/actions/oidc/customization/sub`;
137
+ let org;
138
+ try {
139
+ org = JSON.parse(gh(["api", orgEndpoint]));
140
+ } catch {
141
+ throw new OrgOidcTemplateUnreadable(repo, orgEndpoint);
142
+ }
143
+ customization = {
144
+ ...customization,
145
+ include_claim_keys: org.include_claim_keys ?? [],
146
+ use_immutable_subject: customization.use_immutable_subject ?? org.use_immutable_subject
147
+ };
148
+ }
149
+ const facts = needsRepoFacts(customization) ? readRepoFacts(gh, repo) : void 0;
150
+ return oidcSubject(repo, stage, customization, facts);
151
+ }
152
+ function readRepoFacts(gh, repo) {
153
+ const raw = JSON.parse(gh(["api", `repos/${repo}`]));
154
+ return {
155
+ ownerId: raw.owner.id,
156
+ repoId: raw.id,
157
+ visibility: raw.visibility
158
+ };
159
+ }
160
+ /**
161
+ * The repository's custom subject template includes a claim whose value
162
+ * depends on the run — or names none — so no one subject can be trusted.
163
+ */
164
+ var OidcSubjectNotSupported = class extends GkmError {
165
+ repo;
166
+ includeClaimKeys;
167
+ unsupportedKeys;
168
+ constructor(repo, includeClaimKeys, unsupportedKeys) {
169
+ super(`${repo} builds its OIDC subject from a custom template, ${JSON.stringify(includeClaimKeys)}, and ${unsupportedKeys.length > 0 ? `${unsupportedKeys.join(", ")} depend${unsupportedKeys.length === 1 ? "s" : ""} on the run` : "it names no claims"}, so the deploy role cannot trust one exact subject. Set the repository back to the default subject — gh api --method PUT ${customizationEndpoint(repo)} -F use_default=true — (or keep the immutable one by also passing -F use_immutable_subject=true), or use a template built only from ${SUPPORTED_CLAIM_KEYS.join(", ")}; then run this again.`);
170
+ this.repo = repo;
171
+ this.includeClaimKeys = includeClaimKeys;
172
+ this.unsupportedKeys = unsupportedKeys;
173
+ this.name = "OidcSubjectNotSupported";
174
+ }
175
+ };
176
+ /** The subject needs the repository's ids, and none were read. */
177
+ var RepoFactsRequired = class extends GkmError {
178
+ repo;
179
+ constructor(repo) {
180
+ super(`The OIDC subject of ${repo} includes its owner and repository ids; read them with gh api repos/${repo} and pass them in.`);
181
+ this.repo = repo;
182
+ this.name = "RepoFactsRequired";
183
+ }
184
+ };
185
+ /**
186
+ * The repository uses its organisation's subject template, and that template
187
+ * could not be read — so what GitHub sends is unknown, and is not guessed.
188
+ */
189
+ var OrgOidcTemplateUnreadable = class extends GkmError {
190
+ repo;
191
+ endpoint;
192
+ constructor(repo, endpoint) {
193
+ super(`${repo} uses its organisation's OIDC subject template, and ${endpoint} could not be read. Run this as an organisation owner (gh auth refresh -s admin:org), or set the repository back to the default subject with gh api --method PUT ${customizationEndpoint(repo)} -F use_default=true; then run this again.`);
194
+ this.repo = repo;
195
+ this.endpoint = endpoint;
196
+ this.name = "OrgOidcTemplateUnreadable";
197
+ }
198
+ };
199
+ //#endregion
200
+ //#region src/deploy/githubPolicy.ts
201
+ /**
202
+ * What SST needs to create a stack is most of AWS, so this is the default
203
+ * outside compose — said out loud in the output, and replaceable with
204
+ * `--policy-arn`.
205
+ */
206
+ const DEFAULT_POLICY_ARN = "arn:aws:iam::aws:policy/AdministratorAccess";
207
+ /**
208
+ * What the deploy does to a bucket of the stage's: creates it, and puts each
209
+ * of its settings back where they drifted.
210
+ */
211
+ const BUCKET_ACTIONS = [
212
+ "s3:CreateBucket",
213
+ "s3:ListBucket",
214
+ "s3:GetBucketTagging",
215
+ "s3:PutBucketTagging",
216
+ "s3:GetBucketPublicAccessBlock",
217
+ "s3:PutBucketPublicAccessBlock",
218
+ "s3:GetBucketPolicy",
219
+ "s3:PutBucketPolicy",
220
+ "s3:GetEncryptionConfiguration",
221
+ "s3:PutEncryptionConfiguration",
222
+ "s3:GetBucketVersioning",
223
+ "s3:PutBucketVersioning",
224
+ "s3:GetBucketCORS",
225
+ "s3:PutBucketCORS",
226
+ "s3:GetBucketNotification",
227
+ "s3:PutBucketNotification",
228
+ "s3:GetLifecycleConfiguration",
229
+ "s3:PutLifecycleConfiguration"
230
+ ];
231
+ /** What the deploy does to a topic a bucket or an inbox announces on. */
232
+ const TOPIC_ACTIONS = [
233
+ "sns:CreateTopic",
234
+ "sns:TagResource",
235
+ "sns:GetTopicAttributes",
236
+ "sns:SetTopicAttributes",
237
+ "sns:Subscribe",
238
+ "sns:Unsubscribe",
239
+ "sns:ListSubscriptionsByTopic",
240
+ "sns:GetSubscriptionAttributes",
241
+ "sns:SetSubscriptionAttributes"
242
+ ];
243
+ /** What the deploy does to an IAM user it reaches a resource with, and its key. */
244
+ const USER_ACTIONS = [
245
+ "iam:GetUser",
246
+ "iam:CreateUser",
247
+ "iam:TagUser",
248
+ "iam:ListUserTags",
249
+ "iam:GetUserPolicy",
250
+ "iam:PutUserPolicy",
251
+ "iam:ListAccessKeys",
252
+ "iam:CreateAccessKey",
253
+ "iam:DeleteAccessKey"
254
+ ];
255
+ /** The name of the inline policy a compose stage's role is given. */
256
+ const SCOPED_POLICY_NAME = "gkm-deploy";
257
+ /** Every target the stage's apps deploy through. */
258
+ function deployTargets(workspace) {
259
+ const targets = /* @__PURE__ */ new Set([workspace.deploy?.default ?? "dokploy"]);
260
+ for (const app of Object.values(workspace.apps)) targets.add(app.resolvedDeployTarget);
261
+ return [...targets].sort();
262
+ }
263
+ /**
264
+ * The access the stage's deploy role is given: `--policy-arn` when passed,
265
+ * the scoped policy for a stage only the compose target deploys, and
266
+ * `AdministratorAccess` otherwise.
267
+ */
268
+ function deployAccess(workspace, stage, policyArn, manifest = {}) {
269
+ const buckets = Object.entries(manifest).filter(([, d]) => d.kind === "objects").map(([id]) => id);
270
+ if (policyArn) return {
271
+ kind: "managed",
272
+ policyArn,
273
+ reason: "--policy-arn"
274
+ };
275
+ const targets = deployTargets(workspace);
276
+ if (targets.length !== 1 || targets[0] !== "compose") return {
277
+ kind: "managed",
278
+ policyArn: DEFAULT_POLICY_ARN,
279
+ reason: `the ${targets.join(", ")} target${targets.length === 1 ? "" : "s"} deploy${targets.length === 1 ? "s" : ""} infrastructure; --policy-arn to narrow`
280
+ };
281
+ const project = workspace.name;
282
+ const store = workspace.secrets.store ?? "file";
283
+ const state = workspace.state;
284
+ if (typeof store === "object" && typeof store.provider === "object" || state !== void 0 && typeof state.provider === "object") return {
285
+ kind: "managed",
286
+ policyArn: DEFAULT_POLICY_ARN,
287
+ reason: `a custom ${typeof store === "object" && typeof store.provider === "object" ? "secrets store" : "state provider"} cannot be scoped; --policy-arn to narrow`
288
+ };
289
+ const describe = [];
290
+ const build = [];
291
+ const projectBucketIn = (account) => projectBucketName(deployIdentity(workspace, stage).scope, account);
292
+ const projectBucketStatement = (account) => ({
293
+ Sid: "ProjectBucket",
294
+ Effect: "Allow",
295
+ Action: [...PROJECT_BUCKET_CREATE_ACTIONS],
296
+ Resource: `arn:aws:s3:::${projectBucketIn(account)}`
297
+ });
298
+ const stateInSecretsBucket = typeof store === "object" && store.provider === "s3" && state?.provider === "s3" && state.bucket === store.bucket;
299
+ if (typeof store === "object" && store.provider === "s3") {
300
+ const location = s3SecretsLocation(store, state);
301
+ const key = s3SecretsKey(location.prefix, project, stage);
302
+ const named = location.bucket;
303
+ const bucketIn = (account) => named ?? projectBucketIn(account);
304
+ describe.push(named ? `read and update s3://${named}/${key}` : `read and update ${key} in the project bucket ${projectBucketIn("<account>")}${stateInSecretsBucket ? "" : ", creating it"}`);
305
+ build.push((account) => [{
306
+ Sid: "StageSecrets",
307
+ Effect: "Allow",
308
+ Action: ["s3:GetObject", "s3:PutObject"],
309
+ Resource: `arn:aws:s3:::${bucketIn(account)}/${key}`
310
+ }, ...stateInSecretsBucket ? [] : [{
311
+ Sid: "StageSecretsBucket",
312
+ Effect: "Allow",
313
+ Action: ["s3:ListBucket"],
314
+ Resource: `arn:aws:s3:::${bucketIn(account)}`
315
+ }, ...named ? [] : [projectBucketStatement(account)]]]);
316
+ } else if (typeof store === "object" && store.provider === "ssm") {
317
+ const { region } = store;
318
+ const name = secretsParameterName(project, stage);
319
+ describe.push(`read and update ${name} (SSM, ${region})`);
320
+ build.push((account) => [{
321
+ Sid: "StageSecrets",
322
+ Effect: "Allow",
323
+ Action: ["ssm:GetParameter", "ssm:PutParameter"],
324
+ Resource: `arn:aws:ssm:${region}:${account}:parameter${name}`
325
+ }]);
326
+ } else if (typeof store === "object" && store.provider === "secrets-manager") {
327
+ const { region, kmsKeyId } = store;
328
+ const name = secretsManagerSecretName(project, stage);
329
+ describe.push(`read and update ${name} (Secrets Manager, ${region})`);
330
+ build.push((account) => {
331
+ const statements = [{
332
+ Sid: "StageSecrets",
333
+ Effect: "Allow",
334
+ Action: [
335
+ "secretsmanager:GetSecretValue",
336
+ "secretsmanager:PutSecretValue",
337
+ "secretsmanager:CreateSecret"
338
+ ],
339
+ Resource: `arn:aws:secretsmanager:${region}:${account}:secret:${name}-??????`
340
+ }];
341
+ if (kmsKeyId) statements.push({
342
+ Sid: "StageSecretsKey",
343
+ Effect: "Allow",
344
+ Action: ["kms:Decrypt", "kms:GenerateDataKey"],
345
+ Resource: kmsKeyId.startsWith("arn:") ? kmsKeyId : "*",
346
+ Condition: { StringEquals: { "kms:ViaService": `secretsmanager.${region}.amazonaws.com` } }
347
+ });
348
+ return statements;
349
+ });
350
+ }
351
+ if (state?.provider === "ssm") {
352
+ const { region } = state;
353
+ const path = `/gkm/${project}/${stage}/`;
354
+ describe.push(`read and write the deploy state under ${path} (SSM, ${region})`);
355
+ build.push((account) => [{
356
+ Sid: "StageState",
357
+ Effect: "Allow",
358
+ Action: [
359
+ "ssm:GetParameter",
360
+ "ssm:PutParameter",
361
+ "ssm:DeleteParameter"
362
+ ],
363
+ Resource: `arn:aws:ssm:${region}:${account}:parameter${path}*`
364
+ }]);
365
+ } else if (state?.provider === "s3") {
366
+ const prefix = (state.prefix ?? "gkm").replace(/\/+$/, "");
367
+ const path = `${prefix ? `${prefix}/` : ""}${project}/${stage}/`;
368
+ const named = state.bucket;
369
+ const bucketIn = (account) => named ?? projectBucketIn(account);
370
+ describe.push(named ? `read and write the deploy state under s3://${named}/${path}` : `create the project bucket ${projectBucketIn("<account>")}, and read and write the deploy state under ${path} in it`);
371
+ build.push((account) => [...stateBucketStatements(bucketIn(account), path), ...named ? [] : [projectBucketStatement(account)]]);
372
+ }
373
+ const objects = stageProvider(workspace, "objects", stage);
374
+ if (objects.mode === "provider" && objects.name === "s3" && buckets.length) {
375
+ const { scope } = deployIdentity(workspace, stage);
376
+ const names = [...buckets].sort().map((id) => ({
377
+ bucket: bucketName({
378
+ scope,
379
+ stage,
380
+ id
381
+ }),
382
+ user: iamUserName({
383
+ scope,
384
+ stage,
385
+ id
386
+ })
387
+ }));
388
+ const suffix = "?".repeat(6);
389
+ describe.push(`create and configure the buckets ${names.map((n) => n.bucket).join(", ")}, their IAM users, and — for a bucket a subscriber watches — its events topic, dead-letter queue and subscriptions (S3, IAM, SNS, SQS)`);
390
+ build.push((account) => [
391
+ {
392
+ Sid: "StageBuckets",
393
+ Effect: "Allow",
394
+ Action: BUCKET_ACTIONS,
395
+ Resource: names.flatMap((n) => [`arn:aws:s3:::${n.bucket}`, `arn:aws:s3:::${n.bucket}-${suffix}`])
396
+ },
397
+ {
398
+ Sid: "StageBucketTopics",
399
+ Effect: "Allow",
400
+ Action: TOPIC_ACTIONS,
401
+ Resource: names.flatMap((n) => [`${n.bucket}-events`, `${n.bucket}-${suffix}-events`].flatMap((topic) => [`arn:aws:sns:*:${account}:${topic}`, `arn:aws:sns:*:${account}:${topic}:*`]))
402
+ },
403
+ {
404
+ Sid: "StageBucketDeadLetters",
405
+ Effect: "Allow",
406
+ Action: [
407
+ "sqs:CreateQueue",
408
+ "sqs:TagQueue",
409
+ "sqs:GetQueueUrl",
410
+ "sqs:GetQueueAttributes",
411
+ "sqs:SetQueueAttributes"
412
+ ],
413
+ Resource: names.flatMap((n) => [`arn:aws:sqs:*:${account}:${n.bucket}-events-dlq`, `arn:aws:sqs:*:${account}:${n.bucket}-${suffix}-events-dlq`])
414
+ },
415
+ {
416
+ Sid: "StageBucketUsers",
417
+ Effect: "Allow",
418
+ Action: USER_ACTIONS,
419
+ Resource: names.map((n) => `arn:aws:iam::${account}:user${IAM_USER_PATH}${n.user}`)
420
+ }
421
+ ]);
422
+ if (Object.values(manifest).some((d) => d.kind === "file-server") && objects.config.cdn !== false) {
423
+ describe.push("create the file servers’ certificates and CloudFront distributions (ACM, CloudFront)");
424
+ build.push(() => [{
425
+ Sid: "StageFileServerCertificates",
426
+ Effect: "Allow",
427
+ Action: [
428
+ "acm:RequestCertificate",
429
+ "acm:DescribeCertificate",
430
+ "acm:ListCertificates",
431
+ "acm:AddTagsToCertificate"
432
+ ],
433
+ Resource: "*"
434
+ }, {
435
+ Sid: "StageFileServerCdn",
436
+ Effect: "Allow",
437
+ Action: [
438
+ "cloudfront:CreateDistribution",
439
+ "cloudfront:CreateDistributionWithTags",
440
+ "cloudfront:GetDistribution",
441
+ "cloudfront:GetDistributionConfig",
442
+ "cloudfront:UpdateDistribution",
443
+ "cloudfront:ListDistributions",
444
+ "cloudfront:TagResource",
445
+ "cloudfront:CreateOriginAccessControl",
446
+ "cloudfront:GetOriginAccessControl",
447
+ "cloudfront:ListOriginAccessControls",
448
+ "cloudfront:CreateResponseHeadersPolicy",
449
+ "cloudfront:GetResponseHeadersPolicy",
450
+ "cloudfront:GetResponseHeadersPolicyConfig",
451
+ "cloudfront:UpdateResponseHeadersPolicy",
452
+ "cloudfront:ListResponseHeadersPolicies"
453
+ ],
454
+ Resource: "*"
455
+ }]);
456
+ }
457
+ }
458
+ const emails = Object.entries(manifest).filter(([, d]) => d.kind === "email").map(([id]) => id).sort();
459
+ const email = stageProvider(workspace, "email", stage);
460
+ if (email.mode === "provider" && email.name === "ses" && emails.length) {
461
+ const { scope } = deployIdentity(workspace, stage);
462
+ const users = emails.map((id) => emailUserName(scope, stage, id));
463
+ describe.push(`verify the sending domain in SES and create the mail users ${users.join(", ")} and their keys (SES, IAM)`);
464
+ build.push((account) => [{
465
+ Sid: "StageMailIdentity",
466
+ Effect: "Allow",
467
+ Action: [
468
+ "ses:GetIdentityDkimAttributes",
469
+ "ses:VerifyDomainDkim",
470
+ "ses:SetIdentityDkimEnabled",
471
+ "ses:GetSendQuota"
472
+ ],
473
+ Resource: "*"
474
+ }, {
475
+ Sid: "StageMailUsers",
476
+ Effect: "Allow",
477
+ Action: USER_ACTIONS,
478
+ Resource: users.map((user) => `arn:aws:iam::${account}:user${IAM_USER_PATH}${user}`)
479
+ }]);
480
+ }
481
+ const inboxes = Object.entries(manifest).filter(([, d]) => d.kind === "inbox").map(([id]) => id).sort();
482
+ const inbox = stageProvider(workspace, "inbox", stage);
483
+ if (inbox.mode === "provider" && inbox.name === "ses" && inboxes.length) {
484
+ const { scope } = deployIdentity(workspace, stage);
485
+ const names = inboxes.map((id) => {
486
+ const named = {
487
+ scope,
488
+ stage,
489
+ id: inboxBucketId(id)
490
+ };
491
+ return {
492
+ bucket: bucketName(named),
493
+ user: iamUserName(named),
494
+ topic: inboxTopicName(scope, stage, id)
495
+ };
496
+ });
497
+ const suffix = "?".repeat(6);
498
+ describe.push(`verify the stage's domain in SES and keep its receipt rules, and create the inbox buckets ${names.map((n) => n.bucket).join(", ")}, their IAM users and topics (SES, S3, IAM, SNS)`);
499
+ build.push((account) => [
500
+ {
501
+ Sid: "StageInboxRules",
502
+ Effect: "Allow",
503
+ Action: [
504
+ "ses:VerifyDomainDkim",
505
+ "ses:DescribeActiveReceiptRuleSet",
506
+ "ses:CreateReceiptRuleSet",
507
+ "ses:SetActiveReceiptRuleSet",
508
+ "ses:DescribeReceiptRuleSet",
509
+ "ses:DescribeReceiptRule",
510
+ "ses:CreateReceiptRule",
511
+ "ses:UpdateReceiptRule",
512
+ "ses:DeleteReceiptRule"
513
+ ],
514
+ Resource: "*"
515
+ },
516
+ {
517
+ Sid: "StageInboxBuckets",
518
+ Effect: "Allow",
519
+ Action: BUCKET_ACTIONS,
520
+ Resource: names.flatMap((n) => [`arn:aws:s3:::${n.bucket}`, `arn:aws:s3:::${n.bucket}-${suffix}`])
521
+ },
522
+ {
523
+ Sid: "StageInboxTopics",
524
+ Effect: "Allow",
525
+ Action: TOPIC_ACTIONS,
526
+ Resource: names.flatMap((n) => [`arn:aws:sns:*:${account}:${n.topic}`, `arn:aws:sns:*:${account}:${n.topic}:*`])
527
+ },
528
+ {
529
+ Sid: "StageInboxUsers",
530
+ Effect: "Allow",
531
+ Action: USER_ACTIONS,
532
+ Resource: names.map((n) => `arn:aws:iam::${account}:user${IAM_USER_PATH}${n.user}`)
533
+ }
534
+ ]);
535
+ }
536
+ if (stageBackups(workspace, manifest, stage).mode === "on") {
537
+ const { scope } = deployIdentity(workspace, stage);
538
+ const user = backupsUserName(scope, stage);
539
+ const bucketIn = (account) => projectBucketName(scope, account);
540
+ describe.push(`create the project bucket ${bucketIn("<account>")} and keep its lifecycle, and create the backups user ${user} and its key (S3, IAM)`);
541
+ build.push((account) => [{
542
+ Sid: "StageBackupsBucket",
543
+ Effect: "Allow",
544
+ Action: ["s3:ListBucket", .../* @__PURE__ */ new Set([...PROJECT_BUCKET_CREATE_ACTIONS, ...PROJECT_BUCKET_LIFECYCLE_ACTIONS])],
545
+ Resource: `arn:aws:s3:::${bucketIn(account)}`
546
+ }, {
547
+ Sid: "StageBackupsUser",
548
+ Effect: "Allow",
549
+ Action: USER_ACTIONS,
550
+ Resource: `arn:aws:iam::${account}:user${IAM_USER_PATH}${user}`
551
+ }]);
552
+ }
553
+ for (const { domain, config } of stageDnsDomains(stage, workspace.domains, workspace.dns)) {
554
+ if (config.provider !== "route53") continue;
555
+ const zoneId = config.hostedZoneId?.replace(/^\/?hostedzone\//, "");
556
+ describe.push(`write the A, AAAA and CNAME records of ${domain} (Route53${zoneId ? `, ${zoneId}` : ""})`);
557
+ build.push(() => [
558
+ {
559
+ Sid: "StageDnsRecords",
560
+ Effect: "Allow",
561
+ Action: ["route53:ChangeResourceRecordSets", "route53:ListResourceRecordSets"],
562
+ Resource: `arn:aws:route53:::hostedzone/${zoneId ?? "*"}`
563
+ },
564
+ {
565
+ Sid: "StageDnsChanges",
566
+ Effect: "Allow",
567
+ Action: ["route53:GetChange"],
568
+ Resource: "arn:aws:route53:::change/*"
569
+ },
570
+ ...zoneId ? [] : [{
571
+ Sid: "StageDnsZones",
572
+ Effect: "Allow",
573
+ Action: ["route53:ListHostedZonesByName"],
574
+ Resource: "*"
575
+ }]
576
+ ]);
577
+ }
578
+ return {
579
+ kind: "scoped",
580
+ statements: (account) => build.flatMap((statements) => statements(account)),
581
+ describe
582
+ };
583
+ }
584
+ /**
585
+ * Reading and writing one stage's deploy state in `bucket`, as the deploy
586
+ * role is given it.
587
+ */
588
+ function stateBucketStatements(bucket, path) {
589
+ return [{
590
+ Sid: "StageState",
591
+ Effect: "Allow",
592
+ Action: [
593
+ "s3:GetObject",
594
+ "s3:PutObject",
595
+ "s3:DeleteObject"
596
+ ],
597
+ Resource: `arn:aws:s3:::${bucket}/${path}*`
598
+ }, {
599
+ Sid: "StageStateBucket",
600
+ Effect: "Allow",
601
+ Action: ["s3:ListBucket"],
602
+ Resource: `arn:aws:s3:::${bucket}`
603
+ }];
604
+ }
605
+ /** The scoped access as a policy document, or null when it allows nothing. */
606
+ function scopedPolicyDocument(statements) {
607
+ if (statements.length === 0) return null;
608
+ return JSON.stringify({
609
+ Version: "2012-10-17",
610
+ Statement: statements
611
+ });
612
+ }
613
+ /** The account an IAM ARN is in: `arn:aws:iam::<account>:…`. */
614
+ function accountOf(arn) {
615
+ return arn.split(":")[4] ?? "";
616
+ }
617
+ //#endregion
618
+ //#region src/deploy/github.ts
619
+ /**
620
+ * `gkm deploy:github` — let GitHub Actions deploy one stage, with no keys.
621
+ *
622
+ * A stage usually lives in its own AWS account — staging in one, production in
623
+ * another — so this runs once per stage, with that account's profile:
624
+ *
625
+ * gkm deploy:github --stage staging --profile acme-dev
626
+ * gkm deploy:github --stage prod --profile acme-prod
627
+ *
628
+ * In the stage's account it makes sure GitHub's OIDC provider exists, and a
629
+ * role that only this repository's `<stage>` environment can assume. On
630
+ * GitHub it creates that environment and gives it what the generated deploy
631
+ * workflow reads: `AWS_ROLE_ARN`, and — when the stage's secrets are kept in
632
+ * the local file — its key as `GKM_SECRETS_KEY`. With `secrets.store` set to
633
+ * S3, SSM or Secrets Manager the deploy job reads them with the role instead, so
634
+ * no key is handed to GitHub, and this checks the stage's store in the same
635
+ * account, with the same profile. Re-running it converges rather than duplicating.
636
+ *
637
+ * The role trusts the exact `sub` GitHub sends for the environment, read from
638
+ * the repository's OIDC subject settings (`githubOidc.ts`) — the default, the
639
+ * immutable subject with the owner's and repository's ids, or a custom
640
+ * template. A re-run rewrites an existing role's trust to it, so running this
641
+ * again repairs a role that trusted the wrong format. What the role may do is
642
+ * `githubPolicy.ts`: `AdministratorAccess` for SST, and for a compose stage
643
+ * only its own secrets (and deploy state, when that is in AWS).
644
+ */
645
+ const logger = console;
646
+ const GITHUB_OIDC_HOST = "token.actions.githubusercontent.com";
647
+ const AUDIENCE = "sts.amazonaws.com";
648
+ /**
649
+ * The tag recording which managed policy gkm attached to the role — so a
650
+ * re-run detaches only what gkm put there, never a policy someone else did.
651
+ */
652
+ const POLICY_TAG = "gkm:policy-arn";
653
+ /** The system's `gh`. */
654
+ const ghCli = (args, input) => execFileSync("gh", args, {
655
+ encoding: "utf-8",
656
+ stdio: [
657
+ "pipe",
658
+ "pipe",
659
+ "pipe"
660
+ ],
661
+ ...input === void 0 ? {} : { input }
662
+ }).trim();
663
+ /** The role a stage deploys as: `<project>-github-<stage>`, within IAM's 64. */
664
+ function roleName(project, stage) {
665
+ return `${project}-github-${stage}`.toLowerCase().replace(/[^a-z0-9+=,.@_-]/g, "-").slice(0, 64);
666
+ }
667
+ /**
668
+ * Who may assume the role: a workflow job whose OIDC token carries exactly
669
+ * `subject` — the repository's `<stage>` environment, in the format the
670
+ * repository sends (see `githubOidc.ts`), and nothing else. Not another
671
+ * branch's job, not another environment's: that is what keeps a staging
672
+ * deploy from using the production role.
673
+ */
674
+ function trustPolicy(providerArn, subject) {
675
+ return JSON.stringify({
676
+ Version: "2012-10-17",
677
+ Statement: [{
678
+ Effect: "Allow",
679
+ Principal: { Federated: providerArn },
680
+ Action: "sts:AssumeRoleWithWebIdentity",
681
+ Condition: { StringEquals: {
682
+ [`${GITHUB_OIDC_HOST}:aud`]: AUDIENCE,
683
+ [`${GITHUB_OIDC_HOST}:sub`]: subject
684
+ } }
685
+ }]
686
+ });
687
+ }
688
+ /**
689
+ * The subject a trust policy trusts, or undefined when it names none. IAM
690
+ * hands documents back URL-encoded.
691
+ */
692
+ function trustedSubject(document) {
693
+ if (!document) return void 0;
694
+ let parsed;
695
+ try {
696
+ parsed = JSON.parse(safeDecode(document));
697
+ } catch {
698
+ return;
699
+ }
700
+ for (const statement of parsed.Statement ?? []) for (const operator of Object.values(statement.Condition ?? {})) {
701
+ const value = operator[`${GITHUB_OIDC_HOST}:sub`];
702
+ if (typeof value === "string") return value;
703
+ if (Array.isArray(value)) return value.join(", ");
704
+ }
705
+ }
706
+ function safeDecode(value) {
707
+ try {
708
+ return decodeURIComponent(value);
709
+ } catch {
710
+ return value;
711
+ }
712
+ }
713
+ /** GitHub's OIDC provider in this account, created if it is not there. */
714
+ async function ensureOidcProvider(iam) {
715
+ const { OpenIDConnectProviderList = [] } = await iam.send(new ListOpenIDConnectProvidersCommand({}));
716
+ const existing = OpenIDConnectProviderList.find((p) => p.Arn?.endsWith(`oidc-provider/${GITHUB_OIDC_HOST}`))?.Arn;
717
+ if (existing) return existing;
718
+ return (await iam.send(new CreateOpenIDConnectProviderCommand({
719
+ Url: `https://${GITHUB_OIDC_HOST}`,
720
+ ClientIDList: [AUDIENCE]
721
+ }))).OpenIDConnectProviderArn;
722
+ }
723
+ function isNoSuchEntity(error) {
724
+ return error.name === "NoSuchEntityException";
725
+ }
726
+ /**
727
+ * The deploy role, created or brought back to this trust and access.
728
+ *
729
+ * Converges: re-running rewrites the trust, and moves the role from one access
730
+ * to another — detaching a managed policy only when the role's
731
+ * {@link POLICY_TAG} says gkm attached it.
732
+ */
733
+ async function ensureRole(iam, name, trust, access) {
734
+ let arn;
735
+ let created = false;
736
+ let previousSubject;
737
+ let recorded;
738
+ try {
739
+ const { Role } = await iam.send(new GetRoleCommand({ RoleName: name }));
740
+ previousSubject = trustedSubject(Role.AssumeRolePolicyDocument);
741
+ await iam.send(new UpdateAssumeRolePolicyCommand({
742
+ RoleName: name,
743
+ PolicyDocument: trust
744
+ }));
745
+ arn = Role.Arn;
746
+ const { Tags = [] } = await iam.send(new ListRoleTagsCommand({ RoleName: name }));
747
+ recorded = Tags.find((tag) => tag.Key === POLICY_TAG)?.Value;
748
+ } catch (error) {
749
+ if (!isNoSuchEntity(error)) throw error;
750
+ const { Role } = await iam.send(new CreateRoleCommand({
751
+ RoleName: name,
752
+ AssumeRolePolicyDocument: trust,
753
+ Description: "Deploys from GitHub Actions (gkm deploy:github)",
754
+ MaxSessionDuration: 7200
755
+ }));
756
+ arn = Role.Arn;
757
+ created = true;
758
+ }
759
+ const detached = [];
760
+ const leftAttached = [];
761
+ const detach = async (policyArn) => {
762
+ try {
763
+ await iam.send(new DetachRolePolicyCommand({
764
+ RoleName: name,
765
+ PolicyArn: policyArn
766
+ }));
767
+ detached.push(policyArn);
768
+ } catch (error) {
769
+ if (!isNoSuchEntity(error)) throw error;
770
+ }
771
+ };
772
+ const deleteInline = async () => {
773
+ try {
774
+ await iam.send(new DeleteRolePolicyCommand({
775
+ RoleName: name,
776
+ PolicyName: SCOPED_POLICY_NAME
777
+ }));
778
+ } catch (error) {
779
+ if (!isNoSuchEntity(error)) throw error;
780
+ }
781
+ };
782
+ if ("managed" in access) {
783
+ await iam.send(new AttachRolePolicyCommand({
784
+ RoleName: name,
785
+ PolicyArn: access.managed
786
+ }));
787
+ if (recorded && recorded !== access.managed) await detach(recorded);
788
+ if (recorded !== access.managed) await iam.send(new TagRoleCommand({
789
+ RoleName: name,
790
+ Tags: [{
791
+ Key: POLICY_TAG,
792
+ Value: access.managed
793
+ }]
794
+ }));
795
+ if (!created) await deleteInline();
796
+ return {
797
+ arn,
798
+ created,
799
+ previousSubject,
800
+ detached,
801
+ leftAttached
802
+ };
803
+ }
804
+ if (access.inline) await iam.send(new PutRolePolicyCommand({
805
+ RoleName: name,
806
+ PolicyName: SCOPED_POLICY_NAME,
807
+ PolicyDocument: access.inline
808
+ }));
809
+ else if (!created) await deleteInline();
810
+ if (created) return {
811
+ arn,
812
+ created,
813
+ previousSubject,
814
+ detached,
815
+ leftAttached
816
+ };
817
+ if (recorded) {
818
+ await detach(recorded);
819
+ await iam.send(new UntagRoleCommand({
820
+ RoleName: name,
821
+ TagKeys: [POLICY_TAG]
822
+ }));
823
+ }
824
+ const { AttachedPolicies = [] } = await iam.send(new ListAttachedRolePoliciesCommand({ RoleName: name }));
825
+ for (const policy of AttachedPolicies) if (policy.PolicyArn && !detached.includes(policy.PolicyArn)) leftAttached.push(policy.PolicyArn);
826
+ return {
827
+ arn,
828
+ created,
829
+ previousSubject,
830
+ detached,
831
+ leftAttached
832
+ };
833
+ }
834
+ /**
835
+ * An IAM client for the stage's account.
836
+ *
837
+ * `fromIni` for a named profile, deliberately: it resolves exactly that
838
+ * profile — keys, assume-role, `credential_process` or SSO, whichever
839
+ * ~/.aws/config says — and never falls back to AWS_* in the environment. The
840
+ * provider chain checks the environment first, so exported staging keys would
841
+ * quietly win over `--profile prod` and the production role would land in the
842
+ * staging account.
843
+ */
844
+ async function iamFor(profile, endpoint) {
845
+ const config = { region: "us-east-1" };
846
+ if (profile) {
847
+ const { fromIni } = await import("@aws-sdk/credential-providers");
848
+ config.credentials = fromIni({ profile });
849
+ }
850
+ if (endpoint) {
851
+ config.endpoint = endpoint;
852
+ config.credentials = {
853
+ accessKeyId: "test",
854
+ secretAccessKey: "test"
855
+ };
856
+ }
857
+ return new IAMClient(config);
858
+ }
859
+ async function deployGithubCommand(options, deps = {}) {
860
+ const gh = deps.gh ?? ghCli;
861
+ const { workspace } = await loadWorkspaceConfig(deps.cwd);
862
+ assertDeployedStage(workspace.stages, options.stage);
863
+ const repo = options.repo ?? gh([
864
+ "repo",
865
+ "view",
866
+ "--json",
867
+ "nameWithOwner",
868
+ "-q",
869
+ ".nameWithOwner"
870
+ ]);
871
+ const role = roleName(workspace.name, options.stage);
872
+ const oidc = resolveOidcSubject(gh, repo, options.stage);
873
+ const manifest = await discover({
874
+ patterns: constructGlobs(workspace),
875
+ cwd: workspace.root
876
+ });
877
+ const access = deployAccess(workspace, options.stage, options.policyArn, manifest);
878
+ const key = await readKey(options.stage, keystoreProject(workspace));
879
+ const keyPath = getKeyPath(options.stage, keystoreProject(workspace));
880
+ const hasKey = key !== null;
881
+ const remote = isRemoteStore(workspace, options.stage);
882
+ const store = await secretsStoreFor(workspace, options.stage, { ...options.profile ? { profile: options.profile } : {} });
883
+ const hasSecrets = remote && await store.read(options.stage) !== null;
884
+ const via = options.profile ? `profile "${options.profile}"` : "the default credentials";
885
+ logger.log(`\n🔐 GitHub → AWS for stage "${options.stage}"\n`);
886
+ logger.log(` Repository: ${repo}`);
887
+ logger.log(` AWS profile: ${options.profile ?? "(default credentials)"}`);
888
+ logger.log(` Role: ${role}`);
889
+ if (access.kind === "managed") logger.log(` Policy: ${access.policyArn} (${access.reason})`);
890
+ else if (access.describe.length > 0) {
891
+ logger.log(` Policy: inline "${SCOPED_POLICY_NAME}", scoped to the compose deploy — only:`);
892
+ for (const line of access.describe) logger.log(` ${line}`);
893
+ } else logger.log(" Policy: none — a compose deploy with file secrets and local state reads nothing from AWS");
894
+ logger.log(` Trusted by: ${oidc.subject} only (${SUBJECT_KINDS[oidc.kind]})`);
895
+ if (oidc.warning) logger.log(` ⚠ ${oidc.warning}`);
896
+ if (remote) logger.log(` Secrets: ${hasSecrets ? `in the store (${store.name}), read with ${via}` : `none in the store yet — gkm secrets:set <KEY> '…' --stage ${options.stage}`}`);
897
+ else logger.log(` Secrets key: ${hasKey ? keyPath : `none at ${keyPath} — run gkm secrets:init --stage ${options.stage} first`}`);
898
+ if (options.dryRun) {
899
+ if (access.kind === "scoped") {
900
+ const document = scopedPolicyDocument(access.statements("<account>"));
901
+ if (document) logger.log(`\n Inline policy:\n${JSON.stringify(JSON.parse(document), null, 2).replace(/^/gm, " ")}`);
902
+ }
903
+ logger.log("\n --dry-run: nothing changed.\n");
904
+ return {
905
+ repo,
906
+ subject: oidc.subject
907
+ };
908
+ }
909
+ const iam = deps.iam ?? await iamFor(options.profile);
910
+ const providerArn = await ensureOidcProvider(iam).catch((error) => {
911
+ if (/SSO session/i.test(String(error?.message)) && options.profile) throw new SsoSessionExpired(options.profile);
912
+ throw error;
913
+ });
914
+ const outcome = await ensureRole(iam, role, trustPolicy(providerArn, oidc.subject), access.kind === "managed" ? { managed: access.policyArn } : { inline: scopedPolicyDocument(access.statements(accountOf(providerArn))) });
915
+ const roleArn = outcome.arn;
916
+ logger.log(`\n ✓ AWS: ${roleArn}${outcome.created ? " (created)" : ""}`);
917
+ if (!outcome.created) logger.log(outcome.previousSubject === oidc.subject ? ` ✓ Trust: unchanged, ${oidc.subject}` : ` ✓ Trust: ${outcome.previousSubject ?? "(no subject)"} → ${oidc.subject}`);
918
+ for (const detached of outcome.detached) logger.log(` ✓ Detached ${detached} (attached by gkm, no longer needed)`);
919
+ if (access.kind === "scoped") for (const attached of outcome.leftAttached) logger.log(` ⚠ ${attached} is still attached to ${role}. gkm has no record of attaching it, so it is left; the compose deploy does not need it. Detach it with: aws iam detach-role-policy --role-name ${role} --policy-arn ${attached}${options.profile ? ` --profile ${options.profile}` : ""}`);
920
+ gh([
921
+ "api",
922
+ "--method",
923
+ "PUT",
924
+ `repos/${repo}/environments/${options.stage}`
925
+ ]);
926
+ gh([
927
+ "variable",
928
+ "set",
929
+ "AWS_ROLE_ARN",
930
+ "--env",
931
+ options.stage,
932
+ "--repo",
933
+ repo,
934
+ "--body",
935
+ roleArn
936
+ ]);
937
+ logger.log(` ✓ GitHub: environment "${options.stage}", AWS_ROLE_ARN`);
938
+ if (remote) {
939
+ if (!hasSecrets) logger.log(` ⚠ The "${options.stage}" store holds no secrets yet; set them with gkm secrets:set <KEY> '…' --stage ${options.stage}${options.profile ? ` (AWS_PROFILE=${options.profile})` : ""}.`);
940
+ } else if (hasKey) {
941
+ gh([
942
+ "secret",
943
+ "set",
944
+ "GKM_SECRETS_KEY",
945
+ "--env",
946
+ options.stage,
947
+ "--repo",
948
+ repo
949
+ ], key);
950
+ logger.log(" ✓ GitHub: GKM_SECRETS_KEY");
951
+ } else logger.log(` ⚠ No secrets key for "${options.stage}"; run gkm secrets:init --stage ${options.stage}, then this again.`);
952
+ logger.log(`\n Protect it: add required reviewers to the "${options.stage}" environment in the repository settings.\n`);
953
+ return {
954
+ roleArn,
955
+ repo,
956
+ subject: oidc.subject
957
+ };
958
+ }
959
+ const SUBJECT_KINDS = {
960
+ default: "the repository's default subject",
961
+ immutable: "the repository's immutable subject",
962
+ custom: "the repository's custom subject template",
963
+ assumed: "assumed: the default format"
964
+ };
965
+ /** The profile's SSO login has lapsed; the fix is one command away. */
966
+ var SsoSessionExpired = class extends GkmError {
967
+ profile;
968
+ constructor(profile) {
969
+ super(`The SSO session for profile "${profile}" has expired or is invalid. Run: aws sso login --profile ${profile}`);
970
+ this.profile = profile;
971
+ this.name = "SsoSessionExpired";
972
+ }
973
+ };
974
+ //#endregion
975
+ export { deployGithubCommand, ghCli };
976
+
977
+ //# sourceMappingURL=github-DdaV-Gll.mjs.map