@geekmidas/cli 10.0.0-alpha.160 → 10.0.0-alpha.162

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 (245) hide show
  1. package/dist/{GoDaddyProvider-C9dDlH9I.mjs → GoDaddyProvider-COSh6bNI.mjs} +2 -2
  2. package/dist/{GoDaddyProvider-C9dDlH9I.mjs.map → GoDaddyProvider-COSh6bNI.mjs.map} +1 -1
  3. package/dist/{GoDaddyProvider-DkUMcMYy.cjs → GoDaddyProvider-DyhN8PEn.cjs} +2 -2
  4. package/dist/{GoDaddyProvider-DkUMcMYy.cjs.map → GoDaddyProvider-DyhN8PEn.cjs.map} +1 -1
  5. package/dist/{HostingerProvider-BEuKG2gz.mjs → HostingerProvider-5Nekoneq.mjs} +2 -2
  6. package/dist/{HostingerProvider-BEuKG2gz.mjs.map → HostingerProvider-5Nekoneq.mjs.map} +1 -1
  7. package/dist/{HostingerProvider-9faYOQnQ.cjs → HostingerProvider-DG08aTyh.cjs} +2 -2
  8. package/dist/{HostingerProvider-9faYOQnQ.cjs.map → HostingerProvider-DG08aTyh.cjs.map} +1 -1
  9. package/dist/{LegacyStateStore-C44jUnMH.cjs → LegacyStateStore-5W4kFia3.cjs} +3 -3
  10. package/dist/{LegacyStateStore-C44jUnMH.cjs.map → LegacyStateStore-5W4kFia3.cjs.map} +1 -1
  11. package/dist/{LegacyStateStore-DPKhjUR6.mjs → LegacyStateStore-CafGn2Yl.mjs} +3 -3
  12. package/dist/{LegacyStateStore-DPKhjUR6.mjs.map → LegacyStateStore-CafGn2Yl.mjs.map} +1 -1
  13. package/dist/{LocalStateStore-B95WE99i.cjs → LocalStateStore--CJ7ksx6.cjs} +2 -2
  14. package/dist/{LocalStateStore-B95WE99i.cjs.map → LocalStateStore--CJ7ksx6.cjs.map} +1 -1
  15. package/dist/{LocalStateStore-BU3fWkcT.mjs → LocalStateStore-DrTw_EIu.mjs} +2 -2
  16. package/dist/{LocalStateStore-BU3fWkcT.mjs.map → LocalStateStore-DrTw_EIu.mjs.map} +1 -1
  17. package/dist/{S3StateStore-Cpbeijr5.mjs → S3StateStore-DGEwSkf2.mjs} +4 -4
  18. package/dist/{S3StateStore-Cpbeijr5.mjs.map → S3StateStore-DGEwSkf2.mjs.map} +1 -1
  19. package/dist/{S3StateStore-zU5kClhd.cjs → S3StateStore-M8vVPpr7.cjs} +4 -4
  20. package/dist/{S3StateStore-zU5kClhd.cjs.map → S3StateStore-M8vVPpr7.cjs.map} +1 -1
  21. package/dist/{SSMStateStore-D9uviQ3T.cjs → SSMStateStore-B2A27u0C.cjs} +2 -2
  22. package/dist/{SSMStateStore-D9uviQ3T.cjs.map → SSMStateStore-B2A27u0C.cjs.map} +1 -1
  23. package/dist/{SSMStateStore-BxkKMBi_.mjs → SSMStateStore-VYfuykBd.mjs} +2 -2
  24. package/dist/{SSMStateStore-BxkKMBi_.mjs.map → SSMStateStore-VYfuykBd.mjs.map} +1 -1
  25. package/dist/{add-Bb2IL3Yq.cjs → add-CijlgwVr.cjs} +6 -6
  26. package/dist/{add-Bb2IL3Yq.cjs.map → add-CijlgwVr.cjs.map} +1 -1
  27. package/dist/{add-Dj-gtqTO.mjs → add-CistiUc6.mjs} +6 -6
  28. package/dist/{add-Dj-gtqTO.mjs.map → add-CistiUc6.mjs.map} +1 -1
  29. package/dist/{apps-0vc4Oz9_.cjs → apps-5iJb710M.cjs} +5 -5
  30. package/dist/{apps-0vc4Oz9_.cjs.map → apps-5iJb710M.cjs.map} +1 -1
  31. package/dist/{apps-FRNlECwi.mjs → apps-BE97n0jO.mjs} +5 -5
  32. package/dist/{apps-FRNlECwi.mjs.map → apps-BE97n0jO.mjs.map} +1 -1
  33. package/dist/{aws-8QQ8n-t6.mjs → aws-C5LAU_Ii.mjs} +10 -2
  34. package/dist/aws-C5LAU_Ii.mjs.map +1 -0
  35. package/dist/{aws-DY9NqQIT.cjs → aws-DKC2m3sT.cjs} +9 -1
  36. package/dist/aws-DKC2m3sT.cjs.map +1 -0
  37. package/dist/{bundler-9EM4ZHcu.mjs → bundler-D-SXSUZI.mjs} +6 -6
  38. package/dist/{bundler-9EM4ZHcu.mjs.map → bundler-D-SXSUZI.mjs.map} +1 -1
  39. package/dist/{bundler-Bg2eEFEh.cjs → bundler-D4E7kCYb.cjs} +6 -6
  40. package/dist/{bundler-Bg2eEFEh.cjs.map → bundler-D4E7kCYb.cjs.map} +1 -1
  41. package/dist/{cli-CmoSOzNq.mjs → cli-Brr1IVq1.mjs} +5 -5
  42. package/dist/{cli-CmoSOzNq.mjs.map → cli-Brr1IVq1.mjs.map} +1 -1
  43. package/dist/{cli-YtLjcAZT.cjs → cli-D--xSSlK.cjs} +5 -5
  44. package/dist/{cli-YtLjcAZT.cjs.map → cli-D--xSSlK.cjs.map} +1 -1
  45. package/dist/{compose-D7gOSspy.cjs → compose-BoxgqTF8.cjs} +17 -11
  46. package/dist/compose-BoxgqTF8.cjs.map +1 -0
  47. package/dist/{compose-3AtZF7ul.mjs → compose-CuoV9T9U.mjs} +6 -6
  48. package/dist/{compose-3AtZF7ul.mjs.map → compose-CuoV9T9U.mjs.map} +1 -1
  49. package/dist/{compose-CnXZAYNM.mjs → compose-Dk0Z8zdf.mjs} +17 -11
  50. package/dist/compose-Dk0Z8zdf.mjs.map +1 -0
  51. package/dist/{compose-CW1DGfYc.cjs → compose-Dpkkp-Qq.cjs} +6 -6
  52. package/dist/{compose-CW1DGfYc.cjs.map → compose-Dpkkp-Qq.cjs.map} +1 -1
  53. package/dist/{config-CkuiD9Jv.d.cts → config-BxSSAzVi.d.mts} +3 -3
  54. package/dist/{config-BNmLn0dw.d.mts.map → config-BxSSAzVi.d.mts.map} +1 -1
  55. package/dist/{config-B5Hi3mLK.cjs → config-CLXSXbcs.cjs} +2 -2
  56. package/dist/{config-B5Hi3mLK.cjs.map → config-CLXSXbcs.cjs.map} +1 -1
  57. package/dist/{config-BNmLn0dw.d.mts → config-DNoWqavN.d.cts} +3 -3
  58. package/dist/{config-CkuiD9Jv.d.cts.map → config-DNoWqavN.d.cts.map} +1 -1
  59. package/dist/{config-DWTUVGRE.mjs → config-Da9bxnkT.mjs} +2 -2
  60. package/dist/{config-DWTUVGRE.mjs.map → config-Da9bxnkT.mjs.map} +1 -1
  61. package/dist/config.cjs +2 -2
  62. package/dist/config.d.cts +3 -3
  63. package/dist/config.d.mts +3 -3
  64. package/dist/config.mjs +2 -2
  65. package/dist/{credentials-DwIRfeBL.cjs → credentials-BR3dNNtO.cjs} +12 -8
  66. package/dist/credentials-BR3dNNtO.cjs.map +1 -0
  67. package/dist/{credentials-CjFtNBVH.mjs → credentials-DhCCRQJp.mjs} +12 -8
  68. package/dist/credentials-DhCCRQJp.mjs.map +1 -0
  69. package/dist/deploy/public.cjs +13 -13
  70. package/dist/deploy/public.d.cts +4 -4
  71. package/dist/deploy/public.d.cts.map +1 -1
  72. package/dist/deploy/public.d.mts +4 -4
  73. package/dist/deploy/public.d.mts.map +1 -1
  74. package/dist/deploy/public.mjs +13 -13
  75. package/dist/{deploy-BI3fHnyb.mjs → deploy-Bb-o2KYC.mjs} +294 -531
  76. package/dist/deploy-Bb-o2KYC.mjs.map +1 -0
  77. package/dist/{deploy-3bsiWJxj.cjs → deploy-Ck0zXkM7.cjs} +330 -567
  78. package/dist/deploy-Ck0zXkM7.cjs.map +1 -0
  79. package/dist/destroy-DIV6l_94.mjs +788 -0
  80. package/dist/destroy-DIV6l_94.mjs.map +1 -0
  81. package/dist/destroy-JHapr9UF.cjs +789 -0
  82. package/dist/destroy-JHapr9UF.cjs.map +1 -0
  83. package/dist/{docker-CwayjAF2.cjs → docker-CIpOFfOw.cjs} +5 -5
  84. package/dist/{docker-CwayjAF2.cjs.map → docker-CIpOFfOw.cjs.map} +1 -1
  85. package/dist/{docker-DPdn7tYJ.mjs → docker-zaY5JoqN.mjs} +5 -5
  86. package/dist/{docker-DPdn7tYJ.mjs.map → docker-zaY5JoqN.mjs.map} +1 -1
  87. package/dist/{dokploy-tmnH0Du_.mjs → dokploy-BTzdAG5F.mjs} +2 -2
  88. package/dist/{dokploy-tmnH0Du_.mjs.map → dokploy-BTzdAG5F.mjs.map} +1 -1
  89. package/dist/{dokploy-BMBL-_Xu.cjs → dokploy-DLVSItVD.cjs} +2 -2
  90. package/dist/{dokploy-BMBL-_Xu.cjs.map → dokploy-DLVSItVD.cjs.map} +1 -1
  91. package/dist/{eas-meN1xady.cjs → eas-B6VYsGLs.cjs} +3 -3
  92. package/dist/{eas-meN1xady.cjs.map → eas-B6VYsGLs.cjs.map} +1 -1
  93. package/dist/{eas-BVGQAUDc.mjs → eas-C1WvLOi1.mjs} +3 -3
  94. package/dist/{eas-BVGQAUDc.mjs.map → eas-C1WvLOi1.mjs.map} +1 -1
  95. package/dist/{encryption-C8AMbomA.mjs → encryption-DdnL7dor.mjs} +4 -4
  96. package/dist/{encryption-C8AMbomA.mjs.map → encryption-DdnL7dor.mjs.map} +1 -1
  97. package/dist/{encryption-DvFVZdGz.cjs → encryption-oVcZSyLK.cjs} +4 -4
  98. package/dist/{encryption-DvFVZdGz.cjs.map → encryption-oVcZSyLK.cjs.map} +1 -1
  99. package/dist/{engine-BbWj0w3F.mjs → engine-Viv9p-yK.mjs} +11 -11
  100. package/dist/{engine-BbWj0w3F.mjs.map → engine-Viv9p-yK.mjs.map} +1 -1
  101. package/dist/{engine-BmiIUVWa.cjs → engine-_zA1Selg.cjs} +11 -11
  102. package/dist/{engine-BmiIUVWa.cjs.map → engine-_zA1Selg.cjs.map} +1 -1
  103. package/dist/{github-Dc1daUbH.mjs → github-BOXn5NEP.mjs} +42 -10
  104. package/dist/github-BOXn5NEP.mjs.map +1 -0
  105. package/dist/{github-BWqQr8q6.cjs → github-CRvdaD2Y.cjs} +46 -14
  106. package/dist/github-CRvdaD2Y.cjs.map +1 -0
  107. package/dist/{googlePlay-ByaFUly7.mjs → googlePlay-C4UsG1Vd.mjs} +5 -5
  108. package/dist/{googlePlay-ByaFUly7.mjs.map → googlePlay-C4UsG1Vd.mjs.map} +1 -1
  109. package/dist/{googlePlay-CdVCdfU8.cjs → googlePlay-C5T1SOGW.cjs} +5 -5
  110. package/dist/{googlePlay-CdVCdfU8.cjs.map → googlePlay-C5T1SOGW.cjs.map} +1 -1
  111. package/dist/iam-BVPpX76R.cjs +521 -0
  112. package/dist/iam-BVPpX76R.cjs.map +1 -0
  113. package/dist/iam-q9ALh-Y5.mjs +442 -0
  114. package/dist/iam-q9ALh-Y5.mjs.map +1 -0
  115. package/dist/{index-Dv1Zj86i.d.mts → index-BC1BLv9Q.d.mts} +2 -2
  116. package/dist/{index-B35vTdAW.d.cts.map → index-BC1BLv9Q.d.mts.map} +1 -1
  117. package/dist/{index-B35vTdAW.d.cts → index-Dy4ojz5P.d.cts} +2 -2
  118. package/dist/{index-Dv1Zj86i.d.mts.map → index-Dy4ojz5P.d.cts.map} +1 -1
  119. package/dist/index.cjs +101 -80
  120. package/dist/index.cjs.map +1 -1
  121. package/dist/index.mjs +101 -80
  122. package/dist/index.mjs.map +1 -1
  123. package/dist/{local-CnVFHJjS.mjs → local-Bqx5Xj3z.mjs} +2 -2
  124. package/dist/{local-CnVFHJjS.mjs.map → local-Bqx5Xj3z.mjs.map} +1 -1
  125. package/dist/{local-qevrV6dZ.cjs → local-vSeEreyp.cjs} +2 -2
  126. package/dist/{local-qevrV6dZ.cjs.map → local-vSeEreyp.cjs.map} +1 -1
  127. package/dist/{migrate-BEuCcCwN.mjs → migrate-CEhUGDFy.mjs} +6 -6
  128. package/dist/{migrate-BEuCcCwN.mjs.map → migrate-CEhUGDFy.mjs.map} +1 -1
  129. package/dist/{migrate-CU8_ZWP1.cjs → migrate-CLSY8gSY.cjs} +6 -6
  130. package/dist/{migrate-CU8_ZWP1.cjs.map → migrate-CLSY8gSY.cjs.map} +1 -1
  131. package/dist/{migrate-DgfKZB41.mjs → migrate-D8PSR_08.mjs} +6 -6
  132. package/dist/{migrate-DgfKZB41.mjs.map → migrate-D8PSR_08.mjs.map} +1 -1
  133. package/dist/{migrate-CRRps1i6.cjs → migrate-DvdpT5Y4.cjs} +6 -6
  134. package/dist/{migrate-CRRps1i6.cjs.map → migrate-DvdpT5Y4.cjs.map} +1 -1
  135. package/dist/{notes-BrBnyZz5.cjs → notes-B9ro_R3x.cjs} +24 -15
  136. package/dist/notes-B9ro_R3x.cjs.map +1 -0
  137. package/dist/{notes-CIzrdBKE.mjs → notes-CdbUjLBC.mjs} +24 -15
  138. package/dist/notes-CdbUjLBC.mjs.map +1 -0
  139. package/dist/openapi.cjs +2 -2
  140. package/dist/openapi.d.cts +1 -1
  141. package/dist/openapi.d.mts +1 -1
  142. package/dist/openapi.mjs +2 -2
  143. package/dist/{projectBucket-CDJd3prK.mjs → projectBucket-DPaUiLyY.mjs} +2 -2
  144. package/dist/{projectBucket-CDJd3prK.mjs.map → projectBucket-DPaUiLyY.mjs.map} +1 -1
  145. package/dist/{projectBucket-CKr_zObJ.cjs → projectBucket-DUtWAxWn.cjs} +2 -2
  146. package/dist/{projectBucket-CKr_zObJ.cjs.map → projectBucket-DUtWAxWn.cjs.map} +1 -1
  147. package/dist/{publish-Bq96_QnK.mjs → publish-CoCRpbPl.mjs} +2 -2
  148. package/dist/{publish-Bq96_QnK.mjs.map → publish-CoCRpbPl.mjs.map} +1 -1
  149. package/dist/{publish-DMKXh1Tb.cjs → publish-DbR3j4TS.cjs} +2 -2
  150. package/dist/{publish-DMKXh1Tb.cjs.map → publish-DbR3j4TS.cjs.map} +1 -1
  151. package/dist/reconcile/public.d.cts +1 -1
  152. package/dist/reconcile/public.d.mts +1 -1
  153. package/dist/{resolve-CSsE7frp.mjs → resolve-BjRvKEpw.mjs} +4 -4
  154. package/dist/{resolve-CSsE7frp.mjs.map → resolve-BjRvKEpw.mjs.map} +1 -1
  155. package/dist/{resolve-DF9GrosZ.cjs → resolve-DDcPuS_G.cjs} +4 -4
  156. package/dist/{resolve-DF9GrosZ.cjs.map → resolve-DDcPuS_G.cjs.map} +1 -1
  157. package/dist/{rollback-BBFGGmMa.cjs → rollback-CvlebzBY.cjs} +8 -8
  158. package/dist/{rollback-BBFGGmMa.cjs.map → rollback-CvlebzBY.cjs.map} +1 -1
  159. package/dist/{rollback-CZthwqus.mjs → rollback-xLGFZaHy.mjs} +8 -8
  160. package/dist/{rollback-CZthwqus.mjs.map → rollback-xLGFZaHy.mjs.map} +1 -1
  161. package/dist/{runtime-CFvcLEJW.d.cts → runtime-BySbkdBz.d.cts} +2 -2
  162. package/dist/{runtime-CFvcLEJW.d.cts.map → runtime-BySbkdBz.d.cts.map} +1 -1
  163. package/dist/{runtime-dwsH6ddo.d.mts → runtime-MZ5Pqgan.d.mts} +2 -2
  164. package/dist/{runtime-dwsH6ddo.d.mts.map → runtime-MZ5Pqgan.d.mts.map} +1 -1
  165. package/dist/{s3-BBRkezf7.mjs → s3-CXA6Lleo.mjs} +29 -4
  166. package/dist/s3-CXA6Lleo.mjs.map +1 -0
  167. package/dist/{s3-CI2QYgXH.cjs → s3-D9pFisyo.cjs} +28 -3
  168. package/dist/s3-D9pFisyo.cjs.map +1 -0
  169. package/dist/{secretsManager-CQORubp9.mjs → secretsManager-CJyxFcBH.mjs} +18 -2
  170. package/dist/secretsManager-CJyxFcBH.mjs.map +1 -0
  171. package/dist/{secretsManager-RAGcEDX1.cjs → secretsManager-D8on44WI.cjs} +17 -1
  172. package/dist/secretsManager-D8on44WI.cjs.map +1 -0
  173. package/dist/{seeds-B3xvUAQf.cjs → seeds-D7q1zKCJ.cjs} +7 -1
  174. package/dist/{seeds-B3xvUAQf.cjs.map → seeds-D7q1zKCJ.cjs.map} +1 -1
  175. package/dist/{seeds-BCC8vAXR.mjs → seeds-y1rzXlAc.mjs} +2 -2
  176. package/dist/{seeds-BCC8vAXR.mjs.map → seeds-y1rzXlAc.mjs.map} +1 -1
  177. package/dist/{serverSetup-Dt2DTlwa.cjs → serverSetup-BoxtHWkI.cjs} +8 -8
  178. package/dist/{serverSetup-Dt2DTlwa.cjs.map → serverSetup-BoxtHWkI.cjs.map} +1 -1
  179. package/dist/{serverSetup-C4iAABtI.mjs → serverSetup-DxcbUlwE.mjs} +8 -8
  180. package/dist/{serverSetup-C4iAABtI.mjs.map → serverSetup-DxcbUlwE.mjs.map} +1 -1
  181. package/dist/{sniffer-bTrGuu9z.cjs → sniffer-B2jgjk-F.cjs} +8 -8
  182. package/dist/{sniffer-bTrGuu9z.cjs.map → sniffer-B2jgjk-F.cjs.map} +1 -1
  183. package/dist/{sniffer-C2Ot1IbK.mjs → sniffer-Csft3UaJ.mjs} +8 -8
  184. package/dist/{sniffer-C2Ot1IbK.mjs.map → sniffer-Csft3UaJ.mjs.map} +1 -1
  185. package/dist/{snsSubscriptions-CFKb7fv0.cjs → snsSubscriptions-CSyPnoEQ.cjs} +9 -3
  186. package/dist/{snsSubscriptions-CFKb7fv0.cjs.map → snsSubscriptions-CSyPnoEQ.cjs.map} +1 -1
  187. package/dist/{snsSubscriptions-QDDDn9Qi.mjs → snsSubscriptions-DgbFGyac.mjs} +4 -4
  188. package/dist/{snsSubscriptions-QDDDn9Qi.mjs.map → snsSubscriptions-DgbFGyac.mjs.map} +1 -1
  189. package/dist/{sst-iRdMlGKd.cjs → sst-BtrgnhHy.cjs} +5 -5
  190. package/dist/{sst-iRdMlGKd.cjs.map → sst-BtrgnhHy.cjs.map} +1 -1
  191. package/dist/{sst-DDRWlXdv.mjs → sst-CmNUadAV.mjs} +5 -5
  192. package/dist/{sst-DDRWlXdv.mjs.map → sst-CmNUadAV.mjs.map} +1 -1
  193. package/dist/{stack-B9iDYMrq.cjs → stack-9qBhn2pd.cjs} +8 -8
  194. package/dist/{stack-B9iDYMrq.cjs.map → stack-9qBhn2pd.cjs.map} +1 -1
  195. package/dist/{stack-CIOY44aC.mjs → stack-dVgzDUiH.mjs} +8 -8
  196. package/dist/{stack-CIOY44aC.mjs.map → stack-dVgzDUiH.mjs.map} +1 -1
  197. package/dist/{stage-DA74aD_V.mjs → stage-CwXpkN-y.mjs} +7 -7
  198. package/dist/{stage-DA74aD_V.mjs.map → stage-CwXpkN-y.mjs.map} +1 -1
  199. package/dist/{stage-ycFS9mVn.cjs → stage-HEZZZJKr.cjs} +7 -7
  200. package/dist/{stage-ycFS9mVn.cjs.map → stage-HEZZZJKr.cjs.map} +1 -1
  201. package/dist/{stages-yA9bhStl.mjs → stages-gG-DGHLb.mjs} +3 -3
  202. package/dist/{stages-yA9bhStl.mjs.map → stages-gG-DGHLb.mjs.map} +1 -1
  203. package/dist/{stages-B0yOikgt.cjs → stages-rzyes8Ew.cjs} +3 -3
  204. package/dist/{stages-B0yOikgt.cjs.map → stages-rzyes8Ew.cjs.map} +1 -1
  205. package/dist/target/public.cjs +1 -1
  206. package/dist/target/public.d.cts +2 -2
  207. package/dist/target/public.d.mts +2 -2
  208. package/dist/target/public.mjs +1 -1
  209. package/dist/{terminal-RxfbNUwl.cjs → terminal-8AA2uK0U.cjs} +2 -2
  210. package/dist/{terminal-RxfbNUwl.cjs.map → terminal-8AA2uK0U.cjs.map} +1 -1
  211. package/dist/{terminal-DX22WLvT.mjs → terminal-BqqGsi0O.mjs} +2 -2
  212. package/dist/{terminal-DX22WLvT.mjs.map → terminal-BqqGsi0O.mjs.map} +1 -1
  213. package/dist/{types-Dk--xVOT.d.cts → types-BXboFkn9.d.mts} +56 -3
  214. package/dist/types-BXboFkn9.d.mts.map +1 -0
  215. package/dist/{types-DwQYpd_0.d.mts → types-BsfPHUFZ.d.cts} +57 -2
  216. package/dist/types-BsfPHUFZ.d.cts.map +1 -0
  217. package/dist/workspace/index.cjs +1 -1
  218. package/dist/workspace/index.d.cts +2 -2
  219. package/dist/workspace/index.d.mts +2 -2
  220. package/dist/workspace/index.mjs +1 -1
  221. package/dist/{workspace-DFGsrjGD.mjs → workspace-D5Vm2qcy.mjs} +165 -9
  222. package/dist/workspace-D5Vm2qcy.mjs.map +1 -0
  223. package/dist/{workspace-1szcahj9.cjs → workspace-VhzmoxOv.cjs} +224 -8
  224. package/dist/workspace-VhzmoxOv.cjs.map +1 -0
  225. package/package.json +15 -15
  226. package/dist/aws-8QQ8n-t6.mjs.map +0 -1
  227. package/dist/aws-DY9NqQIT.cjs.map +0 -1
  228. package/dist/compose-CnXZAYNM.mjs.map +0 -1
  229. package/dist/compose-D7gOSspy.cjs.map +0 -1
  230. package/dist/credentials-CjFtNBVH.mjs.map +0 -1
  231. package/dist/credentials-DwIRfeBL.cjs.map +0 -1
  232. package/dist/deploy-3bsiWJxj.cjs.map +0 -1
  233. package/dist/deploy-BI3fHnyb.mjs.map +0 -1
  234. package/dist/github-BWqQr8q6.cjs.map +0 -1
  235. package/dist/github-Dc1daUbH.mjs.map +0 -1
  236. package/dist/notes-BrBnyZz5.cjs.map +0 -1
  237. package/dist/notes-CIzrdBKE.mjs.map +0 -1
  238. package/dist/s3-BBRkezf7.mjs.map +0 -1
  239. package/dist/s3-CI2QYgXH.cjs.map +0 -1
  240. package/dist/secretsManager-CQORubp9.mjs.map +0 -1
  241. package/dist/secretsManager-RAGcEDX1.cjs.map +0 -1
  242. package/dist/types-Dk--xVOT.d.cts.map +0 -1
  243. package/dist/types-DwQYpd_0.d.mts.map +0 -1
  244. package/dist/workspace-1szcahj9.cjs.map +0 -1
  245. package/dist/workspace-DFGsrjGD.mjs.map +0 -1
@@ -1,21 +1,22 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
2
  const require_errors = require("./errors-DMC4Umsb.cjs");
3
- const require_credentials = require("./credentials-DwIRfeBL.cjs");
4
- const require_workspace = require("./workspace-1szcahj9.cjs");
5
- const require_apps = require("./apps-0vc4Oz9_.cjs");
3
+ const require_credentials = require("./credentials-BR3dNNtO.cjs");
4
+ const require_workspace = require("./workspace-VhzmoxOv.cjs");
5
+ const require_apps = require("./apps-5iJb710M.cjs");
6
6
  const require_define = require("./define-crmMcXFS.cjs");
7
- const require_compose = require("./compose-CW1DGfYc.cjs");
7
+ const require_compose = require("./compose-Dpkkp-Qq.cjs");
8
8
  const require_SubscriberGenerator = require("./SubscriberGenerator-mZpSuSU7.cjs");
9
- const require_config = require("./config-B5Hi3mLK.cjs");
9
+ const require_config = require("./config-CLXSXbcs.cjs");
10
10
  const require_discover = require("./discover-CRywE7yc.cjs");
11
- const require_resolve = require("./resolve-DF9GrosZ.cjs");
12
- const require_notes = require("./notes-BrBnyZz5.cjs");
13
- const require_stack = require("./stack-B9iDYMrq.cjs");
14
- const require_snsSubscriptions = require("./snsSubscriptions-CFKb7fv0.cjs");
15
- const require_local = require("./local-qevrV6dZ.cjs");
16
- const require_sniffer = require("./sniffer-bTrGuu9z.cjs");
17
- const require_projectBucket = require("./projectBucket-CKr_zObJ.cjs");
18
- const require_seeds = require("./seeds-B3xvUAQf.cjs");
11
+ const require_resolve = require("./resolve-DDcPuS_G.cjs");
12
+ const require_notes = require("./notes-B9ro_R3x.cjs");
13
+ const require_stack = require("./stack-9qBhn2pd.cjs");
14
+ const require_snsSubscriptions = require("./snsSubscriptions-CSyPnoEQ.cjs");
15
+ const require_local = require("./local-vSeEreyp.cjs");
16
+ const require_sniffer = require("./sniffer-B2jgjk-F.cjs");
17
+ const require_iam = require("./iam-BVPpX76R.cjs");
18
+ const require_projectBucket = require("./projectBucket-DUtWAxWn.cjs");
19
+ const require_seeds = require("./seeds-D7q1zKCJ.cjs");
19
20
  const require_credentialSchemas = require("./credentialSchemas-BAklWDna.cjs");
20
21
  let node_path = require("node:path");
21
22
  let node_crypto = require("node:crypto");
@@ -81,506 +82,6 @@ async function deploySecrets(workspace, stage, redactor, options = {}) {
81
82
  mask: (value) => redactor.add(value)
82
83
  };
83
84
  }
84
- const SUFFIX_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
85
- /** A name that S3 would refuse — what the name builder never returns. */
86
- var InvalidBucketName = class extends require_errors.GkmError {
87
- bucket;
88
- reason;
89
- constructor(bucket, reason) {
90
- super(`'${bucket}' is not a valid S3 bucket name: ${reason}. Rename the construct or set deploy.namespace in gkm.config.ts to something that leaves room for it.`);
91
- this.bucket = bucket;
92
- this.reason = reason;
93
- this.name = "InvalidBucketName";
94
- }
95
- };
96
- /** Lowercase `[a-z0-9-]`, runs of anything else one `-`, no edge dashes. */
97
- function part(value) {
98
- return (0, _geekmidas_manifest.kebabCase)(value).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
99
- }
100
- /**
101
- * `parts` joined by `-`, shortened to `max` characters by trimming the longest
102
- * part one character at a time — so a long construct id gives way before a
103
- * short stage name does, and every part keeps its start.
104
- */
105
- function fitParts(parts, max) {
106
- const kept = parts.map(part).filter(Boolean);
107
- const length = () => kept.reduce((sum, p) => sum + p.length, 0) + kept.length - 1;
108
- while (length() > max) {
109
- let longest = 0;
110
- for (let i = 1; i < kept.length; i++) if (kept[i].length > kept[longest].length) longest = i;
111
- if (kept[longest].length <= 1) break;
112
- kept[longest] = kept[longest].slice(0, -1).replace(/-+$/, "");
113
- }
114
- return kept.join("-");
115
- }
116
- /** Why `name` is not a valid bucket name, or undefined when it is. */
117
- function bucketNameProblem(name) {
118
- if (name.length < 3 || name.length > 63) return `it is ${name.length} characters, and S3 takes 3 to 63`;
119
- if (!/^[a-z0-9-]+$/.test(name)) return "it may hold only lowercase letters, digits and -";
120
- if (!/^[a-z0-9].*[a-z0-9]$/.test(name)) return "it must start and end with a letter or a digit";
121
- if (name.startsWith("xn--") || name.startsWith("sthree-")) return "it starts with a prefix S3 reserves ('xn--', 'sthree-')";
122
- if (name.endsWith("-s3alias") || name.endsWith("--ol-s3")) return "it ends with a suffix S3 reserves ('-s3alias', '--ol-s3')";
123
- }
124
- /**
125
- * The good name: `<namespace>-<project>-<stage>-<bucket id>`, lowercased, no
126
- * dots, shortened to leave room for a clash's suffix.
127
- *
128
- * @throws {InvalidBucketName} when nothing usable is left
129
- */
130
- function bucketName(input) {
131
- const name = fitParts([
132
- input.scope,
133
- input.stage,
134
- input.id
135
- ], 56);
136
- const problem = bucketNameProblem(name);
137
- if (problem) throw new InvalidBucketName(name, problem);
138
- return name;
139
- }
140
- /** Six random `[a-z0-9]` characters. */
141
- function randomSuffix(random = node_crypto.randomInt) {
142
- let suffix = "";
143
- for (let i = 0; i < 6; i++) suffix += SUFFIX_ALPHABET[random(36)];
144
- return suffix;
145
- }
146
- /** The good name with a clash's suffix. */
147
- function suffixedBucketName(good, suffix) {
148
- return `${good}-${suffix}`;
149
- }
150
- /**
151
- * The IAM user a bucket is reached with on a stage:
152
- * `gkm-<project>-<stage>-<bucket id>`, at most 64 characters.
153
- */
154
- function iamUserName(input) {
155
- return fitParts([
156
- "gkm",
157
- input.scope,
158
- input.stage,
159
- input.id
160
- ], 64);
161
- }
162
- /** The path every user gkm creates is under, so it finds its own. */
163
- const IAM_USER_PATH = "/gkm/";
164
- /** The inline policy each user is given. */
165
- const IAM_POLICY_NAME = "gkm-bucket";
166
- //#endregion
167
- //#region src/providers/s3/policy.ts
168
- const bucketArn = (bucket) => `arn:aws:s3:::${bucket}`;
169
- /**
170
- * What the app's key may do: objects in this bucket, and listing it — and
171
- * nothing else in the account.
172
- *
173
- * Multipart uploads are in it because a presigned upload of a large file is
174
- * one, and an abandoned one is cleaned up by the app. Reading old versions is
175
- * added only when the bucket keeps them.
176
- */
177
- function userPolicy(bucket, options = {}) {
178
- return {
179
- Version: "2012-10-17",
180
- Statement: [
181
- {
182
- Sid: "GkmObjects",
183
- Effect: "Allow",
184
- Action: [
185
- "s3:GetObject",
186
- "s3:PutObject",
187
- "s3:DeleteObject",
188
- "s3:AbortMultipartUpload",
189
- "s3:ListMultipartUploadParts",
190
- ...options.versioning ? ["s3:GetObjectVersion"] : []
191
- ],
192
- Resource: `${bucketArn(bucket)}/*`
193
- },
194
- {
195
- Sid: "GkmBucket",
196
- Effect: "Allow",
197
- Action: [
198
- "s3:ListBucket",
199
- "s3:GetBucketLocation",
200
- "s3:ListBucketMultipartUploads"
201
- ],
202
- Resource: bucketArn(bucket)
203
- },
204
- ...options.eventsTopicArn ? [{
205
- Sid: "GkmEvents",
206
- Effect: "Allow",
207
- Action: "sns:ConfirmSubscription",
208
- Resource: options.eventsTopicArn
209
- }] : []
210
- ]
211
- };
212
- }
213
- /**
214
- * One open pattern as the resource it is public on. A `**` is S3's `*`; a
215
- * single `*` is too, which crosses `/` where the construct's own check does
216
- * not — the construct is the stricter of the two (see `bucketPolicy` in
217
- * reconcile, which the local MinIO is given the same way).
218
- */
219
- function openResource(bucket, pattern) {
220
- const path = pattern.replace(/^\/+/, "").replace(/\*\*/g, "*");
221
- return `${bucketArn(bucket)}/${path}`;
222
- }
223
- /**
224
- * The bucket's own policy: every request refused unless it came over TLS,
225
- * and — only when a file server opens paths on it — `s3:GetObject` on
226
- * exactly those prefixes: to anyone, or, when a CDN serves them, to
227
- * CloudFront alone, for exactly the stage's distributions. Behind a CDN the
228
- * bucket is never public: a key outside the open prefixes is refused to
229
- * CloudFront too, so the edge answers it 403.
230
- */
231
- function bucketPolicy(bucket, open = [], options = {}) {
232
- const statements = [{
233
- Sid: "GkmDenyInsecureTransport",
234
- Effect: "Deny",
235
- Principal: "*",
236
- Action: "s3:*",
237
- Resource: [bucketArn(bucket), `${bucketArn(bucket)}/*`],
238
- Condition: { Bool: { "aws:SecureTransport": "false" } }
239
- }];
240
- const resources = [...new Set(open.map((p) => openResource(bucket, p)))].sort();
241
- if (open.length > 0 && options.cdn) statements.push({
242
- Sid: "GkmCdnRead",
243
- Effect: "Allow",
244
- Principal: { Service: "cloudfront.amazonaws.com" },
245
- Action: "s3:GetObject",
246
- Resource: resources,
247
- Condition: { StringEquals: { "AWS:SourceArn": [...new Set(options.cdn.distributionArns)].sort() } }
248
- });
249
- else if (open.length > 0) statements.push({
250
- Sid: "GkmOpenPaths",
251
- Effect: "Allow",
252
- Principal: "*",
253
- Action: "s3:GetObject",
254
- Resource: resources
255
- });
256
- if (options.sesWrite) statements.push({
257
- Sid: "GkmSesWritesMail",
258
- Effect: "Allow",
259
- Principal: { Service: "ses.amazonaws.com" },
260
- Action: "s3:PutObject",
261
- Resource: `${bucketArn(bucket)}/${options.sesWrite.prefix}*`,
262
- Condition: { StringEquals: { "aws:SourceAccount": options.sesWrite.account } }
263
- });
264
- return {
265
- Version: "2012-10-17",
266
- Statement: statements
267
- };
268
- }
269
- /**
270
- * Block Public Access. All four flags on, unless the bucket has open paths:
271
- * then a *policy* may make it public (`BlockPublicPolicy`,
272
- * `RestrictPublicBuckets` off), and ACLs still may not.
273
- */
274
- function publicAccessBlock(open) {
275
- return {
276
- BlockPublicAcls: true,
277
- IgnorePublicAcls: true,
278
- BlockPublicPolicy: !open,
279
- RestrictPublicBuckets: !open
280
- };
281
- }
282
- function corsRule(origins) {
283
- return {
284
- AllowedMethods: [
285
- "GET",
286
- "HEAD",
287
- "POST",
288
- "PUT"
289
- ],
290
- AllowedOrigins: [...new Set(origins)].sort(),
291
- AllowedHeaders: ["*"],
292
- ExposeHeaders: ["ETag"],
293
- MaxAgeSeconds: 3e3
294
- };
295
- }
296
- /**
297
- * A policy document in one canonical form — keys sorted, a lone string a
298
- * one-element list, lists sorted — so one AWS reformatted reads as the same
299
- * document rather than as drift.
300
- */
301
- function canonicalPolicy(value) {
302
- return JSON.stringify(canonical(value));
303
- }
304
- function canonical(value, key) {
305
- if (Array.isArray(value)) {
306
- const items = value.map((v) => canonical(v));
307
- return key === "Statement" ? items : items.map((v) => JSON.stringify(v)).sort();
308
- }
309
- if (value && typeof value === "object") return Object.fromEntries(Object.keys(value).sort().map((k) => {
310
- const v = value[k];
311
- return [k, canonical(k === "Action" || k === "Resource" || k === "AWS" || k === "AWS:SourceArn" ? Array.isArray(v) ? v : [v] : v, k)];
312
- }));
313
- return value;
314
- }
315
- //#endregion
316
- //#region src/providers/iam.ts
317
- /**
318
- * An IAM user gkm creates for one thing on a stage, its inline policy, and
319
- * the access key written into the stage's secrets as an `s3://` URL — what
320
- * the `s3` provider gives each bucket, and the deploy gives a stage's
321
- * backups.
322
- *
323
- * - **The user** is under `/gkm/`, tagged with the deploy identity, the stage
324
- * and what it is for. One that exists without those tags is someone
325
- * else's, and is refused rather than taken over.
326
- * - **Its policy** is read on every run and put back when it drifted.
327
- * - **Its key**: one, written into the stage's secrets the moment IAM shows
328
- * its secret. `--rotate-keys` issues a successor and keeps the old one
329
- * active until the stage has deployed with the new one; the next run after
330
- * that — or `--retire-old-keys` — deletes it.
331
- * - **A new key** takes IAM seconds to become usable: the state records when
332
- * it was issued, and a check made with it waits that out
333
- * ({@link whileKeyIsNew}).
334
- */
335
- /** The tags gkm finds its own buckets and users by. */
336
- const TAG_PROJECT = "gkm:project";
337
- const TAG_STAGE = "gkm:stage";
338
- const TAG_CONSTRUCT = "gkm:construct";
339
- /** The keys gkm tags a bucket and a user with. */
340
- function identityTags(ctx, id) {
341
- return [
342
- {
343
- Key: TAG_PROJECT,
344
- Value: ctx.identity.key
345
- },
346
- {
347
- Key: TAG_STAGE,
348
- Value: ctx.stage
349
- },
350
- {
351
- Key: TAG_CONSTRUCT,
352
- Value: id
353
- }
354
- ];
355
- }
356
- /** A read whose "there is none" answer is one of `missing`. */
357
- async function readOr$3(read, missing) {
358
- try {
359
- return await read();
360
- } catch (error) {
361
- const e = error;
362
- if (missing.includes(e?.Code ?? e?.name ?? "")) return void 0;
363
- throw error;
364
- }
365
- }
366
- /** IAM returns a policy document URL-encoded; an emulator may not. */
367
- function decodePolicy(document) {
368
- try {
369
- return decodeURIComponent(document);
370
- } catch {
371
- return document;
372
- }
373
- }
374
- /**
375
- * The user and its inline policy: found — and refused when it is not this
376
- * stage's — or created, and the policy put back when it drifted.
377
- *
378
- * @throws {IamUserNotOwned}
379
- */
380
- async function ensureIamUser(ctx, clients, input) {
381
- const { IAM, iam } = clients;
382
- const { id, user, policy } = input;
383
- const entry = {
384
- key: `iam-user:${id}`,
385
- type: "iam-user"
386
- };
387
- const found = await readOr$3(() => iam.send(new IAM.GetUserCommand({ UserName: user })), ["NoSuchEntity", "NoSuchEntityException"]);
388
- if (found?.User) {
389
- const tags = await iam.send(new IAM.ListUserTagsCommand({ UserName: user }));
390
- const tag = (key) => tags.Tags?.find((t) => t.Key === key)?.Value;
391
- if (found.User.Path !== "/gkm/" || tag("gkm:project") !== ctx.identity.key || tag("gkm:stage") !== ctx.stage) throw new require_workspace.IamUserNotOwned(user, ctx.identity.key, ctx.stage);
392
- await ctx.state.ready(entry, user);
393
- } else await ctx.change({
394
- construct: id,
395
- resource: `IAM user ${user}`,
396
- change: `create under ${IAM_USER_PATH}`
397
- }, async () => {
398
- await ctx.state.pending(entry);
399
- await iam.send(new IAM.CreateUserCommand({
400
- UserName: user,
401
- Path: IAM_USER_PATH,
402
- Tags: identityTags(ctx, id)
403
- }));
404
- await ctx.state.ready(entry, user);
405
- });
406
- const exists = Boolean(found?.User) || !ctx.dryRun;
407
- const current = exists ? await readOr$3(() => iam.send(new IAM.GetUserPolicyCommand({
408
- UserName: user,
409
- PolicyName: input.policyName
410
- })), ["NoSuchEntity", "NoSuchEntityException"]) : void 0;
411
- const document = current?.PolicyDocument ? JSON.parse(decodePolicy(current.PolicyDocument)) : void 0;
412
- if (!document || canonicalPolicy(document) !== canonicalPolicy(policy)) await ctx.change({
413
- construct: id,
414
- resource: `IAM user ${user}`,
415
- change: `policy ${input.policyName}: ${input.describe}`
416
- }, async () => {
417
- await iam.send(new IAM.PutUserPolicyCommand({
418
- UserName: user,
419
- PolicyName: input.policyName,
420
- PolicyDocument: JSON.stringify(policy)
421
- }));
422
- });
423
- return {
424
- user,
425
- exists
426
- };
427
- }
428
- /**
429
- * The user's access key, in the stage's secrets as the bucket's URL.
430
- *
431
- * - First run: one key, written into the stage's secrets.
432
- * - `--rotate-keys`: a second key, written in place of the first; the first
433
- * stays active until the stage has deployed with the second, and the next
434
- * run after that deploy — or `--retire-old-keys` — deletes it.
435
- * - A key the secrets no longer hold (a store emptied by hand): replaced the
436
- * same way, since its secret cannot be read back.
437
- *
438
- * @throws {BucketKeySetElsewhere} when the secret names another bucket
439
- * @throws {RotationInProgress} on `--rotate-keys` with the last rotation's old key still active
440
- * @throws {AccessKeyLimit} when the user has two keys gkm did not record
441
- */
442
- async function ensureAccessKey(ctx, clients, input) {
443
- const { IAM, iam } = clients;
444
- const { id, bucket, user, urlKey } = input;
445
- const entryKey = `iam-access-key:${id}`;
446
- const record = ctx.state.record(entryKey);
447
- const given = ctx.secrets[urlKey];
448
- let inUrl;
449
- let parsed;
450
- if (given !== void 0) {
451
- try {
452
- parsed = _geekmidas_storage_s3_url.parse(given);
453
- } catch {
454
- parsed = void 0;
455
- }
456
- if (parsed?.bucket !== bucket) throw new require_workspace.BucketKeySetElsewhere(urlKey, bucket, parsed?.bucket ?? given.replace(/\/\/[^@]*@/, "//"), ctx.stage);
457
- inUrl = parsed.accessKeyId;
458
- }
459
- const listed = input.exists ? (await iam.send(new IAM.ListAccessKeysCommand({ UserName: user }))).AccessKeyMetadata?.map((k) => k.AccessKeyId) ?? [] : [];
460
- let current = record?.status === "ready" ? record.id : void 0;
461
- let previous = typeof record?.data?.previous === "string" ? record.data.previous : void 0;
462
- const rotatedAt = typeof record?.data?.rotatedAt === "string" ? record.data.rotatedAt : void 0;
463
- const entry = (data = {}) => ({
464
- key: entryKey,
465
- type: "iam-access-key",
466
- data: {
467
- user,
468
- ...data
469
- }
470
- });
471
- if (previous && current) {
472
- const deployed = rotatedAt !== void 0 && ctx.state.lastDeployedAt !== void 0 && ctx.state.lastDeployedAt > rotatedAt;
473
- if (ctx.retireOldKeys || deployed) {
474
- const old = previous;
475
- const keep = current;
476
- await ctx.change({
477
- construct: id,
478
- resource: `IAM user ${user}`,
479
- change: `delete the rotated-out access key ${old}`
480
- }, async () => {
481
- if (listed.includes(old)) await iam.send(new IAM.DeleteAccessKeyCommand({
482
- UserName: user,
483
- AccessKeyId: old
484
- }));
485
- await ctx.state.ready(entry(), keep);
486
- });
487
- previous = void 0;
488
- } else ctx.log(` ${id}: the old access key ${previous} stays active until '${ctx.stage}' is deployed with the new one; the next deploy after that deletes it (or pass --retire-old-keys)`);
489
- }
490
- if (!current && inUrl && listed.includes(inUrl)) {
491
- await ctx.state.ready(entry(), inUrl);
492
- current = inUrl;
493
- }
494
- if (current !== void 0 && listed.includes(current) && inUrl === current && !ctx.rotateKeys) {
495
- if (parsed && parsed.region !== clients.region) {
496
- const address = parsed;
497
- await ctx.change({
498
- construct: id,
499
- resource: urlKey,
500
- change: `name ${clients.region}, the bucket's region (it said ${address.region ?? "none"})`
501
- }, () => ctx.writeSecrets({ [urlKey]: _geekmidas_storage_s3_url.build({
502
- ...address,
503
- region: clients.region
504
- }) }));
505
- }
506
- return;
507
- }
508
- if (ctx.rotateKeys && previous) throw new require_workspace.RotationInProgress(id, previous, ctx.stage);
509
- const outgoing = current && listed.includes(current) ? current : void 0;
510
- if (listed.length >= 2) throw new require_workspace.AccessKeyLimit(user, listed);
511
- const why = !current ? "create an access key" : ctx.rotateKeys ? "rotate: issue a new access key" : "issue a new access key (the secrets no longer hold the recorded one)";
512
- await ctx.change({
513
- construct: id,
514
- resource: `IAM user ${user}`,
515
- change: why
516
- }, async () => {
517
- await ctx.state.pending(entry(outgoing ? { previous: outgoing } : {}));
518
- const key = (await iam.send(new IAM.CreateAccessKeyCommand({ UserName: user }))).AccessKey;
519
- await ctx.writeSecrets({ [urlKey]: _geekmidas_storage_s3_url.build({
520
- bucket,
521
- region: clients.region,
522
- ...clients.endpoint ? {
523
- endpoint: clients.endpoint,
524
- forcePathStyle: true
525
- } : {},
526
- accessKeyId: key.AccessKeyId,
527
- secretAccessKey: key.SecretAccessKey
528
- }) });
529
- const issuedAt = (/* @__PURE__ */ new Date()).toISOString();
530
- await ctx.state.ready(entry(outgoing ? {
531
- previous: outgoing,
532
- rotatedAt: issuedAt,
533
- issuedAt
534
- } : { issuedAt }), key.AccessKeyId);
535
- });
536
- if (outgoing) ctx.log(` ${urlKey} holds the new key. This deploy moves '${ctx.stage}' onto it; the next deploy after it deletes the old key ${outgoing}`);
537
- }
538
- /** How long a key issued this recently counts as new to IAM. */
539
- const NEW_KEY_WINDOW_MS = 6e5;
540
- /** The waits between asks while a new key becomes usable: about a minute. */
541
- let newKeyWaits = [
542
- 2e3,
543
- 4e3,
544
- 8e3,
545
- 15e3,
546
- 15e3,
547
- 15e3
548
- ];
549
- /**
550
- * When the key in a URL was issued, if the stage's state says it was just
551
- * now — the record of `id`'s key naming that very key.
552
- */
553
- function issuedJustNow(resources, id, accessKeyId) {
554
- const record = resources?.[`iam-access-key:${id}`];
555
- const issuedAt = record?.data?.issuedAt;
556
- if (record?.id !== accessKeyId || typeof issuedAt !== "string") return;
557
- const age = Date.now() - Date.parse(issuedAt);
558
- return age >= 0 && age < NEW_KEY_WINDOW_MS ? issuedAt : void 0;
559
- }
560
- /**
561
- * `ask` again, for about a minute, while it is `refused` and the key was
562
- * issued just now — IAM refuses a key for seconds after making it. Returns
563
- * the last answer and how long was waited.
564
- */
565
- async function whileKeyIsNew(first, options) {
566
- let answer = first;
567
- let waited = 0;
568
- if (!options.issuedAt || !options.refused(answer)) return {
569
- answer,
570
- waited
571
- };
572
- options.onWait?.();
573
- for (const wait of newKeyWaits) {
574
- await new Promise((resolve) => setTimeout(resolve, wait));
575
- waited += wait;
576
- answer = await options.ask();
577
- if (!options.refused(answer)) break;
578
- }
579
- return {
580
- answer,
581
- waited
582
- };
583
- }
584
85
  //#endregion
585
86
  //#region src/backups/provision.ts
586
87
  /** What the backups user and its key are recorded and tagged as. */
@@ -591,7 +92,7 @@ const BACKUPS_POLICY_NAME = "gkm-backups";
591
92
  const VERIFY_MARKER = ".gkm-verify";
592
93
  /** The backups user's name: `gkm-<project>-<stage>-backups`. */
593
94
  function backupsUserName(scope, stage) {
594
- return iamUserName({
95
+ return require_workspace.iamUserName({
595
96
  scope,
596
97
  stage,
597
98
  id: BACKUPS_ID
@@ -720,17 +221,19 @@ async function ensureStageBackups(input) {
720
221
  }, async () => {
721
222
  await require_projectBucket.reconcileProjectBucketLifecycle(clients.s3, bucket, expiries);
722
223
  });
723
- const user = await ensureIamUser(ctx, clients, {
224
+ const user = await require_iam.ensureIamUser(ctx, clients, {
724
225
  id: BACKUPS_ID,
725
226
  user: backupsUserName(ctx.identity.scope, stage),
726
227
  policyName: BACKUPS_POLICY_NAME,
727
228
  policy: backupsPolicy(bucket, prefix),
728
229
  describe: `put objects under ${prefix}/ only`
729
230
  });
730
- await ensureAccessKey(ctx, clients, {
231
+ await require_iam.ensureAccessKey(ctx, clients, {
731
232
  id: BACKUPS_ID,
732
- bucket,
733
- urlKey: require_apps.BACKUPS_URL_KEY,
233
+ secret: require_iam.s3KeySecret(ctx, clients, {
234
+ bucket,
235
+ urlKey: require_apps.BACKUPS_URL_KEY
236
+ }),
734
237
  ...user
735
238
  });
736
239
  return choice;
@@ -805,8 +308,8 @@ async function verifyStageBackups(input) {
805
308
  }
806
309
  };
807
310
  try {
808
- const { answer } = await whileKeyIsNew(await put(), {
809
- issuedAt: issuedJustNow(input.resources, BACKUPS_ID, address.accessKeyId),
311
+ const { answer } = await require_iam.whileKeyIsNew(await put(), {
312
+ issuedAt: require_iam.issuedJustNow(input.resources, BACKUPS_ID, address.accessKeyId),
810
313
  refused: (answer) => !answer.ok && answer.status === 403,
811
314
  ask: put,
812
315
  onWait: () => input.log?.(` backups: waiting for the new key ${address.accessKeyId} to become active…`)
@@ -1351,7 +854,7 @@ async function ensureCertificate(ctx, clients, input) {
1351
854
  DomainName: host,
1352
855
  ValidationMethod: "DNS",
1353
856
  IdempotencyToken: input.name.replace(/[^A-Za-z0-9]/g, "").slice(0, 32),
1354
- Tags: identityTags(ctx, id).map((t) => ({
857
+ Tags: require_iam.identityTags(ctx, id).map((t) => ({
1355
858
  Key: t.Key,
1356
859
  Value: t.Value
1357
860
  }))
@@ -1566,7 +1069,7 @@ async function ensureDistribution(ctx, clients, input) {
1566
1069
  await ctx.state.pending(entry);
1567
1070
  const out = await cloudfront.send(new CF.CreateDistributionWithTagsCommand({ DistributionConfigWithTags: {
1568
1071
  DistributionConfig: input.config,
1569
- Tags: { Items: identityTags(ctx, input.id).map((t) => ({
1072
+ Tags: { Items: require_iam.identityTags(ctx, input.id).map((t) => ({
1570
1073
  Key: t.Key,
1571
1074
  Value: t.Value
1572
1075
  })) }
@@ -1750,13 +1253,13 @@ async function ensureTopic(ctx, clients, input) {
1750
1253
  await ctx.state.pending(topicEntry);
1751
1254
  await sns.send(new SNS.CreateTopicCommand({
1752
1255
  Name: topicName,
1753
- Tags: identityTags(ctx, id)
1256
+ Tags: require_iam.identityTags(ctx, id)
1754
1257
  }));
1755
1258
  await ctx.state.ready(topicEntry, topicArn);
1756
1259
  });
1757
1260
  const topicPolicy = input.policy(topicArn);
1758
1261
  const currentTopicPolicy = topic?.Attributes?.Policy;
1759
- if (!currentTopicPolicy || canonicalPolicy(JSON.parse(currentTopicPolicy)) !== canonicalPolicy(topicPolicy)) await ctx.change({
1262
+ if (!currentTopicPolicy || require_iam.canonicalPolicy(JSON.parse(currentTopicPolicy)) !== require_iam.canonicalPolicy(topicPolicy)) await ctx.change({
1760
1263
  construct: id,
1761
1264
  resource: `SNS topic ${topicName}`,
1762
1265
  change: `publishable by ${input.publisher} only`
@@ -1803,7 +1306,7 @@ async function ensureBucketEvents(ctx, s3, input) {
1803
1306
  queueUrl = (await sqs.send(new SQS.CreateQueueCommand({
1804
1307
  QueueName: queueName,
1805
1308
  Attributes: { MessageRetentionPeriod: "1209600" },
1806
- tags: Object.fromEntries(identityTags(ctx, id).map((t) => [t.Key, t.Value]))
1309
+ tags: Object.fromEntries(require_iam.identityTags(ctx, id).map((t) => [t.Key, t.Value]))
1807
1310
  }))).QueueUrl;
1808
1311
  await ctx.state.ready(queueEntry, deadLetterArn);
1809
1312
  });
@@ -1812,7 +1315,7 @@ async function ensureBucketEvents(ctx, s3, input) {
1812
1315
  QueueUrl: queue.QueueUrl,
1813
1316
  AttributeNames: ["Policy"]
1814
1317
  }))).Attributes?.Policy : void 0;
1815
- if (!currentQueuePolicy || canonicalPolicy(JSON.parse(currentQueuePolicy)) !== canonicalPolicy(queuePolicy)) await ctx.change({
1318
+ if (!currentQueuePolicy || require_iam.canonicalPolicy(JSON.parse(currentQueuePolicy)) !== require_iam.canonicalPolicy(queuePolicy)) await ctx.change({
1816
1319
  construct: id,
1817
1320
  resource: `SQS queue ${queueName}`,
1818
1321
  change: `receives what ${topicName} cannot deliver`
@@ -2180,7 +1683,7 @@ async function ensureBucket(ctx, stageClients, construct, watchers) {
2180
1683
  };
2181
1684
  const versioning = ctx.config.versioning ?? construct.versioned;
2182
1685
  const open = [...new Set(construct.servers.flatMap((s) => s.open))].sort();
2183
- const located = await ensureBucketName(ctx, stageClients, id, bucketName(nameInput));
1686
+ const located = await ensureBucketName(ctx, stageClients, id, require_workspace.bucketName(nameInput));
2184
1687
  const { bucket, exists } = located;
2185
1688
  let clients = stageClients;
2186
1689
  if (located.region !== stageClients.region) {
@@ -2212,20 +1715,22 @@ async function ensureBucket(ctx, stageClients, construct, watchers) {
2212
1715
  bucket,
2213
1716
  region: clients.region
2214
1717
  }) : void 0;
2215
- const user = await ensureIamUser(ctx, clients, {
1718
+ const user = await require_iam.ensureIamUser(ctx, clients, {
2216
1719
  id,
2217
- user: iamUserName(nameInput),
2218
- policyName: IAM_POLICY_NAME,
2219
- policy: userPolicy(bucket, {
1720
+ user: require_workspace.iamUserName(nameInput),
1721
+ policyName: require_workspace.IAM_POLICY_NAME,
1722
+ policy: require_iam.userPolicy(bucket, {
2220
1723
  versioning,
2221
1724
  ...events ? { eventsTopicArn: events.topicArn } : {}
2222
1725
  }),
2223
1726
  describe: "this bucket only"
2224
1727
  });
2225
- await ensureAccessKey(ctx, clients, {
1728
+ await require_iam.ensureAccessKey(ctx, clients, {
2226
1729
  id,
2227
- bucket,
2228
- urlKey: (0, _geekmidas_manifest.provideKey)(id, "url"),
1730
+ secret: require_iam.s3KeySecret(ctx, clients, {
1731
+ bucket,
1732
+ urlKey: (0, _geekmidas_manifest.provideKey)(id, "url")
1733
+ }),
2229
1734
  ...user
2230
1735
  });
2231
1736
  if (events && watchers) {
@@ -2288,7 +1793,7 @@ async function ensureOwnedBucket(ctx, input) {
2288
1793
  stage: ctx.stage,
2289
1794
  id: input.name
2290
1795
  };
2291
- const located = await ensureBucketName(bucketCtx, stageClients, input.id, bucketName(nameInput));
1796
+ const located = await ensureBucketName(bucketCtx, stageClients, input.id, require_workspace.bucketName(nameInput));
2292
1797
  const clients = located.region === stageClients.region ? stageClients : await makeClients(ctx.credential, located.region);
2293
1798
  await ensureBucketSettings(bucketCtx, clients, {
2294
1799
  id: input.id,
@@ -2298,17 +1803,19 @@ async function ensureOwnedBucket(ctx, input) {
2298
1803
  open: [],
2299
1804
  ...input.sesWrite ? { sesWrite: input.sesWrite } : {}
2300
1805
  });
2301
- const user = await ensureIamUser(bucketCtx, clients, {
1806
+ const user = await require_iam.ensureIamUser(bucketCtx, clients, {
2302
1807
  id: input.id,
2303
- user: iamUserName(nameInput),
2304
- policyName: IAM_POLICY_NAME,
2305
- policy: userPolicy(located.bucket, input.topicArn ? { eventsTopicArn: input.topicArn } : {}),
1808
+ user: require_workspace.iamUserName(nameInput),
1809
+ policyName: require_workspace.IAM_POLICY_NAME,
1810
+ policy: require_iam.userPolicy(located.bucket, input.topicArn ? { eventsTopicArn: input.topicArn } : {}),
2306
1811
  describe: "this bucket only"
2307
1812
  });
2308
- await ensureAccessKey(bucketCtx, clients, {
1813
+ await require_iam.ensureAccessKey(bucketCtx, clients, {
2309
1814
  id: input.id,
2310
- bucket: located.bucket,
2311
- urlKey: input.urlKey,
1815
+ secret: require_iam.s3KeySecret(bucketCtx, clients, {
1816
+ bucket: located.bucket,
1817
+ urlKey: input.urlKey
1818
+ }),
2312
1819
  ...user
2313
1820
  });
2314
1821
  return {
@@ -2380,7 +1887,7 @@ async function ensureBucketName(ctx, clients, id, good) {
2380
1887
  };
2381
1888
  const adopt = async (name, where) => {
2382
1889
  const there = where === region ? clients : await makeClients(ctx.credential, where);
2383
- const owner = (await readOr(() => there.s3.send(new there.S3.GetBucketTaggingCommand({ Bucket: name })), ["NoSuchTagSet", "NoSuchTagSetError"]))?.TagSet?.find((t) => t.Key === TAG_PROJECT)?.Value;
1890
+ const owner = (await readOr(() => there.s3.send(new there.S3.GetBucketTaggingCommand({ Bucket: name })), ["NoSuchTagSet", "NoSuchTagSetError"]))?.TagSet?.find((t) => t.Key === require_iam.TAG_PROJECT)?.Value;
2384
1891
  if (owner && owner !== ctx.identity.key) throw new require_workspace.BucketOwnedByAnotherProject(name, owner, ctx.identity.key);
2385
1892
  };
2386
1893
  if (record?.status === "ready" && record.id) {
@@ -2400,7 +1907,7 @@ async function ensureBucketName(ctx, clients, id, good) {
2400
1907
  const names = [
2401
1908
  ...typeof pending === "string" && pending !== good ? [pending] : [],
2402
1909
  good,
2403
- ...Array.from({ length: 5 }, () => suffixedBucketName(good, randomSuffix()))
1910
+ ...Array.from({ length: 5 }, () => require_workspace.suffixedBucketName(good, require_workspace.randomSuffix()))
2404
1911
  ];
2405
1912
  const tried = [];
2406
1913
  for (const name of names) {
@@ -2435,7 +1942,7 @@ async function ensureBucketSettings(ctx, clients, input) {
2435
1942
  change
2436
1943
  }, () => apply().then(() => void 0));
2437
1944
  const tagged = await read(() => s3.send(new S3.GetBucketTaggingCommand({ Bucket })), ["NoSuchTagSet", "NoSuchTagSetError"]);
2438
- const ours = identityTags(ctx, id);
1945
+ const ours = require_iam.identityTags(ctx, id);
2439
1946
  const others = (tagged?.TagSet ?? []).filter((t) => !ours.some((o) => o.Key === t.Key));
2440
1947
  if (ours.some((o) => !tagged?.TagSet?.some((t) => t.Key === o.Key && t.Value === o.Value))) await set("tag", () => s3.send(new S3.PutBucketTaggingCommand({
2441
1948
  Bucket,
@@ -2445,7 +1952,7 @@ async function ensureBucketSettings(ctx, clients, input) {
2445
1952
  })) }
2446
1953
  })));
2447
1954
  const isOpen = input.open.length > 0 && !input.cdn;
2448
- const block = publicAccessBlock(isOpen);
1955
+ const block = require_iam.publicAccessBlock(isOpen);
2449
1956
  const ensureBlock = async () => {
2450
1957
  const now = (await read(() => s3.send(new S3.GetPublicAccessBlockCommand({ Bucket })), ["NoSuchPublicAccessBlockConfiguration"]))?.PublicAccessBlockConfiguration;
2451
1958
  if (!(now && Object.keys(block).every((k) => (now[k] ?? false) === block[k]))) await set(isOpen ? "block public access (ACLs; the policy opens the open paths)" : "block all public access", () => s3.send(new S3.PutPublicAccessBlockCommand({
@@ -2453,13 +1960,13 @@ async function ensureBucketSettings(ctx, clients, input) {
2453
1960
  PublicAccessBlockConfiguration: block
2454
1961
  })));
2455
1962
  };
2456
- const policy = bucketPolicy(bucket, input.open, {
1963
+ const policy = require_iam.bucketPolicy(bucket, input.open, {
2457
1964
  ...input.cdn ? { cdn: input.cdn } : {},
2458
1965
  ...input.sesWrite ? { sesWrite: input.sesWrite } : {}
2459
1966
  });
2460
1967
  const ensurePolicy = async () => {
2461
1968
  const current = await read(() => s3.send(new S3.GetBucketPolicyCommand({ Bucket })), ["NoSuchBucketPolicy"]);
2462
- if (!(current?.Policy !== void 0 && canonicalPolicy(JSON.parse(current.Policy)) === canonicalPolicy(policy))) await set(isOpen ? `policy: TLS only, public read on ${input.open.join(", ")}` : input.cdn && input.open.length > 0 ? `policy: TLS only, CloudFront reads ${input.open.join(", ")}` : "policy: TLS only", () => s3.send(new S3.PutBucketPolicyCommand({
1969
+ if (!(current?.Policy !== void 0 && require_iam.canonicalPolicy(JSON.parse(current.Policy)) === require_iam.canonicalPolicy(policy))) await set(isOpen ? `policy: TLS only, public read on ${input.open.join(", ")}` : input.cdn && input.open.length > 0 ? `policy: TLS only, CloudFront reads ${input.open.join(", ")}` : "policy: TLS only", () => s3.send(new S3.PutBucketPolicyCommand({
2463
1970
  Bucket,
2464
1971
  Policy: JSON.stringify(policy)
2465
1972
  })));
@@ -2498,7 +2005,7 @@ async function ensureBucketSettings(ctx, clients, input) {
2498
2005
  });
2499
2006
  if (unresolved.length > 0) ctx.log(` ${unresolved.join(", ")} ${unresolved.length === 1 ? "has" : "have"} no address on '${ctx.stage}' (domains.${ctx.stage}), so ${unresolved.length === 1 ? "is" : "are"} not in '${bucket}''s CORS`);
2500
2007
  if (origins.length === 0) return;
2501
- const rule = corsRule(origins);
2008
+ const rule = require_iam.corsRule(origins);
2502
2009
  const cors = await read(() => s3.send(new S3.GetBucketCorsCommand({ Bucket })), ["NoSuchCORSConfiguration"]);
2503
2010
  if (!(cors?.CORSRules?.length === 1 && canonicalCors(cors.CORSRules[0]) === canonicalCors(rule))) await set(`CORS for ${origins.join(", ")}`, () => s3.send(new S3.PutBucketCorsCommand({
2504
2011
  Bucket,
@@ -2547,8 +2054,8 @@ async function verifyS3(ctx) {
2547
2054
  ...address.forcePathStyle ? { forcePathStyle: true } : {}
2548
2055
  });
2549
2056
  try {
2550
- const issuedAt = issuedJustNow(ctx.resources, id, address.accessKeyId);
2551
- const { answer: head, waited } = await whileKeyIsNew(await headBucket(S3, client, address.bucket), {
2057
+ const issuedAt = require_iam.issuedJustNow(ctx.resources, id, address.accessKeyId);
2058
+ const { answer: head, waited } = await require_iam.whileKeyIsNew(await headBucket(S3, client, address.bucket), {
2552
2059
  issuedAt,
2553
2060
  refused: (answer) => !answer.ok && answer.status === 403,
2554
2061
  ask: () => headBucket(S3, client, address.bucket),
@@ -2693,6 +2200,10 @@ const defaultSesClients = async (credential, region) => {
2693
2200
  };
2694
2201
  };
2695
2202
  let makeSesClients = defaultSesClients;
2203
+ /** The stage's SES, through the factory a test may replace. */
2204
+ function sesClients(credential, region) {
2205
+ return makeSesClients(credential, region);
2206
+ }
2696
2207
  function errorName(error) {
2697
2208
  const e = error;
2698
2209
  return e?.name ?? e?.Code ?? e?.code ?? "";
@@ -2715,7 +2226,7 @@ async function ensureSes(ctx) {
2715
2226
  }, inboxes.length > 0);
2716
2227
  if (inboxes.length > 0) {
2717
2228
  const domain = stageDomain(ctx);
2718
- await ensureIdentity(ctx, {
2229
+ await ensureIdentity$1(ctx, {
2719
2230
  SES,
2720
2231
  ses
2721
2232
  }, domain);
@@ -2769,7 +2280,7 @@ async function activeRuleSet(ctx, { SES, ses }, needed) {
2769
2280
  * The stage's domain as an SES identity, verified by Easy DKIM: its three
2770
2281
  * CNAMEs, through the stage's DNS. Receiving requires a verified domain.
2771
2282
  */
2772
- async function ensureIdentity(ctx, { SES, ses }, domain) {
2283
+ async function ensureIdentity$1(ctx, { SES, ses }, domain) {
2773
2284
  let tokens = [];
2774
2285
  await ctx.change({
2775
2286
  construct: "inbox",
@@ -2922,6 +2433,257 @@ const sesProvider = {
2922
2433
  verify: verifySes
2923
2434
  };
2924
2435
  //#endregion
2436
+ //#region src/providers/ses/smtp.ts
2437
+ /**
2438
+ * SES's SMTP interface: where it is, and the password an IAM access key signs
2439
+ * in with there.
2440
+ *
2441
+ * SES issues IAM credentials, not SMTP ones. The SMTP password is derived
2442
+ * from the key's secret and the region, by SigV4's key derivation over a
2443
+ * fixed date and the message `SendRawEmail` — the algorithm the SES
2444
+ * Developer Guide gives ("Obtaining Amazon SES SMTP credentials"). A
2445
+ * password works in that region only.
2446
+ */
2447
+ /** The SMTP endpoint of `region`. */
2448
+ function smtpHost(region) {
2449
+ return `email-smtp.${region}.amazonaws.com`;
2450
+ }
2451
+ /** The SMTP password for an access key's secret, in `region`. */
2452
+ function smtpPassword(secretAccessKey, region) {
2453
+ const sign = (key, message) => (0, node_crypto.createHmac)("sha256", key).update(message, "utf8").digest();
2454
+ let signature = sign(`AWS4${secretAccessKey}`, "11111111");
2455
+ for (const part of [
2456
+ region,
2457
+ "ses",
2458
+ "aws4_request",
2459
+ "SendRawEmail"
2460
+ ]) signature = sign(signature, part);
2461
+ return Buffer.concat([Buffer.from([4]), signature]).toString("base64");
2462
+ }
2463
+ /** `smtp://<key id>:<smtp password>@email-smtp.<region>.amazonaws.com:587`. */
2464
+ function smtpUrl(accessKeyId, secretAccessKey, region) {
2465
+ return `smtp://${encodeURIComponent(accessKeyId)}:${encodeURIComponent(smtpPassword(secretAccessKey, region))}@${smtpHost(region)}:587`;
2466
+ }
2467
+ /** The user an `smtp://` URL signs in as, whatever its host. */
2468
+ function smtpUser(value) {
2469
+ try {
2470
+ const url = new URL(value);
2471
+ return url.username ? decodeURIComponent(url.username) : void 0;
2472
+ } catch {
2473
+ return;
2474
+ }
2475
+ }
2476
+ /**
2477
+ * A mail construct's URL as a key's secret. A URL on another region's
2478
+ * endpoint holds no key this region can use — its password was derived for
2479
+ * that region — so it counts as holding none, and a new key is issued.
2480
+ */
2481
+ function smtpKeySecret(urlKey, region) {
2482
+ return {
2483
+ key: urlKey,
2484
+ keyIdOf(value) {
2485
+ try {
2486
+ return new URL(value).hostname === smtpHost(region) ? smtpUser(value) : void 0;
2487
+ } catch {
2488
+ return;
2489
+ }
2490
+ },
2491
+ value: (accessKeyId, secretAccessKey) => smtpUrl(accessKeyId, secretAccessKey, region)
2492
+ };
2493
+ }
2494
+ //#endregion
2495
+ //#region src/providers/ses/email.ts
2496
+ /**
2497
+ * The `ses` provider for mail: what sends an `Email` construct's mail on a
2498
+ * deployed stage.
2499
+ *
2500
+ * `deploy.email.<stage> = { provider: 'ses', region?, from? }` has the deploy
2501
+ * create, in the stage's AWS account:
2502
+ *
2503
+ * - **the sender's domain as an SES identity**, verified through Easy DKIM's
2504
+ * CNAMEs written through the stage's DNS — the same identity an inbox on
2505
+ * that domain uses: SES has one per domain, and neither provider deletes it;
2506
+ * - for each mail construct, **an IAM user** allowed `ses:SendRawEmail` from
2507
+ * that identity and nothing else, and **its access key**, written into the
2508
+ * stage's secrets as `<ID>_URL` — `smtp://<key id>:<smtp password>@
2509
+ * email-smtp.<region>.amazonaws.com:587`, the password derived from the key;
2510
+ * - **`<ID>_FROM`**: `from`, else what the secrets hold, else `noreply@` the
2511
+ * stage's domain.
2512
+ *
2513
+ * A `<ID>_URL` the stage's secrets already hold, and this provider did not
2514
+ * write, wins: the construct sends with it and nothing is created for it — an
2515
+ * identity that already has sending credentials is not given a second set.
2516
+ * Moving an existing stack onto compose stays a `secrets:import`.
2517
+ *
2518
+ * `--rotate-keys` issues each user a successor key, and with it a new
2519
+ * password, as every other provider's keys are rotated.
2520
+ */
2521
+ /** The inline policy each sending user is given. */
2522
+ const SEND_POLICY_NAME = "gkm-email";
2523
+ /**
2524
+ * The most a sandboxed account sends in a day. An account with no more is
2525
+ * taken to be in the sandbox, where SES delivers only to verified addresses.
2526
+ */
2527
+ const SANDBOX_DAILY_QUOTA = 200;
2528
+ /** Every mail construct in the manifest. */
2529
+ function emailConstructs(manifest) {
2530
+ return Object.values(manifest).filter((d) => d.kind === "email").sort((a, b) => a.id.localeCompare(b.id));
2531
+ }
2532
+ /** What a sending user may do: send as `identityArn`, and nothing else. */
2533
+ function sendPolicy(identityArn) {
2534
+ return {
2535
+ Version: "2012-10-17",
2536
+ Statement: [{
2537
+ Sid: "GkmSendEmail",
2538
+ Effect: "Allow",
2539
+ Action: "ses:SendRawEmail",
2540
+ Resource: identityArn
2541
+ }]
2542
+ };
2543
+ }
2544
+ /** The ARN of a domain's SES identity. */
2545
+ function identityArn(region, account, domain) {
2546
+ return `arn:aws:ses:${region}:${account}:identity/${domain}`;
2547
+ }
2548
+ /**
2549
+ * Whether the stage's secrets hold a URL for `email` that this provider did
2550
+ * not write — one set by hand, or imported — which it then leaves alone.
2551
+ */
2552
+ function urlSetElsewhere(ctx, email) {
2553
+ const given = ctx.secrets[(0, _geekmidas_manifest.provideKey)(email, "url")];
2554
+ if (given === void 0) return false;
2555
+ const record = ctx.state.record(`iam-access-key:${email}`);
2556
+ if (!record) return true;
2557
+ const user = smtpUser(given);
2558
+ return user !== record.id && user !== record.data?.previous;
2559
+ }
2560
+ /**
2561
+ * The address `email` sends from: `from`, else what the stage's secrets
2562
+ * hold, else `noreply@` the stage's domain.
2563
+ *
2564
+ * @throws {EmailSenderUnknown} with none of them
2565
+ */
2566
+ function senderOf(ctx, email) {
2567
+ if (ctx.config.from) return ctx.config.from;
2568
+ const held = ctx.secrets[(0, _geekmidas_manifest.provideKey)(email, "from")];
2569
+ if (held) return held;
2570
+ const domain = ctx.workspace.domains?.[ctx.stage];
2571
+ if (!domain) throw new require_workspace.EmailSenderUnknown(ctx.stage);
2572
+ return `noreply@${domain}`;
2573
+ }
2574
+ /** The domain of an address — `noreply@x.com` or `Acme <noreply@x.com>`. */
2575
+ function domainOf(address) {
2576
+ return address.slice(address.lastIndexOf("@") + 1).replace(/>\s*$/, "").trim().toLowerCase();
2577
+ }
2578
+ async function iamClients(credential, region) {
2579
+ const IAM = await import("@aws-sdk/client-iam");
2580
+ const { STSClient } = await import("@aws-sdk/client-sts");
2581
+ const config = await require_snsSubscriptions.awsClientConfig(credential, region);
2582
+ const stsEndpoint = require_snsSubscriptions.awsEndpoint(process.env, "STS");
2583
+ return {
2584
+ IAM,
2585
+ iam: new IAM.IAMClient(config),
2586
+ sts: new STSClient({
2587
+ ...config,
2588
+ ...stsEndpoint ? { endpoint: stsEndpoint } : {}
2589
+ }),
2590
+ region
2591
+ };
2592
+ }
2593
+ async function ensureSesEmail(ctx) {
2594
+ const owned = emailConstructs(ctx.manifest).filter((email) => {
2595
+ if (!urlSetElsewhere(ctx, email.id)) return true;
2596
+ ctx.log(` ${email.id}: ${(0, _geekmidas_manifest.provideKey)(email.id, "url")} is set in the stage's secrets — it sends with that, and nothing is created for it`);
2597
+ return false;
2598
+ });
2599
+ if (owned.length === 0) return;
2600
+ const region = s3Region(ctx);
2601
+ const senders = new Map(owned.map((e) => [e.id, senderOf(ctx, e.id)]));
2602
+ const domains = [...new Set([...senders.values()].map(domainOf))].sort();
2603
+ const ses = await sesClients(ctx.credential, region);
2604
+ const clients = await iamClients(ctx.credential, region);
2605
+ try {
2606
+ const account = await require_projectBucket.callerAccountId(clients.sts);
2607
+ for (const domain of domains) await ensureIdentity(ctx, ses, domain);
2608
+ await noteSandbox(ctx, ses, region);
2609
+ for (const email of owned) {
2610
+ const from = senders.get(email.id);
2611
+ const domain = domainOf(from);
2612
+ const user = await require_iam.ensureIamUser(ctx, clients, {
2613
+ id: email.id,
2614
+ user: require_workspace.emailUserName(ctx.identity.scope, ctx.stage, email.id),
2615
+ policyName: SEND_POLICY_NAME,
2616
+ policy: sendPolicy(identityArn(region, account, domain)),
2617
+ describe: `send as ${domain} only`
2618
+ });
2619
+ await require_iam.ensureAccessKey(ctx, clients, {
2620
+ id: email.id,
2621
+ secret: smtpKeySecret((0, _geekmidas_manifest.provideKey)(email.id, "url"), region),
2622
+ ...user
2623
+ });
2624
+ const fromKey = (0, _geekmidas_manifest.provideKey)(email.id, "from");
2625
+ if (ctx.secrets[fromKey] !== from) await ctx.change({
2626
+ construct: email.id,
2627
+ resource: fromKey,
2628
+ change: `set to ${from}`
2629
+ }, () => ctx.writeSecrets({ [fromKey]: from }));
2630
+ }
2631
+ } finally {
2632
+ ses.ses.destroy();
2633
+ clients.iam.destroy();
2634
+ clients.sts.destroy();
2635
+ }
2636
+ }
2637
+ /**
2638
+ * The domain as an SES identity, verified by Easy DKIM: its three CNAMEs,
2639
+ * through the stage's DNS. A verified one is left as it is; one that is not
2640
+ * — new, or created by another stack and never finished — is asked for its
2641
+ * tokens again, which SES answers without making a second identity.
2642
+ */
2643
+ async function ensureIdentity(ctx, { SES, ses }, domain) {
2644
+ if ((await ses.send(new SES.GetIdentityVerificationAttributesCommand({ Identities: [domain] }))).VerificationAttributes?.[domain]?.VerificationStatus === "Success") return;
2645
+ let tokens = [];
2646
+ await ctx.change({
2647
+ construct: "email",
2648
+ resource: `SES identity ${domain}`,
2649
+ change: "verify with DKIM"
2650
+ }, async () => {
2651
+ tokens = (await ses.send(new SES.VerifyDomainDkimCommand({ Domain: domain }))).DkimTokens ?? [];
2652
+ });
2653
+ if (tokens.length === 0) return;
2654
+ await ctx.writeDns(tokens.map((token) => ({
2655
+ host: `${token}._domainkey.${domain}`,
2656
+ type: "CNAME",
2657
+ value: `${token}.dkim.amazonses.com`
2658
+ })));
2659
+ ctx.log(` ${domain}: SES sends as it once its DKIM records resolve — usually minutes, at most 72 hours`);
2660
+ }
2661
+ /** Say so when the account is in SES's sandbox, rather than fail on a send. */
2662
+ async function noteSandbox(ctx, { SES, ses }, region) {
2663
+ const quota = await ses.send(new SES.GetSendQuotaCommand({}));
2664
+ if ((quota.Max24HourSend ?? 0) > SANDBOX_DAILY_QUOTA) return;
2665
+ ctx.log(` ⚠️ SES in ${region} looks to be in the sandbox (${quota.Max24HourSend ?? 0} messages a day): it delivers only to addresses verified in SES. Request production access in the SES console before sending to anyone else.`);
2666
+ }
2667
+ /** The cheap check every deploy runs: each mail construct's keys are in the stage's secrets. */
2668
+ async function verifySesEmail(ctx) {
2669
+ for (const email of emailConstructs(ctx.manifest)) {
2670
+ const missing = [(0, _geekmidas_manifest.provideKey)(email.id, "url"), (0, _geekmidas_manifest.provideKey)(email.id, "from")].filter((key) => ctx.secrets[key] === void 0);
2671
+ if (missing.length > 0) throw new require_workspace.EmailNotProvisioned(ctx.stage, email.id, missing);
2672
+ }
2673
+ }
2674
+ const sesEmailProvider = {
2675
+ kind: "email",
2676
+ name: "ses",
2677
+ check: require_workspace.checkSesEmailConfig,
2678
+ provisioning: require_workspace.SES_PROVISIONING,
2679
+ credentials: require_snsSubscriptions.awsProvisioningCredentials,
2680
+ runtimeKeys(manifest) {
2681
+ return emailConstructs(manifest).flatMap((email) => [(0, _geekmidas_manifest.provideKey)(email.id, "url"), (0, _geekmidas_manifest.provideKey)(email.id, "from")]);
2682
+ },
2683
+ ensure: ensureSesEmail,
2684
+ verify: verifySesEmail
2685
+ };
2686
+ //#endregion
2925
2687
  //#region src/providers/registry.ts
2926
2688
  /**
2927
2689
  * The providers gkm ships, by kind and name — registered the way a deploy
@@ -2930,7 +2692,8 @@ const sesProvider = {
2930
2692
  */
2931
2693
  const BUILTIN_PROVIDERS = {
2932
2694
  objects: { s3: s3Provider },
2933
- inbox: { ses: sesProvider }
2695
+ inbox: { ses: sesProvider },
2696
+ email: { ses: sesEmailProvider }
2934
2697
  };
2935
2698
  /** The provider `kind` names `name`, if gkm has one. */
2936
2699
  function builtinProvider(kind, name) {
@@ -3867,12 +3630,6 @@ async function load(input, sandbox) {
3867
3630
  return workspace;
3868
3631
  }
3869
3632
  //#endregion
3870
- Object.defineProperty(exports, "IAM_USER_PATH", {
3871
- enumerable: true,
3872
- get: function() {
3873
- return IAM_USER_PATH;
3874
- }
3875
- });
3876
3633
  Object.defineProperty(exports, "NoDeployableApps", {
3877
3634
  enumerable: true,
3878
3635
  get: function() {
@@ -3903,23 +3660,29 @@ Object.defineProperty(exports, "backupsUserName", {
3903
3660
  return backupsUserName;
3904
3661
  }
3905
3662
  });
3906
- Object.defineProperty(exports, "bucketName", {
3663
+ Object.defineProperty(exports, "cdnName", {
3907
3664
  enumerable: true,
3908
3665
  get: function() {
3909
- return bucketName;
3666
+ return cdnName;
3910
3667
  }
3911
3668
  });
3912
- Object.defineProperty(exports, "deploy", {
3669
+ Object.defineProperty(exports, "defaultCdnClients", {
3913
3670
  enumerable: true,
3914
3671
  get: function() {
3915
- return deploy;
3672
+ return defaultCdnClients;
3916
3673
  }
3917
3674
  });
3918
- Object.defineProperty(exports, "iamUserName", {
3675
+ Object.defineProperty(exports, "defaultClients", {
3919
3676
  enumerable: true,
3920
3677
  get: function() {
3921
- return iamUserName;
3678
+ return defaultClients;
3679
+ }
3680
+ });
3681
+ Object.defineProperty(exports, "deploy", {
3682
+ enumerable: true,
3683
+ get: function() {
3684
+ return deploy;
3922
3685
  }
3923
3686
  });
3924
3687
 
3925
- //# sourceMappingURL=deploy-3bsiWJxj.cjs.map
3688
+ //# sourceMappingURL=deploy-Ck0zXkM7.cjs.map