@geekmidas/cli 10.0.0-alpha.14 → 10.0.0-alpha.140
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.
- package/README.md +313 -380
- package/bin/adjacent-tsconfig.mjs +46 -8
- package/bin/gkm.mjs +11 -3
- package/bin/owning-tsconfig-jsx-register.mjs +18 -0
- package/bin/owning-tsconfig-jsx.mjs +108 -0
- package/dist/EndpointGenerator-BMRL04ic.mjs +1037 -0
- package/dist/EndpointGenerator-BMRL04ic.mjs.map +1 -0
- package/dist/EndpointGenerator-ePscnbwB.cjs +1096 -0
- package/dist/EndpointGenerator-ePscnbwB.cjs.map +1 -0
- package/dist/GoDaddyProvider-BgY6mqoH.mjs +413 -0
- package/dist/GoDaddyProvider-BgY6mqoH.mjs.map +1 -0
- package/dist/GoDaddyProvider-C-rs22Zv.cjs +413 -0
- package/dist/GoDaddyProvider-C-rs22Zv.cjs.map +1 -0
- package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-CgMuKgO_.mjs} +23 -9
- package/dist/HostingerProvider-CgMuKgO_.mjs.map +1 -0
- package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-DEqpvoiD.cjs} +23 -9
- package/dist/HostingerProvider-DEqpvoiD.cjs.map +1 -0
- package/dist/LegacyStateStore-6xskEtld.cjs +124 -0
- package/dist/LegacyStateStore-6xskEtld.cjs.map +1 -0
- package/dist/LegacyStateStore-Dx65SWE9.mjs +124 -0
- package/dist/LegacyStateStore-Dx65SWE9.mjs.map +1 -0
- package/dist/LocalStateStore-DFtTtHty.cjs +178 -0
- package/dist/LocalStateStore-DFtTtHty.cjs.map +1 -0
- package/dist/LocalStateStore-Dto39TCx.mjs +167 -0
- package/dist/LocalStateStore-Dto39TCx.mjs.map +1 -0
- package/dist/OpenApiTsGenerator-B-PQLx8X.mjs +534 -0
- package/dist/OpenApiTsGenerator-B-PQLx8X.mjs.map +1 -0
- package/dist/OpenApiTsGenerator-BvacdbiG.cjs +539 -0
- package/dist/OpenApiTsGenerator-BvacdbiG.cjs.map +1 -0
- package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-Di_SD9CF.mjs} +3 -3
- package/dist/Route53Provider-Di_SD9CF.mjs.map +1 -0
- package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-emLuQHVw.cjs} +3 -3
- package/dist/Route53Provider-emLuQHVw.cjs.map +1 -0
- package/dist/S3StateStore-B-9ea-sX.cjs +222 -0
- package/dist/S3StateStore-B-9ea-sX.cjs.map +1 -0
- package/dist/S3StateStore-C01zMOYm.mjs +223 -0
- package/dist/S3StateStore-C01zMOYm.mjs.map +1 -0
- package/dist/SSMStateStore-CKArcPUh.cjs +204 -0
- package/dist/SSMStateStore-CKArcPUh.cjs.map +1 -0
- package/dist/SSMStateStore-k-4XM7mb.mjs +205 -0
- package/dist/SSMStateStore-k-4XM7mb.mjs.map +1 -0
- package/dist/SubscriberGenerator-DLPH-ynS.mjs +783 -0
- package/dist/SubscriberGenerator-DLPH-ynS.mjs.map +1 -0
- package/dist/SubscriberGenerator-DR4Y7ihK.cjs +848 -0
- package/dist/SubscriberGenerator-DR4Y7ihK.cjs.map +1 -0
- package/dist/add-BgzsYxUq.cjs +713 -0
- package/dist/add-BgzsYxUq.cjs.map +1 -0
- package/dist/add-CiIrpOb9.mjs +711 -0
- package/dist/add-CiIrpOb9.mjs.map +1 -0
- package/dist/appPorts-BoXMwolc.mjs +249 -0
- package/dist/appPorts-BoXMwolc.mjs.map +1 -0
- package/dist/appPorts-IW-OZmRi.cjs +296 -0
- package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
- package/dist/aws-8QQ8n-t6.mjs +89 -0
- package/dist/aws-8QQ8n-t6.mjs.map +1 -0
- package/dist/aws-DY9NqQIT.cjs +100 -0
- package/dist/aws-DY9NqQIT.cjs.map +1 -0
- package/dist/awsStore-Bx5nCFnS.mjs +121 -0
- package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
- package/dist/awsStore-u3ehhMoY.cjs +138 -0
- package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
- package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
- package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
- package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
- package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
- package/dist/backups/runner.cjs +519 -0
- package/dist/backups/runner.cjs.map +1 -0
- package/dist/backups/runner.d.cts +102 -0
- package/dist/backups/runner.d.cts.map +1 -0
- package/dist/backups/runner.d.mts +102 -0
- package/dist/backups/runner.d.mts.map +1 -0
- package/dist/backups/runner.mjs +506 -0
- package/dist/backups/runner.mjs.map +1 -0
- package/dist/{bundler-BodTL4kf.mjs → bundler-C4uMSy8e.mjs} +32 -11
- package/dist/bundler-C4uMSy8e.mjs.map +1 -0
- package/dist/{bundler-BeNDZdHQ.cjs → bundler-DKxuDoVL.cjs} +32 -11
- package/dist/bundler-DKxuDoVL.cjs.map +1 -0
- package/dist/cli-Bm2is6R_.mjs +71 -0
- package/dist/cli-Bm2is6R_.mjs.map +1 -0
- package/dist/cli-na0npMhC.cjs +71 -0
- package/dist/cli-na0npMhC.cjs.map +1 -0
- package/dist/compose-CVatM7Cl.mjs +4275 -0
- package/dist/compose-CVatM7Cl.mjs.map +1 -0
- package/dist/compose-D8U9ygdm.cjs +4418 -0
- package/dist/compose-D8U9ygdm.cjs.map +1 -0
- package/dist/config-BbivVpq0.d.mts +268 -0
- package/dist/config-BbivVpq0.d.mts.map +1 -0
- package/dist/config-BcL1Fojs.d.cts +268 -0
- package/dist/config-BcL1Fojs.d.cts.map +1 -0
- package/dist/config.cjs +420 -9
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +4 -117
- package/dist/config.d.mts +4 -117
- package/dist/config.mjs +406 -3
- package/dist/config.mjs.map +1 -0
- package/dist/credentialSchemas-DUCSYl9a.mjs +237 -0
- package/dist/credentialSchemas-DUCSYl9a.mjs.map +1 -0
- package/dist/credentialSchemas-DZ2Nh5li.cjs +272 -0
- package/dist/credentialSchemas-DZ2Nh5li.cjs.map +1 -0
- package/dist/credentials-D7XJypNd.cjs +520 -0
- package/dist/credentials-D7XJypNd.cjs.map +1 -0
- package/dist/credentials-DpfnUvIR.mjs +395 -0
- package/dist/credentials-DpfnUvIR.mjs.map +1 -0
- package/dist/databases-Db48ZIXL.mjs +588 -0
- package/dist/databases-Db48ZIXL.mjs.map +1 -0
- package/dist/databases-P824RTnx.cjs +703 -0
- package/dist/databases-P824RTnx.cjs.map +1 -0
- package/dist/define-6poNqm5O.mjs +106 -0
- package/dist/define-6poNqm5O.mjs.map +1 -0
- package/dist/define-crmMcXFS.cjs +153 -0
- package/dist/define-crmMcXFS.cjs.map +1 -0
- package/dist/deploy/public.cjs +211 -0
- package/dist/deploy/public.cjs.map +1 -0
- package/dist/deploy/public.d.cts +647 -0
- package/dist/deploy/public.d.cts.map +1 -0
- package/dist/deploy/public.d.mts +647 -0
- package/dist/deploy/public.d.mts.map +1 -0
- package/dist/deploy/public.mjs +144 -0
- package/dist/deploy/public.mjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
- package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
- package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
- package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
- package/dist/deploy/sniffer-hooks.cjs +1 -1
- package/dist/deploy/sniffer-hooks.mjs +1 -1
- package/dist/deploy/sniffer-loader.cjs +2 -2
- package/dist/deploy/sniffer-loader.mjs +1 -1
- package/dist/deploy/sniffer-routes-worker.cjs +2 -2
- package/dist/deploy/sniffer-routes-worker.mjs +1 -1
- package/dist/deploy-CDcO08Xz.mjs +3835 -0
- package/dist/deploy-CDcO08Xz.mjs.map +1 -0
- package/dist/deploy-DrQB7ytj.cjs +3891 -0
- package/dist/deploy-DrQB7ytj.cjs.map +1 -0
- package/dist/derive-Cd7Hl3r2.mjs +259 -0
- package/dist/derive-Cd7Hl3r2.mjs.map +1 -0
- package/dist/derive-CgZfoBU2.cjs +282 -0
- package/dist/derive-CgZfoBU2.cjs.map +1 -0
- package/dist/discover-B2m8ytyq.mjs +831 -0
- package/dist/discover-B2m8ytyq.mjs.map +1 -0
- package/dist/discover-yqeJ2Bx7.cjs +934 -0
- package/dist/discover-yqeJ2Bx7.cjs.map +1 -0
- package/dist/dokploy-BKjPDvSN.cjs +38 -0
- package/dist/dokploy-BKjPDvSN.cjs.map +1 -0
- package/dist/dokploy-k4_ZN8zN.mjs +38 -0
- package/dist/dokploy-k4_ZN8zN.mjs.map +1 -0
- package/dist/drivers-C47nm-wB.cjs +311 -0
- package/dist/drivers-C47nm-wB.cjs.map +1 -0
- package/dist/drivers-CDjpjakg.mjs +252 -0
- package/dist/drivers-CDjpjakg.mjs.map +1 -0
- package/dist/eas-B1wBvwPH.mjs +334 -0
- package/dist/eas-B1wBvwPH.mjs.map +1 -0
- package/dist/eas-Bg4dI6n2.cjs +337 -0
- package/dist/eas-Bg4dI6n2.cjs.map +1 -0
- package/dist/emit-Bj6XSivk.mjs +136 -0
- package/dist/emit-Bj6XSivk.mjs.map +1 -0
- package/dist/emit-CDC__ubE.cjs +147 -0
- package/dist/emit-CDC__ubE.cjs.map +1 -0
- package/dist/encryption-Bve0PVOo.mjs +89 -0
- package/dist/encryption-Bve0PVOo.mjs.map +1 -0
- package/dist/encryption-DL_y8t6V.cjs +90 -0
- package/dist/encryption-DL_y8t6V.cjs.map +1 -0
- package/dist/engine-BhR5lt_V.cjs +3323 -0
- package/dist/engine-BhR5lt_V.cjs.map +1 -0
- package/dist/engine-HMLf20iZ.mjs +3210 -0
- package/dist/engine-HMLf20iZ.mjs.map +1 -0
- package/dist/errors-D8Gwp5kU.mjs +23 -0
- package/dist/errors-D8Gwp5kU.mjs.map +1 -0
- package/dist/errors-DMC4Umsb.cjs +34 -0
- package/dist/errors-DMC4Umsb.cjs.map +1 -0
- package/dist/github-B2hJVl-n.cjs +901 -0
- package/dist/github-B2hJVl-n.cjs.map +1 -0
- package/dist/github-DKn9ACi2.mjs +900 -0
- package/dist/github-DKn9ACi2.mjs.map +1 -0
- package/dist/googlePlay-CWq7ND_X.mjs +931 -0
- package/dist/googlePlay-CWq7ND_X.mjs.map +1 -0
- package/dist/googlePlay-DtuN0-7D.cjs +931 -0
- package/dist/googlePlay-DtuN0-7D.cjs.map +1 -0
- package/dist/identity-CBXr4wNi.mjs +129 -0
- package/dist/identity-CBXr4wNi.mjs.map +1 -0
- package/dist/identity-CbLfgQNT.cjs +182 -0
- package/dist/identity-CbLfgQNT.cjs.map +1 -0
- package/dist/{index-D-iAVHx-.d.cts → index-BZZeEWug.d.mts} +39 -15
- package/dist/index-BZZeEWug.d.mts.map +1 -0
- package/dist/{index-Cd-qeOam.d.mts → index-C1jffZ5_.d.cts} +39 -15
- package/dist/index-C1jffZ5_.d.cts.map +1 -0
- package/dist/index.cjs +13502 -12269
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +13522 -12287
- package/dist/index.mjs.map +1 -1
- package/dist/local-B7Zv1NoA.mjs +224 -0
- package/dist/local-B7Zv1NoA.mjs.map +1 -0
- package/dist/local-OPC9BCZt.cjs +241 -0
- package/dist/local-OPC9BCZt.cjs.map +1 -0
- package/dist/migrate-BLVZqHtN.cjs +181 -0
- package/dist/migrate-BLVZqHtN.cjs.map +1 -0
- package/dist/migrate-DCvD4RJW.mjs +265 -0
- package/dist/migrate-DCvD4RJW.mjs.map +1 -0
- package/dist/migrate-W0ruUNb9.mjs +181 -0
- package/dist/migrate-W0ruUNb9.mjs.map +1 -0
- package/dist/migrate-iUui7B4q.cjs +270 -0
- package/dist/migrate-iUui7B4q.cjs.map +1 -0
- package/dist/openapi.cjs +214 -7
- package/dist/openapi.cjs.map +1 -0
- package/dist/openapi.d.cts +32 -8
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.mts +32 -8
- package/dist/openapi.d.mts.map +1 -1
- package/dist/openapi.mjs +209 -2
- package/dist/openapi.mjs.map +1 -0
- package/dist/projectBucket-BBbQ1lHF.cjs +263 -0
- package/dist/projectBucket-BBbQ1lHF.cjs.map +1 -0
- package/dist/projectBucket-C_DN4WzF.mjs +222 -0
- package/dist/projectBucket-C_DN4WzF.mjs.map +1 -0
- package/dist/provider-BqpjG9QM.cjs +57 -0
- package/dist/provider-BqpjG9QM.cjs.map +1 -0
- package/dist/provider-CEOKk8NS.mjs +46 -0
- package/dist/provider-CEOKk8NS.mjs.map +1 -0
- package/dist/publish-CqvDA5ry.cjs +124 -0
- package/dist/publish-CqvDA5ry.cjs.map +1 -0
- package/dist/publish-CxIBBD3b.mjs +123 -0
- package/dist/publish-CxIBBD3b.mjs.map +1 -0
- package/dist/ready-CGqJ74Kt.mjs +375 -0
- package/dist/ready-CGqJ74Kt.mjs.map +1 -0
- package/dist/ready-DuU0FXSj.cjs +404 -0
- package/dist/ready-DuU0FXSj.cjs.map +1 -0
- package/dist/reconcile/public.cjs +3 -5
- package/dist/reconcile/public.d.cts +31 -89
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +31 -89
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +3 -3
- package/dist/{reconcile-DhQ00DpU.mjs → reconcile--I7V4Klj.mjs} +2 -2
- package/dist/{reconcile-DhQ00DpU.mjs.map → reconcile--I7V4Klj.mjs.map} +1 -1
- package/dist/{reconcile-Dd2iyILf.cjs → reconcile-CuCQBa5-.cjs} +3 -3
- package/dist/{reconcile-Dd2iyILf.cjs.map → reconcile-CuCQBa5-.cjs.map} +1 -1
- package/dist/resolve-BEVVvi13.cjs +316 -0
- package/dist/resolve-BEVVvi13.cjs.map +1 -0
- package/dist/resolve-CMC0MI0Z.mjs +263 -0
- package/dist/resolve-CMC0MI0Z.mjs.map +1 -0
- package/dist/rollback-CZiQkukY.mjs +136 -0
- package/dist/rollback-CZiQkukY.mjs.map +1 -0
- package/dist/rollback-e0zGkaBx.cjs +165 -0
- package/dist/rollback-e0zGkaBx.cjs.map +1 -0
- package/dist/runtime-Bvgyxm88.d.cts +82 -0
- package/dist/runtime-Bvgyxm88.d.cts.map +1 -0
- package/dist/runtime-CeAt1IJd.d.mts +82 -0
- package/dist/runtime-CeAt1IJd.d.mts.map +1 -0
- package/dist/s3-BKnL6YGQ.cjs +215 -0
- package/dist/s3-BKnL6YGQ.cjs.map +1 -0
- package/dist/s3-DW7SLsb8.mjs +215 -0
- package/dist/s3-DW7SLsb8.mjs.map +1 -0
- package/dist/sandbox/config-worker.cjs +43 -0
- package/dist/sandbox/config-worker.cjs.map +1 -0
- package/dist/sandbox/config-worker.d.cts +1 -0
- package/dist/sandbox/config-worker.d.mts +1 -0
- package/dist/sandbox/config-worker.mjs +44 -0
- package/dist/sandbox/config-worker.mjs.map +1 -0
- package/dist/sandbox/credentials-worker.cjs +54 -0
- package/dist/sandbox/credentials-worker.cjs.map +1 -0
- package/dist/sandbox/credentials-worker.d.cts +1 -0
- package/dist/sandbox/credentials-worker.d.mts +1 -0
- package/dist/sandbox/credentials-worker.mjs +55 -0
- package/dist/sandbox/credentials-worker.mjs.map +1 -0
- package/dist/sandbox/discover-worker.cjs +47 -0
- package/dist/sandbox/discover-worker.cjs.map +1 -0
- package/dist/sandbox/discover-worker.d.cts +1 -0
- package/dist/sandbox/discover-worker.d.mts +1 -0
- package/dist/sandbox/discover-worker.mjs +48 -0
- package/dist/sandbox/discover-worker.mjs.map +1 -0
- package/dist/sandbox/migrate-worker.cjs +76 -0
- package/dist/sandbox/migrate-worker.cjs.map +1 -0
- package/dist/sandbox/migrate-worker.d.cts +1 -0
- package/dist/sandbox/migrate-worker.d.mts +1 -0
- package/dist/sandbox/migrate-worker.mjs +77 -0
- package/dist/sandbox/migrate-worker.mjs.map +1 -0
- package/dist/sandbox-CHv3OYXg.cjs +165 -0
- package/dist/sandbox-CHv3OYXg.cjs.map +1 -0
- package/dist/sandbox-CbVB7uOD.mjs +118 -0
- package/dist/sandbox-CbVB7uOD.mjs.map +1 -0
- package/dist/{workspace-mFpI_ky_.cjs → schemas-BCwKKA42.mjs} +399 -1162
- package/dist/schemas-BCwKKA42.mjs.map +1 -0
- package/dist/{workspace-CgwmXEtc.mjs → schemas-BQ_v0lEX.cjs} +487 -971
- package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
- package/dist/secretsManager-CQORubp9.mjs +97 -0
- package/dist/secretsManager-CQORubp9.mjs.map +1 -0
- package/dist/secretsManager-RAGcEDX1.cjs +108 -0
- package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
- package/dist/seeds-BR_7hJTw.cjs +10541 -0
- package/dist/seeds-BR_7hJTw.cjs.map +1 -0
- package/dist/seeds-nCxxlP5h.mjs +9418 -0
- package/dist/seeds-nCxxlP5h.mjs.map +1 -0
- package/dist/serverSetup-C3Tt9X1R.mjs +651 -0
- package/dist/serverSetup-C3Tt9X1R.mjs.map +1 -0
- package/dist/serverSetup-D2Xzsp2t.cjs +651 -0
- package/dist/serverSetup-D2Xzsp2t.cjs.map +1 -0
- package/dist/sniffer-BWgXPFAt.cjs +1998 -0
- package/dist/sniffer-BWgXPFAt.cjs.map +1 -0
- package/dist/sniffer-eEF_fIId.mjs +1825 -0
- package/dist/sniffer-eEF_fIId.mjs.map +1 -0
- package/dist/snsSubscriptions-BSoqUgsq.mjs +1497 -0
- package/dist/snsSubscriptions-BSoqUgsq.mjs.map +1 -0
- package/dist/snsSubscriptions-Y9declDd.cjs +1720 -0
- package/dist/snsSubscriptions-Y9declDd.cjs.map +1 -0
- package/dist/sst-Bz2HJlqc.mjs +440 -0
- package/dist/sst-Bz2HJlqc.mjs.map +1 -0
- package/dist/sst-lvCHdYsY.cjs +463 -0
- package/dist/sst-lvCHdYsY.cjs.map +1 -0
- package/dist/stage-BEcxppsu.cjs +310 -0
- package/dist/stage-BEcxppsu.cjs.map +1 -0
- package/dist/stage-DhcbcAar.mjs +299 -0
- package/dist/stage-DhcbcAar.mjs.map +1 -0
- package/dist/stages--icWbhPy.cjs +190 -0
- package/dist/stages--icWbhPy.cjs.map +1 -0
- package/dist/stages-CUwSy39f.mjs +190 -0
- package/dist/stages-CUwSy39f.mjs.map +1 -0
- package/dist/target/public.cjs +15 -0
- package/dist/target/public.d.cts +28 -0
- package/dist/target/public.d.cts.map +1 -0
- package/dist/target/public.d.mts +28 -0
- package/dist/target/public.d.mts.map +1 -0
- package/dist/target/public.mjs +4 -0
- package/dist/terminal-DURcYlVX.cjs +85 -0
- package/dist/terminal-DURcYlVX.cjs.map +1 -0
- package/dist/terminal-yOZ7kKF9.mjs +85 -0
- package/dist/terminal-yOZ7kKF9.mjs.map +1 -0
- package/dist/{types-C5ZNpUad.d.cts → types-C6hDCkV2.d.mts} +2229 -456
- package/dist/types-C6hDCkV2.d.mts.map +1 -0
- package/dist/{types-BGo5TaNE.d.mts → types-Dy1eV7yc.d.cts} +2231 -456
- package/dist/types-Dy1eV7yc.d.cts.map +1 -0
- package/dist/utils-D2Nk1Nv2.cjs +205 -0
- package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
- package/dist/utils-D_fxUqvU.mjs +156 -0
- package/dist/utils-D_fxUqvU.mjs.map +1 -0
- package/dist/vitest.cjs +65 -0
- package/dist/vitest.cjs.map +1 -0
- package/dist/vitest.d.cts +29 -0
- package/dist/vitest.d.cts.map +1 -0
- package/dist/vitest.d.mts +29 -0
- package/dist/vitest.d.mts.map +1 -0
- package/dist/vitest.mjs +65 -0
- package/dist/vitest.mjs.map +1 -0
- package/dist/workerRuntime-BXfhbe13.cjs +108 -0
- package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
- package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
- package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
- package/dist/workspace/index.cjs +6 -2
- package/dist/workspace/index.d.cts +3 -3
- package/dist/workspace/index.d.mts +3 -3
- package/dist/workspace/index.mjs +2 -2
- package/dist/workspace-BbfBFtjn.mjs +2488 -0
- package/dist/workspace-BbfBFtjn.mjs.map +1 -0
- package/dist/workspace-Dkm3HL9e.cjs +2924 -0
- package/dist/workspace-Dkm3HL9e.cjs.map +1 -0
- package/package.json +61 -14
- package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
- package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
- package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
- package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
- package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
- package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
- package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
- package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
- package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
- package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
- package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
- package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
- package/dist/bundler-BeNDZdHQ.cjs.map +0 -1
- package/dist/bundler-BodTL4kf.mjs.map +0 -1
- package/dist/config-Q1rvKHvw.cjs +0 -467
- package/dist/config-Q1rvKHvw.cjs.map +0 -1
- package/dist/config-pqGD3hF9.mjs +0 -414
- package/dist/config-pqGD3hF9.mjs.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/credentials-BekkKtY_.mjs +0 -2780
- package/dist/credentials-BekkKtY_.mjs.map +0 -1
- package/dist/credentials-Q6F0uqJq.cjs +0 -2917
- package/dist/credentials-Q6F0uqJq.cjs.map +0 -1
- package/dist/discover-BERGFg8v.cjs +0 -288
- package/dist/discover-BERGFg8v.cjs.map +0 -1
- package/dist/discover-CK-n3w6b.mjs +0 -244
- package/dist/discover-CK-n3w6b.mjs.map +0 -1
- package/dist/emit-BdoPFjZf.cjs +0 -253
- package/dist/emit-BdoPFjZf.cjs.map +0 -1
- package/dist/emit-Bzq7JsMP.mjs +0 -224
- package/dist/emit-Bzq7JsMP.mjs.map +0 -1
- package/dist/fullstack-secrets-BET8gqwK.mjs +0 -81
- package/dist/fullstack-secrets-BET8gqwK.mjs.map +0 -1
- package/dist/fullstack-secrets-DXsWO-5m.cjs +0 -92
- package/dist/fullstack-secrets-DXsWO-5m.cjs.map +0 -1
- package/dist/generator-LfZU7NlU.mjs +0 -247
- package/dist/generator-LfZU7NlU.mjs.map +0 -1
- package/dist/generator-Wdfp0jCS.cjs +0 -282
- package/dist/generator-Wdfp0jCS.cjs.map +0 -1
- package/dist/github-BfflNPVe.cjs +0 -203
- package/dist/github-BfflNPVe.cjs.map +0 -1
- package/dist/github-CRwnxKmD.mjs +0 -203
- package/dist/github-CRwnxKmD.mjs.map +0 -1
- package/dist/index-Cd-qeOam.d.mts.map +0 -1
- package/dist/index-D-iAVHx-.d.cts.map +0 -1
- package/dist/keystore-B4PRlbgE.mjs +0 -81
- package/dist/keystore-B4PRlbgE.mjs.map +0 -1
- package/dist/keystore-DgGRj2Yy.cjs +0 -98
- package/dist/keystore-DgGRj2Yy.cjs.map +0 -1
- package/dist/openapi-Dcbme-Us.cjs +0 -2038
- package/dist/openapi-Dcbme-Us.cjs.map +0 -1
- package/dist/openapi-vy4JzhUv.mjs +0 -1991
- package/dist/openapi-vy4JzhUv.mjs.map +0 -1
- package/dist/storage-C-30BD1e.cjs +0 -272
- package/dist/storage-C-30BD1e.cjs.map +0 -1
- package/dist/storage-P_b3w7uj.mjs +0 -231
- package/dist/storage-P_b3w7uj.mjs.map +0 -1
- package/dist/sync-B3xxXtJT.mjs +0 -88
- package/dist/sync-B3xxXtJT.mjs.map +0 -1
- package/dist/sync-D7uTIIEi.cjs +0 -111
- package/dist/sync-D7uTIIEi.cjs.map +0 -1
- package/dist/types-BGo5TaNE.d.mts.map +0 -1
- package/dist/types-C5ZNpUad.d.cts.map +0 -1
- package/dist/workspace-CgwmXEtc.mjs.map +0 -1
- package/dist/workspace-mFpI_ky_.cjs.map +0 -1
|
@@ -0,0 +1,1720 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
|
+
const require_errors = require("./errors-DMC4Umsb.cjs");
|
|
3
|
+
const require_credentials = require("./credentials-D7XJypNd.cjs");
|
|
4
|
+
const require_workspace = require("./workspace-Dkm3HL9e.cjs");
|
|
5
|
+
const require_seeds = require("./seeds-BR_7hJTw.cjs");
|
|
6
|
+
const require_derive = require("./derive-CgZfoBU2.cjs");
|
|
7
|
+
let node_path = require("node:path");
|
|
8
|
+
let node_fs = require("node:fs");
|
|
9
|
+
let node_net = require("node:net");
|
|
10
|
+
let node_crypto = require("node:crypto");
|
|
11
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
12
|
+
let node_module = require("node:module");
|
|
13
|
+
let node_url = require("node:url");
|
|
14
|
+
let node_dns_promises = require("node:dns/promises");
|
|
15
|
+
let bcryptjs = require("bcryptjs");
|
|
16
|
+
bcryptjs = require_rolldown_runtime.__toESM(bcryptjs, 1);
|
|
17
|
+
//#region src/providers/dns.ts
|
|
18
|
+
/** Whether the workspace deploys through the compose target. */
|
|
19
|
+
function deploysWithCompose(workspace) {
|
|
20
|
+
return workspace.deploy?.default === "compose" || Object.values(workspace.apps).some((app) => app.resolvedDeployTarget === "compose");
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/backups/config.ts
|
|
24
|
+
/**
|
|
25
|
+
* Which stages take backups, and where they are kept.
|
|
26
|
+
*
|
|
27
|
+
* A deployed compose stage whose stack runs Postgres is backed up by
|
|
28
|
+
* default — every day at 02:00 UTC, kept 30 days — unless
|
|
29
|
+
* `deploy.backups.<stage>` says otherwise. The local stage never is.
|
|
30
|
+
*
|
|
31
|
+
* Every backup is kept in the project bucket (`providers/projectBucket.ts`),
|
|
32
|
+
* beside the stage's deploy state, one folder per run and one file per
|
|
33
|
+
* database:
|
|
34
|
+
*
|
|
35
|
+
* ```
|
|
36
|
+
* gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/database.sql.gz
|
|
37
|
+
* gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/auth-database.sql.gz
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* The file is named after the database's construct, the way its migrations
|
|
41
|
+
* folder is: `AuthDatabase` is `db/auth-database`, and `auth-database.sql.gz`.
|
|
42
|
+
*/
|
|
43
|
+
/** Whether the stack runs Postgres: some construct is a database. */
|
|
44
|
+
function runsPostgres(manifest) {
|
|
45
|
+
return Object.values(manifest).some((d) => d.kind === "database");
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* What `stage`'s backups are: on — by its entry or the default — off by
|
|
49
|
+
* `false`, or none, for the local stage, a stage compose does not deploy,
|
|
50
|
+
* and a stack with no database.
|
|
51
|
+
*/
|
|
52
|
+
function stageBackups(workspace, manifest, stage) {
|
|
53
|
+
if (stage === workspace.stages?.local) return {
|
|
54
|
+
mode: "none",
|
|
55
|
+
reason: "local"
|
|
56
|
+
};
|
|
57
|
+
if (!deploysWithCompose(workspace)) return {
|
|
58
|
+
mode: "none",
|
|
59
|
+
reason: "not-compose"
|
|
60
|
+
};
|
|
61
|
+
if (!runsPostgres(manifest)) return {
|
|
62
|
+
mode: "none",
|
|
63
|
+
reason: "no-postgres"
|
|
64
|
+
};
|
|
65
|
+
const value = (workspace.deploy?.backups)?.[stage];
|
|
66
|
+
const checked = require_workspace.checkStageBackups(stage, value ?? {});
|
|
67
|
+
if (checked === false) return { mode: "disabled" };
|
|
68
|
+
return {
|
|
69
|
+
mode: "on",
|
|
70
|
+
backups: checked,
|
|
71
|
+
source: value === void 0 ? "default" : "config"
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Where a stage's backups are, in the project bucket — under the same
|
|
76
|
+
* `<prefix>/<project>/<stage>` its deploy state is: `gkm/shop/production/backups`.
|
|
77
|
+
*/
|
|
78
|
+
function backupsPrefix(workspace, stage) {
|
|
79
|
+
const state = workspace.state;
|
|
80
|
+
const prefix = state?.provider === "s3" && state.prefix !== void 0 ? state.prefix.replace(/\/+$/, "") : "gkm";
|
|
81
|
+
return `${prefix ? `${prefix}/` : ""}${workspace.name}/${stage}/backups`;
|
|
82
|
+
}
|
|
83
|
+
/** A run folder's time back, or `undefined` for a key that is not one. */
|
|
84
|
+
function runTime(folder) {
|
|
85
|
+
const match = /^(\d{4}-\d{2}-\d{2})\/(\d{2})-(\d{2})-(\d{2})Z$/.exec(folder);
|
|
86
|
+
if (!match) return void 0;
|
|
87
|
+
const at = /* @__PURE__ */ new Date(`${match[1]}T${match[2]}:${match[3]}:${match[4]}Z`);
|
|
88
|
+
return Number.isNaN(at.getTime()) ? void 0 : at;
|
|
89
|
+
}
|
|
90
|
+
/** A database's file in a run's folder: `auth-database.sql.gz`. */
|
|
91
|
+
function backupFile(database) {
|
|
92
|
+
return `${database.file}.sql.gz`;
|
|
93
|
+
}
|
|
94
|
+
/** Each database the stack runs, by its construct and its name in Postgres. */
|
|
95
|
+
function backupDatabases(resources) {
|
|
96
|
+
return resources.filter((r) => r.kind === "database").map((r) => ({
|
|
97
|
+
id: r.id,
|
|
98
|
+
file: (0, _geekmidas_manifest.kebabCase)(r.id),
|
|
99
|
+
name: r.name
|
|
100
|
+
})).sort((a, b) => a.file.localeCompare(b.file));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The expiry of every stage's backups, by each stage's own entry — what the
|
|
104
|
+
* project bucket's lifecycle carries beside its own rule.
|
|
105
|
+
*
|
|
106
|
+
* A put replaces a bucket's whole lifecycle, so this is built from every
|
|
107
|
+
* deployed stage each time, never from the stage being deployed alone: one
|
|
108
|
+
* stage's deploy keeps every other's rule. A stage set to `false` has none,
|
|
109
|
+
* and its backups are kept until someone deletes them.
|
|
110
|
+
*/
|
|
111
|
+
function backupExpiries(workspace, manifest) {
|
|
112
|
+
const expiries = [];
|
|
113
|
+
for (const stage of [...workspace.stages?.deployed ?? []].sort()) {
|
|
114
|
+
const choice = stageBackups(workspace, manifest, stage);
|
|
115
|
+
if (choice.mode !== "on") continue;
|
|
116
|
+
expiries.push({
|
|
117
|
+
id: `gkm-backups-${stage}`,
|
|
118
|
+
prefix: `${backupsPrefix(workspace, stage)}/`,
|
|
119
|
+
days: choice.backups.keepDays,
|
|
120
|
+
abortIncompleteDays: 1
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return expiries;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/backups/service.ts
|
|
127
|
+
/**
|
|
128
|
+
* The stack's `backups` service: what a deployed compose stage with Postgres
|
|
129
|
+
* runs beside its apps, unless `deploy.backups.<stage>` is `false`.
|
|
130
|
+
*
|
|
131
|
+
* - **The image** is built from the stack's own Postgres image —
|
|
132
|
+
* `postgres:<major>-alpine`, already on the server for the stack, and with
|
|
133
|
+
* the `pg_dump` that matches the server — with Node added and gkm's runner
|
|
134
|
+
* (`runner.ts`) copied in. Nothing is pulled that the stack does not have,
|
|
135
|
+
* and nothing is mounted from the host: the build context is two files.
|
|
136
|
+
* - **Its key** is `BACKUPS_URL`, from the stage's secrets, like any app's:
|
|
137
|
+
* allowed to put objects under the stage's backups prefix and nothing else.
|
|
138
|
+
* The server holds no AWS credentials of its own.
|
|
139
|
+
* - **Its login** is a role of its own, `<project>_backups`, granted
|
|
140
|
+
* `pg_read_all_data` — it can read every database and write none. Postgres
|
|
141
|
+
* before 14 has no such role, and there it signs in as the stack's
|
|
142
|
+
* superuser.
|
|
143
|
+
* - **Its health** is the last good run: unhealthy once that is more than
|
|
144
|
+
* twice the schedule's longest gap old, after a startup grace.
|
|
145
|
+
*/
|
|
146
|
+
/** The service's name in the stack. */
|
|
147
|
+
const BACKUPS_SERVICE = "backups";
|
|
148
|
+
/** The secret its key is written to. */
|
|
149
|
+
const BACKUPS_URL_KEY = "BACKUPS_URL";
|
|
150
|
+
/** Where the runner is, in the image. */
|
|
151
|
+
const RUNNER_PATH = "/gkm/backup.mjs";
|
|
152
|
+
/** The first Postgres with `pg_read_all_data`. */
|
|
153
|
+
const READ_ALL_DATA_SINCE = 14;
|
|
154
|
+
/** A stage that backs up, and no key to back up with. */
|
|
155
|
+
var BackupsUrlMissing = class extends require_errors.GkmError {
|
|
156
|
+
stage;
|
|
157
|
+
constructor(stage) {
|
|
158
|
+
super(`'${stage}' runs Postgres, so its stack backs it up, and its secrets hold no ${BACKUPS_URL_KEY} to back up with. The deploy writes it — the IAM user and key it creates in the stage's AWS account — so run the deploy with the account's credentials. To take no backups on this stage, set deploy.backups.${stage}: false.`);
|
|
159
|
+
this.stage = stage;
|
|
160
|
+
this.name = "BackupsUrlMissing";
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
/** The backups role: `<project>_backups`, as the superuser is `<project>_admin`. */
|
|
164
|
+
function backupsRole(project) {
|
|
165
|
+
return `${require_seeds.postgresRoleSlug(project)}_backups`;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The runner's source, as JavaScript: the built `backups/runner.mjs` beside
|
|
169
|
+
* the CLI's bundle, or — run from source — `runner.ts`, with its types
|
|
170
|
+
* stripped by esbuild.
|
|
171
|
+
*/
|
|
172
|
+
function runnerSource() {
|
|
173
|
+
const here = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
174
|
+
for (const path of [
|
|
175
|
+
(0, node_path.join)(here, "backups", "runner.mjs"),
|
|
176
|
+
(0, node_path.join)(here, "runner.mjs"),
|
|
177
|
+
(0, node_path.join)(here, "..", "backups", "runner.mjs")
|
|
178
|
+
]) if ((0, node_fs.existsSync)(path)) return (0, node_fs.readFileSync)(path, "utf-8");
|
|
179
|
+
const { transformSync } = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("esbuild");
|
|
180
|
+
return transformSync((0, node_fs.readFileSync)((0, node_path.join)(here, "runner.ts"), "utf-8"), {
|
|
181
|
+
loader: "ts",
|
|
182
|
+
format: "esm",
|
|
183
|
+
target: "node22"
|
|
184
|
+
}).code;
|
|
185
|
+
}
|
|
186
|
+
/** The image's Dockerfile: the stack's Postgres, Node, and the runner. */
|
|
187
|
+
function backupsDockerfile(from) {
|
|
188
|
+
return `# Generated by gkm — the stage's backups: pg_dump from ${from}, and gkm's uploader.
|
|
189
|
+
FROM ${from}
|
|
190
|
+
RUN apk add --no-cache nodejs
|
|
191
|
+
COPY backup.mjs ${RUNNER_PATH}
|
|
192
|
+
USER postgres
|
|
193
|
+
ENTRYPOINT []
|
|
194
|
+
CMD ["node", "${RUNNER_PATH}", "serve"]
|
|
195
|
+
`;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The stack's backups service, for a stage whose backups are on.
|
|
199
|
+
*
|
|
200
|
+
* @throws {BackupsUrlMissing} when the stage's secrets hold no key
|
|
201
|
+
*/
|
|
202
|
+
function stackBackups(input) {
|
|
203
|
+
const { plan, stage } = input;
|
|
204
|
+
const version = plan.resources.find((r) => r.version)?.version ?? _geekmidas_manifest.DEFAULT_POSTGRES_VERSION;
|
|
205
|
+
const from = require_seeds.postgresImage(version);
|
|
206
|
+
const script = runnerSource();
|
|
207
|
+
const dockerfile = backupsDockerfile(from);
|
|
208
|
+
const hash = (0, node_crypto.createHash)("sha256").update(dockerfile).update(script).digest("hex").slice(0, 12);
|
|
209
|
+
const readOnly = version >= READ_ALL_DATA_SINCE;
|
|
210
|
+
const role = backupsRole(input.workspace.name);
|
|
211
|
+
const login = readOnly ? {
|
|
212
|
+
user: role,
|
|
213
|
+
password: require_seeds.localRolePassword(input.workspace.name, plan, role, input.seed)
|
|
214
|
+
} : input.superuser;
|
|
215
|
+
const databases = backupDatabases(plan.resources);
|
|
216
|
+
const prefix = backupsPrefix(input.workspace, stage);
|
|
217
|
+
const { kind, ...schedule } = input.backups.schedule;
|
|
218
|
+
let env = {};
|
|
219
|
+
if (!input.buildOnly) {
|
|
220
|
+
const url = input.custom[BACKUPS_URL_KEY];
|
|
221
|
+
if (!url) throw new BackupsUrlMissing(stage);
|
|
222
|
+
env = {
|
|
223
|
+
BACKUPS_URL: url,
|
|
224
|
+
BACKUPS_PREFIX: prefix,
|
|
225
|
+
BACKUPS_DATABASES: JSON.stringify(databases.map(({ file, name }) => ({
|
|
226
|
+
file,
|
|
227
|
+
name
|
|
228
|
+
}))),
|
|
229
|
+
BACKUPS_SCHEDULE: JSON.stringify(kind === "cron" ? {
|
|
230
|
+
kind,
|
|
231
|
+
minutes: input.backups.schedule.minutes,
|
|
232
|
+
hours: input.backups.schedule.hours,
|
|
233
|
+
days: input.backups.schedule.days,
|
|
234
|
+
months: input.backups.schedule.months,
|
|
235
|
+
weekdays: input.backups.schedule.weekdays
|
|
236
|
+
} : {
|
|
237
|
+
kind,
|
|
238
|
+
...schedule
|
|
239
|
+
}),
|
|
240
|
+
BACKUPS_MAX_GAP_SECONDS: String(input.backups.maxGapSeconds),
|
|
241
|
+
PGHOST: "postgres",
|
|
242
|
+
PGPORT: "5432",
|
|
243
|
+
PGUSER: login.user,
|
|
244
|
+
PGPASSWORD: login.password,
|
|
245
|
+
...input.telemetry?.OTEL_EXPORTER_OTLP_ENDPOINT ? {
|
|
246
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: input.telemetry.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
247
|
+
...input.telemetry.OTEL_EXPORTER_OTLP_HEADERS ? { OTEL_EXPORTER_OTLP_HEADERS: input.telemetry.OTEL_EXPORTER_OTLP_HEADERS } : {},
|
|
248
|
+
OTEL_SERVICE_NAME: BACKUPS_SERVICE
|
|
249
|
+
} : {}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
backups: input.backups,
|
|
254
|
+
databases,
|
|
255
|
+
prefix,
|
|
256
|
+
from,
|
|
257
|
+
image: `${input.project}-backups:pg${version}-${hash}`,
|
|
258
|
+
files: {
|
|
259
|
+
Dockerfile: dockerfile,
|
|
260
|
+
"backup.mjs": script
|
|
261
|
+
},
|
|
262
|
+
login,
|
|
263
|
+
readOnly,
|
|
264
|
+
env
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/** The service in the stack's compose file. */
|
|
268
|
+
function backupsService(backups, envFiles) {
|
|
269
|
+
return {
|
|
270
|
+
image: backups.image,
|
|
271
|
+
build: {
|
|
272
|
+
context: `./${BACKUPS_SERVICE}`,
|
|
273
|
+
dockerfile: "Dockerfile"
|
|
274
|
+
},
|
|
275
|
+
pull_policy: "build",
|
|
276
|
+
restart: "unless-stopped",
|
|
277
|
+
...envFiles ? { env_file: [{
|
|
278
|
+
path: `./${BACKUPS_SERVICE}.env`,
|
|
279
|
+
format: "raw"
|
|
280
|
+
}] } : {},
|
|
281
|
+
depends_on: { postgres: { condition: "service_healthy" } },
|
|
282
|
+
healthcheck: {
|
|
283
|
+
test: [
|
|
284
|
+
"CMD",
|
|
285
|
+
"node",
|
|
286
|
+
RUNNER_PATH,
|
|
287
|
+
"health"
|
|
288
|
+
],
|
|
289
|
+
interval: "1m",
|
|
290
|
+
timeout: "10s",
|
|
291
|
+
retries: 3,
|
|
292
|
+
start_period: "30s"
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The backups role, created and kept: able to sign in and read every
|
|
298
|
+
* database, and nothing else. None when it signs in as the superuser.
|
|
299
|
+
*/
|
|
300
|
+
function backupsRoleStatements(backups) {
|
|
301
|
+
if (!backups.readOnly) return [];
|
|
302
|
+
const role = require_seeds.quoteIdentifier(backups.login.user);
|
|
303
|
+
const password = `'${backups.login.password.replace(/'/g, "''")}'`;
|
|
304
|
+
return [
|
|
305
|
+
{
|
|
306
|
+
id: BACKUPS_SERVICE,
|
|
307
|
+
describe: `role ${backups.login.user}`,
|
|
308
|
+
exists: {
|
|
309
|
+
sql: "SELECT 1 FROM pg_roles WHERE rolname = $1",
|
|
310
|
+
values: [backups.login.user]
|
|
311
|
+
},
|
|
312
|
+
create: `CREATE ROLE ${role} LOGIN PASSWORD ${password}`
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
id: BACKUPS_SERVICE,
|
|
316
|
+
describe: `role ${backups.login.user}: its password`,
|
|
317
|
+
create: `ALTER ROLE ${role} WITH LOGIN PASSWORD ${password}`
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
id: BACKUPS_SERVICE,
|
|
321
|
+
describe: `role ${backups.login.user}: read every database`,
|
|
322
|
+
create: `GRANT pg_read_all_data TO ${role}`
|
|
323
|
+
}
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/compose/sitePassword.ts
|
|
328
|
+
/**
|
|
329
|
+
* A site served behind a password on some deployed stages — a `StaticSite`'s
|
|
330
|
+
* `password`, naming a `RandomPassword` — so a staging build is not public
|
|
331
|
+
* while it is being tried.
|
|
332
|
+
*
|
|
333
|
+
* The edge asks for it with HTTP basic auth, before a request reaches the
|
|
334
|
+
* site: the browser prompts, and nothing of the site loads until the stage's
|
|
335
|
+
* login is given. The user is the stage's name; the password is the
|
|
336
|
+
* `RandomPassword`'s value on the stage, generated and kept like any other.
|
|
337
|
+
* Only its bcrypt hash reaches the edge's config.
|
|
338
|
+
*
|
|
339
|
+
* Pure.
|
|
340
|
+
*/
|
|
341
|
+
/** A site's `password` names a `RandomPassword` the manifest does not hold. */
|
|
342
|
+
var SitePasswordNotDeclared = class extends require_errors.GkmError {
|
|
343
|
+
site;
|
|
344
|
+
secret;
|
|
345
|
+
constructor(site, secret) {
|
|
346
|
+
super(`'${site}' is served behind the password '${secret}', and no RandomPassword '${secret}' was found. Export it from a constructs file, as any construct is: export const ${secret[0].toLowerCase()}${secret.slice(1)} = new RandomPassword('${secret}');`);
|
|
347
|
+
this.site = site;
|
|
348
|
+
this.secret = secret;
|
|
349
|
+
this.name = "SitePasswordNotDeclared";
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
/** A site's `password` names a stage the workspace does not deploy. */
|
|
353
|
+
var UnknownPasswordStage = class extends require_errors.GkmError {
|
|
354
|
+
site;
|
|
355
|
+
stage;
|
|
356
|
+
deployed;
|
|
357
|
+
constructor(site, stage, deployed) {
|
|
358
|
+
super(`'${site}' is served behind a password on '${stage}', which is not one of the workspace's deployed stages (${deployed.map((s) => `'${s}'`).join(", ")}). Name one of them in its password's stages.`);
|
|
359
|
+
this.site = site;
|
|
360
|
+
this.stage = stage;
|
|
361
|
+
this.deployed = deployed;
|
|
362
|
+
this.name = "UnknownPasswordStage";
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
/** A site behind a password, with none in the stage's secrets. */
|
|
366
|
+
var SitePasswordMissing = class extends require_errors.GkmError {
|
|
367
|
+
stage;
|
|
368
|
+
key;
|
|
369
|
+
constructor(stage, key) {
|
|
370
|
+
super(`A site of '${stage}' is served behind a password, and the stage has no ${key} in its secrets. Run gkm compose --stage ${stage} once to generate it, or set one: gkm secrets:set ${key} '…' --stage ${stage}`);
|
|
371
|
+
this.stage = stage;
|
|
372
|
+
this.key = key;
|
|
373
|
+
this.name = "SitePasswordMissing";
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* A site behind a password on a stage it deploys through a target that cannot
|
|
378
|
+
* ask for a login. Refused rather than ignored: ignored, the site would be
|
|
379
|
+
* public while its construct says it is not.
|
|
380
|
+
*/
|
|
381
|
+
var SitePasswordNeedsCompose = class extends require_errors.GkmError {
|
|
382
|
+
site;
|
|
383
|
+
stage;
|
|
384
|
+
target;
|
|
385
|
+
constructor(site, stage, target) {
|
|
386
|
+
super(`'${site}' is served behind a password on '${stage}', and it deploys through '${target}', which cannot ask for one yet — only compose does. Remove ${stage} from its password's stages, or deploy it with compose.`);
|
|
387
|
+
this.site = site;
|
|
388
|
+
this.stage = stage;
|
|
389
|
+
this.target = target;
|
|
390
|
+
this.name = "SitePasswordNeedsCompose";
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* The `RandomPassword` a site is served behind on `stage`, by its key —
|
|
395
|
+
* `SITE_PASSWORD` — or `undefined` where the stage asks for none.
|
|
396
|
+
*
|
|
397
|
+
* @throws {SitePasswordNotDeclared} where the password is not in the manifest
|
|
398
|
+
*/
|
|
399
|
+
function sitePasswordKey(manifest, site, stage) {
|
|
400
|
+
const password = site.password;
|
|
401
|
+
if (!password?.stages.includes(stage)) return void 0;
|
|
402
|
+
const secret = manifest[password.secret];
|
|
403
|
+
const key = secret?.kind === "secret" ? secret.provides?.[0] : void 0;
|
|
404
|
+
if (!key) throw new SitePasswordNotDeclared(site.id, password.secret);
|
|
405
|
+
return key;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Before anything is deployed: every site behind a password names a deployed
|
|
409
|
+
* stage and a declared `RandomPassword`, and one of `apps` behind it on
|
|
410
|
+
* `stage` deploys through compose.
|
|
411
|
+
*
|
|
412
|
+
* @throws {UnknownPasswordStage}, {SitePasswordNotDeclared},
|
|
413
|
+
* {SitePasswordNeedsCompose}
|
|
414
|
+
*/
|
|
415
|
+
function assertSitePasswords(workspace, manifest, stage, apps, target) {
|
|
416
|
+
for (const site of Object.values(manifest)) {
|
|
417
|
+
if (site.kind !== "site" || !site.password) continue;
|
|
418
|
+
for (const named of site.password.stages) if (!workspace.stages.deployed.includes(named)) throw new UnknownPasswordStage(site.id, named, workspace.stages.deployed);
|
|
419
|
+
if (sitePasswordKey(manifest, site, stage) && target !== "compose" && apps.includes(require_derive.appKey(site.id))) throw new SitePasswordNeedsCompose(site.id, stage, target);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* The login a site is served behind on `stage`, from the password kept under
|
|
424
|
+
* `key`.
|
|
425
|
+
*
|
|
426
|
+
* The hash's salt is derived from the password, so the same password always
|
|
427
|
+
* renders the same edge config: a deploy that changed nothing rewrites
|
|
428
|
+
* nothing, and the proxy is not reloaded for it. A per-hash random salt
|
|
429
|
+
* guards against a precomputed table of common passwords; a generated one is
|
|
430
|
+
* 43 random characters, which no table holds.
|
|
431
|
+
*
|
|
432
|
+
* @throws {SitePasswordMissing} where the stage's secrets hold none
|
|
433
|
+
*/
|
|
434
|
+
function siteAuth(stage, key, custom) {
|
|
435
|
+
const password = custom[key];
|
|
436
|
+
if (!password) throw new SitePasswordMissing(stage, key);
|
|
437
|
+
return {
|
|
438
|
+
user: stage,
|
|
439
|
+
password,
|
|
440
|
+
hash: bcryptjs.default.hashSync(password, saltFor(password)),
|
|
441
|
+
key
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
/** bcrypt's own base-64 alphabet, in which a salt is written. */
|
|
445
|
+
const BCRYPT_ALPHABET = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
446
|
+
/**
|
|
447
|
+
* A bcrypt salt — `$2a$`, which Caddy and Traefik both read, at cost 10 —
|
|
448
|
+
* derived from the password.
|
|
449
|
+
*/
|
|
450
|
+
function saltFor(password) {
|
|
451
|
+
const digest = (0, node_crypto.createHash)("sha256").update(password).digest();
|
|
452
|
+
let salt = "";
|
|
453
|
+
for (let i = 0; i < 22; i++) salt += BCRYPT_ALPHABET[digest[i] % 64];
|
|
454
|
+
return `$2a$10$${salt}`;
|
|
455
|
+
}
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/providers/aws.ts
|
|
458
|
+
/**
|
|
459
|
+
* The AWS account a provider provisions in — the stage's, found the way the
|
|
460
|
+
* SSM and Secrets Manager stores find it.
|
|
461
|
+
*
|
|
462
|
+
* 1. `--profile`, resolved on its own: exported keys left over from another
|
|
463
|
+
* account never win over a profile someone named.
|
|
464
|
+
* 2. `AWS_PROFILE`, else `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` — the
|
|
465
|
+
* deploy's own `aws` credential kind (`storedCredentials`).
|
|
466
|
+
* 3. The SDK's default chain: `~/.aws` default profile, SSO, a role. In CI,
|
|
467
|
+
* whatever `aws-actions/configure-aws-credentials` exported.
|
|
468
|
+
*
|
|
469
|
+
* None of them: the provider has no provisioning credentials, and the stage
|
|
470
|
+
* is treated as `external`.
|
|
471
|
+
*/
|
|
472
|
+
async function awsProvisioningCredentials(lookup) {
|
|
473
|
+
const region = lookup.env.AWS_REGION ?? lookup.env.AWS_DEFAULT_REGION;
|
|
474
|
+
const where = region ? { region } : {};
|
|
475
|
+
if (lookup.profile) return {
|
|
476
|
+
profile: lookup.profile,
|
|
477
|
+
...where
|
|
478
|
+
};
|
|
479
|
+
const stored = await require_credentials.storedCredentials({
|
|
480
|
+
env: lookup.env,
|
|
481
|
+
...lookup.home ? { home: lookup.home } : {}
|
|
482
|
+
}).get({
|
|
483
|
+
kind: "aws",
|
|
484
|
+
stage: lookup.stage
|
|
485
|
+
});
|
|
486
|
+
if (stored) return stored;
|
|
487
|
+
try {
|
|
488
|
+
const { fromNodeProviderChain } = await import("@aws-sdk/credential-providers");
|
|
489
|
+
await fromNodeProviderChain({
|
|
490
|
+
timeout: 1e3,
|
|
491
|
+
maxRetries: 0
|
|
492
|
+
})();
|
|
493
|
+
return {
|
|
494
|
+
chain: true,
|
|
495
|
+
...where
|
|
496
|
+
};
|
|
497
|
+
} catch {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* An S3-compatible endpoint the environment points the SDK at — the AWS
|
|
503
|
+
* emulator in tests. The SDK reads it itself; it is read here too, because
|
|
504
|
+
* an emulator takes path-style requests, and a key written for one has to
|
|
505
|
+
* say where it is.
|
|
506
|
+
*/
|
|
507
|
+
function awsEndpoint(env, service) {
|
|
508
|
+
return env[`AWS_ENDPOINT_URL_${service}`] ?? env.AWS_ENDPOINT_URL;
|
|
509
|
+
}
|
|
510
|
+
/** An SDK client's config for a provisioning credential. */
|
|
511
|
+
async function awsClientConfig(credential, region) {
|
|
512
|
+
if ("profile" in credential) {
|
|
513
|
+
const { fromIni } = await import("@aws-sdk/credential-providers");
|
|
514
|
+
return {
|
|
515
|
+
region,
|
|
516
|
+
credentials: fromIni({ profile: credential.profile })
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
if ("accessKeyId" in credential) return {
|
|
520
|
+
region,
|
|
521
|
+
credentials: {
|
|
522
|
+
accessKeyId: credential.accessKeyId,
|
|
523
|
+
secretAccessKey: credential.secretAccessKey,
|
|
524
|
+
...credential.sessionToken ? { sessionToken: credential.sessionToken } : {}
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
return { region };
|
|
528
|
+
}
|
|
529
|
+
//#endregion
|
|
530
|
+
//#region src/compose/dns.ts
|
|
531
|
+
/**
|
|
532
|
+
* A compose stage's DNS: the records its public hosts need, and the check that
|
|
533
|
+
* they resolve to its server before a certificate is asked for.
|
|
534
|
+
*
|
|
535
|
+
* - **The server** (`serverAddress`): the stage's own secrets hold its public
|
|
536
|
+
* addresses — `GKM_SERVER_IPV4`, and `GKM_SERVER_IPV6` where it has one.
|
|
537
|
+
* Reserved for gkm: never handed to an app.
|
|
538
|
+
* - **The plan** (`planStackDns`, pure): every public host the stack serves —
|
|
539
|
+
* its apex, each app, each file server, the public log UI — pointed at the
|
|
540
|
+
* server. An A record per host (and an AAAA with an IPv6 address), or, where
|
|
541
|
+
* the domain's `dns` entry says `records: { mode: 'cname', target }`, one A
|
|
542
|
+
* record for the target and a CNAME to it for every other host but the
|
|
543
|
+
* apex, which DNS forbids a CNAME at.
|
|
544
|
+
* - **Applying it** (`applyStackDns`): through the domain's provider in `dns`,
|
|
545
|
+
* a record set at a time. A record with the right value is left alone; one
|
|
546
|
+
* with another value is replaced and the change printed. A `manual` domain
|
|
547
|
+
* is printed and nothing else. A dry run reads, prints and writes nothing.
|
|
548
|
+
* - **The check** (`checkStackDns`): each host resolved with the system
|
|
549
|
+
* resolver. One that is not the server stops the deploy with
|
|
550
|
+
* {@link HostNotPointingAtServer}, before Caddy or Traefik ask Let's Encrypt
|
|
551
|
+
* for a certificate it cannot get — and use up the rate limit trying.
|
|
552
|
+
* - **What gkm wrote before** (`diffRecordedDns`, pure): the plan against the
|
|
553
|
+
* records the stage's state says gkm wrote — added, kept, and stale: a
|
|
554
|
+
* host the stage no longer serves, after a domain or an app changed.
|
|
555
|
+
* - **The prune** (`pruneStackDns`): each stale record deleted through its
|
|
556
|
+
* domain's provider, if it still holds the value gkm wrote. One someone
|
|
557
|
+
* pointed elsewhere is left alone; one no provider can delete is printed.
|
|
558
|
+
* - **The step** (`stageDns`): all of it, as every deploy runs it — the plan applied through each provider,
|
|
559
|
+
* what was written read back from the provider, the stale records pruned,
|
|
560
|
+
* and only the hosts no provider wrote resolved publicly. A brand-new name
|
|
561
|
+
* is never looked up before its record exists, so no resolver caches it as
|
|
562
|
+
* missing.
|
|
563
|
+
*/
|
|
564
|
+
/** The line that says how to set the server's address. */
|
|
565
|
+
function serverAddressHint(stage) {
|
|
566
|
+
return `gkm secrets:set ${require_workspace.SERVER_IPV4_KEY} '<ip>' --stage ${stage}`;
|
|
567
|
+
}
|
|
568
|
+
/** A server address in the stage's secrets that is not an address. */
|
|
569
|
+
var ServerAddressInvalid = class extends require_errors.GkmError {
|
|
570
|
+
stage;
|
|
571
|
+
key;
|
|
572
|
+
value;
|
|
573
|
+
constructor(stage, key, value) {
|
|
574
|
+
const ipv4 = key === require_workspace.SERVER_IPV4_KEY;
|
|
575
|
+
super(`${key} in the '${stage}' stage's secrets is ${JSON.stringify(value)}, which is not an ${ipv4 ? "IPv4 address (like 203.0.113.10)" : "IPv6 address (like 2001:db8::10)"}. Set the server's public address: gkm secrets:set ${key} '<ip>' --stage ${stage}.`);
|
|
576
|
+
this.stage = stage;
|
|
577
|
+
this.key = key;
|
|
578
|
+
this.value = value;
|
|
579
|
+
this.name = "ServerAddressInvalid";
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
/**
|
|
583
|
+
* A compose stage that serves real domains with no server address: its hosts
|
|
584
|
+
* cannot be pointed or checked, and a certificate would be asked for blind.
|
|
585
|
+
*/
|
|
586
|
+
var ServerAddressMissing = class extends require_errors.GkmError {
|
|
587
|
+
stage;
|
|
588
|
+
domain;
|
|
589
|
+
constructor(stage, domain) {
|
|
590
|
+
super(`The '${stage}' stage serves ${domain} and its secrets hold no ${require_workspace.SERVER_IPV4_KEY} — the public address of the server its stack runs on, which its hosts' DNS records point at and every deploy checks before asking for certificates. Set it: ${serverAddressHint(stage)} (and ${require_workspace.SERVER_IPV6_KEY} for an IPv6 address).`);
|
|
591
|
+
this.stage = stage;
|
|
592
|
+
this.domain = domain;
|
|
593
|
+
this.name = "ServerAddressMissing";
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
/**
|
|
597
|
+
* The server's address from the stage's secrets, checked — `undefined` when
|
|
598
|
+
* `GKM_SERVER_IPV4` is not set.
|
|
599
|
+
*
|
|
600
|
+
* @throws {ServerAddressInvalid} for a value that is not an address
|
|
601
|
+
*/
|
|
602
|
+
function serverAddress(stage, custom) {
|
|
603
|
+
const ipv4 = custom?.[require_workspace.SERVER_IPV4_KEY]?.trim();
|
|
604
|
+
const ipv6 = custom?.[require_workspace.SERVER_IPV6_KEY]?.trim();
|
|
605
|
+
if (ipv6 && !(0, node_net.isIPv6)(ipv6)) throw new ServerAddressInvalid(stage, require_workspace.SERVER_IPV6_KEY, ipv6);
|
|
606
|
+
if (!ipv4) return void 0;
|
|
607
|
+
if (!(0, node_net.isIPv4)(ipv4)) throw new ServerAddressInvalid(stage, require_workspace.SERVER_IPV4_KEY, ipv4);
|
|
608
|
+
return {
|
|
609
|
+
ipv4,
|
|
610
|
+
...ipv6 ? { ipv6 } : {}
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* A name that resolves to this machine by definition — `localhost` and every
|
|
615
|
+
* `*.localhost` — and is in nobody's DNS.
|
|
616
|
+
*/
|
|
617
|
+
function isLocalHost(host) {
|
|
618
|
+
const name = host.toLowerCase().replace(/\.$/, "");
|
|
619
|
+
return name === "localhost" || name.endsWith(".localhost");
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* The server's address, required where the stage serves real domains — not
|
|
623
|
+
* `*.localhost` ones, which point at this machine already.
|
|
624
|
+
*
|
|
625
|
+
* @throws {ServerAddressMissing} when the stage has a domain and no address
|
|
626
|
+
* @throws {ServerAddressInvalid} for a value that is not an address
|
|
627
|
+
*/
|
|
628
|
+
function requiredServerAddress(stage, domain, custom) {
|
|
629
|
+
const server = serverAddress(stage, custom);
|
|
630
|
+
if (!server && domain && !isLocalHost(domain)) throw new ServerAddressMissing(stage, domain);
|
|
631
|
+
return server;
|
|
632
|
+
}
|
|
633
|
+
/** The types that point a name somewhere — a name holds a CNAME or the others. */
|
|
634
|
+
const ADDRESS_TYPES = [
|
|
635
|
+
"A",
|
|
636
|
+
"AAAA",
|
|
637
|
+
"CNAME"
|
|
638
|
+
];
|
|
639
|
+
/** Every public host the stack serves, once each, sorted. */
|
|
640
|
+
function stackHosts(stack) {
|
|
641
|
+
return [...new Set(stack.routes.map((route) => route.host))].sort();
|
|
642
|
+
}
|
|
643
|
+
/** The TTL a domain's records are written with. */
|
|
644
|
+
function recordTtl(config) {
|
|
645
|
+
const ttl = "ttl" in config ? config.ttl : void 0;
|
|
646
|
+
if (ttl) return ttl;
|
|
647
|
+
return config.provider === "godaddy" ? 600 : 300;
|
|
648
|
+
}
|
|
649
|
+
function providerName(config) {
|
|
650
|
+
return typeof config.provider === "string" ? config.provider : "custom";
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* A wildcard host that is not the stage's wildcard site's: gkm writes one
|
|
654
|
+
* record per public host, so a stage on another server — or a name someone
|
|
655
|
+
* else points elsewhere — is never caught by a record it did not ask for.
|
|
656
|
+
* Only `*.<domain>` for a site declared `subdomain: '*'` is written, and it
|
|
657
|
+
* covers no name that has a record of its own.
|
|
658
|
+
*/
|
|
659
|
+
var DnsWildcardRefused = class extends require_errors.GkmError {
|
|
660
|
+
stage;
|
|
661
|
+
host;
|
|
662
|
+
constructor(stage, host) {
|
|
663
|
+
super(`'${stage}' would point ${host} at its server, and gkm never writes a wildcard record: each public host gets its own. Give the app a subdomain of its own instead.`);
|
|
664
|
+
this.stage = stage;
|
|
665
|
+
this.host = host;
|
|
666
|
+
this.name = "DnsWildcardRefused";
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
/** The records a stage's hosts need — pure. */
|
|
670
|
+
function planStackDns(input) {
|
|
671
|
+
const { stage, server } = input;
|
|
672
|
+
const dns = input.dns ? require_seeds.normalizeDnsConfig(input.dns) : {};
|
|
673
|
+
const records = /* @__PURE__ */ new Map();
|
|
674
|
+
const uncovered = [];
|
|
675
|
+
const add = (host, domain, type, value) => {
|
|
676
|
+
const name = require_seeds.extractSubdomain(host, domain);
|
|
677
|
+
records.set(`${domain} ${name} ${type}`, {
|
|
678
|
+
host,
|
|
679
|
+
domain,
|
|
680
|
+
name,
|
|
681
|
+
type,
|
|
682
|
+
value,
|
|
683
|
+
ttl: recordTtl(dns[domain])
|
|
684
|
+
});
|
|
685
|
+
};
|
|
686
|
+
const pointAt = (host, domain) => {
|
|
687
|
+
add(host, domain, "A", server.ipv4);
|
|
688
|
+
if (server.ipv6) add(host, domain, "AAAA", server.ipv6);
|
|
689
|
+
};
|
|
690
|
+
for (const raw of input.hosts) {
|
|
691
|
+
const host = raw.toLowerCase();
|
|
692
|
+
if (host.includes("*") && host !== input.wildcard?.toLowerCase()) throw new DnsWildcardRefused(stage, host);
|
|
693
|
+
const domain = require_seeds.findRootDomain(host, dns);
|
|
694
|
+
if (!domain) {
|
|
695
|
+
uncovered.push(host);
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
const target = require_workspace.cnameTarget(dns[domain].records, stage);
|
|
699
|
+
if (target) pointAt(target, domain);
|
|
700
|
+
if (target && host !== domain && host !== target) add(host, domain, "CNAME", target);
|
|
701
|
+
else pointAt(host, domain);
|
|
702
|
+
}
|
|
703
|
+
const domains = /* @__PURE__ */ new Map();
|
|
704
|
+
for (const record of [...records.values()].sort((a, b) => a.domain.localeCompare(b.domain) || a.name.localeCompare(b.name) || a.type.localeCompare(b.type))) {
|
|
705
|
+
const config = dns[record.domain];
|
|
706
|
+
const plan = domains.get(record.domain) ?? {
|
|
707
|
+
domain: record.domain,
|
|
708
|
+
provider: providerName(config),
|
|
709
|
+
config,
|
|
710
|
+
records: []
|
|
711
|
+
};
|
|
712
|
+
plan.records.push(record);
|
|
713
|
+
domains.set(record.domain, plan);
|
|
714
|
+
}
|
|
715
|
+
return {
|
|
716
|
+
stage,
|
|
717
|
+
server,
|
|
718
|
+
domains: [...domains.values()],
|
|
719
|
+
uncovered: uncovered.sort()
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
/** Records a provider accepted and then did not read back with their value. */
|
|
723
|
+
var DnsRecordsNotConfirmed = class extends require_errors.GkmError {
|
|
724
|
+
stage;
|
|
725
|
+
domain;
|
|
726
|
+
provider;
|
|
727
|
+
records;
|
|
728
|
+
constructor(stage, domain, provider, records) {
|
|
729
|
+
const lines = records.map((r) => ` - ${r.host} ${r.type}: ${r.found.length > 0 ? r.found.join(", ") : "nothing"}, expected ${r.expected}`);
|
|
730
|
+
super(`${provider} accepted '${stage}''s records for ${domain}, and reading them back does not show them:\n${lines.join("\n")}\nDeploy again; if it persists, check the records in the provider's console — another tool may be writing the same names.`);
|
|
731
|
+
this.stage = stage;
|
|
732
|
+
this.domain = domain;
|
|
733
|
+
this.provider = provider;
|
|
734
|
+
this.records = records;
|
|
735
|
+
this.name = "DnsRecordsNotConfirmed";
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
/** `api.example.com A 203.0.113.10 (TTL 600)` */
|
|
739
|
+
function describe(record) {
|
|
740
|
+
return `${record.host.padEnd(32)} ${record.type.padEnd(5)} ${record.value} (TTL ${record.ttl})`;
|
|
741
|
+
}
|
|
742
|
+
function printManual(plan, log, why) {
|
|
743
|
+
log(` ${plan.domain}: ${why} — create these records at its DNS host:`);
|
|
744
|
+
for (const record of plan.records) log(` ${describe(record)}`);
|
|
745
|
+
return plan.records.map((r) => ({
|
|
746
|
+
domain: r.domain,
|
|
747
|
+
name: r.name,
|
|
748
|
+
type: r.type,
|
|
749
|
+
action: "manual",
|
|
750
|
+
value: r.value,
|
|
751
|
+
ttl: r.ttl
|
|
752
|
+
}));
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* The existing records of every planned name: A, AAAA and CNAME where one of
|
|
756
|
+
* them is planned — what the name points at, and what a change of mode
|
|
757
|
+
* deletes — and MX where an MX is. No other type is read.
|
|
758
|
+
*/
|
|
759
|
+
async function existingRecords(provider, plan) {
|
|
760
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
761
|
+
for (const record of plan.records) {
|
|
762
|
+
const types = ADDRESS_TYPES.includes(record.type) ? ADDRESS_TYPES : [record.type];
|
|
763
|
+
for (const type of types) wanted.set(`${record.name} ${type}`, {
|
|
764
|
+
name: record.name,
|
|
765
|
+
type
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
return readRecords(provider, plan.domain, [...wanted.values()]);
|
|
769
|
+
}
|
|
770
|
+
/** Exactly these names and types, as the provider holds them. */
|
|
771
|
+
async function readRecords(provider, domain, wanted) {
|
|
772
|
+
if (provider.readRecords) return provider.readRecords(domain, wanted);
|
|
773
|
+
return (await provider.getRecords(domain)).filter((r) => wanted.some((w) => w.name === r.name && w.type === r.type));
|
|
774
|
+
}
|
|
775
|
+
/** The provider for a domain's config: `providerFor`, or the real one. */
|
|
776
|
+
function providerResolver(options) {
|
|
777
|
+
return options.providerFor ?? ((config) => require_seeds.createDnsProvider({
|
|
778
|
+
config,
|
|
779
|
+
...options.credentials ? { godaddy: options.credentials } : {},
|
|
780
|
+
...options.hostinger ? { hostinger: options.hostinger } : {}
|
|
781
|
+
}));
|
|
782
|
+
}
|
|
783
|
+
/** Two values compared as DNS does: case, a trailing dot and spacing aside. */
|
|
784
|
+
const same = (a, b) => {
|
|
785
|
+
const normalize = (value) => value.trim().replace(/\.$/, "").replace(/\s+/g, " ").toLowerCase();
|
|
786
|
+
return normalize(a) === normalize(b);
|
|
787
|
+
};
|
|
788
|
+
/**
|
|
789
|
+
* What each domain's records need, compared with what is there: creates,
|
|
790
|
+
* updates, and the deletes a change of mode needs — a name moving from an A
|
|
791
|
+
* record to a CNAME, or back, cannot hold both. Nothing else is deleted: an
|
|
792
|
+
* MX planned at a name deletes nothing, and a CNAME or A planned at a name
|
|
793
|
+
* never deletes its MX.
|
|
794
|
+
*/
|
|
795
|
+
function diffDomainDns(plan, existing) {
|
|
796
|
+
const changes = [];
|
|
797
|
+
const find = (name, type) => existing.find((r) => r.name === name && r.type === type);
|
|
798
|
+
const planned = /* @__PURE__ */ new Map();
|
|
799
|
+
for (const record of plan.records) {
|
|
800
|
+
const types = planned.get(record.name) ?? /* @__PURE__ */ new Set();
|
|
801
|
+
types.add(record.type);
|
|
802
|
+
planned.set(record.name, types);
|
|
803
|
+
}
|
|
804
|
+
for (const [name, types] of planned) {
|
|
805
|
+
const conflicting = types.has("CNAME") ? ["A", "AAAA"] : types.has("A") || types.has("AAAA") ? ["CNAME"] : [];
|
|
806
|
+
for (const type of conflicting) {
|
|
807
|
+
const found = find(name, type);
|
|
808
|
+
if (!found || found.values.length === 0) continue;
|
|
809
|
+
changes.push({
|
|
810
|
+
domain: plan.domain,
|
|
811
|
+
name,
|
|
812
|
+
type,
|
|
813
|
+
action: "delete",
|
|
814
|
+
previous: found.values.join(", ")
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
for (const record of plan.records) {
|
|
819
|
+
const found = find(record.name, record.type);
|
|
820
|
+
const base = {
|
|
821
|
+
domain: plan.domain,
|
|
822
|
+
name: record.name,
|
|
823
|
+
type: record.type,
|
|
824
|
+
value: record.value,
|
|
825
|
+
ttl: record.ttl
|
|
826
|
+
};
|
|
827
|
+
if (!found || found.values.length === 0) changes.push({
|
|
828
|
+
...base,
|
|
829
|
+
action: "create"
|
|
830
|
+
});
|
|
831
|
+
else if (found.values.length === 1 && same(found.values[0], record.value)) changes.push({
|
|
832
|
+
...base,
|
|
833
|
+
action: "unchanged"
|
|
834
|
+
});
|
|
835
|
+
else changes.push({
|
|
836
|
+
...base,
|
|
837
|
+
action: "update",
|
|
838
|
+
previous: found.values.join(", ")
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
return changes;
|
|
842
|
+
}
|
|
843
|
+
/** A host's full name from a domain and a relative name. */
|
|
844
|
+
function fullName(domain, name) {
|
|
845
|
+
return name === "@" ? domain : `${name}.${domain}`;
|
|
846
|
+
}
|
|
847
|
+
function printChange(change, dryRun, log) {
|
|
848
|
+
const host = fullName(change.domain, change.name).padEnd(32);
|
|
849
|
+
const type = change.type.padEnd(5);
|
|
850
|
+
const would = dryRun ? "would " : "";
|
|
851
|
+
switch (change.action) {
|
|
852
|
+
case "unchanged":
|
|
853
|
+
log(` ✓ ${host} ${type} ${change.value} (TTL ${change.ttl}) — up to date`);
|
|
854
|
+
break;
|
|
855
|
+
case "create":
|
|
856
|
+
log(` + ${host} ${type} ${change.value} (TTL ${change.ttl}) — ${would}create`);
|
|
857
|
+
break;
|
|
858
|
+
case "update":
|
|
859
|
+
log(` ~ ${host} ${type} ${change.previous} → ${change.value} (TTL ${change.ttl}) — ${would}update`);
|
|
860
|
+
break;
|
|
861
|
+
case "write":
|
|
862
|
+
log(dryRun ? ` ? ${host} ${type} ${change.value} (TTL ${change.ttl}) — would write; current value unknown (key cannot read DNS)` : ` ! ${host} ${type} ${change.value} (TTL ${change.ttl}) — written (not diffed)`);
|
|
863
|
+
break;
|
|
864
|
+
case "delete": log(` - ${host} ${type} ${change.previous} — ${would}delete (a name cannot hold a CNAME and an A record)`);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Each domain's records, through its provider — and, with `confirm`, what was
|
|
869
|
+
* written read back from it. A record already holding its value is neither
|
|
870
|
+
* written nor read again.
|
|
871
|
+
*
|
|
872
|
+
* @throws {DnsRecordsNotConfirmed} when a written record does not read back
|
|
873
|
+
*/
|
|
874
|
+
async function settleStackDns(plan, options = {}) {
|
|
875
|
+
const dryRun = options.dryRun === true;
|
|
876
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
877
|
+
const providerFor = providerResolver(options);
|
|
878
|
+
const changes = [];
|
|
879
|
+
const confirmed = /* @__PURE__ */ new Set();
|
|
880
|
+
const unconfirmed = /* @__PURE__ */ new Set();
|
|
881
|
+
const hostsOf = (domain) => new Set(domain.records.map((r) => r.host));
|
|
882
|
+
for (const host of plan.uncovered) log(` ⚠ ${host} is under no domain in dns — point it at ${plan.server.ipv4} yourself`);
|
|
883
|
+
for (const domain of plan.domains) {
|
|
884
|
+
if (domain.provider === "manual") {
|
|
885
|
+
changes.push(...printManual(domain, log, "manual"));
|
|
886
|
+
for (const host of hostsOf(domain)) unconfirmed.add(host);
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
const provider = await providerFor(domain.config);
|
|
890
|
+
if (!provider) {
|
|
891
|
+
changes.push(...printManual(domain, log, "manual"));
|
|
892
|
+
for (const host of hostsOf(domain)) unconfirmed.add(host);
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
log(` ${domain.domain} (${provider.name})${dryRun ? " — dry run" : ""}`);
|
|
896
|
+
let existing;
|
|
897
|
+
let diff;
|
|
898
|
+
let unreadable = false;
|
|
899
|
+
try {
|
|
900
|
+
existing = await existingRecords(provider, domain);
|
|
901
|
+
diff = diffDomainDns(domain, existing);
|
|
902
|
+
} catch (error) {
|
|
903
|
+
if (!(error instanceof require_seeds.DnsRecordsUnreadable)) throw error;
|
|
904
|
+
log(` ℹ The ${provider.name} key cannot read ${domain.domain}'s DNS records, so changes cannot be diffed: every record is written (idempotent).`);
|
|
905
|
+
unreadable = true;
|
|
906
|
+
existing = [];
|
|
907
|
+
diff = domain.records.map((r) => ({
|
|
908
|
+
domain: r.domain,
|
|
909
|
+
name: r.name,
|
|
910
|
+
type: r.type,
|
|
911
|
+
action: "write",
|
|
912
|
+
value: r.value,
|
|
913
|
+
ttl: r.ttl
|
|
914
|
+
}));
|
|
915
|
+
}
|
|
916
|
+
for (const change of diff) printChange(change, dryRun, log);
|
|
917
|
+
if (!plan.server.ipv6) for (const name of new Set(domain.records.map((r) => r.name))) {
|
|
918
|
+
const aaaa = existing.find((r) => r.name === name && r.type === "AAAA");
|
|
919
|
+
const planned = domain.records.find((r) => r.name === name && r.type === "A");
|
|
920
|
+
if (aaaa && planned && aaaa.values.length > 0) log(` ⚠ ${fullName(domain.domain, name)} also has AAAA ${aaaa.values.join(", ")}: set ${require_workspace.SERVER_IPV6_KEY} in the '${plan.stage}' stage's secrets to the server's IPv6 address, or remove that record, or IPv6 clients go elsewhere`);
|
|
921
|
+
}
|
|
922
|
+
changes.push(...diff);
|
|
923
|
+
const written = new Set(diff.filter((c) => c.action !== "unchanged").map((c) => fullName(c.domain, c.name)));
|
|
924
|
+
for (const host of hostsOf(domain)) if (unreadable) {
|
|
925
|
+
if (!dryRun) unconfirmed.add(host);
|
|
926
|
+
} else if (!written.has(host)) confirmed.add(host);
|
|
927
|
+
if (dryRun) continue;
|
|
928
|
+
const deletes = diff.filter((c) => c.action === "delete");
|
|
929
|
+
if (deletes.length > 0) await provider.deleteRecords(domain.domain, deletes.map((c) => ({
|
|
930
|
+
name: c.name,
|
|
931
|
+
type: c.type
|
|
932
|
+
})));
|
|
933
|
+
const writes = diff.filter((c) => c.action === "create" || c.action === "update" || c.action === "write");
|
|
934
|
+
if (writes.length > 0) await provider.upsertRecords(domain.domain, writes.map((c) => ({
|
|
935
|
+
name: c.name,
|
|
936
|
+
type: c.type,
|
|
937
|
+
value: c.value,
|
|
938
|
+
ttl: c.ttl
|
|
939
|
+
})));
|
|
940
|
+
if (!options.confirm || unreadable || written.size === 0) continue;
|
|
941
|
+
const rewritten = {
|
|
942
|
+
...domain,
|
|
943
|
+
records: domain.records.filter((r) => written.has(r.host))
|
|
944
|
+
};
|
|
945
|
+
const after = await existingRecords(provider, rewritten);
|
|
946
|
+
const missing = [];
|
|
947
|
+
for (const record of rewritten.records) {
|
|
948
|
+
const values = after.find((r) => r.name === record.name && r.type === record.type)?.values ?? [];
|
|
949
|
+
if (values.length !== 1 || !same(values[0], record.value)) missing.push({
|
|
950
|
+
host: record.host,
|
|
951
|
+
type: record.type,
|
|
952
|
+
expected: record.value,
|
|
953
|
+
found: values
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
if (missing.length > 0) throw new DnsRecordsNotConfirmed(plan.stage, domain.domain, provider.name, missing);
|
|
957
|
+
for (const host of written) confirmed.add(host);
|
|
958
|
+
log(` ✓ ${written.size} host${written.size === 1 ? "" : "s"} read back from ${provider.name}`);
|
|
959
|
+
}
|
|
960
|
+
for (const host of plan.uncovered) unconfirmed.add(host);
|
|
961
|
+
return {
|
|
962
|
+
changes,
|
|
963
|
+
confirmed: [...confirmed].sort(),
|
|
964
|
+
unconfirmed: [...unconfirmed].filter((h) => !confirmed.has(h)).sort()
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
/** `api.example.com A` — a record's identity, whatever its value. */
|
|
968
|
+
const recordKey = (fqdn, type) => `${fqdn.trim().replace(/\.$/, "").toLowerCase()} ${type.toUpperCase()}`;
|
|
969
|
+
/**
|
|
970
|
+
* The plan against the records gkm wrote for the stage — pure. A record is
|
|
971
|
+
* its full name and its type: one the plan has at another value is kept (the
|
|
972
|
+
* apply updates it), and one whose name or type the plan no longer has is
|
|
973
|
+
* stale — a host the stage stopped serving when its domain or an app changed,
|
|
974
|
+
* or an AAAA once its server has no IPv6 address.
|
|
975
|
+
*/
|
|
976
|
+
function diffRecordedDns(plan, recorded) {
|
|
977
|
+
const planned = plan.domains.flatMap((domain) => domain.records);
|
|
978
|
+
const wanted = new Set(planned.map((r) => recordKey(r.host, r.type)));
|
|
979
|
+
const written = new Set(recorded.map((r) => recordKey(r.fqdn, r.type)));
|
|
980
|
+
return {
|
|
981
|
+
added: planned.filter((r) => !written.has(recordKey(r.host, r.type))),
|
|
982
|
+
kept: planned.filter((r) => written.has(recordKey(r.host, r.type))),
|
|
983
|
+
stale: recorded.filter((r) => !wanted.has(recordKey(r.fqdn, r.type)))
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Each stale record deleted through its domain's provider — only where the
|
|
988
|
+
* provider still holds exactly the value gkm wrote, so a name someone has
|
|
989
|
+
* since pointed elsewhere is never taken from them. Where no provider can
|
|
990
|
+
* read and delete it — a `manual` domain, one gone from `dns`, a key that
|
|
991
|
+
* can only write — it is printed for a person to remove. A dry run reads
|
|
992
|
+
* and prints, and deletes nothing.
|
|
993
|
+
*/
|
|
994
|
+
async function pruneStackDns(stale, options) {
|
|
995
|
+
if (stale.length === 0) return [];
|
|
996
|
+
const dryRun = options.dryRun === true;
|
|
997
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
998
|
+
const providerFor = providerResolver(options);
|
|
999
|
+
const dns = options.dns ? require_seeds.normalizeDnsConfig(options.dns) : {};
|
|
1000
|
+
const byDomain = /* @__PURE__ */ new Map();
|
|
1001
|
+
for (const record of stale) byDomain.set(record.domain, [...byDomain.get(record.domain) ?? [], record]);
|
|
1002
|
+
log(` No longer served by '${options.stage}':`);
|
|
1003
|
+
const pruned = [];
|
|
1004
|
+
const byHand = (domain, records, why) => {
|
|
1005
|
+
log(` ${domain}: ${why} — remove these records at its DNS host:`);
|
|
1006
|
+
for (const record of records) {
|
|
1007
|
+
log(` ${record.fqdn.padEnd(32)} ${record.type.padEnd(5)} ${record.value}`);
|
|
1008
|
+
pruned.push({
|
|
1009
|
+
record,
|
|
1010
|
+
action: "manual"
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
for (const [domain, records] of byDomain) {
|
|
1015
|
+
const config = dns[domain];
|
|
1016
|
+
if (!config) {
|
|
1017
|
+
byHand(domain, records, "no longer in dns");
|
|
1018
|
+
continue;
|
|
1019
|
+
}
|
|
1020
|
+
const provider = providerName(config) === "manual" ? null : await providerFor(config);
|
|
1021
|
+
if (!provider) {
|
|
1022
|
+
byHand(domain, records, "manual");
|
|
1023
|
+
continue;
|
|
1024
|
+
}
|
|
1025
|
+
let existing;
|
|
1026
|
+
try {
|
|
1027
|
+
existing = await readRecords(provider, domain, records.map((r) => ({
|
|
1028
|
+
name: r.name,
|
|
1029
|
+
type: r.type
|
|
1030
|
+
})));
|
|
1031
|
+
} catch (error) {
|
|
1032
|
+
if (!(error instanceof require_seeds.DnsRecordsUnreadable)) throw error;
|
|
1033
|
+
byHand(domain, records, `the ${provider.name} key cannot read its records, so none is deleted unchecked`);
|
|
1034
|
+
continue;
|
|
1035
|
+
}
|
|
1036
|
+
const would = dryRun ? "would " : "";
|
|
1037
|
+
const deletes = [];
|
|
1038
|
+
for (const record of records) {
|
|
1039
|
+
const host = record.fqdn.padEnd(32);
|
|
1040
|
+
const type = record.type.padEnd(5);
|
|
1041
|
+
const found = existing.find((r) => r.name === record.name && r.type === record.type)?.values ?? [];
|
|
1042
|
+
if (found.length === 0) {
|
|
1043
|
+
log(` · ${host} ${type} already gone`);
|
|
1044
|
+
pruned.push({
|
|
1045
|
+
record,
|
|
1046
|
+
action: "gone"
|
|
1047
|
+
});
|
|
1048
|
+
} else if (found.length === 1 && same(found[0], record.value)) {
|
|
1049
|
+
log(` - ${host} ${type} ${record.value} — ${would}delete`);
|
|
1050
|
+
deletes.push({
|
|
1051
|
+
record,
|
|
1052
|
+
action: "delete"
|
|
1053
|
+
});
|
|
1054
|
+
} else {
|
|
1055
|
+
log(` ⚠ ${host} ${type} ${found.join(", ")} — pointed elsewhere since gkm wrote ${record.value}; left as it is`);
|
|
1056
|
+
pruned.push({
|
|
1057
|
+
record,
|
|
1058
|
+
action: "changed",
|
|
1059
|
+
found
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
if (!dryRun && deletes.length > 0) await provider.deleteRecords(domain, deletes.map(({ record }) => ({
|
|
1064
|
+
name: record.name,
|
|
1065
|
+
type: record.type
|
|
1066
|
+
})));
|
|
1067
|
+
pruned.push(...deletes);
|
|
1068
|
+
}
|
|
1069
|
+
return pruned;
|
|
1070
|
+
}
|
|
1071
|
+
/** The system resolver: what the server's own clients would be told. */
|
|
1072
|
+
const systemLookup = async (host) => {
|
|
1073
|
+
return (await (0, node_dns_promises.lookup)(host, { all: true })).map((a) => a.address);
|
|
1074
|
+
};
|
|
1075
|
+
/** Hosts that do not resolve to the stage's server. */
|
|
1076
|
+
var HostNotPointingAtServer = class extends require_errors.GkmError {
|
|
1077
|
+
stage;
|
|
1078
|
+
hosts;
|
|
1079
|
+
expected;
|
|
1080
|
+
fix;
|
|
1081
|
+
constructor(stage, hosts, expected, fix) {
|
|
1082
|
+
const want = expected.ipv6 ? `${expected.ipv4} (and ${expected.ipv6})` : expected.ipv4;
|
|
1083
|
+
const lines = hosts.map((h) => ` - ${h.host} → ${h.resolved.length > 0 ? h.resolved.join(", ") : `nothing${h.error ? ` (${h.error})` : ""}`}, expected ${want}`);
|
|
1084
|
+
super(`${hosts.length === 1 ? "A host" : `${hosts.length} hosts`} of '${stage}' do${hosts.length === 1 ? "es" : ""} not resolve to its server, so a certificate for ${hosts.length === 1 ? "it" : "them"} cannot be issued:\n${lines.join("\n")}\n${fix}\nRecords can take a few minutes to propagate. With a CDN or proxy in front of the server, pass --skip-dns.`);
|
|
1085
|
+
this.stage = stage;
|
|
1086
|
+
this.hosts = hosts;
|
|
1087
|
+
this.expected = expected;
|
|
1088
|
+
this.fix = fix;
|
|
1089
|
+
this.name = "HostNotPointingAtServer";
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
/**
|
|
1093
|
+
* The name a wildcard record is resolved through: one label no app takes,
|
|
1094
|
+
* which only the `*` record answers.
|
|
1095
|
+
*/
|
|
1096
|
+
const WILDCARD_PROBE = "gkm-wildcard-check";
|
|
1097
|
+
/**
|
|
1098
|
+
* Every host resolved: each must resolve to the server's IPv4 address and to
|
|
1099
|
+
* nothing but the server's addresses.
|
|
1100
|
+
*
|
|
1101
|
+
* @throws {HostNotPointingAtServer} naming every host that does not
|
|
1102
|
+
*/
|
|
1103
|
+
async function checkStackDns(input) {
|
|
1104
|
+
const lookup = input.lookup ?? systemLookup;
|
|
1105
|
+
const { server } = input;
|
|
1106
|
+
const ours = new Set([server.ipv4, server.ipv6].filter(Boolean).map((a) => a.toLowerCase()));
|
|
1107
|
+
const bad = [];
|
|
1108
|
+
const ok = [];
|
|
1109
|
+
for (const host of input.hosts) {
|
|
1110
|
+
let resolved;
|
|
1111
|
+
const asked = host.startsWith("*.") ? `${WILDCARD_PROBE}.${host.slice(2)}` : host;
|
|
1112
|
+
try {
|
|
1113
|
+
resolved = [...new Set(await lookup(asked))];
|
|
1114
|
+
} catch (error) {
|
|
1115
|
+
const code = error && typeof error === "object" && "code" in error ? String(error.code) : error instanceof Error ? error.message : String(error);
|
|
1116
|
+
bad.push({
|
|
1117
|
+
host,
|
|
1118
|
+
resolved: [],
|
|
1119
|
+
error: code
|
|
1120
|
+
});
|
|
1121
|
+
continue;
|
|
1122
|
+
}
|
|
1123
|
+
if (resolved.some((a) => a.toLowerCase() === server.ipv4.toLowerCase()) && resolved.every((a) => ours.has(a.toLowerCase()))) ok.push(host);
|
|
1124
|
+
else bad.push({
|
|
1125
|
+
host,
|
|
1126
|
+
resolved
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
if (bad.length > 0) throw new HostNotPointingAtServer(input.stage, bad, {
|
|
1130
|
+
ipv4: server.ipv4,
|
|
1131
|
+
...server.ipv6 ? { ipv6: server.ipv6 } : {}
|
|
1132
|
+
}, dnsFix(input, bad));
|
|
1133
|
+
return ok;
|
|
1134
|
+
}
|
|
1135
|
+
/** How to fix it: the deploy, or the records to create by hand. */
|
|
1136
|
+
function dnsFix(input, bad) {
|
|
1137
|
+
const hosts = bad.map((h) => h.host);
|
|
1138
|
+
let plan;
|
|
1139
|
+
try {
|
|
1140
|
+
plan = planStackDns({
|
|
1141
|
+
stage: input.stage,
|
|
1142
|
+
hosts,
|
|
1143
|
+
server: input.server,
|
|
1144
|
+
dns: input.dns
|
|
1145
|
+
});
|
|
1146
|
+
} catch {
|
|
1147
|
+
plan = {
|
|
1148
|
+
stage: input.stage,
|
|
1149
|
+
server: input.server,
|
|
1150
|
+
domains: [],
|
|
1151
|
+
uncovered: hosts
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
const automatic = plan.domains.filter((d) => d.provider !== "manual");
|
|
1155
|
+
const byHand = [...plan.domains.filter((d) => d.provider === "manual").flatMap((d) => d.records.map(describe)), ...plan.uncovered.flatMap((host) => [`${host.padEnd(32)} A ${input.server.ipv4}`, ...input.server.ipv6 ? [`${host.padEnd(32)} AAAA ${input.server.ipv6}`] : []])];
|
|
1156
|
+
const lines = [];
|
|
1157
|
+
if (automatic.length > 0) lines.push(`Fix: gkm deploy --stage ${input.stage} writes the records for ${automatic.map((d) => d.domain).join(", ")} through their provider (--dry-run shows them first).`);
|
|
1158
|
+
if (byHand.length > 0) lines.push(`${automatic.length > 0 ? "And create" : "Fix: create"} these records at the DNS host:`, ...byHand.map((line) => ` ${line}`));
|
|
1159
|
+
return lines.join("\n");
|
|
1160
|
+
}
|
|
1161
|
+
/** The environment variable each token-authenticated provider reads. */
|
|
1162
|
+
const DNS_TOKEN_KEYS = {
|
|
1163
|
+
godaddy: "GODADDY_API_TOKEN",
|
|
1164
|
+
hostinger: "HOSTINGER_API_TOKEN"
|
|
1165
|
+
};
|
|
1166
|
+
/**
|
|
1167
|
+
* A domain whose records the deploy writes, and no token to write them with.
|
|
1168
|
+
* Raised before anything is built, started or written.
|
|
1169
|
+
*/
|
|
1170
|
+
var DnsCredentialMissing = class extends require_errors.GkmError {
|
|
1171
|
+
stage;
|
|
1172
|
+
domain;
|
|
1173
|
+
provider;
|
|
1174
|
+
key;
|
|
1175
|
+
constructor(stage, domain, provider, key) {
|
|
1176
|
+
super(`'${stage}''s hosts are under ${domain}, whose DNS is ${provider}'s, and the deploy writes their records — but ${key} is not set. In CI, add ${key} as a secret on the '${stage}' GitHub environment and pass it to the step that writes the records: env: { ${key}: \${{ secrets.${key} }} }. On this machine, export ${key} or run gkm login --provider ${provider}. With a CDN or proxy in front of the server, pass --skip-dns.`);
|
|
1177
|
+
this.stage = stage;
|
|
1178
|
+
this.domain = domain;
|
|
1179
|
+
this.provider = provider;
|
|
1180
|
+
this.key = key;
|
|
1181
|
+
this.name = "DnsCredentialMissing";
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
/**
|
|
1185
|
+
* The `dns` domain a stage's own domain (`domains.<stage>`) is under — where
|
|
1186
|
+
* its hosts' records go — or none.
|
|
1187
|
+
*/
|
|
1188
|
+
function stageDnsDomains(stage, domains, dns) {
|
|
1189
|
+
const own = domains?.[stage];
|
|
1190
|
+
if (!own || !dns || isLocalHost(own)) return [];
|
|
1191
|
+
const normalized = require_seeds.normalizeDnsConfig(dns);
|
|
1192
|
+
const root = require_seeds.findRootDomain(own.toLowerCase(), normalized);
|
|
1193
|
+
return root ? [{
|
|
1194
|
+
domain: root,
|
|
1195
|
+
config: normalized[root]
|
|
1196
|
+
}] : [];
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Each token the domains' providers need, from `credentials` — `manual`,
|
|
1200
|
+
* Route53 (the AWS SDK's own chain) and a provider object need none.
|
|
1201
|
+
*
|
|
1202
|
+
* @throws {DnsCredentialMissing} naming the first domain with no token
|
|
1203
|
+
*/
|
|
1204
|
+
async function dnsCredentials(stage, domains, credentials) {
|
|
1205
|
+
const found = {};
|
|
1206
|
+
for (const { domain, config } of domains) {
|
|
1207
|
+
const provider = config.provider;
|
|
1208
|
+
if (provider !== "godaddy" && provider !== "hostinger") continue;
|
|
1209
|
+
if (found[provider]) continue;
|
|
1210
|
+
const token = await credentials.get({ kind: provider });
|
|
1211
|
+
if (!token?.token) throw new DnsCredentialMissing(stage, domain, provider, DNS_TOKEN_KEYS[provider]);
|
|
1212
|
+
found[provider] = token;
|
|
1213
|
+
}
|
|
1214
|
+
return found;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* A stage's DNS, as every deploy runs it: the
|
|
1218
|
+
* stage's own hosts planned, written through each domain's provider where
|
|
1219
|
+
* they differ, and read back from it — and each record gkm wrote for a host
|
|
1220
|
+
* the stage no longer serves found, for `prune` to delete. Only A, AAAA and CNAME records of those
|
|
1221
|
+
* names are touched; nothing is a wildcard but a wildcard site's
|
|
1222
|
+
* `*.<domain>`, and no other name is read,
|
|
1223
|
+
* written or deleted. What no provider confirms — a `manual` domain, a host
|
|
1224
|
+
* under no domain in `dns`, a key that cannot read — is resolved publicly.
|
|
1225
|
+
* A dry run prints the plan and writes nothing.
|
|
1226
|
+
*
|
|
1227
|
+
* @throws {DnsCredentialMissing} before anything is read or written
|
|
1228
|
+
* @throws {DnsRecordsNotConfirmed} when a written record does not read back
|
|
1229
|
+
* @throws {HostNotPointingAtServer} when a resolved host is not the server
|
|
1230
|
+
*/
|
|
1231
|
+
async function stageDns(input) {
|
|
1232
|
+
const { stage, server } = input;
|
|
1233
|
+
const log = input.log ?? ((line) => console.log(line));
|
|
1234
|
+
const plan = planStackDns({
|
|
1235
|
+
stage,
|
|
1236
|
+
hosts: input.hosts,
|
|
1237
|
+
server,
|
|
1238
|
+
dns: input.dns,
|
|
1239
|
+
...input.wildcard ? { wildcard: input.wildcard } : {}
|
|
1240
|
+
});
|
|
1241
|
+
const recorded = diffRecordedDns(plan, input.recorded ?? []);
|
|
1242
|
+
const dns = input.dns ? require_seeds.normalizeDnsConfig(input.dns) : {};
|
|
1243
|
+
const staleDomains = [...new Set(recorded.stale.map((r) => r.domain))].filter((domain) => dns[domain] && !plan.domains.some((d) => d.domain === domain)).map((domain) => ({
|
|
1244
|
+
domain,
|
|
1245
|
+
config: dns[domain]
|
|
1246
|
+
}));
|
|
1247
|
+
const tokens = await dnsCredentials(stage, [...plan.domains.map(({ domain, config }) => ({
|
|
1248
|
+
domain,
|
|
1249
|
+
config
|
|
1250
|
+
})), ...staleDomains], input.credentials);
|
|
1251
|
+
const providers = {
|
|
1252
|
+
log,
|
|
1253
|
+
credentials: {
|
|
1254
|
+
...input.godaddy ?? {},
|
|
1255
|
+
...tokens.godaddy ? { credential: tokens.godaddy } : {},
|
|
1256
|
+
log
|
|
1257
|
+
},
|
|
1258
|
+
...tokens.hostinger ? { hostinger: tokens.hostinger } : {},
|
|
1259
|
+
...input.providerFor ? { providerFor: input.providerFor } : {}
|
|
1260
|
+
};
|
|
1261
|
+
const applied = !input.dns ? {
|
|
1262
|
+
changes: [],
|
|
1263
|
+
confirmed: [],
|
|
1264
|
+
unconfirmed: [...plan.uncovered]
|
|
1265
|
+
} : await settleStackDns(plan, {
|
|
1266
|
+
...input.dryRun ? { dryRun: true } : { confirm: true },
|
|
1267
|
+
...providers
|
|
1268
|
+
});
|
|
1269
|
+
const deleted = new Set(applied.changes.filter((c) => c.action === "delete").map((c) => recordKey(fullName(c.domain, c.name), c.type)));
|
|
1270
|
+
const stale = recorded.stale.filter((r) => !deleted.has(recordKey(r.fqdn, r.type)));
|
|
1271
|
+
const prune = () => pruneStackDns(stale, {
|
|
1272
|
+
stage,
|
|
1273
|
+
dns: input.dns,
|
|
1274
|
+
...input.dryRun ? { dryRun: true } : {},
|
|
1275
|
+
...providers
|
|
1276
|
+
});
|
|
1277
|
+
let resolved = [];
|
|
1278
|
+
if (applied.unconfirmed.length > 0) resolved = await checkStackDns({
|
|
1279
|
+
stage,
|
|
1280
|
+
hosts: applied.unconfirmed,
|
|
1281
|
+
server,
|
|
1282
|
+
dns: input.dns,
|
|
1283
|
+
...input.lookup ? { lookup: input.lookup } : {}
|
|
1284
|
+
});
|
|
1285
|
+
return {
|
|
1286
|
+
plan,
|
|
1287
|
+
changes: applied.changes,
|
|
1288
|
+
confirmed: applied.confirmed,
|
|
1289
|
+
resolved,
|
|
1290
|
+
recorded,
|
|
1291
|
+
prune
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
//#endregion
|
|
1295
|
+
//#region src/deploy/snsSubscriptions.ts
|
|
1296
|
+
/** The type every recorded subscription has in the stage's state. */
|
|
1297
|
+
const SUBSCRIPTION_TYPE = "sns-subscription";
|
|
1298
|
+
/** The state key a subscriber's SNS subscription is recorded under. */
|
|
1299
|
+
const subscriptionKey = (worker, name) => `${SUBSCRIPTION_TYPE}:${worker}/${name}`;
|
|
1300
|
+
/** What a recorded subscription is written to the stage's state as. */
|
|
1301
|
+
function subscriptionResource(subscription, arn) {
|
|
1302
|
+
const { name, ...data } = subscription;
|
|
1303
|
+
return {
|
|
1304
|
+
key: subscriptionKey(subscription.worker, name),
|
|
1305
|
+
type: SUBSCRIPTION_TYPE,
|
|
1306
|
+
id: arn,
|
|
1307
|
+
status: "ready",
|
|
1308
|
+
data: {
|
|
1309
|
+
...data,
|
|
1310
|
+
...data.events ? { events: [...data.events] } : {}
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
/** The subscription a record holds, as an endpoint to reconcile. */
|
|
1315
|
+
function specOf(record) {
|
|
1316
|
+
const events = record.data?.events;
|
|
1317
|
+
return {
|
|
1318
|
+
name: record.key.split("/").pop(),
|
|
1319
|
+
endpoint: String(record.data?.endpoint),
|
|
1320
|
+
...record.data?.deadLetterQueueArn ? { deadLetterQueueArn: String(record.data.deadLetterQueueArn) } : {},
|
|
1321
|
+
...Array.isArray(events) ? { events: events.map(String) } : {}
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* The subscriptions the deploy recorded, by worker and export — what each
|
|
1326
|
+
* worker is handed as `GKM_SNS_SUBSCRIPTIONS`.
|
|
1327
|
+
*/
|
|
1328
|
+
function recordedPushSubscriptions(resources) {
|
|
1329
|
+
const byWorker = {};
|
|
1330
|
+
for (const record of Object.values(resources ?? {})) {
|
|
1331
|
+
if (record.type !== "sns-subscription" || !record.id) continue;
|
|
1332
|
+
const [worker, name] = record.key.slice(`${SUBSCRIPTION_TYPE}:`.length).split("/");
|
|
1333
|
+
if (!worker || !name) continue;
|
|
1334
|
+
byWorker[worker] = {
|
|
1335
|
+
...byWorker[worker],
|
|
1336
|
+
[name]: record.id
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
return byWorker;
|
|
1340
|
+
}
|
|
1341
|
+
/** A topic connection string the deploy cannot sign with. */
|
|
1342
|
+
var TopicSubscriptionUnsigned = class extends require_errors.GkmError {
|
|
1343
|
+
connectionKey;
|
|
1344
|
+
constructor(connectionKey) {
|
|
1345
|
+
super(`'${connectionKey}' carries no keys, and the deploy found no AWS credentials of its own to subscribe the worker's routes with. Put accessKeyId and secretAccessKey in it — keys allowed sns:Subscribe, sns:ListSubscriptionsByTopic, sns:GetSubscriptionAttributes, sns:SetSubscriptionAttributes and sns:Unsubscribe on the topic — or sign in with \`gkm login\`.`);
|
|
1346
|
+
this.connectionKey = connectionKey;
|
|
1347
|
+
this.name = "TopicSubscriptionUnsigned";
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
/**
|
|
1351
|
+
* A connection to the topic a stage's connection string names, signed with
|
|
1352
|
+
* its own keys — or, carrying none, the deploy's.
|
|
1353
|
+
*
|
|
1354
|
+
* The emulator the environment points the SDK at stands in for SNS, as it
|
|
1355
|
+
* does for every provider: a string with no `endpoint` is SNS itself.
|
|
1356
|
+
*
|
|
1357
|
+
* @throws {TopicSubscriptionUnsigned} with no keys from either
|
|
1358
|
+
*/
|
|
1359
|
+
async function topicConnection(input) {
|
|
1360
|
+
const { SNSConnection, snsUrl } = await import("@geekmidas/events/sns");
|
|
1361
|
+
const { topicArn, region, endpoint } = snsUrl.parse(input.connectionString);
|
|
1362
|
+
const params = new URL(input.connectionString).searchParams;
|
|
1363
|
+
const accessKeyId = params.get("accessKeyId");
|
|
1364
|
+
const secretAccessKey = params.get("secretAccessKey");
|
|
1365
|
+
const where = region ?? topicArn.split(":")[3];
|
|
1366
|
+
let credentials;
|
|
1367
|
+
if (accessKeyId && secretAccessKey) {
|
|
1368
|
+
const sessionToken = params.get("sessionToken");
|
|
1369
|
+
credentials = {
|
|
1370
|
+
accessKeyId,
|
|
1371
|
+
secretAccessKey,
|
|
1372
|
+
...sessionToken ? { sessionToken } : {}
|
|
1373
|
+
};
|
|
1374
|
+
} else {
|
|
1375
|
+
const provisioning = await awsProvisioningCredentials({
|
|
1376
|
+
stage: input.stage,
|
|
1377
|
+
env: input.env,
|
|
1378
|
+
...input.home ? { home: input.home } : {}
|
|
1379
|
+
});
|
|
1380
|
+
if (!provisioning) throw new TopicSubscriptionUnsigned(input.connectionKey);
|
|
1381
|
+
credentials = (await awsClientConfig(provisioning, where ?? "us-east-1")).credentials;
|
|
1382
|
+
}
|
|
1383
|
+
const override = endpoint ?? awsEndpoint(input.env, "SNS");
|
|
1384
|
+
return new SNSConnection({
|
|
1385
|
+
topicArn,
|
|
1386
|
+
...where ? { region: where } : {},
|
|
1387
|
+
...override ? { endpoint: override } : {},
|
|
1388
|
+
...credentials ? { credentials } : {}
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
/** A subscription still waiting to be confirmed once its worker is up. */
|
|
1392
|
+
var PushSubscriptionsUnconfirmed = class extends require_errors.GkmError {
|
|
1393
|
+
endpoints;
|
|
1394
|
+
constructor(endpoints) {
|
|
1395
|
+
super(`SNS still waits for ${endpoints.join(", ")} to confirm ${endpoints.length === 1 ? "its subscription" : "their subscriptions"}, so nothing is pushed there yet. Check the worker's logs for the confirmation it refused, and that its host answers from the internet; the next deploy sends the confirmation again.`);
|
|
1396
|
+
this.endpoints = endpoints;
|
|
1397
|
+
this.name = "PushSubscriptionsUnconfirmed";
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
/**
|
|
1401
|
+
* Once the workers are up: every subscription recorded as pending is
|
|
1402
|
+
* subscribed again — SNS resends its confirmation to a worker now there to
|
|
1403
|
+
* answer it — and waited on until confirmed.
|
|
1404
|
+
*
|
|
1405
|
+
* The first deploy needs it: the subscription is made before the worker
|
|
1406
|
+
* starts, so SNS's first confirmation finds nobody.
|
|
1407
|
+
*
|
|
1408
|
+
* A bucket's subscriptions are reached with the deploy's provisioning
|
|
1409
|
+
* credentials; a hand-set topic's with the connection string they were made
|
|
1410
|
+
* with, read from the stage's secrets.
|
|
1411
|
+
*
|
|
1412
|
+
* @returns what is still pending when the wait ran out — none, normally.
|
|
1413
|
+
*/
|
|
1414
|
+
async function confirmPendingSubscriptions(input) {
|
|
1415
|
+
const env = input.env ?? process.env;
|
|
1416
|
+
const records = Object.values(input.resources ?? {}).filter((r) => r.type === "sns-subscription" && r.id);
|
|
1417
|
+
if (!records.some((r) => r.data?.pending === true)) return [];
|
|
1418
|
+
const { SNSConnection, reconcileHttpSubscriptions } = await import("@geekmidas/events/sns");
|
|
1419
|
+
const { GetSubscriptionAttributesCommand } = await import("@aws-sdk/client-sns");
|
|
1420
|
+
const endpoint = awsEndpoint(env, "SNS");
|
|
1421
|
+
let provisioning = null;
|
|
1422
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1423
|
+
for (const record of records) {
|
|
1424
|
+
const host = new URL(String(record.data?.endpoint)).host;
|
|
1425
|
+
const group = `${record.data?.topicArn}|${host}`;
|
|
1426
|
+
groups.set(group, [...groups.get(group) ?? [], record]);
|
|
1427
|
+
}
|
|
1428
|
+
const left = [];
|
|
1429
|
+
for (const [group, members] of groups) {
|
|
1430
|
+
const pending = members.filter((r) => r.data?.pending === true);
|
|
1431
|
+
if (pending.length === 0) continue;
|
|
1432
|
+
const [topicArn, host] = group.split("|");
|
|
1433
|
+
const unreachable = () => left.push(...pending.map((r) => String(r.data?.endpoint)));
|
|
1434
|
+
let connection;
|
|
1435
|
+
const connectionKey = members[0].data?.connectionKey;
|
|
1436
|
+
if (typeof connectionKey === "string") {
|
|
1437
|
+
const connectionString = input.secrets?.[connectionKey];
|
|
1438
|
+
if (!connectionString?.startsWith("sns:")) {
|
|
1439
|
+
unreachable();
|
|
1440
|
+
continue;
|
|
1441
|
+
}
|
|
1442
|
+
connection = await topicConnection({
|
|
1443
|
+
connectionKey,
|
|
1444
|
+
connectionString,
|
|
1445
|
+
stage: input.stage,
|
|
1446
|
+
env,
|
|
1447
|
+
...input.home ? { home: input.home } : {}
|
|
1448
|
+
});
|
|
1449
|
+
} else {
|
|
1450
|
+
if (provisioning === null) provisioning = await awsProvisioningCredentials({
|
|
1451
|
+
stage: input.stage,
|
|
1452
|
+
env,
|
|
1453
|
+
...input.home ? { home: input.home } : {}
|
|
1454
|
+
});
|
|
1455
|
+
if (!provisioning) {
|
|
1456
|
+
unreachable();
|
|
1457
|
+
continue;
|
|
1458
|
+
}
|
|
1459
|
+
const region = topicArn.split(":")[3];
|
|
1460
|
+
const { credentials } = await awsClientConfig(provisioning, region);
|
|
1461
|
+
connection = new SNSConnection({
|
|
1462
|
+
topicArn,
|
|
1463
|
+
region,
|
|
1464
|
+
...endpoint ? { endpoint } : {},
|
|
1465
|
+
...credentials ? { credentials } : {}
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
await reconcileHttpSubscriptions(connection, {
|
|
1469
|
+
endpoints: members.map(specOf),
|
|
1470
|
+
ownedHost: host
|
|
1471
|
+
});
|
|
1472
|
+
const deadline = Date.now() + (input.timeoutMs ?? 6e4);
|
|
1473
|
+
for (const record of pending) {
|
|
1474
|
+
let confirmed = false;
|
|
1475
|
+
while (!confirmed) {
|
|
1476
|
+
const { Attributes = {} } = await connection.snsClient.send(new GetSubscriptionAttributesCommand({ SubscriptionArn: record.id }));
|
|
1477
|
+
confirmed = Attributes.PendingConfirmation !== "true";
|
|
1478
|
+
if (confirmed || Date.now() > deadline) break;
|
|
1479
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
1480
|
+
}
|
|
1481
|
+
if (confirmed) {
|
|
1482
|
+
input.log?.(` ✓ ${record.data?.endpoint} confirmed its subscription`);
|
|
1483
|
+
await input.record?.({
|
|
1484
|
+
...record,
|
|
1485
|
+
data: {
|
|
1486
|
+
...record.data,
|
|
1487
|
+
pending: false
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
} else left.push(String(record.data?.endpoint));
|
|
1491
|
+
}
|
|
1492
|
+
await connection.close();
|
|
1493
|
+
}
|
|
1494
|
+
return left;
|
|
1495
|
+
}
|
|
1496
|
+
//#endregion
|
|
1497
|
+
Object.defineProperty(exports, "BACKUPS_SERVICE", {
|
|
1498
|
+
enumerable: true,
|
|
1499
|
+
get: function() {
|
|
1500
|
+
return BACKUPS_SERVICE;
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
Object.defineProperty(exports, "BACKUPS_URL_KEY", {
|
|
1504
|
+
enumerable: true,
|
|
1505
|
+
get: function() {
|
|
1506
|
+
return BACKUPS_URL_KEY;
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
Object.defineProperty(exports, "HostNotPointingAtServer", {
|
|
1510
|
+
enumerable: true,
|
|
1511
|
+
get: function() {
|
|
1512
|
+
return HostNotPointingAtServer;
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
Object.defineProperty(exports, "PushSubscriptionsUnconfirmed", {
|
|
1516
|
+
enumerable: true,
|
|
1517
|
+
get: function() {
|
|
1518
|
+
return PushSubscriptionsUnconfirmed;
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
Object.defineProperty(exports, "RUNNER_PATH", {
|
|
1522
|
+
enumerable: true,
|
|
1523
|
+
get: function() {
|
|
1524
|
+
return RUNNER_PATH;
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
Object.defineProperty(exports, "SUBSCRIPTION_TYPE", {
|
|
1528
|
+
enumerable: true,
|
|
1529
|
+
get: function() {
|
|
1530
|
+
return SUBSCRIPTION_TYPE;
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
Object.defineProperty(exports, "assertSitePasswords", {
|
|
1534
|
+
enumerable: true,
|
|
1535
|
+
get: function() {
|
|
1536
|
+
return assertSitePasswords;
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
Object.defineProperty(exports, "awsClientConfig", {
|
|
1540
|
+
enumerable: true,
|
|
1541
|
+
get: function() {
|
|
1542
|
+
return awsClientConfig;
|
|
1543
|
+
}
|
|
1544
|
+
});
|
|
1545
|
+
Object.defineProperty(exports, "awsEndpoint", {
|
|
1546
|
+
enumerable: true,
|
|
1547
|
+
get: function() {
|
|
1548
|
+
return awsEndpoint;
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
Object.defineProperty(exports, "awsProvisioningCredentials", {
|
|
1552
|
+
enumerable: true,
|
|
1553
|
+
get: function() {
|
|
1554
|
+
return awsProvisioningCredentials;
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1557
|
+
Object.defineProperty(exports, "backupDatabases", {
|
|
1558
|
+
enumerable: true,
|
|
1559
|
+
get: function() {
|
|
1560
|
+
return backupDatabases;
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
Object.defineProperty(exports, "backupExpiries", {
|
|
1564
|
+
enumerable: true,
|
|
1565
|
+
get: function() {
|
|
1566
|
+
return backupExpiries;
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1569
|
+
Object.defineProperty(exports, "backupFile", {
|
|
1570
|
+
enumerable: true,
|
|
1571
|
+
get: function() {
|
|
1572
|
+
return backupFile;
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1575
|
+
Object.defineProperty(exports, "backupsPrefix", {
|
|
1576
|
+
enumerable: true,
|
|
1577
|
+
get: function() {
|
|
1578
|
+
return backupsPrefix;
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
Object.defineProperty(exports, "backupsRoleStatements", {
|
|
1582
|
+
enumerable: true,
|
|
1583
|
+
get: function() {
|
|
1584
|
+
return backupsRoleStatements;
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
Object.defineProperty(exports, "backupsService", {
|
|
1588
|
+
enumerable: true,
|
|
1589
|
+
get: function() {
|
|
1590
|
+
return backupsService;
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
Object.defineProperty(exports, "confirmPendingSubscriptions", {
|
|
1594
|
+
enumerable: true,
|
|
1595
|
+
get: function() {
|
|
1596
|
+
return confirmPendingSubscriptions;
|
|
1597
|
+
}
|
|
1598
|
+
});
|
|
1599
|
+
Object.defineProperty(exports, "deploysWithCompose", {
|
|
1600
|
+
enumerable: true,
|
|
1601
|
+
get: function() {
|
|
1602
|
+
return deploysWithCompose;
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
1605
|
+
Object.defineProperty(exports, "dnsCredentials", {
|
|
1606
|
+
enumerable: true,
|
|
1607
|
+
get: function() {
|
|
1608
|
+
return dnsCredentials;
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
Object.defineProperty(exports, "isLocalHost", {
|
|
1612
|
+
enumerable: true,
|
|
1613
|
+
get: function() {
|
|
1614
|
+
return isLocalHost;
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
Object.defineProperty(exports, "recordTtl", {
|
|
1618
|
+
enumerable: true,
|
|
1619
|
+
get: function() {
|
|
1620
|
+
return recordTtl;
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
Object.defineProperty(exports, "recordedPushSubscriptions", {
|
|
1624
|
+
enumerable: true,
|
|
1625
|
+
get: function() {
|
|
1626
|
+
return recordedPushSubscriptions;
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
Object.defineProperty(exports, "requiredServerAddress", {
|
|
1630
|
+
enumerable: true,
|
|
1631
|
+
get: function() {
|
|
1632
|
+
return requiredServerAddress;
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
Object.defineProperty(exports, "runTime", {
|
|
1636
|
+
enumerable: true,
|
|
1637
|
+
get: function() {
|
|
1638
|
+
return runTime;
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
Object.defineProperty(exports, "serverAddressHint", {
|
|
1642
|
+
enumerable: true,
|
|
1643
|
+
get: function() {
|
|
1644
|
+
return serverAddressHint;
|
|
1645
|
+
}
|
|
1646
|
+
});
|
|
1647
|
+
Object.defineProperty(exports, "settleStackDns", {
|
|
1648
|
+
enumerable: true,
|
|
1649
|
+
get: function() {
|
|
1650
|
+
return settleStackDns;
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
Object.defineProperty(exports, "siteAuth", {
|
|
1654
|
+
enumerable: true,
|
|
1655
|
+
get: function() {
|
|
1656
|
+
return siteAuth;
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
Object.defineProperty(exports, "sitePasswordKey", {
|
|
1660
|
+
enumerable: true,
|
|
1661
|
+
get: function() {
|
|
1662
|
+
return sitePasswordKey;
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
Object.defineProperty(exports, "stackBackups", {
|
|
1666
|
+
enumerable: true,
|
|
1667
|
+
get: function() {
|
|
1668
|
+
return stackBackups;
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
Object.defineProperty(exports, "stackHosts", {
|
|
1672
|
+
enumerable: true,
|
|
1673
|
+
get: function() {
|
|
1674
|
+
return stackHosts;
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
Object.defineProperty(exports, "stageBackups", {
|
|
1678
|
+
enumerable: true,
|
|
1679
|
+
get: function() {
|
|
1680
|
+
return stageBackups;
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
Object.defineProperty(exports, "stageDns", {
|
|
1684
|
+
enumerable: true,
|
|
1685
|
+
get: function() {
|
|
1686
|
+
return stageDns;
|
|
1687
|
+
}
|
|
1688
|
+
});
|
|
1689
|
+
Object.defineProperty(exports, "stageDnsDomains", {
|
|
1690
|
+
enumerable: true,
|
|
1691
|
+
get: function() {
|
|
1692
|
+
return stageDnsDomains;
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
Object.defineProperty(exports, "subscriptionKey", {
|
|
1696
|
+
enumerable: true,
|
|
1697
|
+
get: function() {
|
|
1698
|
+
return subscriptionKey;
|
|
1699
|
+
}
|
|
1700
|
+
});
|
|
1701
|
+
Object.defineProperty(exports, "subscriptionResource", {
|
|
1702
|
+
enumerable: true,
|
|
1703
|
+
get: function() {
|
|
1704
|
+
return subscriptionResource;
|
|
1705
|
+
}
|
|
1706
|
+
});
|
|
1707
|
+
Object.defineProperty(exports, "systemLookup", {
|
|
1708
|
+
enumerable: true,
|
|
1709
|
+
get: function() {
|
|
1710
|
+
return systemLookup;
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
Object.defineProperty(exports, "topicConnection", {
|
|
1714
|
+
enumerable: true,
|
|
1715
|
+
get: function() {
|
|
1716
|
+
return topicConnection;
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
|
|
1720
|
+
//# sourceMappingURL=snsSubscriptions-Y9declDd.cjs.map
|