@geekmidas/cli 10.0.0-alpha.161 → 10.0.0-alpha.163
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/dist/{GoDaddyProvider-CwqdLM1E.mjs → GoDaddyProvider-COSh6bNI.mjs} +2 -2
- package/dist/{GoDaddyProvider-CwqdLM1E.mjs.map → GoDaddyProvider-COSh6bNI.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-CBqsvbER.cjs → GoDaddyProvider-DyhN8PEn.cjs} +2 -2
- package/dist/{GoDaddyProvider-CBqsvbER.cjs.map → GoDaddyProvider-DyhN8PEn.cjs.map} +1 -1
- package/dist/{HostingerProvider-gD4uqzMN.mjs → HostingerProvider-5Nekoneq.mjs} +2 -2
- package/dist/{HostingerProvider-gD4uqzMN.mjs.map → HostingerProvider-5Nekoneq.mjs.map} +1 -1
- package/dist/{HostingerProvider-DtOtsFkM.cjs → HostingerProvider-DG08aTyh.cjs} +2 -2
- package/dist/{HostingerProvider-DtOtsFkM.cjs.map → HostingerProvider-DG08aTyh.cjs.map} +1 -1
- package/dist/{LegacyStateStore-C0rm5slD.cjs → LegacyStateStore-5W4kFia3.cjs} +2 -2
- package/dist/{LegacyStateStore-C0rm5slD.cjs.map → LegacyStateStore-5W4kFia3.cjs.map} +1 -1
- package/dist/{LegacyStateStore-6xsGADme.mjs → LegacyStateStore-CafGn2Yl.mjs} +2 -2
- package/dist/{LegacyStateStore-6xsGADme.mjs.map → LegacyStateStore-CafGn2Yl.mjs.map} +1 -1
- package/dist/{LocalStateStore-NBMF3zCb.cjs → LocalStateStore--CJ7ksx6.cjs} +2 -2
- package/dist/{LocalStateStore-NBMF3zCb.cjs.map → LocalStateStore--CJ7ksx6.cjs.map} +1 -1
- package/dist/{LocalStateStore-G0JHXOVW.mjs → LocalStateStore-DrTw_EIu.mjs} +2 -2
- package/dist/{LocalStateStore-G0JHXOVW.mjs.map → LocalStateStore-DrTw_EIu.mjs.map} +1 -1
- package/dist/{S3StateStore-B7IPTvu0.mjs → S3StateStore-DGEwSkf2.mjs} +4 -4
- package/dist/{S3StateStore-B7IPTvu0.mjs.map → S3StateStore-DGEwSkf2.mjs.map} +1 -1
- package/dist/{S3StateStore-7n6gIYEJ.cjs → S3StateStore-M8vVPpr7.cjs} +4 -4
- package/dist/{S3StateStore-7n6gIYEJ.cjs.map → S3StateStore-M8vVPpr7.cjs.map} +1 -1
- package/dist/{SSMStateStore-O12NeGEg.cjs → SSMStateStore-B2A27u0C.cjs} +2 -2
- package/dist/{SSMStateStore-O12NeGEg.cjs.map → SSMStateStore-B2A27u0C.cjs.map} +1 -1
- package/dist/{SSMStateStore-CWEShHLS.mjs → SSMStateStore-VYfuykBd.mjs} +2 -2
- package/dist/{SSMStateStore-CWEShHLS.mjs.map → SSMStateStore-VYfuykBd.mjs.map} +1 -1
- package/dist/{add-ktNZmJb-.cjs → add-CijlgwVr.cjs} +6 -6
- package/dist/{add-ktNZmJb-.cjs.map → add-CijlgwVr.cjs.map} +1 -1
- package/dist/{add-C-nlqQgN.mjs → add-CistiUc6.mjs} +6 -6
- package/dist/{add-C-nlqQgN.mjs.map → add-CistiUc6.mjs.map} +1 -1
- package/dist/{apps-CtjYJS9e.cjs → apps-5iJb710M.cjs} +5 -5
- package/dist/{apps-CtjYJS9e.cjs.map → apps-5iJb710M.cjs.map} +1 -1
- package/dist/{apps-C7SujLV-.mjs → apps-BE97n0jO.mjs} +5 -5
- package/dist/{apps-C7SujLV-.mjs.map → apps-BE97n0jO.mjs.map} +1 -1
- package/dist/{bundler-DnHKVaZz.mjs → bundler-D-SXSUZI.mjs} +6 -6
- package/dist/{bundler-DnHKVaZz.mjs.map → bundler-D-SXSUZI.mjs.map} +1 -1
- package/dist/{bundler-DGwgZmim.cjs → bundler-D4E7kCYb.cjs} +6 -6
- package/dist/{bundler-DGwgZmim.cjs.map → bundler-D4E7kCYb.cjs.map} +1 -1
- package/dist/{cli-CI9v138l.mjs → cli-BAn-gJ6S.mjs} +5 -5
- package/dist/{cli-CI9v138l.mjs.map → cli-BAn-gJ6S.mjs.map} +1 -1
- package/dist/{cli-k2G7rG15.cjs → cli-CI-wO3-w.cjs} +5 -5
- package/dist/{cli-k2G7rG15.cjs.map → cli-CI-wO3-w.cjs.map} +1 -1
- package/dist/{compose-nGgRylPu.cjs → compose-BoxgqTF8.cjs} +8 -8
- package/dist/{compose-nGgRylPu.cjs.map → compose-BoxgqTF8.cjs.map} +1 -1
- package/dist/{compose-Co-Dt-a4.mjs → compose-CuoV9T9U.mjs} +6 -6
- package/dist/{compose-Co-Dt-a4.mjs.map → compose-CuoV9T9U.mjs.map} +1 -1
- package/dist/{compose-reJW9x-G.mjs → compose-Dk0Z8zdf.mjs} +8 -8
- package/dist/{compose-reJW9x-G.mjs.map → compose-Dk0Z8zdf.mjs.map} +1 -1
- package/dist/{compose-BD2rwRfn.cjs → compose-Dpkkp-Qq.cjs} +6 -6
- package/dist/{compose-BD2rwRfn.cjs.map → compose-Dpkkp-Qq.cjs.map} +1 -1
- package/dist/{config-CfI2g_Ho.d.mts → config-BxSSAzVi.d.mts} +3 -3
- package/dist/{config-C60T2h98.d.cts.map → config-BxSSAzVi.d.mts.map} +1 -1
- package/dist/{config-B5Hi3mLK.cjs → config-CLXSXbcs.cjs} +2 -2
- package/dist/{config-B5Hi3mLK.cjs.map → config-CLXSXbcs.cjs.map} +1 -1
- package/dist/{config-C60T2h98.d.cts → config-DNoWqavN.d.cts} +3 -3
- package/dist/{config-CfI2g_Ho.d.mts.map → config-DNoWqavN.d.cts.map} +1 -1
- package/dist/{config-DWTUVGRE.mjs → config-Da9bxnkT.mjs} +2 -2
- package/dist/{config-DWTUVGRE.mjs.map → config-Da9bxnkT.mjs.map} +1 -1
- package/dist/config.cjs +2 -2
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +2 -2
- package/dist/{credentials-UlL1n_Rd.cjs → credentials-BR3dNNtO.cjs} +6 -6
- package/dist/{credentials-UlL1n_Rd.cjs.map → credentials-BR3dNNtO.cjs.map} +1 -1
- package/dist/{credentials-BG1KOq9I.mjs → credentials-DhCCRQJp.mjs} +6 -6
- package/dist/{credentials-BG1KOq9I.mjs.map → credentials-DhCCRQJp.mjs.map} +1 -1
- package/dist/deploy/public.cjs +12 -12
- package/dist/deploy/public.d.cts +4 -4
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +4 -4
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +12 -12
- package/dist/{deploy-DRkCNV7f.mjs → deploy-C4Qb-A-z.mjs} +311 -28
- package/dist/deploy-C4Qb-A-z.mjs.map +1 -0
- package/dist/{deploy-CqIULk0k.cjs → deploy-CGywNg5R.cjs} +314 -31
- package/dist/deploy-CGywNg5R.cjs.map +1 -0
- package/dist/{destroy-CMldkiX-.cjs → destroy-IUx8vz1q.cjs} +10 -10
- package/dist/{destroy-CMldkiX-.cjs.map → destroy-IUx8vz1q.cjs.map} +1 -1
- package/dist/{destroy-DXIAL8nF.mjs → destroy-xjqqzAmU.mjs} +10 -10
- package/dist/{destroy-DXIAL8nF.mjs.map → destroy-xjqqzAmU.mjs.map} +1 -1
- package/dist/{docker-LwJW3dx_.cjs → docker-CIpOFfOw.cjs} +5 -5
- package/dist/{docker-LwJW3dx_.cjs.map → docker-CIpOFfOw.cjs.map} +1 -1
- package/dist/{docker-DFFzQe2f.mjs → docker-zaY5JoqN.mjs} +5 -5
- package/dist/{docker-DFFzQe2f.mjs.map → docker-zaY5JoqN.mjs.map} +1 -1
- package/dist/{dokploy-DYm0D6Tp.mjs → dokploy-BTzdAG5F.mjs} +2 -2
- package/dist/{dokploy-DYm0D6Tp.mjs.map → dokploy-BTzdAG5F.mjs.map} +1 -1
- package/dist/{dokploy-wTsJqG-N.cjs → dokploy-DLVSItVD.cjs} +2 -2
- package/dist/{dokploy-wTsJqG-N.cjs.map → dokploy-DLVSItVD.cjs.map} +1 -1
- package/dist/{eas-C4EkjTGJ.cjs → eas-B6VYsGLs.cjs} +3 -3
- package/dist/{eas-C4EkjTGJ.cjs.map → eas-B6VYsGLs.cjs.map} +1 -1
- package/dist/{eas-BJ_Zlvm8.mjs → eas-C1WvLOi1.mjs} +3 -3
- package/dist/{eas-BJ_Zlvm8.mjs.map → eas-C1WvLOi1.mjs.map} +1 -1
- package/dist/{encryption-Cu5YTs9V.mjs → encryption-DdnL7dor.mjs} +4 -4
- package/dist/{encryption-Cu5YTs9V.mjs.map → encryption-DdnL7dor.mjs.map} +1 -1
- package/dist/{encryption-BQEqqrGq.cjs → encryption-oVcZSyLK.cjs} +4 -4
- package/dist/{encryption-BQEqqrGq.cjs.map → encryption-oVcZSyLK.cjs.map} +1 -1
- package/dist/{engine-q8aCVbLH.mjs → engine-Viv9p-yK.mjs} +10 -10
- package/dist/{engine-q8aCVbLH.mjs.map → engine-Viv9p-yK.mjs.map} +1 -1
- package/dist/{engine-DdRauUQC.cjs → engine-_zA1Selg.cjs} +10 -10
- package/dist/{engine-DdRauUQC.cjs.map → engine-_zA1Selg.cjs.map} +1 -1
- package/dist/{github-OVZF2k0L.cjs → github-82k5-OZO.cjs} +45 -13
- package/dist/github-82k5-OZO.cjs.map +1 -0
- package/dist/{github-CoXirRes.mjs → github-DxgGIvq1.mjs} +41 -9
- package/dist/github-DxgGIvq1.mjs.map +1 -0
- package/dist/{googlePlay-HXRRVq0l.mjs → googlePlay-C4UsG1Vd.mjs} +5 -5
- package/dist/{googlePlay-HXRRVq0l.mjs.map → googlePlay-C4UsG1Vd.mjs.map} +1 -1
- package/dist/{googlePlay-CUeTUT7s.cjs → googlePlay-C5T1SOGW.cjs} +5 -5
- package/dist/{googlePlay-CUeTUT7s.cjs.map → googlePlay-C5T1SOGW.cjs.map} +1 -1
- package/dist/{iam-6LH6wptf.cjs → iam-BVPpX76R.cjs} +65 -162
- package/dist/iam-BVPpX76R.cjs.map +1 -0
- package/dist/{iam-c0e8m04X.mjs → iam-q9ALh-Y5.mjs} +62 -129
- package/dist/iam-q9ALh-Y5.mjs.map +1 -0
- package/dist/{index-DWNwkcy7.d.mts → index-BC1BLv9Q.d.mts} +2 -2
- package/dist/{index-DDY0cZCo.d.cts.map → index-BC1BLv9Q.d.mts.map} +1 -1
- package/dist/{index-DDY0cZCo.d.cts → index-Dy4ojz5P.d.cts} +2 -2
- package/dist/{index-DWNwkcy7.d.mts.map → index-Dy4ojz5P.d.cts.map} +1 -1
- package/dist/index.cjs +64 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +64 -64
- package/dist/index.mjs.map +1 -1
- package/dist/{local-CCJ-T37d.mjs → local-Bqx5Xj3z.mjs} +2 -2
- package/dist/{local-CCJ-T37d.mjs.map → local-Bqx5Xj3z.mjs.map} +1 -1
- package/dist/{local-Dx0o6vfp.cjs → local-vSeEreyp.cjs} +2 -2
- package/dist/{local-Dx0o6vfp.cjs.map → local-vSeEreyp.cjs.map} +1 -1
- package/dist/{migrate-Dr0BeWsY.mjs → migrate-CEhUGDFy.mjs} +6 -6
- package/dist/{migrate-Dr0BeWsY.mjs.map → migrate-CEhUGDFy.mjs.map} +1 -1
- package/dist/{migrate-CJoKOCGY.cjs → migrate-CLSY8gSY.cjs} +4 -4
- package/dist/{migrate-CJoKOCGY.cjs.map → migrate-CLSY8gSY.cjs.map} +1 -1
- package/dist/{migrate-BkwSXhxv.mjs → migrate-D8PSR_08.mjs} +4 -4
- package/dist/{migrate-BkwSXhxv.mjs.map → migrate-D8PSR_08.mjs.map} +1 -1
- package/dist/{migrate-DEsYfgzn.cjs → migrate-DvdpT5Y4.cjs} +6 -6
- package/dist/{migrate-DEsYfgzn.cjs.map → migrate-DvdpT5Y4.cjs.map} +1 -1
- package/dist/{notes-VFPa51Pd.cjs → notes-B9ro_R3x.cjs} +24 -15
- package/dist/notes-B9ro_R3x.cjs.map +1 -0
- package/dist/{notes-BOyzuPqr.mjs → notes-CdbUjLBC.mjs} +24 -15
- package/dist/notes-CdbUjLBC.mjs.map +1 -0
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +2 -2
- package/dist/{projectBucket-B26ucBRI.mjs → projectBucket-DPaUiLyY.mjs} +2 -2
- package/dist/{projectBucket-B26ucBRI.mjs.map → projectBucket-DPaUiLyY.mjs.map} +1 -1
- package/dist/{projectBucket-CWpY3Vxv.cjs → projectBucket-DUtWAxWn.cjs} +2 -2
- package/dist/{projectBucket-CWpY3Vxv.cjs.map → projectBucket-DUtWAxWn.cjs.map} +1 -1
- package/dist/{publish-Bg4iffje.mjs → publish-CoCRpbPl.mjs} +2 -2
- package/dist/{publish-Bg4iffje.mjs.map → publish-CoCRpbPl.mjs.map} +1 -1
- package/dist/{publish-IjcRoorJ.cjs → publish-DbR3j4TS.cjs} +2 -2
- package/dist/{publish-IjcRoorJ.cjs.map → publish-DbR3j4TS.cjs.map} +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/{resolve-rw7mLp5E.mjs → resolve-BjRvKEpw.mjs} +4 -4
- package/dist/{resolve-rw7mLp5E.mjs.map → resolve-BjRvKEpw.mjs.map} +1 -1
- package/dist/{resolve-CgVDhWW8.cjs → resolve-DDcPuS_G.cjs} +4 -4
- package/dist/{resolve-CgVDhWW8.cjs.map → resolve-DDcPuS_G.cjs.map} +1 -1
- package/dist/{rollback-vdkPi_Rm.cjs → rollback-CvlebzBY.cjs} +7 -7
- package/dist/{rollback-vdkPi_Rm.cjs.map → rollback-CvlebzBY.cjs.map} +1 -1
- package/dist/{rollback-Cv02Cnky.mjs → rollback-xLGFZaHy.mjs} +7 -7
- package/dist/{rollback-Cv02Cnky.mjs.map → rollback-xLGFZaHy.mjs.map} +1 -1
- package/dist/{runtime-D-rOcRoq.d.cts → runtime-BySbkdBz.d.cts} +2 -2
- package/dist/{runtime-D-rOcRoq.d.cts.map → runtime-BySbkdBz.d.cts.map} +1 -1
- package/dist/{runtime-DG1mNh_5.d.mts → runtime-MZ5Pqgan.d.mts} +2 -2
- package/dist/{runtime-DG1mNh_5.d.mts.map → runtime-MZ5Pqgan.d.mts.map} +1 -1
- package/dist/{s3-DmsM_V2R.mjs → s3-CXA6Lleo.mjs} +3 -3
- package/dist/{s3-DmsM_V2R.mjs.map → s3-CXA6Lleo.mjs.map} +1 -1
- package/dist/{s3-DIvAtJwk.cjs → s3-D9pFisyo.cjs} +3 -3
- package/dist/{s3-DIvAtJwk.cjs.map → s3-D9pFisyo.cjs.map} +1 -1
- package/dist/{serverSetup-qXIRRhgw.cjs → serverSetup-BXk8SGuz.cjs} +7 -7
- package/dist/{serverSetup-qXIRRhgw.cjs.map → serverSetup-BXk8SGuz.cjs.map} +1 -1
- package/dist/{serverSetup-CvcN4zJQ.mjs → serverSetup-CzoKT3nH.mjs} +7 -7
- package/dist/{serverSetup-CvcN4zJQ.mjs.map → serverSetup-CzoKT3nH.mjs.map} +1 -1
- package/dist/{sniffer-CGfL25Bc.cjs → sniffer-B2jgjk-F.cjs} +7 -7
- package/dist/{sniffer-CGfL25Bc.cjs.map → sniffer-B2jgjk-F.cjs.map} +1 -1
- package/dist/{sniffer-DuKVVAs_.mjs → sniffer-Csft3UaJ.mjs} +7 -7
- package/dist/{sniffer-DuKVVAs_.mjs.map → sniffer-Csft3UaJ.mjs.map} +1 -1
- package/dist/{snsSubscriptions-DPfGjpuB.cjs → snsSubscriptions-CSyPnoEQ.cjs} +3 -3
- package/dist/{snsSubscriptions-DPfGjpuB.cjs.map → snsSubscriptions-CSyPnoEQ.cjs.map} +1 -1
- package/dist/{snsSubscriptions-nnSUW2Eh.mjs → snsSubscriptions-DgbFGyac.mjs} +3 -3
- package/dist/{snsSubscriptions-nnSUW2Eh.mjs.map → snsSubscriptions-DgbFGyac.mjs.map} +1 -1
- package/dist/{sst-Md7c1UC_.cjs → sst-BtrgnhHy.cjs} +5 -5
- package/dist/{sst-Md7c1UC_.cjs.map → sst-BtrgnhHy.cjs.map} +1 -1
- package/dist/{sst-Bw7686br.mjs → sst-CmNUadAV.mjs} +5 -5
- package/dist/{sst-Bw7686br.mjs.map → sst-CmNUadAV.mjs.map} +1 -1
- package/dist/{stack-DTcnynGb.cjs → stack-9qBhn2pd.cjs} +8 -8
- package/dist/{stack-DTcnynGb.cjs.map → stack-9qBhn2pd.cjs.map} +1 -1
- package/dist/{stack-D2cLLaO-.mjs → stack-dVgzDUiH.mjs} +8 -8
- package/dist/{stack-D2cLLaO-.mjs.map → stack-dVgzDUiH.mjs.map} +1 -1
- package/dist/{stage-Bw3bJ7Au.mjs → stage-CwXpkN-y.mjs} +7 -7
- package/dist/{stage-Bw3bJ7Au.mjs.map → stage-CwXpkN-y.mjs.map} +1 -1
- package/dist/{stage-RLOenlHV.cjs → stage-HEZZZJKr.cjs} +7 -7
- package/dist/{stage-RLOenlHV.cjs.map → stage-HEZZZJKr.cjs.map} +1 -1
- package/dist/{stages-yA9bhStl.mjs → stages-gG-DGHLb.mjs} +3 -3
- package/dist/{stages-yA9bhStl.mjs.map → stages-gG-DGHLb.mjs.map} +1 -1
- package/dist/{stages-B0yOikgt.cjs → stages-rzyes8Ew.cjs} +3 -3
- package/dist/{stages-B0yOikgt.cjs.map → stages-rzyes8Ew.cjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-C-_cMKTY.cjs → terminal-8AA2uK0U.cjs} +2 -2
- package/dist/{terminal-C-_cMKTY.cjs.map → terminal-8AA2uK0U.cjs.map} +1 -1
- package/dist/{terminal-Dq29bK3u.mjs → terminal-BqqGsi0O.mjs} +2 -2
- package/dist/{terminal-Dq29bK3u.mjs.map → terminal-BqqGsi0O.mjs.map} +1 -1
- package/dist/{types-CvucX3yD.d.mts → types-BXboFkn9.d.mts} +50 -2
- package/dist/types-BXboFkn9.d.mts.map +1 -0
- package/dist/{types-D1C8pUyh.d.cts → types-BsfPHUFZ.d.cts} +50 -2
- package/dist/types-BsfPHUFZ.d.cts.map +1 -0
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-DFGsrjGD.mjs → workspace-D5Vm2qcy.mjs} +165 -9
- package/dist/workspace-D5Vm2qcy.mjs.map +1 -0
- package/dist/{workspace-1szcahj9.cjs → workspace-VhzmoxOv.cjs} +224 -8
- package/dist/workspace-VhzmoxOv.cjs.map +1 -0
- package/package.json +15 -15
- package/dist/deploy-CqIULk0k.cjs.map +0 -1
- package/dist/deploy-DRkCNV7f.mjs.map +0 -1
- package/dist/github-CoXirRes.mjs.map +0 -1
- package/dist/github-OVZF2k0L.cjs.map +0 -1
- package/dist/iam-6LH6wptf.cjs.map +0 -1
- package/dist/iam-c0e8m04X.mjs.map +0 -1
- package/dist/notes-BOyzuPqr.mjs.map +0 -1
- package/dist/notes-VFPa51Pd.cjs.map +0 -1
- package/dist/types-CvucX3yD.d.mts.map +0 -1
- package/dist/types-D1C8pUyh.d.cts.map +0 -1
- package/dist/workspace-1szcahj9.cjs.map +0 -1
- package/dist/workspace-DFGsrjGD.mjs.map +0 -1
|
@@ -1,93 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
|
-
const
|
|
3
|
-
const require_workspace = require("./workspace-1szcahj9.cjs");
|
|
4
|
-
let node_crypto = require("node:crypto");
|
|
5
|
-
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
2
|
+
const require_workspace = require("./workspace-VhzmoxOv.cjs");
|
|
6
3
|
let _geekmidas_storage_s3_url = require("@geekmidas/storage/s3-url");
|
|
7
4
|
_geekmidas_storage_s3_url = require_rolldown_runtime.__toESM(_geekmidas_storage_s3_url, 1);
|
|
8
|
-
const SUFFIX_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
9
|
-
/** A name that S3 would refuse — what the name builder never returns. */
|
|
10
|
-
var InvalidBucketName = class extends require_errors.GkmError {
|
|
11
|
-
bucket;
|
|
12
|
-
reason;
|
|
13
|
-
constructor(bucket, reason) {
|
|
14
|
-
super(`'${bucket}' is not a valid S3 bucket name: ${reason}. Rename the construct or set deploy.namespace in gkm.config.ts to something that leaves room for it.`);
|
|
15
|
-
this.bucket = bucket;
|
|
16
|
-
this.reason = reason;
|
|
17
|
-
this.name = "InvalidBucketName";
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
/** Lowercase `[a-z0-9-]`, runs of anything else one `-`, no edge dashes. */
|
|
21
|
-
function part(value) {
|
|
22
|
-
return (0, _geekmidas_manifest.kebabCase)(value).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* `parts` joined by `-`, shortened to `max` characters by trimming the longest
|
|
26
|
-
* part one character at a time — so a long construct id gives way before a
|
|
27
|
-
* short stage name does, and every part keeps its start.
|
|
28
|
-
*/
|
|
29
|
-
function fitParts(parts, max) {
|
|
30
|
-
const kept = parts.map(part).filter(Boolean);
|
|
31
|
-
const length = () => kept.reduce((sum, p) => sum + p.length, 0) + kept.length - 1;
|
|
32
|
-
while (length() > max) {
|
|
33
|
-
let longest = 0;
|
|
34
|
-
for (let i = 1; i < kept.length; i++) if (kept[i].length > kept[longest].length) longest = i;
|
|
35
|
-
if (kept[longest].length <= 1) break;
|
|
36
|
-
kept[longest] = kept[longest].slice(0, -1).replace(/-+$/, "");
|
|
37
|
-
}
|
|
38
|
-
return kept.join("-");
|
|
39
|
-
}
|
|
40
|
-
/** Why `name` is not a valid bucket name, or undefined when it is. */
|
|
41
|
-
function bucketNameProblem(name) {
|
|
42
|
-
if (name.length < 3 || name.length > 63) return `it is ${name.length} characters, and S3 takes 3 to 63`;
|
|
43
|
-
if (!/^[a-z0-9-]+$/.test(name)) return "it may hold only lowercase letters, digits and -";
|
|
44
|
-
if (!/^[a-z0-9].*[a-z0-9]$/.test(name)) return "it must start and end with a letter or a digit";
|
|
45
|
-
if (name.startsWith("xn--") || name.startsWith("sthree-")) return "it starts with a prefix S3 reserves ('xn--', 'sthree-')";
|
|
46
|
-
if (name.endsWith("-s3alias") || name.endsWith("--ol-s3")) return "it ends with a suffix S3 reserves ('-s3alias', '--ol-s3')";
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* The good name: `<namespace>-<project>-<stage>-<bucket id>`, lowercased, no
|
|
50
|
-
* dots, shortened to leave room for a clash's suffix.
|
|
51
|
-
*
|
|
52
|
-
* @throws {InvalidBucketName} when nothing usable is left
|
|
53
|
-
*/
|
|
54
|
-
function bucketName(input) {
|
|
55
|
-
const name = fitParts([
|
|
56
|
-
input.scope,
|
|
57
|
-
input.stage,
|
|
58
|
-
input.id
|
|
59
|
-
], 56);
|
|
60
|
-
const problem = bucketNameProblem(name);
|
|
61
|
-
if (problem) throw new InvalidBucketName(name, problem);
|
|
62
|
-
return name;
|
|
63
|
-
}
|
|
64
|
-
/** Six random `[a-z0-9]` characters. */
|
|
65
|
-
function randomSuffix(random = node_crypto.randomInt) {
|
|
66
|
-
let suffix = "";
|
|
67
|
-
for (let i = 0; i < 6; i++) suffix += SUFFIX_ALPHABET[random(36)];
|
|
68
|
-
return suffix;
|
|
69
|
-
}
|
|
70
|
-
/** The good name with a clash's suffix. */
|
|
71
|
-
function suffixedBucketName(good, suffix) {
|
|
72
|
-
return `${good}-${suffix}`;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* The IAM user a bucket is reached with on a stage:
|
|
76
|
-
* `gkm-<project>-<stage>-<bucket id>`, at most 64 characters.
|
|
77
|
-
*/
|
|
78
|
-
function iamUserName(input) {
|
|
79
|
-
return fitParts([
|
|
80
|
-
"gkm",
|
|
81
|
-
input.scope,
|
|
82
|
-
input.stage,
|
|
83
|
-
input.id
|
|
84
|
-
], 64);
|
|
85
|
-
}
|
|
86
|
-
/** The path every user gkm creates is under, so it finds its own. */
|
|
87
|
-
const IAM_USER_PATH = "/gkm/";
|
|
88
|
-
/** The inline policy each user is given. */
|
|
89
|
-
const IAM_POLICY_NAME = "gkm-bucket";
|
|
90
|
-
//#endregion
|
|
91
5
|
//#region src/providers/s3/policy.ts
|
|
92
6
|
const bucketArn = (bucket) => `arn:aws:s3:::${bucket}`;
|
|
93
7
|
/**
|
|
@@ -240,9 +154,9 @@ function canonical(value, key) {
|
|
|
240
154
|
//#region src/providers/iam.ts
|
|
241
155
|
/**
|
|
242
156
|
* An IAM user gkm creates for one thing on a stage, its inline policy, and
|
|
243
|
-
* the access key written into the stage's secrets as an `s3://` URL
|
|
244
|
-
* the `s3` provider gives each bucket
|
|
245
|
-
* backups.
|
|
157
|
+
* the access key written into the stage's secrets — as an `s3://` URL for
|
|
158
|
+
* what the `s3` provider gives each bucket and the deploy gives a stage's
|
|
159
|
+
* backups, as an `smtp://` one for the `ses` mail provider.
|
|
246
160
|
*
|
|
247
161
|
* - **The user** is under `/gkm/`, tagged with the deploy identity, the stage
|
|
248
162
|
* and what it is for. One that exists without those tags is someone
|
|
@@ -317,12 +231,12 @@ async function ensureIamUser(ctx, clients, input) {
|
|
|
317
231
|
} else await ctx.change({
|
|
318
232
|
construct: id,
|
|
319
233
|
resource: `IAM user ${user}`,
|
|
320
|
-
change: `create under ${IAM_USER_PATH}`
|
|
234
|
+
change: `create under ${require_workspace.IAM_USER_PATH}`
|
|
321
235
|
}, async () => {
|
|
322
236
|
await ctx.state.pending(entry);
|
|
323
237
|
await iam.send(new IAM.CreateUserCommand({
|
|
324
238
|
UserName: user,
|
|
325
|
-
Path: IAM_USER_PATH,
|
|
239
|
+
Path: require_workspace.IAM_USER_PATH,
|
|
326
240
|
Tags: identityTags(ctx, id)
|
|
327
241
|
}));
|
|
328
242
|
await ctx.state.ready(entry, user);
|
|
@@ -350,7 +264,50 @@ async function ensureIamUser(ctx, clients, input) {
|
|
|
350
264
|
};
|
|
351
265
|
}
|
|
352
266
|
/**
|
|
353
|
-
*
|
|
267
|
+
* A bucket's URL as a key's secret: `s3://KEY:SECRET@bucket?region=…`.
|
|
268
|
+
*
|
|
269
|
+
* @throws {BucketKeySetElsewhere} from `keyIdOf`, when the URL names another bucket
|
|
270
|
+
*/
|
|
271
|
+
function s3KeySecret(ctx, clients, input) {
|
|
272
|
+
const { bucket, urlKey } = input;
|
|
273
|
+
const parse = (value) => {
|
|
274
|
+
let parsed;
|
|
275
|
+
try {
|
|
276
|
+
parsed = _geekmidas_storage_s3_url.parse(value);
|
|
277
|
+
} catch {
|
|
278
|
+
parsed = void 0;
|
|
279
|
+
}
|
|
280
|
+
if (parsed?.bucket !== bucket) throw new require_workspace.BucketKeySetElsewhere(urlKey, bucket, parsed?.bucket ?? value.replace(/\/\/[^@]*@/, "//"), ctx.stage);
|
|
281
|
+
return parsed;
|
|
282
|
+
};
|
|
283
|
+
return {
|
|
284
|
+
key: urlKey,
|
|
285
|
+
keyIdOf: (value) => parse(value).accessKeyId,
|
|
286
|
+
value: (accessKeyId, secretAccessKey) => _geekmidas_storage_s3_url.build({
|
|
287
|
+
bucket,
|
|
288
|
+
region: clients.region,
|
|
289
|
+
...clients.endpoint ? {
|
|
290
|
+
endpoint: clients.endpoint,
|
|
291
|
+
forcePathStyle: true
|
|
292
|
+
} : {},
|
|
293
|
+
accessKeyId,
|
|
294
|
+
secretAccessKey
|
|
295
|
+
}),
|
|
296
|
+
repair(value) {
|
|
297
|
+
const address = parse(value);
|
|
298
|
+
if (address.region === clients.region) return void 0;
|
|
299
|
+
return {
|
|
300
|
+
value: _geekmidas_storage_s3_url.build({
|
|
301
|
+
...address,
|
|
302
|
+
region: clients.region
|
|
303
|
+
}),
|
|
304
|
+
change: `name ${clients.region}, the bucket's region (it said ${address.region ?? "none"})`
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* The user's access key, in the stage's secrets as `secret` writes it.
|
|
354
311
|
*
|
|
355
312
|
* - First run: one key, written into the stage's secrets.
|
|
356
313
|
* - `--rotate-keys`: a second key, written in place of the first; the first
|
|
@@ -359,27 +316,17 @@ async function ensureIamUser(ctx, clients, input) {
|
|
|
359
316
|
* - A key the secrets no longer hold (a store emptied by hand): replaced the
|
|
360
317
|
* same way, since its secret cannot be read back.
|
|
361
318
|
*
|
|
362
|
-
* @throws
|
|
319
|
+
* @throws whatever `secret.keyIdOf` throws for a value set elsewhere
|
|
363
320
|
* @throws {RotationInProgress} on `--rotate-keys` with the last rotation's old key still active
|
|
364
321
|
* @throws {AccessKeyLimit} when the user has two keys gkm did not record
|
|
365
322
|
*/
|
|
366
323
|
async function ensureAccessKey(ctx, clients, input) {
|
|
367
324
|
const { IAM, iam } = clients;
|
|
368
|
-
const { id,
|
|
325
|
+
const { id, user, secret } = input;
|
|
369
326
|
const entryKey = `iam-access-key:${id}`;
|
|
370
327
|
const record = ctx.state.record(entryKey);
|
|
371
|
-
const given = ctx.secrets[
|
|
372
|
-
|
|
373
|
-
let parsed;
|
|
374
|
-
if (given !== void 0) {
|
|
375
|
-
try {
|
|
376
|
-
parsed = _geekmidas_storage_s3_url.parse(given);
|
|
377
|
-
} catch {
|
|
378
|
-
parsed = void 0;
|
|
379
|
-
}
|
|
380
|
-
if (parsed?.bucket !== bucket) throw new require_workspace.BucketKeySetElsewhere(urlKey, bucket, parsed?.bucket ?? given.replace(/\/\/[^@]*@/, "//"), ctx.stage);
|
|
381
|
-
inUrl = parsed.accessKeyId;
|
|
382
|
-
}
|
|
328
|
+
const given = ctx.secrets[secret.key];
|
|
329
|
+
const inUrl = given !== void 0 ? secret.keyIdOf(given) : void 0;
|
|
383
330
|
const listed = input.exists ? (await iam.send(new IAM.ListAccessKeysCommand({ UserName: user }))).AccessKeyMetadata?.map((k) => k.AccessKeyId) ?? [] : [];
|
|
384
331
|
let current = record?.status === "ready" ? record.id : void 0;
|
|
385
332
|
let previous = typeof record?.data?.previous === "string" ? record.data.previous : void 0;
|
|
@@ -416,17 +363,12 @@ async function ensureAccessKey(ctx, clients, input) {
|
|
|
416
363
|
current = inUrl;
|
|
417
364
|
}
|
|
418
365
|
if (current !== void 0 && listed.includes(current) && inUrl === current && !ctx.rotateKeys) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}, () => ctx.writeSecrets({ [urlKey]: _geekmidas_storage_s3_url.build({
|
|
426
|
-
...address,
|
|
427
|
-
region: clients.region
|
|
428
|
-
}) }));
|
|
429
|
-
}
|
|
366
|
+
const repaired = given !== void 0 ? secret.repair?.(given) : void 0;
|
|
367
|
+
if (repaired) await ctx.change({
|
|
368
|
+
construct: id,
|
|
369
|
+
resource: secret.key,
|
|
370
|
+
change: repaired.change
|
|
371
|
+
}, () => ctx.writeSecrets({ [secret.key]: repaired.value }));
|
|
430
372
|
return;
|
|
431
373
|
}
|
|
432
374
|
if (ctx.rotateKeys && previous) throw new require_workspace.RotationInProgress(id, previous, ctx.stage);
|
|
@@ -440,16 +382,7 @@ async function ensureAccessKey(ctx, clients, input) {
|
|
|
440
382
|
}, async () => {
|
|
441
383
|
await ctx.state.pending(entry(outgoing ? { previous: outgoing } : {}));
|
|
442
384
|
const key = (await iam.send(new IAM.CreateAccessKeyCommand({ UserName: user }))).AccessKey;
|
|
443
|
-
await ctx.writeSecrets({ [
|
|
444
|
-
bucket,
|
|
445
|
-
region: clients.region,
|
|
446
|
-
...clients.endpoint ? {
|
|
447
|
-
endpoint: clients.endpoint,
|
|
448
|
-
forcePathStyle: true
|
|
449
|
-
} : {},
|
|
450
|
-
accessKeyId: key.AccessKeyId,
|
|
451
|
-
secretAccessKey: key.SecretAccessKey
|
|
452
|
-
}) });
|
|
385
|
+
await ctx.writeSecrets({ [secret.key]: secret.value(key.AccessKeyId, key.SecretAccessKey) });
|
|
453
386
|
const issuedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
454
387
|
await ctx.state.ready(entry(outgoing ? {
|
|
455
388
|
previous: outgoing,
|
|
@@ -457,7 +390,7 @@ async function ensureAccessKey(ctx, clients, input) {
|
|
|
457
390
|
issuedAt
|
|
458
391
|
} : { issuedAt }), key.AccessKeyId);
|
|
459
392
|
});
|
|
460
|
-
if (outgoing) ctx.log(` ${
|
|
393
|
+
if (outgoing) ctx.log(` ${secret.key} holds the new key. This deploy moves '${ctx.stage}' onto it; the next deploy after it deletes the old key ${outgoing}`);
|
|
461
394
|
}
|
|
462
395
|
/** How long a key issued this recently counts as new to IAM. */
|
|
463
396
|
const NEW_KEY_WINDOW_MS = 6e5;
|
|
@@ -506,18 +439,6 @@ async function whileKeyIsNew(first, options) {
|
|
|
506
439
|
};
|
|
507
440
|
}
|
|
508
441
|
//#endregion
|
|
509
|
-
Object.defineProperty(exports, "IAM_POLICY_NAME", {
|
|
510
|
-
enumerable: true,
|
|
511
|
-
get: function() {
|
|
512
|
-
return IAM_POLICY_NAME;
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
Object.defineProperty(exports, "IAM_USER_PATH", {
|
|
516
|
-
enumerable: true,
|
|
517
|
-
get: function() {
|
|
518
|
-
return IAM_USER_PATH;
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
442
|
Object.defineProperty(exports, "TAG_PROJECT", {
|
|
522
443
|
enumerable: true,
|
|
523
444
|
get: function() {
|
|
@@ -530,12 +451,6 @@ Object.defineProperty(exports, "TAG_STAGE", {
|
|
|
530
451
|
return TAG_STAGE;
|
|
531
452
|
}
|
|
532
453
|
});
|
|
533
|
-
Object.defineProperty(exports, "bucketName", {
|
|
534
|
-
enumerable: true,
|
|
535
|
-
get: function() {
|
|
536
|
-
return bucketName;
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
454
|
Object.defineProperty(exports, "bucketPolicy", {
|
|
540
455
|
enumerable: true,
|
|
541
456
|
get: function() {
|
|
@@ -566,12 +481,6 @@ Object.defineProperty(exports, "ensureIamUser", {
|
|
|
566
481
|
return ensureIamUser;
|
|
567
482
|
}
|
|
568
483
|
});
|
|
569
|
-
Object.defineProperty(exports, "iamUserName", {
|
|
570
|
-
enumerable: true,
|
|
571
|
-
get: function() {
|
|
572
|
-
return iamUserName;
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
484
|
Object.defineProperty(exports, "identityTags", {
|
|
576
485
|
enumerable: true,
|
|
577
486
|
get: function() {
|
|
@@ -590,16 +499,10 @@ Object.defineProperty(exports, "publicAccessBlock", {
|
|
|
590
499
|
return publicAccessBlock;
|
|
591
500
|
}
|
|
592
501
|
});
|
|
593
|
-
Object.defineProperty(exports, "
|
|
594
|
-
enumerable: true,
|
|
595
|
-
get: function() {
|
|
596
|
-
return randomSuffix;
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
Object.defineProperty(exports, "suffixedBucketName", {
|
|
502
|
+
Object.defineProperty(exports, "s3KeySecret", {
|
|
600
503
|
enumerable: true,
|
|
601
504
|
get: function() {
|
|
602
|
-
return
|
|
505
|
+
return s3KeySecret;
|
|
603
506
|
}
|
|
604
507
|
});
|
|
605
508
|
Object.defineProperty(exports, "userPolicy", {
|
|
@@ -615,4 +518,4 @@ Object.defineProperty(exports, "whileKeyIsNew", {
|
|
|
615
518
|
}
|
|
616
519
|
});
|
|
617
520
|
|
|
618
|
-
//# sourceMappingURL=iam-
|
|
521
|
+
//# sourceMappingURL=iam-BVPpX76R.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam-BVPpX76R.cjs","names":["IamUserNotOwned","IAM_USER_PATH","s3Url","BucketKeySetElsewhere","RotationInProgress","AccessKeyLimit"],"sources":["../src/providers/s3/policy.ts","../src/providers/iam.ts"],"sourcesContent":["/**\n * The documents the `s3` provider writes: the user's inline policy, the\n * bucket's policy, its CORS rule and its public access block.\n *\n * Pure, so each is tested as JSON and compared with what AWS holds on every\n * run — a document that differs is drift, and is put back.\n */\n\n/** One IAM or bucket policy statement. */\nexport interface PolicyStatement {\n\tSid: string;\n\tEffect: 'Allow' | 'Deny';\n\tPrincipal?: '*' | { AWS: string | string[] } | { Service: string };\n\tAction: string | string[];\n\tResource: string | string[];\n\tCondition?: Record<string, Record<string, string | string[]>>;\n}\n\nexport interface PolicyDocument {\n\tVersion: '2012-10-17';\n\tStatement: PolicyStatement[];\n}\n\nconst bucketArn = (bucket: string) => `arn:aws:s3:::${bucket}`;\n\n/**\n * What the app's key may do: objects in this bucket, and listing it — and\n * nothing else in the account.\n *\n * Multipart uploads are in it because a presigned upload of a large file is\n * one, and an abandoned one is cleaned up by the app. Reading old versions is\n * added only when the bucket keeps them.\n */\nexport function userPolicy(\n\tbucket: string,\n\toptions: {\n\t\tversioning?: boolean;\n\t\t/**\n\t\t * The bucket's events topic, when a subscriber watches it: the worker\n\t\t * confirms the subscriptions the deploy made with this key, and does\n\t\t * nothing else to the topic.\n\t\t */\n\t\teventsTopicArn?: string;\n\t} = {},\n): PolicyDocument {\n\treturn {\n\t\tVersion: '2012-10-17',\n\t\tStatement: [\n\t\t\t{\n\t\t\t\tSid: 'GkmObjects',\n\t\t\t\tEffect: 'Allow',\n\t\t\t\tAction: [\n\t\t\t\t\t's3:GetObject',\n\t\t\t\t\t's3:PutObject',\n\t\t\t\t\t's3:DeleteObject',\n\t\t\t\t\t's3:AbortMultipartUpload',\n\t\t\t\t\t's3:ListMultipartUploadParts',\n\t\t\t\t\t...(options.versioning ? ['s3:GetObjectVersion'] : []),\n\t\t\t\t],\n\t\t\t\tResource: `${bucketArn(bucket)}/*`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tSid: 'GkmBucket',\n\t\t\t\tEffect: 'Allow',\n\t\t\t\tAction: [\n\t\t\t\t\t's3:ListBucket',\n\t\t\t\t\t's3:GetBucketLocation',\n\t\t\t\t\t's3:ListBucketMultipartUploads',\n\t\t\t\t],\n\t\t\t\tResource: bucketArn(bucket),\n\t\t\t},\n\t\t\t...(options.eventsTopicArn\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSid: 'GkmEvents',\n\t\t\t\t\t\t\tEffect: 'Allow' as const,\n\t\t\t\t\t\t\tAction: 'sns:ConfirmSubscription',\n\t\t\t\t\t\t\tResource: options.eventsTopicArn,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t],\n\t};\n}\n\n/**\n * One open pattern as the resource it is public on. A `**` is S3's `*`; a\n * single `*` is too, which crosses `/` where the construct's own check does\n * not — the construct is the stricter of the two (see `bucketPolicy` in\n * reconcile, which the local MinIO is given the same way).\n */\nexport function openResource(bucket: string, pattern: string): string {\n\tconst path = pattern.replace(/^\\/+/, '').replace(/\\*\\*/g, '*');\n\treturn `${bucketArn(bucket)}/${path}`;\n}\n\n/**\n * The bucket's own policy: every request refused unless it came over TLS,\n * and — only when a file server opens paths on it — `s3:GetObject` on\n * exactly those prefixes: to anyone, or, when a CDN serves them, to\n * CloudFront alone, for exactly the stage's distributions. Behind a CDN the\n * bucket is never public: a key outside the open prefixes is refused to\n * CloudFront too, so the edge answers it 403.\n */\nexport function bucketPolicy(\n\tbucket: string,\n\topen: readonly string[] = [],\n\toptions: {\n\t\tcdn?: { distributionArns: readonly string[] };\n\t\t/**\n\t\t * SES may write received mail under this prefix — the bucket an inbox\n\t\t * owns — and only for this account's receipt rules.\n\t\t */\n\t\tsesWrite?: { prefix: string; account: string };\n\t} = {},\n): PolicyDocument {\n\tconst statements: PolicyStatement[] = [\n\t\t{\n\t\t\tSid: 'GkmDenyInsecureTransport',\n\t\t\tEffect: 'Deny',\n\t\t\tPrincipal: '*',\n\t\t\tAction: 's3:*',\n\t\t\tResource: [bucketArn(bucket), `${bucketArn(bucket)}/*`],\n\t\t\tCondition: { Bool: { 'aws:SecureTransport': 'false' } },\n\t\t},\n\t];\n\tconst resources = [\n\t\t...new Set(open.map((p) => openResource(bucket, p))),\n\t].sort();\n\tif (open.length > 0 && options.cdn) {\n\t\tstatements.push({\n\t\t\tSid: 'GkmCdnRead',\n\t\t\tEffect: 'Allow',\n\t\t\tPrincipal: { Service: 'cloudfront.amazonaws.com' },\n\t\t\tAction: 's3:GetObject',\n\t\t\tResource: resources,\n\t\t\tCondition: {\n\t\t\t\tStringEquals: {\n\t\t\t\t\t'AWS:SourceArn': [...new Set(options.cdn.distributionArns)].sort(),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t} else if (open.length > 0) {\n\t\tstatements.push({\n\t\t\tSid: 'GkmOpenPaths',\n\t\t\tEffect: 'Allow',\n\t\t\tPrincipal: '*',\n\t\t\tAction: 's3:GetObject',\n\t\t\tResource: resources,\n\t\t});\n\t}\n\tif (options.sesWrite) {\n\t\tstatements.push({\n\t\t\tSid: 'GkmSesWritesMail',\n\t\t\tEffect: 'Allow',\n\t\t\tPrincipal: { Service: 'ses.amazonaws.com' },\n\t\t\tAction: 's3:PutObject',\n\t\t\tResource: `${bucketArn(bucket)}/${options.sesWrite.prefix}*`,\n\t\t\tCondition: {\n\t\t\t\tStringEquals: { 'aws:SourceAccount': options.sesWrite.account },\n\t\t\t},\n\t\t});\n\t}\n\treturn { Version: '2012-10-17', Statement: statements };\n}\n\n/**\n * Block Public Access. All four flags on, unless the bucket has open paths:\n * then a *policy* may make it public (`BlockPublicPolicy`,\n * `RestrictPublicBuckets` off), and ACLs still may not.\n */\nexport function publicAccessBlock(open: boolean): {\n\tBlockPublicAcls: boolean;\n\tIgnorePublicAcls: boolean;\n\tBlockPublicPolicy: boolean;\n\tRestrictPublicBuckets: boolean;\n} {\n\treturn {\n\t\tBlockPublicAcls: true,\n\t\tIgnorePublicAcls: true,\n\t\tBlockPublicPolicy: !open,\n\t\tRestrictPublicBuckets: !open,\n\t};\n}\n\n/** The one CORS rule: browsers on the stage's sites upload and read. */\nexport interface CorsRule {\n\tAllowedMethods: string[];\n\tAllowedOrigins: string[];\n\tAllowedHeaders: string[];\n\tExposeHeaders: string[];\n\tMaxAgeSeconds: number;\n}\n\nexport function corsRule(origins: readonly string[]): CorsRule {\n\treturn {\n\t\tAllowedMethods: ['GET', 'HEAD', 'POST', 'PUT'],\n\t\tAllowedOrigins: [...new Set(origins)].sort(),\n\t\tAllowedHeaders: ['*'],\n\t\tExposeHeaders: ['ETag'],\n\t\tMaxAgeSeconds: 3000,\n\t};\n}\n\n/**\n * A policy document in one canonical form — keys sorted, a lone string a\n * one-element list, lists sorted — so one AWS reformatted reads as the same\n * document rather than as drift.\n */\nexport function canonicalPolicy(value: unknown): string {\n\treturn JSON.stringify(canonical(value));\n}\n\nfunction canonical(value: unknown, key?: string): unknown {\n\tif (Array.isArray(value)) {\n\t\tconst items = value.map((v) => canonical(v));\n\t\treturn key === 'Statement'\n\t\t\t? items\n\t\t\t: items.map((v) => JSON.stringify(v)).sort();\n\t}\n\tif (value && typeof value === 'object') {\n\t\treturn Object.fromEntries(\n\t\t\tObject.keys(value)\n\t\t\t\t.sort()\n\t\t\t\t.map((k) => {\n\t\t\t\t\tconst v = (value as Record<string, unknown>)[k];\n\t\t\t\t\tconst listy =\n\t\t\t\t\t\tk === 'Action' ||\n\t\t\t\t\t\tk === 'Resource' ||\n\t\t\t\t\t\tk === 'AWS' ||\n\t\t\t\t\t\tk === 'AWS:SourceArn'\n\t\t\t\t\t\t\t? Array.isArray(v)\n\t\t\t\t\t\t\t\t? v\n\t\t\t\t\t\t\t\t: [v]\n\t\t\t\t\t\t\t: v;\n\t\t\t\t\treturn [k, canonical(listy, k)];\n\t\t\t\t}),\n\t\t);\n\t}\n\treturn value;\n}\n","/**\n * An IAM user gkm creates for one thing on a stage, its inline policy, and\n * the access key written into the stage's secrets — as an `s3://` URL for\n * what the `s3` provider gives each bucket and the deploy gives a stage's\n * backups, as an `smtp://` one for the `ses` mail provider.\n *\n * - **The user** is under `/gkm/`, tagged with the deploy identity, the stage\n * and what it is for. One that exists without those tags is someone\n * else's, and is refused rather than taken over.\n * - **Its policy** is read on every run and put back when it drifted.\n * - **Its key**: one, written into the stage's secrets the moment IAM shows\n * its secret. `--rotate-keys` issues a successor and keeps the old one\n * active until the stage has deployed with the new one; the next run after\n * that — or `--retire-old-keys` — deletes it.\n * - **A new key** takes IAM seconds to become usable: the state records when\n * it was issued, and a check made with it waits that out\n * ({@link whileKeyIsNew}).\n */\n\nimport * as s3Url from '@geekmidas/storage/s3-url';\nimport type { ResourceRecord } from '../deploy/StateStore.js';\nimport {\n\tAccessKeyLimit,\n\tBucketKeySetElsewhere,\n\tIamUserNotOwned,\n\tRotationInProgress,\n} from './s3/errors.js';\nimport { IAM_USER_PATH } from './s3/naming.js';\nimport { canonicalPolicy } from './s3/policy.js';\nimport type { EnsureContext, ProviderConfig, StateEntry } from './types.js';\n\ntype IamModule = typeof import('@aws-sdk/client-iam');\n\n/** The tags gkm finds its own buckets and users by. */\nexport const TAG_PROJECT = 'gkm:project';\nexport const TAG_STAGE = 'gkm:stage';\nexport const TAG_CONSTRUCT = 'gkm:construct';\n\n/** What creating a user and its key is done through. */\nexport interface IamClients {\n\tIAM: IamModule;\n\tiam: InstanceType<IamModule['IAMClient']>;\n\t/** The region the key's URL names. */\n\tregion: string;\n\t/** An emulator's endpoint, written into the URL when there is one. */\n\tendpoint?: string;\n}\n\n/** What creating a user and its key reads from a provisioning run. */\nexport type KeyContext = Pick<\n\tEnsureContext<ProviderConfig, unknown>,\n\t| 'identity'\n\t| 'stage'\n\t| 'state'\n\t| 'change'\n\t| 'dryRun'\n\t| 'secrets'\n\t| 'writeSecrets'\n\t| 'rotateKeys'\n\t| 'retireOldKeys'\n\t| 'log'\n>;\n\n/** The keys gkm tags a bucket and a user with. */\nexport function identityTags(\n\tctx: Pick<KeyContext, 'identity' | 'stage'>,\n\tid: string,\n) {\n\treturn [\n\t\t{ Key: TAG_PROJECT, Value: ctx.identity.key },\n\t\t{ Key: TAG_STAGE, Value: ctx.stage },\n\t\t{ Key: TAG_CONSTRUCT, Value: id },\n\t];\n}\n\n/** A read whose \"there is none\" answer is one of `missing`. */\nasync function readOr<T>(\n\tread: () => Promise<T>,\n\tmissing: readonly string[],\n): Promise<T | undefined> {\n\ttry {\n\t\treturn await read();\n\t} catch (error) {\n\t\tconst e = error as { name?: string; Code?: string };\n\t\tif (missing.includes(e?.Code ?? e?.name ?? '')) return undefined;\n\t\tthrow error;\n\t}\n}\n\n/** IAM returns a policy document URL-encoded; an emulator may not. */\nfunction decodePolicy(document: string): string {\n\ttry {\n\t\treturn decodeURIComponent(document);\n\t} catch {\n\t\treturn document;\n\t}\n}\n\nexport interface IamUserInput {\n\t/** What it is for: a bucket construct's id, or `backups`. */\n\tid: string;\n\t/** `gkm-<project>-<stage>-<id>`. */\n\tuser: string;\n\t/** The inline policy's name. */\n\tpolicyName: string;\n\tpolicy: object;\n\t/** The policy's change line: `this bucket only`. */\n\tdescribe: string;\n}\n\n/**\n * The user and its inline policy: found — and refused when it is not this\n * stage's — or created, and the policy put back when it drifted.\n *\n * @throws {IamUserNotOwned}\n */\nexport async function ensureIamUser(\n\tctx: KeyContext,\n\tclients: IamClients,\n\tinput: IamUserInput,\n): Promise<{ user: string; exists: boolean }> {\n\tconst { IAM, iam } = clients;\n\tconst { id, user, policy } = input;\n\tconst entry: StateEntry = { key: `iam-user:${id}`, type: 'iam-user' };\n\tconst found = await readOr(\n\t\t() => iam.send(new IAM.GetUserCommand({ UserName: user })),\n\t\t['NoSuchEntity', 'NoSuchEntityException'],\n\t);\n\n\tif (found?.User) {\n\t\tconst tags = await iam.send(\n\t\t\tnew IAM.ListUserTagsCommand({ UserName: user }),\n\t\t);\n\t\tconst tag = (key: string) => tags.Tags?.find((t) => t.Key === key)?.Value;\n\t\tif (\n\t\t\tfound.User.Path !== IAM_USER_PATH ||\n\t\t\ttag(TAG_PROJECT) !== ctx.identity.key ||\n\t\t\ttag(TAG_STAGE) !== ctx.stage\n\t\t) {\n\t\t\tthrow new IamUserNotOwned(user, ctx.identity.key, ctx.stage);\n\t\t}\n\t\tawait ctx.state.ready(entry, user);\n\t} else {\n\t\tawait ctx.change(\n\t\t\t{\n\t\t\t\tconstruct: id,\n\t\t\t\tresource: `IAM user ${user}`,\n\t\t\t\tchange: `create under ${IAM_USER_PATH}`,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tawait ctx.state.pending(entry);\n\t\t\t\tawait iam.send(\n\t\t\t\t\tnew IAM.CreateUserCommand({\n\t\t\t\t\t\tUserName: user,\n\t\t\t\t\t\tPath: IAM_USER_PATH,\n\t\t\t\t\t\tTags: identityTags(ctx, id),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tawait ctx.state.ready(entry, user);\n\t\t\t},\n\t\t);\n\t}\n\n\tconst exists = Boolean(found?.User) || !ctx.dryRun;\n\tconst current = exists\n\t\t? await readOr(\n\t\t\t\t() =>\n\t\t\t\t\tiam.send(\n\t\t\t\t\t\tnew IAM.GetUserPolicyCommand({\n\t\t\t\t\t\t\tUserName: user,\n\t\t\t\t\t\t\tPolicyName: input.policyName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t['NoSuchEntity', 'NoSuchEntityException'],\n\t\t\t)\n\t\t: undefined;\n\tconst document = current?.PolicyDocument\n\t\t? JSON.parse(decodePolicy(current.PolicyDocument))\n\t\t: undefined;\n\tif (!document || canonicalPolicy(document) !== canonicalPolicy(policy)) {\n\t\tawait ctx.change(\n\t\t\t{\n\t\t\t\tconstruct: id,\n\t\t\t\tresource: `IAM user ${user}`,\n\t\t\t\tchange: `policy ${input.policyName}: ${input.describe}`,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tawait iam.send(\n\t\t\t\t\tnew IAM.PutUserPolicyCommand({\n\t\t\t\t\t\tUserName: user,\n\t\t\t\t\t\tPolicyName: input.policyName,\n\t\t\t\t\t\tPolicyDocument: JSON.stringify(policy),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t}\n\treturn { user, exists };\n}\n\n/**\n * The secret a user's access key is written into, and how: an `s3://` URL\n * for a bucket ({@link s3KeySecret}), an `smtp://` one for mail.\n */\nexport interface KeySecret {\n\t/** The secret's key: `UPLOADS_URL`, `BACKUPS_URL`, `MAIL_URL`. */\n\tkey: string;\n\t/**\n\t * The access key a stored value holds — or `undefined` when it holds\n\t * none this user could have issued for it, so a new one is.\n\t *\n\t * @throws when the value is another resource's, set by hand\n\t */\n\tkeyIdOf(value: string): string | undefined;\n\t/** The value for a newly issued key. */\n\tvalue(accessKeyId: string, secretAccessKey: string): string;\n\t/**\n\t * A value holding the right key whose address drifted: what it should\n\t * be, and the change line. `undefined` when it is right.\n\t */\n\trepair?(value: string): { value: string; change: string } | undefined;\n}\n\n/**\n * A bucket's URL as a key's secret: `s3://KEY:SECRET@bucket?region=…`.\n *\n * @throws {BucketKeySetElsewhere} from `keyIdOf`, when the URL names another bucket\n */\nexport function s3KeySecret(\n\tctx: Pick<KeyContext, 'stage'>,\n\tclients: Pick<IamClients, 'region' | 'endpoint'>,\n\tinput: { bucket: string; urlKey: string },\n): KeySecret {\n\tconst { bucket, urlKey } = input;\n\tconst parse = (value: string) => {\n\t\tlet parsed: s3Url.S3Address | undefined;\n\t\ttry {\n\t\t\tparsed = s3Url.parse(value);\n\t\t} catch {\n\t\t\tparsed = undefined;\n\t\t}\n\t\tif (parsed?.bucket !== bucket) {\n\t\t\tthrow new BucketKeySetElsewhere(\n\t\t\t\turlKey,\n\t\t\t\tbucket,\n\t\t\t\tparsed?.bucket ?? value.replace(/\\/\\/[^@]*@/, '//'),\n\t\t\t\tctx.stage,\n\t\t\t);\n\t\t}\n\t\treturn parsed;\n\t};\n\treturn {\n\t\tkey: urlKey,\n\t\tkeyIdOf: (value) => parse(value).accessKeyId,\n\t\tvalue: (accessKeyId, secretAccessKey) =>\n\t\t\ts3Url.build({\n\t\t\t\tbucket,\n\t\t\t\tregion: clients.region,\n\t\t\t\t...(clients.endpoint\n\t\t\t\t\t? { endpoint: clients.endpoint, forcePathStyle: true }\n\t\t\t\t\t: {}),\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey,\n\t\t\t}),\n\t\trepair(value) {\n\t\t\t// The key is good; the address must name where the bucket is.\n\t\t\tconst address = parse(value);\n\t\t\tif (address.region === clients.region) return undefined;\n\t\t\treturn {\n\t\t\t\tvalue: s3Url.build({ ...address, region: clients.region }),\n\t\t\t\tchange: `name ${clients.region}, the bucket's region (it said ${address.region ?? 'none'})`,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport interface AccessKeyInput {\n\t/** What it is for, as {@link IamUserInput.id}. */\n\tid: string;\n\tuser: string;\n\t/** Whether the user exists yet — false in a dry run that would create it. */\n\texists: boolean;\n\t/** Where the key is written. */\n\tsecret: KeySecret;\n}\n\n/**\n * The user's access key, in the stage's secrets as `secret` writes it.\n *\n * - First run: one key, written into the stage's secrets.\n * - `--rotate-keys`: a second key, written in place of the first; the first\n * stays active until the stage has deployed with the second, and the next\n * run after that deploy — or `--retire-old-keys` — deletes it.\n * - A key the secrets no longer hold (a store emptied by hand): replaced the\n * same way, since its secret cannot be read back.\n *\n * @throws whatever `secret.keyIdOf` throws for a value set elsewhere\n * @throws {RotationInProgress} on `--rotate-keys` with the last rotation's old key still active\n * @throws {AccessKeyLimit} when the user has two keys gkm did not record\n */\nexport async function ensureAccessKey(\n\tctx: KeyContext,\n\tclients: IamClients,\n\tinput: AccessKeyInput,\n): Promise<void> {\n\tconst { IAM, iam } = clients;\n\tconst { id, user, secret } = input;\n\tconst entryKey = `iam-access-key:${id}`;\n\tconst record = ctx.state.record(entryKey);\n\n\tconst given = ctx.secrets[secret.key];\n\tconst inUrl = given !== undefined ? secret.keyIdOf(given) : undefined;\n\n\tconst listed = input.exists\n\t\t? ((\n\t\t\t\tawait iam.send(new IAM.ListAccessKeysCommand({ UserName: user }))\n\t\t\t).AccessKeyMetadata?.map((k) => k.AccessKeyId!) ?? [])\n\t\t: [];\n\n\tlet current = record?.status === 'ready' ? record.id : undefined;\n\tlet previous =\n\t\ttypeof record?.data?.previous === 'string'\n\t\t\t? record.data.previous\n\t\t\t: undefined;\n\tconst rotatedAt =\n\t\ttypeof record?.data?.rotatedAt === 'string'\n\t\t\t? record.data.rotatedAt\n\t\t\t: undefined;\n\tconst entry = (data: Record<string, unknown> = {}): StateEntry => ({\n\t\tkey: entryKey,\n\t\ttype: 'iam-access-key',\n\t\tdata: { user, ...data },\n\t});\n\n\t// The old key of a rotation: deleted once the stage deployed after it.\n\tif (previous && current) {\n\t\tconst deployed =\n\t\t\trotatedAt !== undefined &&\n\t\t\tctx.state.lastDeployedAt !== undefined &&\n\t\t\tctx.state.lastDeployedAt > rotatedAt;\n\t\tif (ctx.retireOldKeys || deployed) {\n\t\t\tconst old = previous;\n\t\t\tconst keep = current;\n\t\t\tawait ctx.change(\n\t\t\t\t{\n\t\t\t\t\tconstruct: id,\n\t\t\t\t\tresource: `IAM user ${user}`,\n\t\t\t\t\tchange: `delete the rotated-out access key ${old}`,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\tif (listed.includes(old)) {\n\t\t\t\t\t\tawait iam.send(\n\t\t\t\t\t\t\tnew IAM.DeleteAccessKeyCommand({\n\t\t\t\t\t\t\t\tUserName: user,\n\t\t\t\t\t\t\t\tAccessKeyId: old,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tawait ctx.state.ready(entry(), keep);\n\t\t\t\t},\n\t\t\t);\n\t\t\tprevious = undefined;\n\t\t} else {\n\t\t\tctx.log(\n\t\t\t\t` ${id}: the old access key ${previous} stays active until '${ctx.stage}' is deployed with the new one; the next deploy after that deletes it (or pass --retire-old-keys)`,\n\t\t\t);\n\t\t}\n\t}\n\n\t// No record, and the secrets hold a key of this user's: adopt it.\n\tif (!current && inUrl && listed.includes(inUrl)) {\n\t\tawait ctx.state.ready(entry(), inUrl);\n\t\tcurrent = inUrl;\n\t}\n\n\tconst valid =\n\t\tcurrent !== undefined && listed.includes(current) && inUrl === current;\n\tif (valid && !ctx.rotateKeys) {\n\t\tconst repaired = given !== undefined ? secret.repair?.(given) : undefined;\n\t\tif (repaired) {\n\t\t\tawait ctx.change(\n\t\t\t\t{ construct: id, resource: secret.key, change: repaired.change },\n\t\t\t\t() => ctx.writeSecrets({ [secret.key]: repaired.value }),\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\tif (ctx.rotateKeys && previous) {\n\t\tthrow new RotationInProgress(id, previous, ctx.stage);\n\t}\n\n\tconst outgoing = current && listed.includes(current) ? current : undefined;\n\tif (listed.length >= 2) throw new AccessKeyLimit(user, listed);\n\n\tconst why = !current\n\t\t? 'create an access key'\n\t\t: ctx.rotateKeys\n\t\t\t? 'rotate: issue a new access key'\n\t\t\t: 'issue a new access key (the secrets no longer hold the recorded one)';\n\tawait ctx.change(\n\t\t{ construct: id, resource: `IAM user ${user}`, change: why },\n\t\tasync () => {\n\t\t\tawait ctx.state.pending(entry(outgoing ? { previous: outgoing } : {}));\n\t\t\tconst created = await iam.send(\n\t\t\t\tnew IAM.CreateAccessKeyCommand({ UserName: user }),\n\t\t\t);\n\t\t\tconst key = created.AccessKey!;\n\t\t\t// Into the stage's secrets before anything else: IAM shows a secret\n\t\t\t// once, and a key whose secret is lost is a key to replace.\n\t\t\tawait ctx.writeSecrets({\n\t\t\t\t[secret.key]: secret.value(key.AccessKeyId!, key.SecretAccessKey!),\n\t\t\t});\n\t\t\t// When it was issued: IAM takes seconds to make a new key usable,\n\t\t\t// and the deploy's check waits for one this young.\n\t\t\tconst issuedAt = new Date().toISOString();\n\t\t\tawait ctx.state.ready(\n\t\t\t\tentry(\n\t\t\t\t\toutgoing\n\t\t\t\t\t\t? { previous: outgoing, rotatedAt: issuedAt, issuedAt }\n\t\t\t\t\t\t: { issuedAt },\n\t\t\t\t),\n\t\t\t\tkey.AccessKeyId!,\n\t\t\t);\n\t\t},\n\t);\n\tif (outgoing) {\n\t\tctx.log(\n\t\t\t` ${secret.key} holds the new key. This deploy moves '${ctx.stage}' onto it; the next deploy after it deletes the old key ${outgoing}`,\n\t\t);\n\t}\n}\n\n/** How long a key issued this recently counts as new to IAM. */\nconst NEW_KEY_WINDOW_MS = 10 * 60 * 1000;\n\n/** The waits between asks while a new key becomes usable: about a minute. */\nlet newKeyWaits: readonly number[] = [2000, 4000, 8000, 15000, 15000, 15000];\n\n/** For tests: the waits for a new key. Returns the old ones. */\nexport function useNewKeyWaits(waits: readonly number[]): readonly number[] {\n\tconst previous = newKeyWaits;\n\tnewKeyWaits = waits;\n\treturn previous;\n}\n\n/**\n * When the key in a URL was issued, if the stage's state says it was just\n * now — the record of `id`'s key naming that very key.\n */\nexport function issuedJustNow(\n\tresources: Readonly<Record<string, ResourceRecord>> | undefined,\n\tid: string,\n\taccessKeyId: string,\n): string | undefined {\n\tconst record = resources?.[`iam-access-key:${id}`];\n\tconst issuedAt = record?.data?.issuedAt;\n\tif (record?.id !== accessKeyId || typeof issuedAt !== 'string') {\n\t\treturn undefined;\n\t}\n\tconst age = Date.now() - Date.parse(issuedAt);\n\treturn age >= 0 && age < NEW_KEY_WINDOW_MS ? issuedAt : undefined;\n}\n\n/**\n * `ask` again, for about a minute, while it is `refused` and the key was\n * issued just now — IAM refuses a key for seconds after making it. Returns\n * the last answer and how long was waited.\n */\nexport async function whileKeyIsNew<T>(\n\tfirst: T,\n\toptions: {\n\t\tissuedAt: string | undefined;\n\t\trefused: (answer: T) => boolean;\n\t\task: () => Promise<T>;\n\t\t/** Said once, before the first wait. */\n\t\tonWait?: () => void;\n\t},\n): Promise<{ answer: T; waited: number }> {\n\tlet answer = first;\n\tlet waited = 0;\n\tif (!options.issuedAt || !options.refused(answer)) return { answer, waited };\n\toptions.onWait?.();\n\tfor (const wait of newKeyWaits) {\n\t\tawait new Promise((resolve) => setTimeout(resolve, wait));\n\t\twaited += wait;\n\t\tanswer = await options.ask();\n\t\tif (!options.refused(answer)) break;\n\t}\n\treturn { answer, waited };\n}\n"],"mappings":";;;;;AAuBA,MAAM,aAAa,WAAmB,gBAAgB;;;;;;;;;AAUtD,SAAgB,WACf,QACA,UAQI,CAAC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;CACzC,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,CAAC,QAAQ,YAAY,CAAC,QAAQ,QAAQ,MAAM,GAAG,OAAO;EAAE;EAAQ;CAAO;CAC3E,QAAQ,SAAS;CACjB,KAAK,MAAM,QAAQ,aAAa;EAC/B,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,IAAI,CAAC;EACxD,UAAU;EACV,SAAS,MAAM,QAAQ,IAAI;EAC3B,IAAI,CAAC,QAAQ,QAAQ,MAAM,GAAG;CAC/B;CACA,OAAO;EAAE;EAAQ;CAAO;AACzB"}
|
|
@@ -1,91 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { X as AccessKeyLimit, Z as BucketKeySetElsewhere, ot as RotationInProgress, rt as IamUserNotOwned } from "./workspace-DFGsrjGD.mjs";
|
|
3
|
-
import { randomInt } from "node:crypto";
|
|
4
|
-
import { kebabCase } from "@geekmidas/manifest";
|
|
1
|
+
import { $ as IAM_USER_PATH, gt as RotationInProgress, ot as AccessKeyLimit, pt as IamUserNotOwned, st as BucketKeySetElsewhere } from "./workspace-D5Vm2qcy.mjs";
|
|
5
2
|
import * as s3Url from "@geekmidas/storage/s3-url";
|
|
6
|
-
const SUFFIX_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
7
|
-
/** A name that S3 would refuse — what the name builder never returns. */
|
|
8
|
-
var InvalidBucketName = class extends GkmError {
|
|
9
|
-
bucket;
|
|
10
|
-
reason;
|
|
11
|
-
constructor(bucket, reason) {
|
|
12
|
-
super(`'${bucket}' is not a valid S3 bucket name: ${reason}. Rename the construct or set deploy.namespace in gkm.config.ts to something that leaves room for it.`);
|
|
13
|
-
this.bucket = bucket;
|
|
14
|
-
this.reason = reason;
|
|
15
|
-
this.name = "InvalidBucketName";
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
/** Lowercase `[a-z0-9-]`, runs of anything else one `-`, no edge dashes. */
|
|
19
|
-
function part(value) {
|
|
20
|
-
return kebabCase(value).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* `parts` joined by `-`, shortened to `max` characters by trimming the longest
|
|
24
|
-
* part one character at a time — so a long construct id gives way before a
|
|
25
|
-
* short stage name does, and every part keeps its start.
|
|
26
|
-
*/
|
|
27
|
-
function fitParts(parts, max) {
|
|
28
|
-
const kept = parts.map(part).filter(Boolean);
|
|
29
|
-
const length = () => kept.reduce((sum, p) => sum + p.length, 0) + kept.length - 1;
|
|
30
|
-
while (length() > max) {
|
|
31
|
-
let longest = 0;
|
|
32
|
-
for (let i = 1; i < kept.length; i++) if (kept[i].length > kept[longest].length) longest = i;
|
|
33
|
-
if (kept[longest].length <= 1) break;
|
|
34
|
-
kept[longest] = kept[longest].slice(0, -1).replace(/-+$/, "");
|
|
35
|
-
}
|
|
36
|
-
return kept.join("-");
|
|
37
|
-
}
|
|
38
|
-
/** Why `name` is not a valid bucket name, or undefined when it is. */
|
|
39
|
-
function bucketNameProblem(name) {
|
|
40
|
-
if (name.length < 3 || name.length > 63) return `it is ${name.length} characters, and S3 takes 3 to 63`;
|
|
41
|
-
if (!/^[a-z0-9-]+$/.test(name)) return "it may hold only lowercase letters, digits and -";
|
|
42
|
-
if (!/^[a-z0-9].*[a-z0-9]$/.test(name)) return "it must start and end with a letter or a digit";
|
|
43
|
-
if (name.startsWith("xn--") || name.startsWith("sthree-")) return "it starts with a prefix S3 reserves ('xn--', 'sthree-')";
|
|
44
|
-
if (name.endsWith("-s3alias") || name.endsWith("--ol-s3")) return "it ends with a suffix S3 reserves ('-s3alias', '--ol-s3')";
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* The good name: `<namespace>-<project>-<stage>-<bucket id>`, lowercased, no
|
|
48
|
-
* dots, shortened to leave room for a clash's suffix.
|
|
49
|
-
*
|
|
50
|
-
* @throws {InvalidBucketName} when nothing usable is left
|
|
51
|
-
*/
|
|
52
|
-
function bucketName(input) {
|
|
53
|
-
const name = fitParts([
|
|
54
|
-
input.scope,
|
|
55
|
-
input.stage,
|
|
56
|
-
input.id
|
|
57
|
-
], 56);
|
|
58
|
-
const problem = bucketNameProblem(name);
|
|
59
|
-
if (problem) throw new InvalidBucketName(name, problem);
|
|
60
|
-
return name;
|
|
61
|
-
}
|
|
62
|
-
/** Six random `[a-z0-9]` characters. */
|
|
63
|
-
function randomSuffix(random = randomInt) {
|
|
64
|
-
let suffix = "";
|
|
65
|
-
for (let i = 0; i < 6; i++) suffix += SUFFIX_ALPHABET[random(36)];
|
|
66
|
-
return suffix;
|
|
67
|
-
}
|
|
68
|
-
/** The good name with a clash's suffix. */
|
|
69
|
-
function suffixedBucketName(good, suffix) {
|
|
70
|
-
return `${good}-${suffix}`;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* The IAM user a bucket is reached with on a stage:
|
|
74
|
-
* `gkm-<project>-<stage>-<bucket id>`, at most 64 characters.
|
|
75
|
-
*/
|
|
76
|
-
function iamUserName(input) {
|
|
77
|
-
return fitParts([
|
|
78
|
-
"gkm",
|
|
79
|
-
input.scope,
|
|
80
|
-
input.stage,
|
|
81
|
-
input.id
|
|
82
|
-
], 64);
|
|
83
|
-
}
|
|
84
|
-
/** The path every user gkm creates is under, so it finds its own. */
|
|
85
|
-
const IAM_USER_PATH = "/gkm/";
|
|
86
|
-
/** The inline policy each user is given. */
|
|
87
|
-
const IAM_POLICY_NAME = "gkm-bucket";
|
|
88
|
-
//#endregion
|
|
89
3
|
//#region src/providers/s3/policy.ts
|
|
90
4
|
const bucketArn = (bucket) => `arn:aws:s3:::${bucket}`;
|
|
91
5
|
/**
|
|
@@ -238,9 +152,9 @@ function canonical(value, key) {
|
|
|
238
152
|
//#region src/providers/iam.ts
|
|
239
153
|
/**
|
|
240
154
|
* An IAM user gkm creates for one thing on a stage, its inline policy, and
|
|
241
|
-
* the access key written into the stage's secrets as an `s3://` URL
|
|
242
|
-
* the `s3` provider gives each bucket
|
|
243
|
-
* backups.
|
|
155
|
+
* the access key written into the stage's secrets — as an `s3://` URL for
|
|
156
|
+
* what the `s3` provider gives each bucket and the deploy gives a stage's
|
|
157
|
+
* backups, as an `smtp://` one for the `ses` mail provider.
|
|
244
158
|
*
|
|
245
159
|
* - **The user** is under `/gkm/`, tagged with the deploy identity, the stage
|
|
246
160
|
* and what it is for. One that exists without those tags is someone
|
|
@@ -348,7 +262,50 @@ async function ensureIamUser(ctx, clients, input) {
|
|
|
348
262
|
};
|
|
349
263
|
}
|
|
350
264
|
/**
|
|
351
|
-
*
|
|
265
|
+
* A bucket's URL as a key's secret: `s3://KEY:SECRET@bucket?region=…`.
|
|
266
|
+
*
|
|
267
|
+
* @throws {BucketKeySetElsewhere} from `keyIdOf`, when the URL names another bucket
|
|
268
|
+
*/
|
|
269
|
+
function s3KeySecret(ctx, clients, input) {
|
|
270
|
+
const { bucket, urlKey } = input;
|
|
271
|
+
const parse = (value) => {
|
|
272
|
+
let parsed;
|
|
273
|
+
try {
|
|
274
|
+
parsed = s3Url.parse(value);
|
|
275
|
+
} catch {
|
|
276
|
+
parsed = void 0;
|
|
277
|
+
}
|
|
278
|
+
if (parsed?.bucket !== bucket) throw new BucketKeySetElsewhere(urlKey, bucket, parsed?.bucket ?? value.replace(/\/\/[^@]*@/, "//"), ctx.stage);
|
|
279
|
+
return parsed;
|
|
280
|
+
};
|
|
281
|
+
return {
|
|
282
|
+
key: urlKey,
|
|
283
|
+
keyIdOf: (value) => parse(value).accessKeyId,
|
|
284
|
+
value: (accessKeyId, secretAccessKey) => s3Url.build({
|
|
285
|
+
bucket,
|
|
286
|
+
region: clients.region,
|
|
287
|
+
...clients.endpoint ? {
|
|
288
|
+
endpoint: clients.endpoint,
|
|
289
|
+
forcePathStyle: true
|
|
290
|
+
} : {},
|
|
291
|
+
accessKeyId,
|
|
292
|
+
secretAccessKey
|
|
293
|
+
}),
|
|
294
|
+
repair(value) {
|
|
295
|
+
const address = parse(value);
|
|
296
|
+
if (address.region === clients.region) return void 0;
|
|
297
|
+
return {
|
|
298
|
+
value: s3Url.build({
|
|
299
|
+
...address,
|
|
300
|
+
region: clients.region
|
|
301
|
+
}),
|
|
302
|
+
change: `name ${clients.region}, the bucket's region (it said ${address.region ?? "none"})`
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* The user's access key, in the stage's secrets as `secret` writes it.
|
|
352
309
|
*
|
|
353
310
|
* - First run: one key, written into the stage's secrets.
|
|
354
311
|
* - `--rotate-keys`: a second key, written in place of the first; the first
|
|
@@ -357,27 +314,17 @@ async function ensureIamUser(ctx, clients, input) {
|
|
|
357
314
|
* - A key the secrets no longer hold (a store emptied by hand): replaced the
|
|
358
315
|
* same way, since its secret cannot be read back.
|
|
359
316
|
*
|
|
360
|
-
* @throws
|
|
317
|
+
* @throws whatever `secret.keyIdOf` throws for a value set elsewhere
|
|
361
318
|
* @throws {RotationInProgress} on `--rotate-keys` with the last rotation's old key still active
|
|
362
319
|
* @throws {AccessKeyLimit} when the user has two keys gkm did not record
|
|
363
320
|
*/
|
|
364
321
|
async function ensureAccessKey(ctx, clients, input) {
|
|
365
322
|
const { IAM, iam } = clients;
|
|
366
|
-
const { id,
|
|
323
|
+
const { id, user, secret } = input;
|
|
367
324
|
const entryKey = `iam-access-key:${id}`;
|
|
368
325
|
const record = ctx.state.record(entryKey);
|
|
369
|
-
const given = ctx.secrets[
|
|
370
|
-
|
|
371
|
-
let parsed;
|
|
372
|
-
if (given !== void 0) {
|
|
373
|
-
try {
|
|
374
|
-
parsed = s3Url.parse(given);
|
|
375
|
-
} catch {
|
|
376
|
-
parsed = void 0;
|
|
377
|
-
}
|
|
378
|
-
if (parsed?.bucket !== bucket) throw new BucketKeySetElsewhere(urlKey, bucket, parsed?.bucket ?? given.replace(/\/\/[^@]*@/, "//"), ctx.stage);
|
|
379
|
-
inUrl = parsed.accessKeyId;
|
|
380
|
-
}
|
|
326
|
+
const given = ctx.secrets[secret.key];
|
|
327
|
+
const inUrl = given !== void 0 ? secret.keyIdOf(given) : void 0;
|
|
381
328
|
const listed = input.exists ? (await iam.send(new IAM.ListAccessKeysCommand({ UserName: user }))).AccessKeyMetadata?.map((k) => k.AccessKeyId) ?? [] : [];
|
|
382
329
|
let current = record?.status === "ready" ? record.id : void 0;
|
|
383
330
|
let previous = typeof record?.data?.previous === "string" ? record.data.previous : void 0;
|
|
@@ -414,17 +361,12 @@ async function ensureAccessKey(ctx, clients, input) {
|
|
|
414
361
|
current = inUrl;
|
|
415
362
|
}
|
|
416
363
|
if (current !== void 0 && listed.includes(current) && inUrl === current && !ctx.rotateKeys) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}, () => ctx.writeSecrets({ [urlKey]: s3Url.build({
|
|
424
|
-
...address,
|
|
425
|
-
region: clients.region
|
|
426
|
-
}) }));
|
|
427
|
-
}
|
|
364
|
+
const repaired = given !== void 0 ? secret.repair?.(given) : void 0;
|
|
365
|
+
if (repaired) await ctx.change({
|
|
366
|
+
construct: id,
|
|
367
|
+
resource: secret.key,
|
|
368
|
+
change: repaired.change
|
|
369
|
+
}, () => ctx.writeSecrets({ [secret.key]: repaired.value }));
|
|
428
370
|
return;
|
|
429
371
|
}
|
|
430
372
|
if (ctx.rotateKeys && previous) throw new RotationInProgress(id, previous, ctx.stage);
|
|
@@ -438,16 +380,7 @@ async function ensureAccessKey(ctx, clients, input) {
|
|
|
438
380
|
}, async () => {
|
|
439
381
|
await ctx.state.pending(entry(outgoing ? { previous: outgoing } : {}));
|
|
440
382
|
const key = (await iam.send(new IAM.CreateAccessKeyCommand({ UserName: user }))).AccessKey;
|
|
441
|
-
await ctx.writeSecrets({ [
|
|
442
|
-
bucket,
|
|
443
|
-
region: clients.region,
|
|
444
|
-
...clients.endpoint ? {
|
|
445
|
-
endpoint: clients.endpoint,
|
|
446
|
-
forcePathStyle: true
|
|
447
|
-
} : {},
|
|
448
|
-
accessKeyId: key.AccessKeyId,
|
|
449
|
-
secretAccessKey: key.SecretAccessKey
|
|
450
|
-
}) });
|
|
383
|
+
await ctx.writeSecrets({ [secret.key]: secret.value(key.AccessKeyId, key.SecretAccessKey) });
|
|
451
384
|
const issuedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
452
385
|
await ctx.state.ready(entry(outgoing ? {
|
|
453
386
|
previous: outgoing,
|
|
@@ -455,7 +388,7 @@ async function ensureAccessKey(ctx, clients, input) {
|
|
|
455
388
|
issuedAt
|
|
456
389
|
} : { issuedAt }), key.AccessKeyId);
|
|
457
390
|
});
|
|
458
|
-
if (outgoing) ctx.log(` ${
|
|
391
|
+
if (outgoing) ctx.log(` ${secret.key} holds the new key. This deploy moves '${ctx.stage}' onto it; the next deploy after it deletes the old key ${outgoing}`);
|
|
459
392
|
}
|
|
460
393
|
/** How long a key issued this recently counts as new to IAM. */
|
|
461
394
|
const NEW_KEY_WINDOW_MS = 6e5;
|
|
@@ -504,6 +437,6 @@ async function whileKeyIsNew(first, options) {
|
|
|
504
437
|
};
|
|
505
438
|
}
|
|
506
439
|
//#endregion
|
|
507
|
-
export {
|
|
440
|
+
export { identityTags as a, whileKeyIsNew as c, corsRule as d, publicAccessBlock as f, ensureIamUser as i, bucketPolicy as l, TAG_STAGE as n, issuedJustNow as o, userPolicy as p, ensureAccessKey as r, s3KeySecret as s, TAG_PROJECT as t, canonicalPolicy as u };
|
|
508
441
|
|
|
509
|
-
//# sourceMappingURL=iam-
|
|
442
|
+
//# sourceMappingURL=iam-q9ALh-Y5.mjs.map
|