@stacksjs/ts-cloud 0.9.4 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/dist/aws/index.js +1 -1
  2. package/dist/bin/chunk-0djsffn6.js +1 -0
  3. package/dist/bin/chunk-0t3sev1j.js +1 -0
  4. package/dist/bin/chunk-0y89hs67.js +6 -0
  5. package/dist/bin/chunk-21gggxvf.js +2 -0
  6. package/dist/bin/chunk-26cj89s6.js +1 -0
  7. package/dist/bin/chunk-35xstvnq.js +1 -0
  8. package/dist/bin/chunk-41yqpdv7.js +2 -0
  9. package/dist/bin/chunk-4a85nk2q.js +92 -0
  10. package/dist/bin/{chunk-rxcvf10f.js → chunk-4a97kbk1.js} +129 -129
  11. package/dist/bin/chunk-4kbhbfq8.js +34 -0
  12. package/dist/bin/chunk-4vdv41nh.js +70 -0
  13. package/dist/bin/chunk-67jsyn0g.js +111 -0
  14. package/dist/bin/chunk-6tct7e89.js +1 -0
  15. package/dist/bin/chunk-6vjrts39.js +1 -0
  16. package/dist/bin/chunk-7v5ff3vc.js +1 -0
  17. package/dist/bin/chunk-80nra92y.js +1 -0
  18. package/dist/bin/chunk-9mydnqr6.js +2 -0
  19. package/dist/bin/chunk-9rsn48qg.js +3 -0
  20. package/dist/bin/chunk-a2t1e5yb.js +1 -0
  21. package/dist/bin/chunk-akbfefwq.js +1 -0
  22. package/dist/bin/chunk-b704nznp.js +1 -0
  23. package/dist/bin/chunk-c1j9v7ee.js +2 -0
  24. package/dist/bin/chunk-cjz36ths.js +1 -0
  25. package/dist/bin/chunk-cxd5cevb.js +2 -0
  26. package/dist/bin/chunk-dbv8w56s.js +50 -0
  27. package/dist/bin/chunk-dxchg0g1.js +1 -0
  28. package/dist/bin/{chunk-tx0tqq2k.js → chunk-e1bfd1yv.js} +6 -6
  29. package/dist/bin/chunk-fpcghdr3.js +585 -0
  30. package/dist/bin/chunk-ftse39wf.js +9 -0
  31. package/dist/bin/chunk-g0ewbkbq.js +1 -0
  32. package/dist/bin/chunk-gskbezam.js +141 -0
  33. package/dist/bin/chunk-gvs85t2j.js +1 -0
  34. package/dist/bin/chunk-hej39dwr.js +2 -0
  35. package/dist/bin/chunk-jce28gnz.js +2 -0
  36. package/dist/bin/chunk-kbtrr0c3.js +1 -0
  37. package/dist/bin/chunk-khrye4x9.js +1 -0
  38. package/dist/bin/{chunk-mh0kdzqp.js → chunk-ks4ewy1s.js} +1 -1
  39. package/dist/bin/chunk-mbnwt3r5.js +2 -0
  40. package/dist/bin/chunk-md2k3n21.js +37 -0
  41. package/dist/bin/chunk-memfxrcn.js +1 -0
  42. package/dist/bin/chunk-mwgxyc0z.js +44 -0
  43. package/dist/bin/chunk-neampxq1.js +4 -0
  44. package/dist/bin/chunk-nkpf91d3.js +1 -0
  45. package/dist/bin/chunk-nmkm1f68.js +2 -0
  46. package/dist/bin/chunk-nyc2jxd8.js +2 -0
  47. package/dist/bin/chunk-pqr8jqnd.js +1 -0
  48. package/dist/bin/chunk-q182t9ba.js +3 -0
  49. package/dist/bin/chunk-r6x7beew.js +60 -0
  50. package/dist/bin/chunk-rfqk5xym.js +1 -0
  51. package/dist/bin/{chunk-etrb03mt.js → chunk-ww770qpn.js} +30 -30
  52. package/dist/bin/chunk-wy20ztb6.js +1 -0
  53. package/dist/bin/chunk-wzepfqf4.js +512 -0
  54. package/dist/bin/chunk-xcqmwphz.js +1 -0
  55. package/dist/bin/chunk-xev7qr2h.js +3 -0
  56. package/dist/bin/chunk-y3rm37z1.js +6 -0
  57. package/dist/bin/chunk-zejwh9cy.js +6 -0
  58. package/dist/bin/chunk-zwwnt4x1.js +1 -0
  59. package/dist/bin/cli.js +431 -418
  60. package/dist/bin/dashboard-server.js +1 -1
  61. package/dist/{chunk-dskvqt67.js → chunk-0hj552t7.js} +127 -127
  62. package/dist/chunk-1ypkh8g6.js +5 -0
  63. package/dist/chunk-2m09t0c0.js +60 -0
  64. package/dist/chunk-7fkyfh65.js +1 -0
  65. package/dist/chunk-7xpxzbkr.js +442 -0
  66. package/dist/chunk-8e0az001.js +2 -0
  67. package/dist/chunk-b10cbk8z.js +44 -0
  68. package/dist/chunk-gk58959n.js +6 -0
  69. package/dist/chunk-h1rc94df.js +114 -0
  70. package/dist/chunk-hbhxk5a0.js +4 -0
  71. package/dist/chunk-hz7k9ymh.js +1 -0
  72. package/dist/chunk-kj7gzdj6.js +1 -0
  73. package/dist/chunk-ky5c6t5y.js +2 -0
  74. package/dist/chunk-mch30cyc.js +1 -0
  75. package/dist/chunk-n04a3bgf.js +1 -0
  76. package/dist/chunk-nnqxmh7f.js +34 -0
  77. package/dist/chunk-p6vszgc2.js +92 -0
  78. package/dist/chunk-q2njk4hx.js +141 -0
  79. package/dist/chunk-qjk1v1gs.js +50 -0
  80. package/dist/chunk-qtp90j44.js +2 -0
  81. package/dist/chunk-r5natbed.js +37 -0
  82. package/dist/chunk-rcxq9aaa.js +704 -0
  83. package/dist/{chunk-gahsdmxf.js → chunk-s3rpd72x.js} +52 -52
  84. package/dist/{chunk-xt3s24vr.js → chunk-spx89gaw.js} +1 -1
  85. package/dist/chunk-t0kh8haz.js +2 -0
  86. package/dist/chunk-vz95qy3n.js +1 -0
  87. package/dist/deploy/attach-credentials.d.ts +4 -8
  88. package/dist/deploy/index.js +1 -1
  89. package/dist/dns/cloudflare.d.ts +27 -0
  90. package/dist/dns/godaddy.d.ts +18 -1
  91. package/dist/dns/index.d.ts +2 -0
  92. package/dist/dns/index.js +1 -1
  93. package/dist/dns/zone-migration.d.ts +92 -0
  94. package/dist/dns/zone-migration.test.d.ts +1 -0
  95. package/dist/drivers/hetzner/driver.d.ts +8 -1
  96. package/dist/drivers/index.js +1 -1
  97. package/dist/drivers/shared/app-updates.d.ts +36 -0
  98. package/dist/drivers/shared/compute-provision.d.ts +14 -2
  99. package/dist/drivers/shared/db-provision.d.ts +3 -2
  100. package/dist/drivers/shared/mail-provision.d.ts +116 -0
  101. package/dist/drivers/shared/mail-provision.test.d.ts +1 -0
  102. package/dist/drivers/shared/managed-services-probe.d.ts +47 -0
  103. package/dist/drivers/shared/managed-services-probe.test.d.ts +1 -0
  104. package/dist/drivers/shared/package-manager.d.ts +1 -0
  105. package/dist/drivers/shared/remote-failure.d.ts +21 -0
  106. package/dist/drivers/shared/remote-failure.test.d.ts +1 -0
  107. package/dist/drivers/shared/sqlite-shared-path.d.ts +50 -0
  108. package/dist/drivers/shared/sqlite-shared-path.test.d.ts +1 -0
  109. package/dist/index.d.ts +2 -0
  110. package/dist/index.js +92 -89
  111. package/dist/operations/plan.d.ts +136 -0
  112. package/dist/operations/plan.test.d.ts +1 -0
  113. package/dist/operations/server-rename.d.ts +84 -0
  114. package/dist/operations/server-rename.test.d.ts +1 -0
  115. package/dist/operations/site-move.d.ts +263 -0
  116. package/dist/operations/site-move.test.d.ts +1 -0
  117. package/dist/protection/index.js +1 -1
  118. package/dist/push/index.js +1 -1
  119. package/dist/spend/index.js +1 -1
  120. package/dist/ui/404.html +1 -1
  121. package/dist/ui/accept-invitation.html +1 -1
  122. package/dist/ui/access-denied.html +1 -1
  123. package/dist/ui/account/automation.html +6 -6
  124. package/dist/ui/account/security.html +2 -2
  125. package/dist/ui/applications/compose.html +6 -6
  126. package/dist/ui/applications/new.html +2 -2
  127. package/dist/ui/data/backups.html +80 -80
  128. package/dist/ui/data/services.html +78 -78
  129. package/dist/ui/data/volumes.html +50 -50
  130. package/dist/ui/index.html +50 -50
  131. package/dist/ui/infrastructure/topology.html +118 -118
  132. package/dist/ui/integrations.html +2 -2
  133. package/dist/ui/operations/alerts.html +48 -48
  134. package/dist/ui/operations/configuration.html +6 -6
  135. package/dist/ui/operations/jobs.html +75 -75
  136. package/dist/ui/operations/maintenance.html +6 -6
  137. package/dist/ui/operations/observability.html +82 -82
  138. package/dist/ui/operations/previews.html +6 -6
  139. package/dist/ui/operations/queue.html +6 -6
  140. package/dist/ui/operations/regions.html +6 -6
  141. package/dist/ui/operations/releases.html +6 -6
  142. package/dist/ui/operations/spend.html +54 -54
  143. package/dist/ui/operations/workloads.html +104 -104
  144. package/dist/ui/security.html +2 -2
  145. package/dist/ui/server/actions.html +56 -56
  146. package/dist/ui/server/activity.html +1 -1
  147. package/dist/ui/server/capacity.html +6 -6
  148. package/dist/ui/server/database.html +106 -106
  149. package/dist/ui/server/deployments.html +50 -50
  150. package/dist/ui/server/diagnostics.html +2 -2
  151. package/dist/ui/server/firewall.html +76 -76
  152. package/dist/ui/server/fleet.html +34 -34
  153. package/dist/ui/server/logs.html +24 -24
  154. package/dist/ui/server/metrics.html +112 -112
  155. package/dist/ui/server/security.html +2 -2
  156. package/dist/ui/server/services.html +27 -27
  157. package/dist/ui/server/sites.html +120 -120
  158. package/dist/ui/server/ssh-keys.html +52 -52
  159. package/dist/ui/server/team.html +144 -144
  160. package/dist/ui/server/terminal.html +15 -15
  161. package/dist/ui/serverless/alarms.html +52 -52
  162. package/dist/ui/serverless/assets.html +27 -27
  163. package/dist/ui/serverless/cost.html +2 -2
  164. package/dist/ui/serverless/data.html +36 -36
  165. package/dist/ui/serverless/deployments.html +27 -27
  166. package/dist/ui/serverless/firewall.html +1 -1
  167. package/dist/ui/serverless/functions.html +40 -40
  168. package/dist/ui/serverless/logs.html +24 -24
  169. package/dist/ui/serverless/metrics.html +2 -2
  170. package/dist/ui/serverless/queues.html +48 -48
  171. package/dist/ui/serverless/secrets.html +51 -51
  172. package/dist/ui/serverless/traces.html +6 -6
  173. package/dist/ui/serverless.html +53 -53
  174. package/dist/ui-src/src/charts.ts +17499 -12662
  175. package/dist/ui-src/src/topology.ts +2 -2
  176. package/package.json +3 -3
  177. package/dist/bin/chunk-00kg80qg.js +0 -1
  178. package/dist/bin/chunk-09nwf2gy.js +0 -34
  179. package/dist/bin/chunk-1k5kszjp.js +0 -111
  180. package/dist/bin/chunk-21e0mavm.js +0 -1
  181. package/dist/bin/chunk-271gk1n2.js +0 -6
  182. package/dist/bin/chunk-2empps47.js +0 -2
  183. package/dist/bin/chunk-38pq971s.js +0 -2
  184. package/dist/bin/chunk-3gykfyq4.js +0 -37
  185. package/dist/bin/chunk-3vqfexc4.js +0 -70
  186. package/dist/bin/chunk-4vrqm9h0.js +0 -2
  187. package/dist/bin/chunk-598yf4bs.js +0 -1
  188. package/dist/bin/chunk-5ectjq0b.js +0 -1
  189. package/dist/bin/chunk-5erkxpt7.js +0 -512
  190. package/dist/bin/chunk-5mrtzemj.js +0 -1
  191. package/dist/bin/chunk-5n9fmabb.js +0 -1
  192. package/dist/bin/chunk-9knpg30y.js +0 -1
  193. package/dist/bin/chunk-9pvsff8g.js +0 -1
  194. package/dist/bin/chunk-ax9mr6wm.js +0 -44
  195. package/dist/bin/chunk-axhnkn5g.js +0 -2
  196. package/dist/bin/chunk-c1vcdgvr.js +0 -1
  197. package/dist/bin/chunk-ctd2vg9w.js +0 -2
  198. package/dist/bin/chunk-dbgffky8.js +0 -1
  199. package/dist/bin/chunk-ddk4rt4j.js +0 -6
  200. package/dist/bin/chunk-dwr30vbv.js +0 -1
  201. package/dist/bin/chunk-e0rkrq70.js +0 -1
  202. package/dist/bin/chunk-e3xrwh9z.js +0 -1
  203. package/dist/bin/chunk-fhc6ntvd.js +0 -2
  204. package/dist/bin/chunk-fpm59y25.js +0 -6
  205. package/dist/bin/chunk-fvbxvq6b.js +0 -1
  206. package/dist/bin/chunk-fy8j3y8p.js +0 -92
  207. package/dist/bin/chunk-fz21b57w.js +0 -1
  208. package/dist/bin/chunk-gavvf0pg.js +0 -141
  209. package/dist/bin/chunk-ggn7ax8p.js +0 -4
  210. package/dist/bin/chunk-gpe2prkm.js +0 -1
  211. package/dist/bin/chunk-h5pa5men.js +0 -2
  212. package/dist/bin/chunk-hm08xdxf.js +0 -2
  213. package/dist/bin/chunk-hzgz13nf.js +0 -1
  214. package/dist/bin/chunk-j703btc5.js +0 -50
  215. package/dist/bin/chunk-k9t9wvms.js +0 -1
  216. package/dist/bin/chunk-m669wtgr.js +0 -1
  217. package/dist/bin/chunk-m7dgskt1.js +0 -1
  218. package/dist/bin/chunk-mr0atd2s.js +0 -2
  219. package/dist/bin/chunk-mz0wbbsj.js +0 -3
  220. package/dist/bin/chunk-ngcyftm2.js +0 -1
  221. package/dist/bin/chunk-p66ptpmr.js +0 -2
  222. package/dist/bin/chunk-qk9qgepa.js +0 -1
  223. package/dist/bin/chunk-rytk89az.js +0 -60
  224. package/dist/bin/chunk-tga3hhwk.js +0 -6
  225. package/dist/bin/chunk-vek8a0w6.js +0 -1
  226. package/dist/bin/chunk-vm3q5gf2.js +0 -3
  227. package/dist/bin/chunk-y7s5r8y6.js +0 -3
  228. package/dist/bin/chunk-yv9sth30.js +0 -1
  229. package/dist/bin/chunk-zmegvjp8.js +0 -581
  230. package/dist/chunk-0ccta6z6.js +0 -6
  231. package/dist/chunk-0k1cs6pp.js +0 -1
  232. package/dist/chunk-1egjn203.js +0 -704
  233. package/dist/chunk-2wx29qga.js +0 -5
  234. package/dist/chunk-5m5rqmv7.js +0 -1
  235. package/dist/chunk-8ea5022g.js +0 -114
  236. package/dist/chunk-8xqn3c0w.js +0 -2
  237. package/dist/chunk-b4esxhmw.js +0 -2
  238. package/dist/chunk-b8e5wzwn.js +0 -44
  239. package/dist/chunk-bggt4n6e.js +0 -2
  240. package/dist/chunk-cwkg37rs.js +0 -37
  241. package/dist/chunk-gnv3r2jg.js +0 -1
  242. package/dist/chunk-hg3c48cp.js +0 -34
  243. package/dist/chunk-m5azeva3.js +0 -2
  244. package/dist/chunk-r3qf56b3.js +0 -92
  245. package/dist/chunk-sdqa9ghv.js +0 -141
  246. package/dist/chunk-svrvvcm7.js +0 -1
  247. package/dist/chunk-v0p3hpc3.js +0 -60
  248. package/dist/chunk-wdzjbecg.js +0 -50
  249. package/dist/chunk-ww8k3g7j.js +0 -1
  250. package/dist/chunk-xmqfc62w.js +0 -1
  251. package/dist/chunk-xrebj679.js +0 -435
  252. package/dist/chunk-y21zk0pn.js +0 -4
@@ -1,92 +0,0 @@
1
- import{Ng as y,Og as b}from"./chunk-fpm59y25.js";import{Vo as H}from"./chunk-mh0kdzqp.js";import*as J from"node:crypto";import{readFileSync as m}from"node:fs";import{readdir as d}from"node:fs/promises";import{join as p}from"node:path";function f(_){if(_){let C=h(_);if(!C)throw Error(`AWS profile '${_}' not found in ~/.aws/credentials`);return C}let E=process.env.AWS_ACCESS_KEY_ID,W=process.env.AWS_SECRET_ACCESS_KEY;if(E&&W)return{accessKeyId:E,secretAccessKey:W,sessionToken:process.env.AWS_SESSION_TOKEN};return h(process.env.AWS_PROFILE||"default")??{accessKeyId:"",secretAccessKey:""}}function h(_){let{existsSync:E,readFileSync:W}=H("node:fs"),{homedir:C}=H("node:os"),{join:A}=H("node:path"),Y=process.env.AWS_SHARED_CREDENTIALS_FILE||A(C(),".aws","credentials");if(!E(Y))return null;let $=W(Y,"utf-8"),G=null,V,Z,Q;for(let N of $.split(`
2
- `)){let L=N.trim();if(!L||L.startsWith("#")||L.startsWith(";"))continue;let w=L.match(/^\[([^\]]+)\]$/);if(w){if(G===_&&V&&Z)return{accessKeyId:V,secretAccessKey:Z,sessionToken:Q};G=w[1],V=void 0,Z=void 0,Q=void 0;continue}if(G===_){let[M,...U]=L.split("="),F=U.join("=").trim();switch(M.trim().toLowerCase()){case"aws_access_key_id":V=F;break;case"aws_secret_access_key":Z=F;break;case"aws_session_token":Q=F;break}}}if(G===_&&V&&Z)return{accessKeyId:V,secretAccessKey:Z,sessionToken:Q};return null}function g(_){let{buffer:E,byteOffset:W,byteLength:C}=_;if(E instanceof ArrayBuffer)return E.slice(W,W+C);let A=new ArrayBuffer(C);return new Uint8Array(A).set(new Uint8Array(_)),A}class l{client;region;explicitProfile;endpoint;endpointProtocol="https";forcePathStyle;explicitCredentials;constructor(_="us-east-1",E,W){let C=typeof _==="string"?W:_,A=typeof _==="string"?_:_.region??"us-east-1",Y=typeof _==="string"?E:_.profile,$=C?.endpoint?y({region:A,path:"/",endpoint:C.endpoint}):void 0;this.region=A,this.explicitProfile=Y,this.endpoint=$?.host,this.endpointProtocol=$?.protocol??"https",this.forcePathStyle=C?.forcePathStyle,this.explicitCredentials=C?.credentials,this.client=new b(C?.credentials,{profile:Y,endpoint:C?.endpoint,forcePathStyle:C?.forcePathStyle})}getCredentials(){if(this.explicitCredentials?.accessKeyId&&this.explicitCredentials.secretAccessKey)return this.explicitCredentials;let _=f(this.explicitProfile);if(_.accessKeyId&&_.secretAccessKey)return _;throw Error("S3 credentials not found. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (or pass explicit credentials/profile), or configure ~/.aws/credentials.")}s3BaseHost(){return this.endpoint||`s3.${this.region}.amazonaws.com`}s3VirtualHost(_){return this.forcePathStyle?this.s3BaseHost():`${_}.${this.s3BaseHost()}`}objectPath(_,E){return this.forcePathStyle?`/${_}/${E}`:`/${E}`}objectUrl(_,E){return`${this.endpointProtocol}://${this.s3VirtualHost(_)}${this.objectPath(_,E)}`}async listBuckets(){let _=await this.client.request({service:"s3",region:this.region,method:"GET",path:"/"}),E=[],C=(_?.ListAllMyBucketsResult??_)?.Buckets?.Bucket;if(C){let A=Array.isArray(C)?C:[C];for(let Y of A)E.push({Name:Y.Name,CreationDate:Y.CreationDate})}return{Buckets:E}}async createBucket(_,E){let W={};if(E?.acl)W["x-amz-acl"]=E.acl;let C;if(this.region!=="us-east-1"&&!this.endpoint)C=`<?xml version="1.0" encoding="UTF-8"?>
3
- <CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
4
- <LocationConstraint>${this.region}</LocationConstraint>
5
- </CreateBucketConfiguration>`,W["Content-Type"]="application/xml";await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,headers:W,body:C})}async deleteBucket(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`})}async emptyAndDeleteBucket(_){let E=!0;while(E){let W=await this.listAllObjects({bucket:_});if(W.length===0){E=!1;break}let C=W.map((A)=>A.Key);for(let A=0;A<C.length;A+=1000){let Y=C.slice(A,A+1000);await this.deleteObjects(_,Y)}}await this.deleteBucket(_)}async listAllObjects(_){let E=[],W;do{let C={"list-type":"2","max-keys":"1000"};if(_.prefix)C.prefix=_.prefix;if(W)C["continuation-token"]=W;let A=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_.bucket}`,queryParams:C}),Y=A?.ListBucketResult??A,$=Y?.Contents;if($){let V=Array.isArray($)?$:[$];for(let Z of V)E.push({Key:Z.Key,LastModified:Z.LastModified||"",Size:Number.parseInt(Z.Size||"0"),ETag:Z.ETag})}let G=Y?.IsTruncated;W=G==="true"||G===!0?Y?.NextContinuationToken:void 0}while(W);return E}async list(_){let E=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_.bucket}`}),W=[],A=(E?.ListBucketResult??E)?.Contents;if(A){let Y=Array.isArray(A)?A:[A];for(let $ of Y){if(_.prefix&&!$.Key?.startsWith(_.prefix))continue;if(W.push({Key:$.Key||"",LastModified:$.LastModified||"",Size:Number.parseInt($.Size||"0"),ETag:$.ETag}),_.maxKeys&&W.length>=_.maxKeys)break}}return W}async putObject(_){let E={};if(_.acl)E["x-amz-acl"]=_.acl;if(_.cacheControl)E["Cache-Control"]=_.cacheControl;if(_.contentType)E["Content-Type"]=_.contentType;if(_.metadata)for(let[A,Y]of Object.entries(_.metadata))E[`x-amz-meta-${A}`]=Y;let W=_.key.split("/").map((A)=>encodeURIComponent(A)).join("/"),C=_.body instanceof Uint8Array&&!Buffer.isBuffer(_.body)?Buffer.from(_.body):_.body;if(Buffer.isBuffer(C)||C instanceof Uint8Array){let A=Buffer.isBuffer(C)?C:Buffer.from(C),{accessKeyId:Y,secretAccessKey:$,sessionToken:G}=this.getCredentials(),V=this.s3VirtualHost(_.bucket),Z=this.objectPath(_.bucket,W),Q=this.objectUrl(_.bucket,W),N=new Date,L=N.toISOString().replace(/[:-]|\.\d{3}/g,""),w=N.toISOString().slice(0,10).replace(/-/g,""),M=J.createHash("sha256").update(A).digest("hex"),U={host:V,"x-amz-date":L,"x-amz-content-sha256":M,...E};if(G)U["x-amz-security-token"]=G;let F=Object.keys(U).sort().map((B)=>`${B.toLowerCase()}:${U[B].trim()}
6
- `).join(""),x=Object.keys(U).sort().map((B)=>B.toLowerCase()).join(";"),I=["PUT",Z,"",F,x,M].join(`
7
- `),z="AWS4-HMAC-SHA256",P=`${w}/${this.region}/s3/aws4_request`,K=[z,L,P,J.createHash("sha256").update(I).digest("hex")].join(`
8
- `),v=J.createHmac("sha256",`AWS4${$}`).update(w).digest(),X=J.createHmac("sha256",v).update(this.region).digest(),O=J.createHmac("sha256",X).update("s3").digest(),j=J.createHmac("sha256",O).update("aws4_request").digest(),T=J.createHmac("sha256",j).update(K).digest("hex"),R=`${z} Credential=${Y}/${P}, SignedHeaders=${x}, Signature=${T}`,D=await fetch(Q,{method:"PUT",headers:{...U,Authorization:R},body:g(A)});if(!D.ok){let B=await D.text();throw Error(`S3 PUT failed: ${D.status} ${B}`)}return}await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${W}`,bucket:_.bucket,headers:E,body:_.body})}async getObject(_,E){let W=E.split("/").map((A)=>encodeURIComponent(A)).join("/");return await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${W}`,bucket:_,rawResponse:!0})}async getObjectBytes(_,E){let{accessKeyId:W,secretAccessKey:C,sessionToken:A}=this.getCredentials(),Y=this.s3VirtualHost(_),$=E.split("/").map((B)=>encodeURIComponent(B)).join("/"),G=this.objectPath(_,$),V=this.objectUrl(_,$),Z=new Date,Q=Z.toISOString().replace(/[:-]|\.\d{3}/g,""),N=Z.toISOString().slice(0,10).replace(/-/g,""),L=J.createHash("sha256").update("").digest("hex"),w={host:Y,"x-amz-date":Q,"x-amz-content-sha256":L};if(A)w["x-amz-security-token"]=A;let M=Object.keys(w).sort().map((B)=>`${B.toLowerCase()}:${w[B].trim()}
9
- `).join(""),U=Object.keys(w).sort().map((B)=>B.toLowerCase()).join(";"),F=["GET",G,"",M,U,L].join(`
10
- `),x="AWS4-HMAC-SHA256",I=`${N}/${this.region}/s3/aws4_request`,z=[x,Q,I,J.createHash("sha256").update(F).digest("hex")].join(`
11
- `),P=J.createHmac("sha256",`AWS4${C}`).update(N).digest(),K=J.createHmac("sha256",P).update(this.region).digest(),v=J.createHmac("sha256",K).update("s3").digest(),X=J.createHmac("sha256",v).update("aws4_request").digest(),O=J.createHmac("sha256",X).update(z).digest("hex"),j=`${x} Credential=${W}/${I}, SignedHeaders=${U}, Signature=${O}`,T=await fetch(V,{method:"GET",headers:{...w,Authorization:j}});if(!T.ok){let B=await T.text();throw Error(`S3 GET failed: ${T.status} ${B}`)}let R=await T.arrayBuffer(),D=T.headers.get("content-length");return{body:new Uint8Array(R),contentType:T.headers.get("content-type")??void 0,contentLength:D?Number.parseInt(D,10):void 0}}async copyObject(_){let E={"x-amz-copy-source":`/${_.sourceBucket}/${_.sourceKey}`};if(_.metadataDirective)E["x-amz-metadata-directive"]=_.metadataDirective;if(_.contentType)E["Content-Type"]=_.contentType;if(_.metadata)for(let[W,C]of Object.entries(_.metadata))E[`x-amz-meta-${W}`]=C;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_.destinationBucket}/${_.destinationKey}`,headers:E})}async deleteObject(_,E){let W=E.split("/").map((C)=>encodeURIComponent(C)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${W}`,bucket:_})}async deleteObjects(_,E){let W=`<?xml version="1.0" encoding="UTF-8"?>
12
- <Delete>
13
- ${E.map((A)=>`<Object><Key>${A}</Key></Object>`).join(`
14
- `)}
15
- </Delete>`,C=J.createHash("md5").update(W).digest("base64");await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${_}`,queryParams:{delete:""},body:W,headers:{"Content-Type":"application/xml","Content-MD5":C}})}async bucketExists(_){try{return await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${_}`}),!0}catch{return!1}}async copy(_){let E=m(_.source);await this.putObject({bucket:_.bucket,key:_.key,body:E,acl:_.acl,cacheControl:_.cacheControl,contentType:_.contentType,metadata:_.metadata})}async sync(_){let E=await this.listFilesRecursive(_.source);for(let W of E){if(_.exclude&&_.exclude.some((Y)=>W.includes(Y)))continue;if(_.include&&!_.include.some((Y)=>W.includes(Y)))continue;let C=W.substring(_.source.length+1),A=_.prefix?`${_.prefix}/${C}`:C;if(!_.dryRun){let Y=m(W);await this.putObject({bucket:_.bucket,key:A,body:Y,acl:_.acl,cacheControl:_.cacheControl,contentType:_.contentType,metadata:_.metadata})}}}async delete(_,E){await this.deleteObject(_,E)}async deletePrefix(_,E){let C=(await this.list({bucket:_,prefix:E})).map((A)=>A.Key);if(C.length>0)await this.deleteObjects(_,C)}async getBucketSize(_,E){return(await this.list({bucket:_,prefix:E})).reduce((C,A)=>C+A.Size,0)}async listFilesRecursive(_){let E=[],W=await d(_,{withFileTypes:!0});for(let C of W){let A=p(_,C.name);if(C.isDirectory()){let Y=await this.listFilesRecursive(A);E.push(...Y)}else E.push(A)}return E}async putBucketPolicy(_,E){let{accessKeyId:W,secretAccessKey:C,sessionToken:A}=this.getCredentials(),Y=this.s3BaseHost(),$=typeof E==="string"?E:JSON.stringify(E),G=new Date,V=G.toISOString().replace(/[:-]|\.\d{3}/g,""),Z=G.toISOString().slice(0,10).replace(/-/g,""),Q=J.createHash("sha256").update($).digest("hex"),N="/"+_,L="policy=",w={host:Y,"x-amz-date":V,"x-amz-content-sha256":Q,"content-type":"application/json"};if(A)w["x-amz-security-token"]=A;let M=Object.keys(w).sort().map((D)=>`${D.toLowerCase()}:${w[D].trim()}
16
- `).join(""),U=Object.keys(w).sort().map((D)=>D.toLowerCase()).join(";"),F=["PUT",N,"policy=",M,U,Q].join(`
17
- `),x="AWS4-HMAC-SHA256",I=`${Z}/${this.region}/s3/aws4_request`,z=[x,V,I,J.createHash("sha256").update(F).digest("hex")].join(`
18
- `),P=J.createHmac("sha256","AWS4"+C).update(Z).digest(),K=J.createHmac("sha256",P).update(this.region).digest(),v=J.createHmac("sha256",K).update("s3").digest(),X=J.createHmac("sha256",v).update("aws4_request").digest(),O=J.createHmac("sha256",X).update(z).digest("hex"),j=`${x} Credential=${W}/${I}, SignedHeaders=${U}, Signature=${O}`,T=`${this.endpointProtocol}://${Y}${N}?policy=`,R=await fetch(T,{method:"PUT",headers:{...w,Authorization:j},body:$});if(!R.ok){let D=await R.text();throw Error(`Failed to put bucket policy: ${R.status} ${D}`)}}async getBucketPolicy(_){let{accessKeyId:E,secretAccessKey:W,sessionToken:C}=this.getCredentials(),A=this.s3BaseHost(),Y=new Date,$=Y.toISOString().replace(/[:-]|\.\d{3}/g,""),G=Y.toISOString().slice(0,10).replace(/-/g,""),V=J.createHash("sha256").update("").digest("hex"),Z="/"+_,Q="policy=",N={host:A,"x-amz-date":$,"x-amz-content-sha256":V};if(C)N["x-amz-security-token"]=C;let L=Object.keys(N).sort().map((R)=>`${R.toLowerCase()}:${N[R].trim()}
19
- `).join(""),w=Object.keys(N).sort().map((R)=>R.toLowerCase()).join(";"),M=["GET",Z,"policy=",L,w,V].join(`
20
- `),U="AWS4-HMAC-SHA256",F=`${G}/${this.region}/s3/aws4_request`,x=[U,$,F,J.createHash("sha256").update(M).digest("hex")].join(`
21
- `),I=J.createHmac("sha256","AWS4"+W).update(G).digest(),z=J.createHmac("sha256",I).update(this.region).digest(),P=J.createHmac("sha256",z).update("s3").digest(),K=J.createHmac("sha256",P).update("aws4_request").digest(),v=J.createHmac("sha256",K).update(x).digest("hex"),X=`${U} Credential=${E}/${F}, SignedHeaders=${w}, Signature=${v}`,O=`${this.endpointProtocol}://${A}${Z}?policy=`,j=await fetch(O,{method:"GET",headers:{...N,Authorization:X}});if(j.status===404)return null;if(!j.ok){let R=await j.text();throw Error(`Failed to get bucket policy: ${j.status} ${R}`)}let T=await j.text();return JSON.parse(T)}async deleteBucketPolicy(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{policy:""}})}async headBucket(_){try{return{exists:!0,region:(await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${_}`,returnHeaders:!0}))?.headers?.["x-amz-bucket-region"]}}catch(E){if(E.statusCode===404)return{exists:!1};throw E}}async headObject(_,E){try{let W=await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${_}/${E}`,returnHeaders:!0});return{ContentLength:W?.headers?.["content-length"]?parseInt(W.headers["content-length"]):void 0,ContentType:W?.headers?.["content-type"],ETag:W?.headers?.etag,LastModified:W?.headers?.["last-modified"]}}catch(W){if(W.statusCode===404)return null;throw W}}async getObjectBuffer(_,E){let W=await this.getObject(_,E);return Buffer.from(W)}async getObjectJson(_,E){let W=await this.getObject(_,E);return JSON.parse(W)}async putObjectJson(_,E,W,C){await this.putObject({bucket:_,key:E,body:JSON.stringify(W),contentType:"application/json",...C})}async getBucketVersioning(_){return{Status:(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{versioning:""}}))?.VersioningConfiguration?.Status}}async putBucketVersioning(_,E){let W=`<?xml version="1.0" encoding="UTF-8"?>
22
- <VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
23
- <Status>${E}</Status>
24
- </VersioningConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{versioning:""},headers:{"Content-Type":"application/xml"},body:W})}async getBucketLifecycleConfiguration(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{lifecycle:""}}))?.LifecycleConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putBucketLifecycleConfiguration(_,E){let C=`<?xml version="1.0" encoding="UTF-8"?>
25
- <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
26
- ${E.map((A)=>{let Y=`<Rule><ID>${A.ID}</ID><Status>${A.Status}</Status>`;if(A.Filter)Y+=`<Filter><Prefix>${A.Filter.Prefix||""}</Prefix></Filter>`;else Y+="<Filter><Prefix></Prefix></Filter>";if(A.Expiration){if(A.Expiration.Days)Y+=`<Expiration><Days>${A.Expiration.Days}</Days></Expiration>`;else if(A.Expiration.Date)Y+=`<Expiration><Date>${A.Expiration.Date}</Date></Expiration>`}if(A.Transitions)for(let $ of A.Transitions)Y+=`<Transition><Days>${$.Days}</Days><StorageClass>${$.StorageClass}</StorageClass></Transition>`;if(A.NoncurrentVersionExpiration)Y+=`<NoncurrentVersionExpiration><NoncurrentDays>${A.NoncurrentVersionExpiration.NoncurrentDays}</NoncurrentDays></NoncurrentVersionExpiration>`;return Y+="</Rule>",Y}).join("")}
27
- </LifecycleConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{lifecycle:""},headers:{"Content-Type":"application/xml"},body:C})}async deleteBucketLifecycleConfiguration(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{lifecycle:""}})}async getBucketCors(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{cors:""}}))?.CORSConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putBucketCors(_,E){let C=`<?xml version="1.0" encoding="UTF-8"?>
28
- <CORSConfiguration>
29
- ${E.map((A)=>{let Y="<CORSRule>";for(let $ of A.AllowedOrigins)Y+=`<AllowedOrigin>${$}</AllowedOrigin>`;for(let $ of A.AllowedMethods)Y+=`<AllowedMethod>${$}</AllowedMethod>`;if(A.AllowedHeaders)for(let $ of A.AllowedHeaders)Y+=`<AllowedHeader>${$}</AllowedHeader>`;if(A.ExposeHeaders)for(let $ of A.ExposeHeaders)Y+=`<ExposeHeader>${$}</ExposeHeader>`;if(A.MaxAgeSeconds)Y+=`<MaxAgeSeconds>${A.MaxAgeSeconds}</MaxAgeSeconds>`;return Y+="</CORSRule>",Y}).join("")}
30
- </CORSConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{cors:""},headers:{"Content-Type":"application/xml"},body:C})}async deleteBucketCors(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{cors:""}})}async getBucketEncryption(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{encryption:""}}))?.ServerSideEncryptionConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putBucketEncryption(_,E,W){let C=`<ApplyServerSideEncryptionByDefault><SSEAlgorithm>${E}</SSEAlgorithm>`;if(W)C+=`<KMSMasterKeyID>${W}</KMSMasterKeyID>`;C+="</ApplyServerSideEncryptionByDefault>";let A=`<?xml version="1.0" encoding="UTF-8"?>
31
- <ServerSideEncryptionConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
32
- <Rule>${C}</Rule>
33
- </ServerSideEncryptionConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{encryption:""},headers:{"Content-Type":"application/xml"},body:A})}async deleteBucketEncryption(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{encryption:""}})}async getBucketTagging(_){try{let W=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!W)return[];return Array.isArray(W)?W:[W]}catch(E){if(E.statusCode===404)return[];throw E}}async putBucketTagging(_,E){let C=`<?xml version="1.0" encoding="UTF-8"?>
34
- <Tagging>
35
- <TagSet>${E.map((A)=>`<Tag><Key>${A.Key}</Key><Value>${A.Value}</Value></Tag>`).join("")}</TagSet>
36
- </Tagging>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{tagging:""},headers:{"Content-Type":"application/xml"},body:C})}async deleteBucketTagging(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{tagging:""}})}async getObjectTagging(_,E){try{let C=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}/${E}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!C)return[];return Array.isArray(C)?C:[C]}catch(W){if(W.statusCode===404)return[];throw W}}async putObjectTagging(_,E,W){let A=`<?xml version="1.0" encoding="UTF-8"?>
37
- <Tagging>
38
- <TagSet>${W.map((Y)=>`<Tag><Key>${Y.Key}</Key><Value>${Y.Value}</Value></Tag>`).join("")}</TagSet>
39
- </Tagging>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}/${E}`,queryParams:{tagging:""},headers:{"Content-Type":"application/xml"},body:A})}async deleteObjectTagging(_,E){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}/${E}`,queryParams:{tagging:""}})}async getBucketAcl(_){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{acl:""}}))?.AccessControlPolicy}async putBucketAcl(_,E){await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{acl:""},headers:{"x-amz-acl":E}})}async getObjectAcl(_,E){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}/${E}`,queryParams:{acl:""}}))?.AccessControlPolicy}async putObjectAcl(_,E,W){await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}/${E}`,queryParams:{acl:""},headers:{"x-amz-acl":W}})}async getBucketLocation(_){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{location:""}}))?.LocationConstraint||"us-east-1"}async getBucketLogging(_){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{logging:""}}))?.BucketLoggingStatus}async putBucketLogging(_,E,W){let C=`<?xml version="1.0" encoding="UTF-8"?>
40
- <BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
41
- <LoggingEnabled>
42
- <TargetBucket>${E}</TargetBucket>
43
- <TargetPrefix>${W}</TargetPrefix>
44
- </LoggingEnabled>
45
- </BucketLoggingStatus>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{logging:""},headers:{"Content-Type":"application/xml"},body:C})}async getBucketNotificationConfiguration(_){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{notification:""}}))?.NotificationConfiguration}async putBucketNotificationConfiguration(_,E){let W="";if(E.LambdaFunctionConfigurations)for(let A of E.LambdaFunctionConfigurations){if(W+="<CloudFunctionConfiguration>",A.Id)W+=`<Id>${A.Id}</Id>`;W+=`<CloudFunction>${A.LambdaFunctionArn}</CloudFunction>`;for(let Y of A.Events)W+=`<Event>${Y}</Event>`;if(A.Filter?.Key?.FilterRules){W+="<Filter><S3Key>";for(let Y of A.Filter.Key.FilterRules)W+=`<FilterRule><Name>${Y.Name}</Name><Value>${Y.Value}</Value></FilterRule>`;W+="</S3Key></Filter>"}W+="</CloudFunctionConfiguration>"}if(E.TopicConfigurations)for(let A of E.TopicConfigurations){if(W+="<TopicConfiguration>",A.Id)W+=`<Id>${A.Id}</Id>`;W+=`<Topic>${A.TopicArn}</Topic>`;for(let Y of A.Events)W+=`<Event>${Y}</Event>`;W+="</TopicConfiguration>"}if(E.QueueConfigurations)for(let A of E.QueueConfigurations){if(W+="<QueueConfiguration>",A.Id)W+=`<Id>${A.Id}</Id>`;W+=`<Queue>${A.QueueArn}</Queue>`;for(let Y of A.Events)W+=`<Event>${Y}</Event>`;W+="</QueueConfiguration>"}let C=`<?xml version="1.0" encoding="UTF-8"?>
46
- <NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
47
- ${W}
48
- </NotificationConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{notification:""},headers:{"Content-Type":"application/xml"},body:C})}async getBucketWebsite(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{website:""}}))?.WebsiteConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putBucketWebsite(_,E){let W="";if(E.RedirectAllRequestsTo)W=`<RedirectAllRequestsTo>
49
- <HostName>${E.RedirectAllRequestsTo.HostName}</HostName>
50
- ${E.RedirectAllRequestsTo.Protocol?`<Protocol>${E.RedirectAllRequestsTo.Protocol}</Protocol>`:""}
51
- </RedirectAllRequestsTo>`;else if(W=`<IndexDocument><Suffix>${E.IndexDocument}</Suffix></IndexDocument>`,E.ErrorDocument)W+=`<ErrorDocument><Key>${E.ErrorDocument}</Key></ErrorDocument>`;let C=`<?xml version="1.0" encoding="UTF-8"?>
52
- <WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
53
- ${W}
54
- </WebsiteConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{website:""},headers:{"Content-Type":"application/xml"},body:C})}async deleteBucketWebsite(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{website:""}})}async getBucketReplication(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{replication:""}}))?.ReplicationConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async deleteBucketReplication(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{replication:""}})}async getPublicAccessBlock(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{publicAccessBlock:""}}))?.PublicAccessBlockConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putPublicAccessBlock(_,E){let W=`<?xml version="1.0" encoding="UTF-8"?>
55
- <PublicAccessBlockConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
56
- <BlockPublicAcls>${E.BlockPublicAcls??!0}</BlockPublicAcls>
57
- <IgnorePublicAcls>${E.IgnorePublicAcls??!0}</IgnorePublicAcls>
58
- <BlockPublicPolicy>${E.BlockPublicPolicy??!0}</BlockPublicPolicy>
59
- <RestrictPublicBuckets>${E.RestrictPublicBuckets??!0}</RestrictPublicBuckets>
60
- </PublicAccessBlockConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{publicAccessBlock:""},headers:{"Content-Type":"application/xml"},body:W})}async deletePublicAccessBlock(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{publicAccessBlock:""}})}generatePresignedGetUrl(_,E,W=3600){let{accessKeyId:C,secretAccessKey:A}=this.getCredentials(),Y=this.s3VirtualHost(_),$=new Date,G=$.toISOString().replace(/[:-]|\.\d{3}/g,""),V=$.toISOString().slice(0,10).replace(/-/g,""),Z=`${V}/${this.region}/s3/aws4_request`,Q=`${C}/${Z}`,N=E.split("/").map((P)=>encodeURIComponent(P)).join("/"),L=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":Q,"X-Amz-Date":G,"X-Amz-Expires":W.toString(),"X-Amz-SignedHeaders":"host"}),w=["GET",this.objectPath(_,N),L.toString(),`host:${Y}
61
- `,"host","UNSIGNED-PAYLOAD"].join(`
62
- `),M=["AWS4-HMAC-SHA256",G,Z,J.createHash("sha256").update(w).digest("hex")].join(`
63
- `),U=J.createHmac("sha256",`AWS4${A}`).update(V).digest(),F=J.createHmac("sha256",U).update(this.region).digest(),x=J.createHmac("sha256",F).update("s3").digest(),I=J.createHmac("sha256",x).update("aws4_request").digest(),z=J.createHmac("sha256",I).update(M).digest("hex");return L.append("X-Amz-Signature",z),`${this.endpointProtocol}://${Y}${this.objectPath(_,N)}?${L.toString()}`}generatePresignedPutUrl(_,E,W,C=3600){let{accessKeyId:A,secretAccessKey:Y}=this.getCredentials(),$=this.s3VirtualHost(_),G=new Date,V=G.toISOString().replace(/[:-]|\.\d{3}/g,""),Z=G.toISOString().slice(0,10).replace(/-/g,""),Q=`${Z}/${this.region}/s3/aws4_request`,N=`${A}/${Q}`,L=E.split("/").map((K)=>encodeURIComponent(K)).join("/"),w=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":N,"X-Amz-Date":V,"X-Amz-Expires":C.toString(),"X-Amz-SignedHeaders":"content-type;host"}),M=["PUT",this.objectPath(_,L),w.toString(),`content-type:${W}
64
- host:${$}
65
- `,"content-type;host","UNSIGNED-PAYLOAD"].join(`
66
- `),U=["AWS4-HMAC-SHA256",V,Q,J.createHash("sha256").update(M).digest("hex")].join(`
67
- `),F=J.createHmac("sha256",`AWS4${Y}`).update(Z).digest(),x=J.createHmac("sha256",F).update(this.region).digest(),I=J.createHmac("sha256",x).update("s3").digest(),z=J.createHmac("sha256",I).update("aws4_request").digest(),P=J.createHmac("sha256",z).update(U).digest("hex");return w.append("X-Amz-Signature",P),`${this.endpointProtocol}://${$}${this.objectPath(_,L)}?${w.toString()}`}async createMultipartUpload(_,E,W){let C={};if(W?.contentType)C["Content-Type"]=W.contentType;if(W?.metadata)for(let[G,V]of Object.entries(W.metadata))C[`x-amz-meta-${G}`]=V;let A=E.split("/").map((G)=>encodeURIComponent(G)).join("/"),Y=await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${A}`,bucket:_,queryParams:{uploads:""},headers:C});return{UploadId:(Y?.InitiateMultipartUploadResult??Y)?.UploadId}}async uploadPart(_,E,W,C,A){let{accessKeyId:Y,secretAccessKey:$,sessionToken:G}=this.getCredentials(),V=this.s3VirtualHost(_),Z=E.split("/").map((q)=>encodeURIComponent(q)).join("/"),Q=this.objectPath(_,Z),N=`${this.objectUrl(_,Z)}?partNumber=${C}&uploadId=${encodeURIComponent(W)}`,L=new Date,w=L.toISOString().replace(/[:-]|\.\d{3}/g,""),M=L.toISOString().slice(0,10).replace(/-/g,""),U=J.createHash("sha256").update(A).digest("hex"),F={host:V,"x-amz-date":w,"x-amz-content-sha256":U};if(G)F["x-amz-security-token"]=G;let x=Object.keys(F).sort().map((q)=>`${q.toLowerCase()}:${F[q].trim()}
68
- `).join(""),I=Object.keys(F).sort().map((q)=>q.toLowerCase()).join(";"),z=["PUT",Q,`partNumber=${C}&uploadId=${encodeURIComponent(W)}`,x,I,U].join(`
69
- `),P="AWS4-HMAC-SHA256",K=`${M}/${this.region}/s3/aws4_request`,v=[P,w,K,J.createHash("sha256").update(z).digest("hex")].join(`
70
- `),X=J.createHmac("sha256",`AWS4${$}`).update(M).digest(),O=J.createHmac("sha256",X).update(this.region).digest(),j=J.createHmac("sha256",O).update("s3").digest(),T=J.createHmac("sha256",j).update("aws4_request").digest(),R=J.createHmac("sha256",T).update(v).digest("hex"),D=`${P} Credential=${Y}/${K}, SignedHeaders=${I}, Signature=${R}`,B=await fetch(N,{method:"PUT",headers:{...F,Authorization:D},body:g(A)});if(!B.ok){let q=await B.text();throw Error(`Upload part failed: ${B.status} ${q}`)}return{ETag:B.headers.get("etag")||""}}async completeMultipartUpload(_,E,W,C){let A=E.split("/").map((G)=>encodeURIComponent(G)).join("/"),$=`<?xml version="1.0" encoding="UTF-8"?>
71
- <CompleteMultipartUpload>${C.sort((G,V)=>G.PartNumber-V.PartNumber).map((G)=>`<Part><PartNumber>${G.PartNumber}</PartNumber><ETag>${G.ETag}</ETag></Part>`).join("")}</CompleteMultipartUpload>`;await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${A}`,bucket:_,queryParams:{uploadId:W},headers:{"Content-Type":"application/xml"},body:$})}async abortMultipartUpload(_,E,W){let C=E.split("/").map((A)=>encodeURIComponent(A)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${C}`,bucket:_,queryParams:{uploadId:W}})}async listMultipartUploads(_){let E=await this.client.request({service:"s3",region:this.region,method:"GET",path:"/",bucket:_,queryParams:{uploads:""}}),W=(E?.ListMultipartUploadsResult??E)?.Upload;if(!W)return[];return(Array.isArray(W)?W:[W]).map((A)=>({Key:A.Key,UploadId:A.UploadId,Initiated:A.Initiated}))}async restoreObject(_,E,W,C="Standard"){let A=`<?xml version="1.0" encoding="UTF-8"?>
72
- <RestoreRequest>
73
- <Days>${W}</Days>
74
- <GlacierJobParameters>
75
- <Tier>${C}</Tier>
76
- </GlacierJobParameters>
77
- </RestoreRequest>`;await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${_}/${E}`,queryParams:{restore:""},headers:{"Content-Type":"application/xml"},body:A})}async selectObjectContent(_,E,W,C,A="JSON"){let Y="";if(C==="CSV")Y="<CSV><FileHeaderInfo>USE</FileHeaderInfo></CSV>";else if(C==="JSON")Y="<JSON><Type>DOCUMENT</Type></JSON>";else Y="<Parquet/>";let $="";if(A==="CSV")$="<CSV/>";else $="<JSON/>";let G=`<?xml version="1.0" encoding="UTF-8"?>
78
- <SelectObjectContentRequest>
79
- <Expression>${W}</Expression>
80
- <ExpressionType>SQL</ExpressionType>
81
- <InputSerialization>${Y}</InputSerialization>
82
- <OutputSerialization>${$}</OutputSerialization>
83
- </SelectObjectContentRequest>`;return await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${_}/${E}`,queryParams:{select:"","select-type":"2"},headers:{"Content-Type":"application/xml"},body:G,rawResponse:!0})}async getSignedUrl(_){let{bucket:E,key:W,expiresIn:C=3600,operation:A="getObject"}=_,{accessKeyId:Y,secretAccessKey:$,sessionToken:G}=this.getCredentials(),V=new Date,Z=V.toISOString().replace(/[:-]|\.\d{3}/g,""),Q=V.toISOString().slice(0,10).replace(/-/g,""),N=this.s3VirtualHost(E),L=A==="putObject"?"PUT":"GET",w="AWS4-HMAC-SHA256",M=`${Q}/${this.region}/s3/aws4_request`,F={"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":`${Y}/${M}`,"X-Amz-Date":Z,"X-Amz-Expires":C.toString(),"X-Amz-SignedHeaders":"host"};if(G)F["X-Amz-Security-Token"]=G;let I=Object.keys(F).sort().map((S)=>`${encodeURIComponent(S)}=${encodeURIComponent(F[S])}`).join("&"),z=W.split("/").map((S)=>encodeURIComponent(S)).join("/"),P=this.objectPath(E,z),K=`host:${N}
84
- `,O=[L,P,I,K,"host","UNSIGNED-PAYLOAD"].join(`
85
- `),j=["AWS4-HMAC-SHA256",Z,M,J.createHash("sha256").update(O).digest("hex")].join(`
86
- `),T=J.createHmac("sha256",`AWS4${$}`).update(Q).digest(),R=J.createHmac("sha256",T).update(this.region).digest(),D=J.createHmac("sha256",R).update("s3").digest(),B=J.createHmac("sha256",D).update("aws4_request").digest(),q=J.createHmac("sha256",B).update(j).digest("hex");return`${this.endpointProtocol}://${N}${P}?${I}&X-Amz-Signature=${q}`}async listObjects(_){let{bucket:E,prefix:W,maxKeys:C=1000,continuationToken:A}=_,Y={"list-type":"2","max-keys":C.toString()};if(W)Y.prefix=W;if(A)Y["continuation-token"]=A;let $=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${E}`,queryParams:Y}),G=[],V=$?.ListBucketResult??$;if(V?.Contents){let Z=Array.isArray(V.Contents)?V.Contents:[V.Contents];for(let Q of Z)G.push({Key:Q.Key||"",LastModified:Q.LastModified||"",Size:Number.parseInt(Q.Size||"0"),ETag:Q.ETag})}return{objects:G,nextContinuationToken:V?.NextContinuationToken}}async emptyBucket(_){let E=0,W=await this.listAllObjects({bucket:_});if(W.length>0)for(let C=0;C<W.length;C+=1000){let Y=W.slice(C,C+1000).map(($)=>$.Key);await this.deleteObjects(_,Y),E+=Y.length}try{let C,A;do{let Y=await this.listObjectVersions({bucket:_,keyMarker:C,versionIdMarker:A,maxKeys:1000}),$=[];if(Y.versions)for(let G of Y.versions)$.push({Key:G.Key,VersionId:G.VersionId});if(Y.deleteMarkers)for(let G of Y.deleteMarkers)$.push({Key:G.Key,VersionId:G.VersionId});if($.length>0)await this.deleteObjectVersions(_,$),E+=$.length;C=Y.nextKeyMarker,A=Y.nextVersionIdMarker}while(C)}catch{}return{deletedCount:E}}async listObjectVersions(_){let{bucket:E,prefix:W,keyMarker:C,versionIdMarker:A,maxKeys:Y=1000}=_,$={versions:"","max-keys":Y.toString()};if(W)$.prefix=W;if(C)$["key-marker"]=C;if(A)$["version-id-marker"]=A;let G=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${E}`,queryParams:$}),V=[],Z=[];if(G.Version){let Q=Array.isArray(G.Version)?G.Version:[G.Version];for(let N of Q)V.push({Key:N.Key,VersionId:N.VersionId,IsLatest:N.IsLatest==="true"})}if(G.DeleteMarker){let Q=Array.isArray(G.DeleteMarker)?G.DeleteMarker:[G.DeleteMarker];for(let N of Q)Z.push({Key:N.Key,VersionId:N.VersionId,IsLatest:N.IsLatest==="true"})}return{versions:V,deleteMarkers:Z,nextKeyMarker:G.NextKeyMarker,nextVersionIdMarker:G.NextVersionIdMarker}}async deleteObjectVersions(_,E){let W=`<?xml version="1.0" encoding="UTF-8"?>
87
- <Delete>
88
- <Quiet>true</Quiet>
89
- ${E.map((A)=>`<Object><Key>${A.Key}</Key>${A.VersionId?`<VersionId>${A.VersionId}</VersionId>`:""}</Object>`).join(`
90
- `)}
91
- </Delete>`,C=J.createHash("md5").update(W).digest("base64");await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${_}`,queryParams:{delete:""},body:W,headers:{"Content-Type":"application/xml","Content-MD5":C}})}}
92
- export{f as _f,l as $f};
@@ -1 +0,0 @@
1
- import{Ua as a}from"./chunk-38pq971s.js";import"./chunk-mh0kdzqp.js";export{a as encodeDashboardPayload};
@@ -1,141 +0,0 @@
1
- import{Og as A}from"./chunk-fpm59y25.js";class N{client;constructor(J,Q){this.client=Q??new A(void 0,{profile:J})}collectionItems(J,Q){let z=J?.Items??J?.[Q];if(!z)return[];if(Array.isArray(z))return z;let Y=z[Q]??z.Item;if(Y===void 0)return typeof z==="object"&&(z.Id||z.PathPattern)?[z]:[];return Array.isArray(Y)?Y:[Y]}validateExistingOriginInput(J,Q){if(!/^[A-Z0-9]{8,32}$/.test(J))throw Error("CloudFront distribution ID is invalid");if(!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(Q.id))throw Error("CloudFront origin ID is invalid");if(!/^(?=.{1,253}$)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/.test(Q.domainName))throw Error("CloudFront origin must be a hostname without a scheme or path");let z=Q.pathPattern.startsWith("/")?Q.pathPattern:`/${Q.pathPattern}`;if(z==="/"||z==="/*"||!/^\/[A-Za-z0-9_.*?~!$&'()+,;=:@%/-]{1,255}$/.test(z))throw Error("CloudFront path pattern must be a non-default absolute pattern");if(Q.originPath&&(!Q.originPath.startsWith("/")||Q.originPath.includes("..")))throw Error("CloudFront origin path must be absolute and traversal-free");if(Object.entries(Q.customHeaders??{}).some(([Y,_])=>!/^[A-Za-z0-9-]{1,64}$/.test(Y)||!_||_.length>1024))throw Error("CloudFront custom origin headers are invalid");return{...Q,pathPattern:z}}async upsertExistingDistributionOrigin(J,Q){let z=this.validateExistingOriginInput(J,Q),Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),_=Y.headers?.etag||Y.headers?.ETag||Y.ETag||"",Z=Y.body?.DistributionConfig||Y.DistributionConfig||Y.body;if(!Z||Z.Enabled===void 0||!_)throw Error("Failed to read an ETag-protected CloudFront distribution config");let $=this.collectionItems(Z.Origins,"Origin"),j=this.collectionItems(Z.CacheBehaviors,"CacheBehavior"),L=$.find((H)=>String(H.Id)===z.id),q=j.find((H)=>String(H.PathPattern)===z.pathPattern);if(L&&String(L.DomainName)!==z.domainName&&!z.replaceExisting)throw Error(`Origin ${z.id} already targets ${L.DomainName}; pass replaceExisting only after reviewing the live config`);if(q&&String(q.TargetOriginId)!==z.id&&!z.replaceExisting)throw Error(`Path ${z.pathPattern} already targets ${q.TargetOriginId}; pass replaceExisting only after reviewing the live config`);let W={Id:z.id,DomainName:z.domainName,OriginPath:z.originPath??"",CustomHeaders:{Quantity:Object.keys(z.customHeaders??{}).length,...Object.keys(z.customHeaders??{}).length?{Items:{OriginCustomHeader:Object.entries(z.customHeaders).map(([H,K])=>({HeaderName:H,HeaderValue:K}))}}:{}},CustomOriginConfig:{HTTPPort:80,HTTPSPort:443,OriginProtocolPolicy:z.protocolPolicy??"https-only",OriginSslProtocols:{Quantity:1,Items:{SslProtocol:["TLSv1.2"]}},OriginReadTimeout:30,OriginKeepaliveTimeout:5},ConnectionAttempts:3,ConnectionTimeout:10,...z.originAccessControlId?{OriginAccessControlId:z.originAccessControlId}:{}},F=["GET","HEAD","OPTIONS","PUT","POST","PATCH","DELETE"],D={PathPattern:z.pathPattern,TargetOriginId:z.id,ViewerProtocolPolicy:"redirect-to-https",Compress:!0,CachePolicyId:"4135ea2d-6df8-44a3-9df3-4b5a84be39ad",OriginRequestPolicyId:"b689b0a8-53d0-40ab-baf2-68738e2966ac",AllowedMethods:{Quantity:F.length,Items:{Method:F},CachedMethods:{Quantity:2,Items:{Method:["GET","HEAD"]}}},SmoothStreaming:!1,FieldLevelEncryptionId:"",TrustedSigners:{Enabled:!1,Quantity:0},TrustedKeyGroups:{Enabled:!1,Quantity:0},LambdaFunctionAssociations:{Quantity:0},FunctionAssociations:{Quantity:0}},G=L?$.map((H)=>String(H.Id)===z.id?W:H):[...$,W],S=q?j.map((H)=>String(H.PathPattern)===z.pathPattern?D:H):[...j,D],U=JSON.stringify($)!==JSON.stringify(G)||JSON.stringify(j)!==JSON.stringify(S);if(!U||z.dryRun)return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:U,applied:!1,etag:_};Z.Origins={Quantity:G.length,Items:{Origin:G}},Z.CacheBehaviors={Quantity:S.length,...S.length?{Items:{CacheBehavior:S}}:{}};let M=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:this.buildDistributionConfigXml(Z),headers:{"Content-Type":"application/xml","If-Match":_}});return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:!0,applied:!0,etag:M.ETag||M.headers?.etag||""}}async removeExistingDistributionOrigin(J,Q){let z=this.validateExistingOriginInput(J,Q),Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),_=Y.headers?.etag||Y.headers?.ETag||Y.ETag||"",Z=Y.body?.DistributionConfig||Y.DistributionConfig||Y.body;if(!Z||Z.Enabled===void 0||!_)throw Error("Failed to read an ETag-protected CloudFront distribution config");let $=this.collectionItems(Z.Origins,"Origin"),j=this.collectionItems(Z.CacheBehaviors,"CacheBehavior"),L=$.find((S)=>String(S.Id)===z.id),q=j.find((S)=>String(S.PathPattern)===z.pathPattern);if(L&&String(L.DomainName)!==z.domainName)throw Error(`Origin ${z.id} no longer targets ${z.domainName}; refusing ambiguous removal`);if(q&&String(q.TargetOriginId)!==z.id)throw Error(`Path ${z.pathPattern} no longer targets ${z.id}; refusing ambiguous removal`);if(!q)return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:!1,applied:!1,originRemoved:!1,etag:_};let W=j.filter((S)=>String(S.PathPattern)!==z.pathPattern),F=String(Z.DefaultCacheBehavior?.TargetOriginId)===z.id||W.some((S)=>String(S.TargetOriginId)===z.id),D=F?$:$.filter((S)=>String(S.Id)!==z.id);if(z.dryRun)return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:!0,applied:!1,originRemoved:!F&&!!L,etag:_};Z.Origins={Quantity:D.length,Items:{Origin:D}},Z.CacheBehaviors={Quantity:W.length,...W.length?{Items:{CacheBehavior:W}}:{}};let G=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:this.buildDistributionConfigXml(Z),headers:{"Content-Type":"application/xml","If-Match":_}});return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:!0,applied:!0,originRemoved:!F&&!!L,etag:G.ETag||G.headers?.etag||""}}async createInvalidation(J){let Q=J.callerReference||Date.now().toString(),z=`<?xml version="1.0" encoding="UTF-8"?>
2
- <InvalidationBatch>
3
- <Paths>
4
- <Quantity>${J.paths.length}</Quantity>
5
- <Items>
6
- ${J.paths.map((_)=>`<Path>${_}</Path>`).join(`
7
- `)}
8
- </Items>
9
- </Paths>
10
- <CallerReference>${Q}</CallerReference>
11
- </InvalidationBatch>`,Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:`/2020-05-31/distribution/${J.distributionId}/invalidation`,body:z,headers:{"Content-Type":"application/xml"}});return{Id:Y.Id||Y.Invalidation?.Id,Status:Y.Status||Y.Invalidation?.Status||"InProgress",CreateTime:Y.CreateTime||Y.Invalidation?.CreateTime||new Date().toISOString()}}async getInvalidation(J,Q){let z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/invalidation/${Q}`});return{Id:z.Id||z.Invalidation?.Id,Status:z.Status||z.Invalidation?.Status,CreateTime:z.CreateTime||z.Invalidation?.CreateTime}}async listInvalidations(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/invalidation`}),z=[];if(Q.InvalidationSummary){let Y=Array.isArray(Q.InvalidationSummary)?Q.InvalidationSummary:[Q.InvalidationSummary];z.push(...Y.map((_)=>({Id:_.Id,Status:_.Status,CreateTime:_.CreateTime})))}return z}async waitForInvalidation(J,Q){let Y=0;while(Y<60){if((await this.getInvalidation(J,Q)).Status==="Completed")return;await new Promise((Z)=>setTimeout(Z,5000)),Y++}throw Error(`Timeout waiting for invalidation ${Q} to complete`)}async listDistributions(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/distribution"}),Q=[],Y=(J.DistributionList||J).Items,_=[];if(Array.isArray(Y))_=Y;else if(Y?.DistributionSummary)_=Array.isArray(Y.DistributionSummary)?Y.DistributionSummary:[Y.DistributionSummary];return Q.push(..._.map((Z)=>({Id:Z.Id,ARN:Z.ARN,Status:Z.Status,DomainName:Z.DomainName,Aliases:Z.Aliases||void 0,Enabled:Z.Enabled==="true"||Z.Enabled===!0}))),Q}async getDistribution(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}`}),z=Q.Distribution||Q;return{Id:z.Id,ARN:z.ARN,Status:z.Status,DomainName:z.DomainName,Aliases:z.DistributionConfig?.Aliases?.Items||z.Aliases?.Items||[],Enabled:z.DistributionConfig?.Enabled==="true"||z.DistributionConfig?.Enabled===!0}}async getDistributionConfig(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`});return{ETag:Q.ETag||"",DistributionConfig:Q.DistributionConfig||Q}}async invalidateAll(J){return this.createInvalidation({distributionId:J,paths:["/*"]})}async invalidatePaths(J,Q){let z=Q.map((Y)=>Y.startsWith("/")?Y:`/${Y}`);return this.createInvalidation({distributionId:J,paths:z})}async invalidatePattern(J,Q){let z=Q.startsWith("/")?Q:`/${Q}`;return this.createInvalidation({distributionId:J,paths:[z]})}async invalidateAfterDeployment(J){let{distributionId:Q,changedPaths:z,invalidateAll:Y=!1,wait:_=!1}=J,Z;if(Y||!z||z.length===0)Z=await this.invalidateAll(Q);else Z=await this.invalidatePaths(Q,z);if(_)await this.waitForInvalidation(Q,Z.Id);return{invalidationId:Z.Id,status:Z.Status}}async findDistributionByDomain(J){return(await this.listDistributions()).find((Y)=>{if(Y.DomainName===J)return!0;if(Y.Aliases?.Items&&Y.Aliases.Items.includes(J))return!0;return!1})||null}async batchInvalidate(J,Q=["/*"]){return await Promise.all(J.map(async(Y)=>{let _=await this.createInvalidation({distributionId:Y,paths:Q});return{distributionId:Y,invalidationId:_.Id,status:_.Status}}))}async updateCustomErrorResponses(J){let{distributionId:Q,customErrorResponses:z}=J,Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${Q}/config`,returnHeaders:!0}),_=Y.headers?.etag||Y.headers?.ETag||"",Z=Y.body?.DistributionConfig||(Y.body?.Enabled!==void 0?Y.body:void 0)||Y.DistributionConfig;if(!Z||Z.Enabled===void 0)throw Error("Failed to get current distribution config");if(z.length===0)Z.CustomErrorResponses={Quantity:0};else Z.CustomErrorResponses={Quantity:z.length,Items:{CustomErrorResponse:z.map((q)=>({ErrorCode:q.errorCode,...q.responsePagePath&&{ResponsePagePath:q.responsePagePath},...q.responseCode&&{ResponseCode:q.responseCode},...q.errorCachingMinTTL!==void 0&&{ErrorCachingMinTTL:q.errorCachingMinTTL}}))}};let $=this.buildDistributionConfigXml(Z),j=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${Q}/config`,body:$,headers:{"Content-Type":"application/xml","If-Match":_}}),L=j.Distribution||j;return{Distribution:{Id:L.Id,ARN:L.ARN,Status:L.Status,DomainName:L.DomainName,Aliases:L.DistributionConfig?.Aliases?.Items||[],Enabled:L.DistributionConfig?.Enabled==="true"||L.DistributionConfig?.Enabled===!0},ETag:j.ETag||""}}async removeCustomErrorResponses(J){return this.updateCustomErrorResponses({distributionId:J,customErrorResponses:[]})}async updateDistribution(J){let{distributionId:Q,aliases:z,certificateArn:Y,comment:_}=J,Z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${Q}/config`,returnHeaders:!0}),$=Z.headers?.etag||Z.headers?.ETag||"",j=Z.body?.DistributionConfig||(Z.body?.Enabled!==void 0?Z.body:void 0)||Z.DistributionConfig;if(!j||j.Enabled===void 0)throw Error("Failed to get current distribution config");if(z&&z.length>0)j.Aliases={Quantity:z.length,Items:{Item:z}};if(Y)j.ViewerCertificate={ACMCertificateArn:Y,SSLSupportMethod:"sni-only",MinimumProtocolVersion:"TLSv1.2_2021",CertificateSource:"acm"};if(_)j.Comment=_;let L=this.buildDistributionConfigXml(j),q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${Q}/config`,body:L,headers:{"Content-Type":"application/xml","If-Match":$}}),W=q.Distribution||q;return{Distribution:{Id:W.Id,ARN:W.ARN,Status:W.Status,DomainName:W.DomainName,Aliases:z?{Quantity:z.length,Items:z}:{Quantity:0,Items:[]},Enabled:W.DistributionConfig?.Enabled==="true"||W.DistributionConfig?.Enabled===!0},ETag:q.ETag||""}}buildDistributionConfigXml(J){let Q=(Z)=>{return Z.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")},z={Items:"",Methods:"Method",Headers:"Name",Cookies:"Name",QueryStringCacheKeys:"Name",TrustedKeyGroups:"KeyGroup",TrustedSigners:"AwsAccountNumber",LambdaFunctionAssociations:"LambdaFunctionAssociation",FunctionAssociations:"FunctionAssociation",CacheBehaviors:"CacheBehavior",CustomErrorResponses:"CustomErrorResponse",GeoRestriction:"Location"},Y={Origins:"Origin",Aliases:"CNAME",AllowedMethods:"Method",CachedMethods:"Method",CustomErrorResponses:"CustomErrorResponse",CacheBehaviors:"CacheBehavior"},_=(Z,$,j="",L="")=>{if($===null||$===void 0)return"";if(Z.startsWith("@_")||Z==="?xml")return"";if(typeof $==="boolean")return`${j}<${Z}>${$}</${Z}>
12
- `;if(typeof $==="number"||typeof $==="string")return`${j}<${Z}>${Q(String($))}</${Z}>
13
- `;if(Array.isArray($)){let q=z[Z]||Z.replace(/s$/,"");return $.map((W)=>_(q,W,j,Z)).join("")}if(typeof $==="object"){if(Z==="Items"){let W=Y[L]||"",F=Object.keys($).filter((D)=>!D.startsWith("@_"));if(F.length===1&&!Array.isArray($[F[0]])){let D=F[0],G=$[D];if(typeof G==="string")return`${j}<Items>
14
- ${j} <${D}>${Q(G)}</${D}>
15
- ${j}</Items>
16
- `;else if(typeof G==="object"&&!Array.isArray(G))return`${j}<Items>
17
- ${_(D,G,j+" ",Z)}${j}</Items>
18
- `}if(F.length===1&&Array.isArray($[F[0]])){let D=F[0],G=$[D],S="";for(let U of G)if(typeof U==="string")S+=`${j} <${D}>${Q(U)}</${D}>
19
- `;else S+=_(D,U,j+" ",Z);return`${j}<Items>
20
- ${S}${j}</Items>
21
- `}if(Array.isArray($)){let D="",G=W||"Item";for(let S of $)if(typeof S==="string")D+=`${j} <${G}>${Q(S)}</${G}>
22
- `;else D+=_(G,S,j+" ",Z);return`${j}<Items>
23
- ${D}${j}</Items>
24
- `}}let q="";for(let[W,F]of Object.entries($))if(!W.startsWith("@_"))q+=_(W,F,j+" ",Z);if(q==="")return`${j}<${Z}/>
25
- `;return`${j}<${Z}>
26
- ${q}${j}</${Z}>
27
- `}return""};return`<?xml version="1.0" encoding="UTF-8"?>
28
- <DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
29
- ${Object.entries(J).filter(([Z])=>!Z.startsWith("@_")).map(([Z,$])=>_(Z,$," ","DistributionConfig")).join("")}</DistributionConfig>`}async ensureDynamicHttpMethods(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),z=Q.headers?.etag||Q.headers?.ETag||"",Y=Q.body?.DistributionConfig||Q.DistributionConfig||Q.body;if(!Y)throw Error("Failed to get current distribution config");let _=!1,Z=["GET","HEAD","OPTIONS","PUT","POST","PATCH","DELETE"],$=(q)=>{if(!q)return[];let W=q.Items;if(!W)return[];if(Array.isArray(W))return W.map(String);if(typeof W==="object"&&W.Method){let F=W.Method;return Array.isArray(F)?F.map(String):[String(F)]}if(W.Item)return Array.isArray(W.Item)?W.Item.map(String):[String(W.Item)];return[]},j=Y.DefaultCacheBehavior;if(j){if(!$(j.AllowedMethods).includes("POST"))j.AllowedMethods={Quantity:Z.length,Items:{Method:Z},CachedMethods:{Quantity:2,Items:{Method:["GET","HEAD"]}}},_=!0}if(!_)return!1;let L=this.buildDistributionConfigXml(Y);return await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:L,headers:{"Content-Type":"application/xml","If-Match":z}}),!0}async addAliases(J,Q,z){return this.updateDistribution({distributionId:J,aliases:Q,certificateArn:z})}async createFunction(J){let{name:Q,code:z,comment:Y="",runtime:_="cloudfront-js-2.0"}=J,Z=`<?xml version="1.0" encoding="UTF-8"?>
30
- <CreateFunctionRequest xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
31
- <Name>${Q}</Name>
32
- <FunctionConfig>
33
- <Comment>${Y}</Comment>
34
- <Runtime>${_}</Runtime>
35
- </FunctionConfig>
36
- <FunctionCode>${Buffer.from(z).toString("base64")}</FunctionCode>
37
- </CreateFunctionRequest>`,$=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/function",body:Z,headers:{"Content-Type":"application/xml"}}),j=$.FunctionSummary||$;return{FunctionARN:j.FunctionMetadata?.FunctionARN||j.FunctionARN,Name:j.Name||Q,Stage:j.FunctionMetadata?.Stage||"DEVELOPMENT",ETag:$.ETag||""}}async listFunctions(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/function"}),Q=[],z=J.FunctionList?.Items?.FunctionSummary;if(z){let Y=Array.isArray(z)?z:[z];for(let _ of Y)Q.push({Name:_.Name,FunctionARN:_.FunctionMetadata?.FunctionARN,Stage:_.FunctionMetadata?.Stage,CreatedTime:_.FunctionMetadata?.CreatedTime,LastModifiedTime:_.FunctionMetadata?.LastModifiedTime})}return Q}async getFunction(J,Q="LIVE"){try{let z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/function/${J}`,queryParams:{Stage:Q},returnHeaders:!0}),Y=z.body?.FunctionSummary||z.FunctionSummary||z.body||z;return{FunctionARN:Y.FunctionMetadata?.FunctionARN,Name:Y.Name||J,Stage:Y.FunctionMetadata?.Stage||Q,ETag:z.headers?.etag||z.ETag||"",FunctionCode:Y.FunctionCode}}catch(z){if(z.message?.includes("404")||z.message?.includes("NoSuchFunctionExists"))return null;throw z}}async publishFunction(J,Q){let z,Y;if(typeof J==="object")z=J.Name,Y=J.IfMatch;else z=J,Y=Q;if(!Y){let $=await this.getFunction(z,"DEVELOPMENT");if(!$)throw Error(`Function ${z} not found`);Y=$.ETag}let _=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:`/2020-05-31/function/${z}/publish`,headers:{"If-Match":Y}}),Z=_.FunctionSummary||_;return{FunctionARN:Z.FunctionMetadata?.FunctionARN,Stage:Z.FunctionMetadata?.Stage||"LIVE",FunctionSummary:Z}}async describeFunction(J){let{Name:Q,Stage:z="DEVELOPMENT"}=J,Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/function/${Q}/describe`,queryParams:{Stage:z},returnHeaders:!0});return{ETag:Y.headers?.etag||Y.ETag||"",FunctionSummary:Y.body?.FunctionSummary||Y.FunctionSummary||Y.body||Y}}async updateFunction(J){let{Name:Q,FunctionCode:z,FunctionConfig:Y,IfMatch:_}=J,Z=`<?xml version="1.0" encoding="UTF-8"?>
38
- <UpdateFunctionRequest xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
39
- <FunctionConfig>
40
- <Comment>${Y.Comment}</Comment>
41
- <Runtime>${Y.Runtime}</Runtime>
42
- </FunctionConfig>
43
- <FunctionCode>${Buffer.from(z).toString("base64")}</FunctionCode>
44
- </UpdateFunctionRequest>`,$=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/function/${Q}`,body:Z,headers:{"Content-Type":"application/xml","If-Match":_},returnHeaders:!0});return{ETag:$.headers?.etag||$.ETag||"",FunctionSummary:$.body?.FunctionSummary||$.FunctionSummary||$.body||$}}async deleteFunction(J,Q){let z=Q;if(!z){let Y=await this.getFunction(J,"DEVELOPMENT");if(!Y)return;z=Y.ETag}await this.client.request({service:"cloudfront",region:"us-east-1",method:"DELETE",path:`/2020-05-31/function/${J}`,headers:{"If-Match":z}})}async createIndexRewriteFunction(J){return this.createFunction({name:J,code:`function handler(event) {
45
- const request = event.request;
46
- var uri = request.uri;
47
-
48
- // Check if the request is for a directory (ends with /)
49
- if (uri.endsWith('/')) {
50
- request.uri += 'index.html';
51
- }
52
- // Check if the request doesn't have a file extension
53
- else if (!uri.includes('.')) {
54
- // Add trailing slash to redirect to directory
55
- request.uri += '/index.html';
56
- }
57
-
58
- return request;
59
- }`,comment:"Rewrite directory requests to index.html for S3 static sites",runtime:"cloudfront-js-2.0"})}async listOriginAccessControls(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/origin-access-control"}),Q=[];if(J.OriginAccessControlList?.Items?.OriginAccessControlSummary){let z=Array.isArray(J.OriginAccessControlList.Items.OriginAccessControlSummary)?J.OriginAccessControlList.Items.OriginAccessControlSummary:[J.OriginAccessControlList.Items.OriginAccessControlSummary];Q.push(...z.map((Y)=>({Id:Y.Id,Name:Y.Name,Description:Y.Description,SigningProtocol:Y.SigningProtocol,SigningBehavior:Y.SigningBehavior,OriginAccessControlOriginType:Y.OriginAccessControlOriginType})))}return Q}async createOriginAccessControl(J){let{name:Q,description:z=`OAC for ${Q}`,signingProtocol:Y="sigv4",signingBehavior:_="always",originType:Z="s3"}=J,$=`<?xml version="1.0" encoding="UTF-8"?>
60
- <OriginAccessControlConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
61
- <Name>${Q}</Name>
62
- <Description>${z}</Description>
63
- <SigningProtocol>${Y}</SigningProtocol>
64
- <SigningBehavior>${_}</SigningBehavior>
65
- <OriginAccessControlOriginType>${Z}</OriginAccessControlOriginType>
66
- </OriginAccessControlConfig>`,j=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/origin-access-control",body:$,headers:{"Content-Type":"application/xml"},returnHeaders:!0}),L=j.body?.OriginAccessControl||j.OriginAccessControl||j.body||j;return{Id:L.Id,Name:L.OriginAccessControlConfig?.Name||Q,Description:L.OriginAccessControlConfig?.Description||z,SigningProtocol:L.OriginAccessControlConfig?.SigningProtocol||Y,SigningBehavior:L.OriginAccessControlConfig?.SigningBehavior||_,OriginAccessControlOriginType:L.OriginAccessControlConfig?.OriginAccessControlOriginType||Z,ETag:j.headers?.etag||j.ETag||""}}async findOrCreateOriginAccessControl(J,Q="s3"){let Y=(await this.listOriginAccessControls()).find((Z)=>Z.Name===J&&Z.OriginAccessControlOriginType===Q);if(Y)return{Id:Y.Id,Name:Y.Name,isNew:!1};let _=await this.createOriginAccessControl({name:J,originType:Q});return{Id:_.Id,Name:_.Name,isNew:!0}}async createDistributionForS3(J){let{bucketName:Q,bucketRegion:z,originAccessControlId:Y,aliases:_=[],certificateArn:Z,defaultRootObject:$="index.html",comment:j=`Distribution for ${Q}`,priceClass:L="PriceClass_100",enabled:q=!0,trustedKeyGroupIds:W=[],mediaDelivery:F=!1}=J,D=`S3-${Q}`,G=`${Q}.s3.${z}.amazonaws.com`,S=`${Date.now()}-${Math.random().toString(36).slice(2)}`,U=W.length>0?`<TrustedKeyGroups>
67
- <Enabled>true</Enabled>
68
- <Quantity>${W.length}</Quantity>
69
- <Items>${W.map((w)=>`<KeyGroup>${w}</KeyGroup>`).join("")}</Items>
70
- </TrustedKeyGroups>`:"<TrustedKeyGroups><Enabled>false</Enabled><Quantity>0</Quantity></TrustedKeyGroups>",M="<Aliases><Quantity>0</Quantity></Aliases>";if(_.length>0)M=`<Aliases>
71
- <Quantity>${_.length}</Quantity>
72
- <Items>
73
- ${_.map((w)=>`<CNAME>${w}</CNAME>`).join(`
74
- `)}
75
- </Items>
76
- </Aliases>`;let H=`<ViewerCertificate>
77
- <CloudFrontDefaultCertificate>true</CloudFrontDefaultCertificate>
78
- </ViewerCertificate>`;if(Z&&_.length>0)H=`<ViewerCertificate>
79
- <ACMCertificateArn>${Z}</ACMCertificateArn>
80
- <SSLSupportMethod>sni-only</SSLSupportMethod>
81
- <MinimumProtocolVersion>TLSv1.2_2021</MinimumProtocolVersion>
82
- <CertificateSource>acm</CertificateSource>
83
- </ViewerCertificate>`;let K=`<?xml version="1.0" encoding="UTF-8"?>
84
- <DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
85
- <CallerReference>${S}</CallerReference>
86
- <Comment>${j}</Comment>
87
- <DefaultRootObject>${$}</DefaultRootObject>
88
- <Origins>
89
- <Quantity>1</Quantity>
90
- <Items>
91
- <Origin>
92
- <Id>${D}</Id>
93
- <DomainName>${G}</DomainName>
94
- <OriginPath></OriginPath>
95
- <S3OriginConfig>
96
- <OriginAccessIdentity></OriginAccessIdentity>
97
- </S3OriginConfig>
98
- <OriginAccessControlId>${Y}</OriginAccessControlId>
99
- </Origin>
100
- </Items>
101
- </Origins>
102
- <DefaultCacheBehavior>
103
- <TargetOriginId>${D}</TargetOriginId>
104
- <ViewerProtocolPolicy>redirect-to-https</ViewerProtocolPolicy>
105
- <AllowedMethods>
106
- <Quantity>2</Quantity>
107
- <Items>
108
- <Method>GET</Method>
109
- <Method>HEAD</Method>
110
- </Items>
111
- <CachedMethods>
112
- <Quantity>2</Quantity>
113
- <Items>
114
- <Method>GET</Method>
115
- <Method>HEAD</Method>
116
- </Items>
117
- </CachedMethods>
118
- </AllowedMethods>
119
- <Compress>true</Compress>
120
- <CachePolicyId>658327ea-f89d-4fab-a63d-7e88639e58f6</CachePolicyId>
121
- ${U}
122
- </DefaultCacheBehavior>
123
- ${M}
124
- ${H}
125
- <PriceClass>${L}</PriceClass>
126
- <Enabled>${q}</Enabled>
127
- <HttpVersion>http2and3</HttpVersion>
128
- <IsIPV6Enabled>true</IsIPV6Enabled>
129
- ${F?"<CustomErrorResponses><Quantity>0</Quantity></CustomErrorResponses>":`<CustomErrorResponses>
130
- <Quantity>1</Quantity>
131
- <Items>
132
- <CustomErrorResponse>
133
- <ErrorCode>403</ErrorCode>
134
- <ResponsePagePath>/index.html</ResponsePagePath>
135
- <ResponseCode>200</ResponseCode>
136
- <ErrorCachingMinTTL>300</ErrorCachingMinTTL>
137
- </CustomErrorResponse>
138
- </Items>
139
- </CustomErrorResponses>`}
140
- </DistributionConfig>`,V=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/distribution",body:K,headers:{"Content-Type":"application/xml"},returnHeaders:!0}),P=V.body?.Distribution||V.Distribution||V.body||V;return{Id:P.Id,ARN:P.ARN,DomainName:P.DomainName,Status:P.Status,ETag:V.headers?.etag||V.ETag||""}}async createMediaDistributionForS3(J){return this.createDistributionForS3({...J,defaultRootObject:"",mediaDelivery:!0,comment:J.comment??`Media distribution for ${J.bucketName}`})}async listPublicKeys(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/public-key"});return this.collectionItems(J.PublicKeyList??J,"PublicKeySummary").map((z)=>({Id:String(z.Id),Name:String(z.Name),Comment:z.Comment?String(z.Comment):void 0}))}async createPublicKey(J){if(!/^[A-Za-z0-9_-]{1,128}$/.test(J.name))throw TypeError("CloudFront public key name is invalid");if(!J.encodedKey.includes("BEGIN PUBLIC KEY"))throw TypeError("CloudFront public key must be PEM encoded");let Q=(_)=>_.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;"),z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/public-key",headers:{"Content-Type":"application/xml"},body:`<PublicKeyConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><CallerReference>${Q(J.callerReference??`${Date.now()}-${J.name}`)}</CallerReference><Name>${Q(J.name)}</Name><EncodedKey>${Q(J.encodedKey)}</EncodedKey><Comment>${Q(J.comment??"")}</Comment></PublicKeyConfig>`}),Y=z.PublicKey??z;return{Id:String(Y.Id),Name:String(Y.PublicKeyConfig?.Name??J.name),EncodedKey:String(Y.PublicKeyConfig?.EncodedKey??J.encodedKey),Comment:String(Y.PublicKeyConfig?.Comment??J.comment??"")}}async listKeyGroups(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/key-group"});return this.collectionItems(J.KeyGroupList??J,"KeyGroupSummary").map((z)=>({Id:String(z.KeyGroup?.Id??z.Id),Name:String(z.KeyGroup?.KeyGroupConfig?.Name??z.KeyGroupConfig?.Name??z.Name),Items:this.collectionItems(z.KeyGroup?.KeyGroupConfig?.Items??z.KeyGroupConfig?.Items??z.Items,"Item").map(String),Comment:z.KeyGroup?.KeyGroupConfig?.Comment??z.KeyGroupConfig?.Comment??z.Comment}))}async createKeyGroup(J){if(!/^[A-Za-z0-9_-]{1,128}$/.test(J.name))throw TypeError("CloudFront key group name is invalid");let Q=[...new Set(J.publicKeyIds)];if(Q.length===0)throw TypeError("CloudFront key group requires at least one public key");let z=($)=>$.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;"),Y=Q.map(($)=>`<Item>${z($)}</Item>`).join(""),_=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/key-group",headers:{"Content-Type":"application/xml"},body:`<KeyGroupConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><Name>${z(J.name)}</Name><Items>${Y}</Items><Comment>${z(J.comment??"")}</Comment></KeyGroupConfig>`}),Z=_.KeyGroup??_;return{Id:String(Z.Id),Name:String(Z.KeyGroupConfig?.Name??J.name),Items:Q,Comment:String(Z.KeyGroupConfig?.Comment??J.comment??"")}}static getS3BucketPolicyForCloudFront(J,Q){return{Version:"2012-10-17",Statement:[{Sid:"AllowCloudFrontServicePrincipal",Effect:"Allow",Principal:{Service:"cloudfront.amazonaws.com"},Action:"s3:GetObject",Resource:`arn:aws:s3:::${J}/*`,Condition:{StringEquals:{"AWS:SourceArn":Q}}}]}}async waitForDistributionDeployed(J,Q=60){for(let z=0;z<Q;z++){if((await this.getDistribution(J)).Status==="Deployed")return!0;await new Promise((_)=>setTimeout(_,30000))}return!1}async disableDistribution(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),z=Q.headers?.etag||Q.headers?.ETag||"",Y=Q.body?.DistributionConfig||(Q.body?.Enabled!==void 0?Q.body:void 0)||Q.DistributionConfig;if(!Y||Y.Enabled===void 0)throw Error("Failed to get current distribution config");Y.Enabled=!1;let _=this.buildDistributionConfigXml(Y),Z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:_,headers:{"Content-Type":"application/xml","If-Match":z},returnHeaders:!0});return{ETag:Z.headers?.etag||Z.headers?.ETag||Z.ETag||""}}async deleteDistribution(J,Q){let z=Q||"";if(!z){let Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}`,returnHeaders:!0});z=Y.headers?.etag||Y.headers?.ETag||""}await this.client.request({service:"cloudfront",region:"us-east-1",method:"DELETE",path:`/2020-05-31/distribution/${J}`,headers:{"If-Match":z}})}async waitForDistributionDisabled(J,Q=60){for(let z=0;z<Q;z++){let Y=await this.getDistribution(J);if(Y.Status==="Deployed"&&!Y.Enabled)return!0;await new Promise((_)=>setTimeout(_,30000))}return!1}async removeAlias(J,Q){let z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),Y=z.headers?.etag||z.headers?.ETag||"",_=z.body?.DistributionConfig||(z.body?.Enabled!==void 0?z.body:void 0)||z.DistributionConfig;if(!_||_.Enabled===void 0)throw Error("Failed to get current distribution config");let Z=[];if(_.Aliases?.Items){if(Array.isArray(_.Aliases.Items))Z=_.Aliases.Items;else if(typeof _.Aliases.Items==="object"){let q=_.Aliases.Items.CNAME;if(typeof q==="string")Z=[q];else if(Array.isArray(q))Z=q}}if(Z.length===0)throw Error("Distribution has no aliases to remove");let $=Z.filter((q)=>q!==Q);if($.length===Z.length)throw Error(`Alias ${Q} not found in distribution`);if(_.Aliases.Quantity=$.length,_.Aliases.Items=$.length>0?$:void 0,$.length===0)_.ViewerCertificate={CloudFrontDefaultCertificate:!0,MinimumProtocolVersion:"TLSv1.2_2021"};let j=this.buildDistributionConfigXml(_),L=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:j,headers:{"Content-Type":"application/xml","If-Match":Y},returnHeaders:!0});return{ETag:L.headers?.etag||L.headers?.ETag||L.ETag||""}}}
141
- export{N as nd};
@@ -1,4 +0,0 @@
1
- import{Og as O}from"./chunk-fpm59y25.js";class Q{client;region;constructor(q="us-east-1"){this.region=q,this.client=new O}async describeInstances(q){let z={Action:"DescribeInstances",Version:"2016-11-15"};if(q?.InstanceIds)q.InstanceIds.forEach((G,J)=>{z[`InstanceId.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});if(q?.MaxResults)z.MaxResults=String(q.MaxResults);if(q?.NextToken)z.NextToken=q.NextToken;let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),B=H.DescribeInstancesResponse||H;return{Reservations:this.parseReservations(B.reservationSet?.item),NextToken:B.nextToken}}async getInstance(q){return(await this.describeInstances({InstanceIds:[q]})).Reservations?.[0]?.Instances?.[0]}async getConsoleOutput(q,z){let H={Action:"GetConsoleOutput",Version:"2016-11-15",InstanceId:q};if(z)H.Latest="true";let B=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(H).toString()}),G=B.GetConsoleOutputResponse||B;return{InstanceId:G.instanceId,Output:G.output,Timestamp:G.timestamp}}async getConsoleOutputDecoded(q,z){let H=await this.getConsoleOutput(q,z?.latest);if(!H.Output)return"No console output available yet";let B=Buffer.from(H.Output,"base64").toString("utf-8");if(z?.tailLines)return B.split(`
2
- `).slice(-z.tailLines).join(`
3
- `);return B}async describeInstanceStatus(q){let z={Action:"DescribeInstanceStatus",Version:"2016-11-15"};if(q?.InstanceIds)q.InstanceIds.forEach((B,G)=>{z[`InstanceId.${G+1}`]=B});if(q?.IncludeAllInstances)z.IncludeAllInstances="true";if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{InstanceStatuses:this.parseArray(H.instanceStatusSet?.item).map((B)=>({InstanceId:B.instanceId,InstanceState:B.instanceState?{Code:Number.parseInt(B.instanceState.code),Name:B.instanceState.name}:void 0,InstanceStatus:B.instanceStatus?{Status:B.instanceStatus.status,Details:this.parseArray(B.instanceStatus.details?.item).map((G)=>({Name:G.name,Status:G.status}))}:void 0,SystemStatus:B.systemStatus?{Status:B.systemStatus.status,Details:this.parseArray(B.systemStatus.details?.item).map((G)=>({Name:G.name,Status:G.status}))}:void 0}))}}async startInstances(q){let z={Action:"StartInstances",Version:"2016-11-15"};q.forEach((B,G)=>{z[`InstanceId.${G+1}`]=B});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{StartingInstances:this.parseArray(H.instancesSet?.item).map((B)=>({InstanceId:B.instanceId,CurrentState:B.currentState?{Name:B.currentState.name}:void 0,PreviousState:B.previousState?{Name:B.previousState.name}:void 0}))}}async stopInstances(q,z){let H={Action:"StopInstances",Version:"2016-11-15"};if(q.forEach((G,J)=>{H[`InstanceId.${J+1}`]=G}),z)H.Force="true";let B=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(H).toString()});return{StoppingInstances:this.parseArray(B.instancesSet?.item).map((G)=>({InstanceId:G.instanceId,CurrentState:G.currentState?{Name:G.currentState.name}:void 0,PreviousState:G.previousState?{Name:G.previousState.name}:void 0}))}}async rebootInstances(q){let z={Action:"RebootInstances",Version:"2016-11-15"};q.forEach((H,B)=>{z[`InstanceId.${B+1}`]=H}),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async terminateInstances(q){let z={Action:"TerminateInstances",Version:"2016-11-15"};q.forEach((B,G)=>{z[`InstanceId.${G+1}`]=B});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{TerminatingInstances:this.parseArray(H.instancesSet?.item).map((B)=>({InstanceId:B.instanceId,CurrentState:B.currentState?{Name:B.currentState.name}:void 0,PreviousState:B.previousState?{Name:B.previousState.name}:void 0}))}}async createImage(q){let z={Action:"CreateImage",Version:"2016-11-15",InstanceId:q.InstanceId,Name:q.Name};if(q.Description)z.Description=q.Description;if(q.NoReboot!==void 0)z.NoReboot=String(q.NoReboot);if(q.TagSpecifications)q.TagSpecifications.forEach((G,J)=>{z[`TagSpecification.${J+1}.ResourceType`]=G.ResourceType,G.Tags.forEach((K,L)=>{z[`TagSpecification.${J+1}.Tag.${L+1}.Key`]=K.Key,z[`TagSpecification.${J+1}.Tag.${L+1}.Value`]=K.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{ImageId:(H.CreateImageResponse||H).imageId}}async deregisterImage(q){await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({Action:"DeregisterImage",Version:"2016-11-15",ImageId:q}).toString()})}async describeVpcs(q){let z={Action:"DescribeVpcs",Version:"2016-11-15"};if(q?.VpcIds)q.VpcIds.forEach((B,G)=>{z[`VpcId.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{Vpcs:this.parseArray(H.vpcSet?.item).map((B)=>({VpcId:B.vpcId,CidrBlock:B.cidrBlock,State:B.state,DhcpOptionsId:B.dhcpOptionsId,InstanceTenancy:B.instanceTenancy,IsDefault:B.isDefault==="true",Tags:this.parseTags(B.tagSet?.item)}))}}async describeSubnets(q){let z={Action:"DescribeSubnets",Version:"2016-11-15"};if(q?.SubnetIds)q.SubnetIds.forEach((B,G)=>{z[`SubnetId.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{Subnets:this.parseArray(H.subnetSet?.item).map((B)=>({SubnetId:B.subnetId,VpcId:B.vpcId,CidrBlock:B.cidrBlock,AvailabilityZone:B.availabilityZone,AvailableIpAddressCount:Number.parseInt(B.availableIpAddressCount),State:B.state,MapPublicIpOnLaunch:B.mapPublicIpOnLaunch==="true",Tags:this.parseTags(B.tagSet?.item)}))}}async describeSecurityGroups(q){let z={Action:"DescribeSecurityGroups",Version:"2016-11-15"};if(q?.GroupIds)q.GroupIds.forEach((B,G)=>{z[`GroupId.${G+1}`]=B});if(q?.GroupNames)q.GroupNames.forEach((B,G)=>{z[`GroupName.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{SecurityGroups:this.parseArray(H.securityGroupInfo?.item).map((B)=>({GroupId:B.groupId,GroupName:B.groupName,Description:B.groupDescription,VpcId:B.vpcId,IpPermissions:this.parseIpPermissions(B.ipPermissions?.item),IpPermissionsEgress:this.parseIpPermissions(B.ipPermissionsEgress?.item),Tags:this.parseTags(B.tagSet?.item)}))}}async describeInternetGateways(q){let z={Action:"DescribeInternetGateways",Version:"2016-11-15"};if(q?.InternetGatewayIds)q.InternetGatewayIds.forEach((B,G)=>{z[`InternetGatewayId.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{InternetGateways:this.parseArray(H.internetGatewaySet?.item).map((B)=>({InternetGatewayId:B.internetGatewayId,Attachments:this.parseArray(B.attachmentSet?.item).map((G)=>({VpcId:G.vpcId,State:G.state})),Tags:this.parseTags(B.tagSet?.item)}))}}async describeAddresses(q){let z={Action:"DescribeAddresses",Version:"2016-11-15"};if(q?.AllocationIds)q.AllocationIds.forEach((B,G)=>{z[`AllocationId.${G+1}`]=B});if(q?.PublicIps)q.PublicIps.forEach((B,G)=>{z[`PublicIp.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{Addresses:this.parseArray(H.addressesSet?.item).map((B)=>({PublicIp:B.publicIp,AllocationId:B.allocationId,AssociationId:B.associationId,InstanceId:B.instanceId,NetworkInterfaceId:B.networkInterfaceId,PrivateIpAddress:B.privateIpAddress,Domain:B.domain,Tags:this.parseTags(B.tagSet?.item)}))}}async allocateAddress(q){let z={Action:"AllocateAddress",Version:"2016-11-15"};if(q?.Domain)z.Domain=q.Domain;if(q?.TagSpecifications)q.TagSpecifications.forEach((B,G)=>{z[`TagSpecification.${G+1}.ResourceType`]=B.ResourceType,B.Tags.forEach((J,K)=>{z[`TagSpecification.${G+1}.Tag.${K+1}.Key`]=J.Key,z[`TagSpecification.${G+1}.Tag.${K+1}.Value`]=J.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{AllocationId:H.allocationId,PublicIp:H.publicIp,Domain:H.domain}}async associateAddress(q){let z={Action:"AssociateAddress",Version:"2016-11-15"};if(q.AllocationId)z.AllocationId=q.AllocationId;if(q.PublicIp)z.PublicIp=q.PublicIp;if(q.InstanceId)z.InstanceId=q.InstanceId;if(q.NetworkInterfaceId)z.NetworkInterfaceId=q.NetworkInterfaceId;if(q.PrivateIpAddress)z.PrivateIpAddress=q.PrivateIpAddress;if(q.AllowReassociation)z.AllowReassociation="true";return{AssociationId:(await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})).associationId}}async createTags(q){let z={Action:"CreateTags",Version:"2016-11-15"};q.Resources.forEach((H,B)=>{z[`ResourceId.${B+1}`]=H}),q.Tags.forEach((H,B)=>{z[`Tag.${B+1}.Key`]=H.Key,z[`Tag.${B+1}.Value`]=H.Value}),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async waitForInstanceState(q,z,H){let B=H?.maxWaitMs||300000,G=H?.pollIntervalMs||5000,J=Date.now();while(Date.now()-J<B){let K;try{K=await this.getInstance(q)}catch{K=void 0}if(K?.State?.Name===z)return K;await new Promise((L)=>setTimeout(L,G))}return}async createVpc(q){let z={Action:"CreateVpc",Version:"2016-11-15",CidrBlock:q.CidrBlock};if(q.InstanceTenancy)z.InstanceTenancy=q.InstanceTenancy;if(q.TagSpecifications)q.TagSpecifications.forEach((J,K)=>{z[`TagSpecification.${K+1}.ResourceType`]=J.ResourceType,J.Tags.forEach((L,M)=>{z[`TagSpecification.${K+1}.Tag.${M+1}.Key`]=L.Key,z[`TagSpecification.${K+1}.Tag.${M+1}.Value`]=L.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),G=(H.CreateVpcResponse||H).vpc;return{Vpc:G?{VpcId:G.vpcId,CidrBlock:G.cidrBlock,State:G.state,DhcpOptionsId:G.dhcpOptionsId,InstanceTenancy:G.instanceTenancy,IsDefault:G.isDefault==="true",Tags:this.parseTags(G.tagSet?.item)}:void 0}}async createSubnet(q){let z={Action:"CreateSubnet",Version:"2016-11-15",VpcId:q.VpcId,CidrBlock:q.CidrBlock};if(q.AvailabilityZone)z.AvailabilityZone=q.AvailabilityZone;if(q.TagSpecifications)q.TagSpecifications.forEach((J,K)=>{z[`TagSpecification.${K+1}.ResourceType`]=J.ResourceType,J.Tags.forEach((L,M)=>{z[`TagSpecification.${K+1}.Tag.${M+1}.Key`]=L.Key,z[`TagSpecification.${K+1}.Tag.${M+1}.Value`]=L.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),G=(H.CreateSubnetResponse||H).subnet;return{Subnet:G?{SubnetId:G.subnetId,VpcId:G.vpcId,CidrBlock:G.cidrBlock,AvailabilityZone:G.availabilityZone,AvailableIpAddressCount:G.availableIpAddressCount?Number.parseInt(G.availableIpAddressCount):void 0,State:G.state,MapPublicIpOnLaunch:G.mapPublicIpOnLaunch==="true",Tags:this.parseTags(G.tagSet?.item)}:void 0}}async modifySubnetAttribute(q){let z={Action:"ModifySubnetAttribute",Version:"2016-11-15",SubnetId:q.SubnetId};if(q.MapPublicIpOnLaunch!==void 0)z["MapPublicIpOnLaunch.Value"]=String(q.MapPublicIpOnLaunch.Value);await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async createSecurityGroup(q){let z={Action:"CreateSecurityGroup",Version:"2016-11-15",GroupName:q.GroupName,GroupDescription:q.Description};if(q.VpcId)z.VpcId=q.VpcId;if(q.TagSpecifications)q.TagSpecifications.forEach((G,J)=>{z[`TagSpecification.${J+1}.ResourceType`]=G.ResourceType,G.Tags.forEach((K,L)=>{z[`TagSpecification.${J+1}.Tag.${L+1}.Key`]=K.Key,z[`TagSpecification.${J+1}.Tag.${L+1}.Value`]=K.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{GroupId:(H.CreateSecurityGroupResponse||H).groupId}}async authorizeSecurityGroupIngress(q){let z={Action:"AuthorizeSecurityGroupIngress",Version:"2016-11-15",GroupId:q.GroupId};this.encodeIpPermissions(z,q.IpPermissions),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async authorizeSecurityGroupEgress(q){let z={Action:"AuthorizeSecurityGroupEgress",Version:"2016-11-15",GroupId:q.GroupId};this.encodeIpPermissions(z,q.IpPermissions),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async describeRouteTables(q){let z={Action:"DescribeRouteTables",Version:"2016-11-15"};if(q?.RouteTableIds)q.RouteTableIds.forEach((G,J)=>{z[`RouteTableId.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),B=H.DescribeRouteTablesResponse||H;return{RouteTables:this.parseArray(B.routeTableSet?.item).map((G)=>({RouteTableId:G.routeTableId,VpcId:G.vpcId,Routes:this.parseArray(G.routeSet?.item).map((J)=>({DestinationCidrBlock:J.destinationCidrBlock,GatewayId:J.gatewayId,NatGatewayId:J.natGatewayId,State:J.state})),Associations:this.parseArray(G.associationSet?.item).map((J)=>({RouteTableAssociationId:J.routeTableAssociationId,SubnetId:J.subnetId,Main:J.main==="true"||J.main===!0})),Tags:this.parseTags(G.tagSet?.item)}))}}async deleteVpc(q){let z={Action:"DeleteVpc",Version:"2016-11-15",VpcId:q};await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async deleteSubnet(q){let z={Action:"DeleteSubnet",Version:"2016-11-15",SubnetId:q};await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async deleteSecurityGroup(q){await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({Action:"DeleteSecurityGroup",Version:"2016-11-15",GroupId:q}).toString()})}async describeNetworkInterfaces(q){let z={Action:"DescribeNetworkInterfaces",Version:"2016-11-15"};if(q?.NetworkInterfaceIds)q.NetworkInterfaceIds.forEach((G,J)=>{z[`NetworkInterfaceId.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),B=H.DescribeNetworkInterfacesResponse||H;return{NetworkInterfaces:this.parseArray(B.networkInterfaceSet?.item).map((G)=>({NetworkInterfaceId:G.networkInterfaceId,SubnetId:G.subnetId,VpcId:G.vpcId,Status:G.status,Attachment:G.attachment?{AttachmentId:G.attachment.attachmentId,InstanceId:G.attachment.instanceId,Status:G.attachment.status}:void 0}))}}async detachNetworkInterface(q,z){let H={Action:"DetachNetworkInterface",Version:"2016-11-15",AttachmentId:q};if(z)H.Force="true";await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(H).toString()})}async deleteNetworkInterface(q){let z={Action:"DeleteNetworkInterface",Version:"2016-11-15",NetworkInterfaceId:q};await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async describeRegions(){let q={Action:"DescribeRegions",Version:"2016-11-15"},z=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(q).toString()}),H=z.DescribeRegionsResponse||z;return{Regions:this.parseArray(H.regionInfo?.item).map((B)=>({RegionName:B.regionName,Endpoint:B.regionEndpoint}))}}async runInstances(q){let z={Action:"RunInstances",Version:"2016-11-15",ImageId:q.ImageId,InstanceType:q.InstanceType,MinCount:String(q.MinCount),MaxCount:String(q.MaxCount)};if(q.SecurityGroupIds)q.SecurityGroupIds.forEach((G,J)=>{z[`SecurityGroupId.${J+1}`]=G});if(q.SubnetId)z.SubnetId=q.SubnetId;if(q.UserData)z.UserData=q.UserData;if(q.IamInstanceProfile){if(q.IamInstanceProfile.Name)z["IamInstanceProfile.Name"]=q.IamInstanceProfile.Name;if(q.IamInstanceProfile.Arn)z["IamInstanceProfile.Arn"]=q.IamInstanceProfile.Arn}if(q.TagSpecifications)q.TagSpecifications.forEach((G,J)=>{z[`TagSpecification.${J+1}.ResourceType`]=G.ResourceType,G.Tags.forEach((K,L)=>{z[`TagSpecification.${J+1}.Tag.${L+1}.Key`]=K.Key,z[`TagSpecification.${J+1}.Tag.${L+1}.Value`]=K.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),B=H.RunInstancesResponse||H;return{Instances:this.parseInstances(B.instancesSet?.item||B.instancesSet)}}encodeIpPermissions(q,z){z.forEach((H,B)=>{let G=`IpPermissions.${B+1}`;if(H.IpProtocol!==void 0)q[`${G}.IpProtocol`]=H.IpProtocol;if(H.FromPort!==void 0)q[`${G}.FromPort`]=String(H.FromPort);if(H.ToPort!==void 0)q[`${G}.ToPort`]=String(H.ToPort);if(H.IpRanges)H.IpRanges.forEach((J,K)=>{if(J.CidrIp)q[`${G}.IpRanges.${K+1}.CidrIp`]=J.CidrIp;if(J.Description)q[`${G}.IpRanges.${K+1}.Description`]=J.Description});if(H.Ipv6Ranges)H.Ipv6Ranges.forEach((J,K)=>{if(J.CidrIpv6)q[`${G}.Ipv6Ranges.${K+1}.CidrIpv6`]=J.CidrIpv6;if(J.Description)q[`${G}.Ipv6Ranges.${K+1}.Description`]=J.Description});if(H.UserIdGroupPairs)H.UserIdGroupPairs.forEach((J,K)=>{if(J.GroupId)q[`${G}.Groups.${K+1}.GroupId`]=J.GroupId;if(J.UserId)q[`${G}.Groups.${K+1}.UserId`]=J.UserId;if(J.Description)q[`${G}.Groups.${K+1}.Description`]=J.Description})})}parseArray(q){if(!q)return[];return Array.isArray(q)?q:[q]}parseFirstIpv6Address(q){for(let z of this.parseArray(q))for(let H of this.parseArray(z?.ipv6AddressesSet?.item))if(H?.ipv6Address)return H.ipv6Address;return}parseTags(q){return this.parseArray(q).map((z)=>({Key:z.key,Value:z.value}))}parseReservations(q){return this.parseArray(q).map((z)=>({ReservationId:z.reservationId,Instances:this.parseInstances(z.instancesSet?.item||z.instancesSet)}))}parseInstances(q){return this.parseArray(q).map((z)=>({InstanceId:z.instanceId,ImageId:z.imageId,InstanceType:z.instanceType,State:z.instanceState?{Code:Number.parseInt(z.instanceState.code),Name:z.instanceState.name}:void 0,PrivateIpAddress:z.privateIpAddress,PublicIpAddress:z.ipAddress,Ipv6Address:this.parseFirstIpv6Address(z.networkInterfaceSet?.item),SubnetId:z.subnetId,VpcId:z.vpcId,SecurityGroups:this.parseArray(z.groupSet?.item).map((H)=>({GroupId:H.groupId,GroupName:H.groupName})),Tags:this.parseTags(z.tagSet?.item),LaunchTime:z.launchTime,Placement:z.placement?{AvailabilityZone:z.placement.availabilityZone,Tenancy:z.placement.tenancy}:void 0,Architecture:z.architecture,RootDeviceType:z.rootDeviceType,RootDeviceName:z.rootDeviceName,BlockDeviceMappings:this.parseArray(z.blockDeviceMapping?.item).map((H)=>({DeviceName:H.deviceName,Ebs:H.ebs?{VolumeId:H.ebs.volumeId,Status:H.ebs.status,AttachTime:H.ebs.attachTime,DeleteOnTermination:H.ebs.deleteOnTermination==="true"}:void 0})),IamInstanceProfile:z.iamInstanceProfile?{Arn:z.iamInstanceProfile.arn,Id:z.iamInstanceProfile.id}:void 0}))}parseIpPermissions(q){return this.parseArray(q).map((z)=>({IpProtocol:z.ipProtocol,FromPort:z.fromPort?Number.parseInt(z.fromPort):void 0,ToPort:z.toPort?Number.parseInt(z.toPort):void 0,IpRanges:this.parseArray(z.ipRanges?.item).map((H)=>({CidrIp:H.cidrIp,Description:H.description})),Ipv6Ranges:this.parseArray(z.ipv6Ranges?.item).map((H)=>({CidrIpv6:H.cidrIpv6,Description:H.description})),UserIdGroupPairs:this.parseArray(z.groups?.item).map((H)=>({GroupId:H.groupId,UserId:H.userId,Description:H.description}))}))}}
4
- export{Q as Xe};
@@ -1 +0,0 @@
1
- import{cd as a}from"./chunk-hm08xdxf.js";import"./chunk-fpm59y25.js";import"./chunk-mh0kdzqp.js";export{a as STSClient};
@@ -1,2 +0,0 @@
1
- import{Og as _}from"./chunk-fpm59y25.js";class ${client;region;constructor(j="us-east-1",q){this.region=j,this.client=new _(void 0,{profile:q})}async createStack(j){let q={Action:"CreateStack",StackName:j.stackName,Version:"2010-05-15"};if(j.templateBody)q.TemplateBody=j.templateBody;else if(j.templateUrl)q.TemplateURL=j.templateUrl;else throw Error("Either templateBody or templateUrl must be provided");if(j.parameters)j.parameters.forEach((z,H)=>{q[`Parameters.member.${H+1}.ParameterKey`]=z.ParameterKey,q[`Parameters.member.${H+1}.ParameterValue`]=z.ParameterValue});if(j.capabilities)j.capabilities.forEach((z,H)=>{q[`Capabilities.member.${H+1}`]=z});if(j.roleArn)q.RoleARN=j.roleArn;if(j.tags)j.tags.forEach((z,H)=>{q[`Tags.member.${H+1}.Key`]=z.Key,q[`Tags.member.${H+1}.Value`]=z.Value});if(j.timeoutInMinutes)q.TimeoutInMinutes=j.timeoutInMinutes;if(j.onFailure)q.OnFailure=j.onFailure;let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{StackId:G.StackId||G.CreateStackResult?.StackId}}async updateStack(j){let q={Action:"UpdateStack",StackName:j.stackName,Version:"2010-05-15"};if(j.templateBody)q.TemplateBody=j.templateBody;else if(j.templateUrl)q.TemplateURL=j.templateUrl;if(j.parameters)j.parameters.forEach((z,H)=>{if(q[`Parameters.member.${H+1}.ParameterKey`]=z.ParameterKey,z.UsePreviousValue)q[`Parameters.member.${H+1}.UsePreviousValue`]="true";else q[`Parameters.member.${H+1}.ParameterValue`]=z.ParameterValue});if(j.capabilities)j.capabilities.forEach((z,H)=>{q[`Capabilities.member.${H+1}`]=z});if(j.roleArn)q.RoleARN=j.roleArn;if(j.tags)j.tags.forEach((z,H)=>{q[`Tags.member.${H+1}.Key`]=z.Key,q[`Tags.member.${H+1}.Value`]=z.Value});let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{StackId:G.StackId||G.UpdateStackResult?.StackId}}async deleteStack(j,q,G){let z={Action:"DeleteStack",StackName:j,Version:"2010-05-15"};if(q)z.RoleARN=q;if(G&&G.length>0)G.forEach((H,Q)=>{z[`RetainResources.member.${Q+1}`]=H});await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(z).toString()})}async describeStacks(j={}){let q={Action:"DescribeStacks",Version:"2010-05-15"};if(j.stackName)q.StackName=j.stackName;let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{Stacks:this.parseStacksResponse(G)}}async describeStackEvents(j){let q={Action:"DescribeStackEvents",StackName:j,Version:"2010-05-15"},G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{StackEvents:this.parseStackEvents(G)}}async listStackResources(j){let q={Action:"ListStackResources",StackName:j,Version:"2010-05-15"},z=(await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()}))?.ListStackResourcesResult?.StackResourceSummaries?.member,H=[];if(z)H=Array.isArray(z)?z:[z];return{StackResourceSummaries:H}}async waitForStack(j,q){let G={"stack-create-complete":["CREATE_COMPLETE"],"stack-update-complete":["UPDATE_COMPLETE"],"stack-delete-complete":["DELETE_COMPLETE"]},z=["CREATE_FAILED","ROLLBACK_FAILED","ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE"],H=G[q],Q=360,J=0;while(J<360)try{let I=await this.describeStacks({stackName:j});if(I.Stacks.length===0){if(q==="stack-delete-complete")return;if(J%10===0)console.log(`[waitForStack] Attempt ${J}: Stack not visible yet`);await new Promise((O)=>setTimeout(O,2000)),J++;continue}let L=I.Stacks[0];if(J%10===0)console.log(`[waitForStack] Attempt ${J}: Status = ${L.StackStatus}${L.StackStatusReason?` (${L.StackStatusReason})`:""}`);if(H.includes(L.StackStatus))return;if((q==="stack-create-complete"||q==="stack-update-complete")&&(L.StackStatus==="DELETE_IN_PROGRESS"||L.StackStatus==="DELETE_COMPLETE")){console.log("[waitForStack] Stack is being deleted (creation/update failed)");let O="";try{let U=await this.describeStackEvents(j);console.log("[waitForStack] Stack events (most recent first):");for(let X of U.StackEvents.slice(0,15))if(X.ResourceStatus.includes("FAILED")||X.ResourceStatusReason){if(console.log(` ${X.LogicalResourceId}: ${X.ResourceStatus} - ${X.ResourceStatusReason||"No reason provided"}`),X.ResourceStatus.includes("FAILED")&&X.ResourceStatusReason&&!O)O=X.ResourceStatusReason}}catch{}let V=O||L.StackStatusReason||"Check CloudFormation console for details.";throw Error(`Stack creation/update failed - stack is being deleted. Reason: ${V}`)}if(L.StackStatus==="DELETE_FAILED"&&q==="stack-delete-complete"){let O=Error("Stack deletion failed - may have resources that need to be retained");throw O.code="DELETE_FAILED",O.stackStatus=L.StackStatus,O.statusReason=L.StackStatusReason,O}if(z.includes(L.StackStatus))throw Error(`Stack reached failure status: ${L.StackStatus}`);await new Promise((O)=>setTimeout(O,5000)),J++}catch(I){if(q==="stack-delete-complete"&&I.message?.includes("does not exist"))return;if(q==="stack-create-complete"&&I.message?.includes("does not exist")){if(J%10===0)console.log(`[waitForStack] Attempt ${J}: Stack does not exist (error), retrying...`);await new Promise((L)=>setTimeout(L,2000)),J++;continue}throw console.log(`[waitForStack] Unexpected error: ${I.message}`),I}throw console.log(`[waitForStack] Timeout after ${J} attempts`),Error(`Timeout waiting for stack to reach ${q}`)}async validateTemplate(j){let q={Action:"ValidateTemplate",TemplateBody:j,Version:"2010-05-15"};return await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()})}async listStacks(j){let q={Action:"ListStacks",Version:"2010-05-15"};if(j)j.forEach((I,L)=>{q[`StackStatusFilter.member.${L+1}`]=I});let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()}),z=G.ListStacksResponse||G,H=z.ListStacksResult||z,Q=H.StackSummaries?.member||H.StackSummaries||[];return{StackSummaries:(Array.isArray(Q)?Q:Q?[Q]:[]).map((I)=>({StackId:I.StackId||"",StackName:I.StackName||"",TemplateDescription:I.TemplateDescription,CreationTime:I.CreationTime||"",LastUpdatedTime:I.LastUpdatedTime,DeletionTime:I.DeletionTime,StackStatus:I.StackStatus||""}))}}async createChangeSet(j){let q={Action:"CreateChangeSet",StackName:j.stackName,ChangeSetName:j.changeSetName,Version:"2010-05-15"};if(j.templateBody)q.TemplateBody=j.templateBody;else if(j.templateUrl)q.TemplateURL=j.templateUrl;if(j.parameters)j.parameters.forEach((z,H)=>{q[`Parameters.member.${H+1}.ParameterKey`]=z.ParameterKey,q[`Parameters.member.${H+1}.ParameterValue`]=z.ParameterValue});if(j.capabilities)j.capabilities.forEach((z,H)=>{q[`Capabilities.member.${H+1}`]=z});if(j.changeSetType)q.ChangeSetType=j.changeSetType;let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{Id:G.Id,StackId:G.StackId}}async describeChangeSet(j,q){let G={Action:"DescribeChangeSet",StackName:j,ChangeSetName:q,Version:"2010-05-15"};return await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(G).toString()})}async executeChangeSet(j,q){let G={Action:"ExecuteChangeSet",StackName:j,ChangeSetName:q,Version:"2010-05-15"};await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(G).toString()})}async deleteChangeSet(j,q){let G={Action:"DeleteChangeSet",StackName:j,ChangeSetName:q,Version:"2010-05-15"};await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(G).toString()})}async getStackOutputs(j){let q=await this.describeStacks({stackName:j});if(!q.Stacks||q.Stacks.length===0)throw Error(`Stack ${j} not found`);let G=q.Stacks[0],z={};if(G.Outputs)for(let H of G.Outputs)z[H.OutputKey]=H.OutputValue;return z}async getTemplate(j){let q={Action:"GetTemplate",StackName:j,Version:"2010-05-15"},G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{TemplateBody:G?.GetTemplateResult?.TemplateBody||G?.TemplateBody||""}}parseStacksResponse(j){let q=[],G=j?.DescribeStacksResult?.Stacks?.member||j?.Stacks?.member||j?.Stacks||j;if(G&&!Array.isArray(G))G=[G];if(Array.isArray(G)){for(let z of G)if(z.StackId||z.StackName){let H;if(z.Outputs?.member)H=(Array.isArray(z.Outputs.member)?z.Outputs.member:[z.Outputs.member]).map((J)=>({OutputKey:J.OutputKey,OutputValue:J.OutputValue,Description:J.Description,ExportName:J.ExportName}));q.push({StackId:z.StackId,StackName:z.StackName,StackStatus:z.StackStatus,CreationTime:z.CreationTime,LastUpdatedTime:z.LastUpdatedTime,StackStatusReason:z.StackStatusReason,Outputs:H})}}else if(j.StackId)q.push({StackId:j.StackId,StackName:j.StackName,StackStatus:j.StackStatus,CreationTime:j.CreationTime,LastUpdatedTime:j.LastUpdatedTime});return q}parseStackEvents(j){let q=[],G=j?.DescribeStackEventsResult?.StackEvents?.member||j?.StackEvents?.member||j?.StackEvents||[];if(G&&!Array.isArray(G))G=[G];for(let z of G)if(z.LogicalResourceId)q.push({Timestamp:z.Timestamp,ResourceType:z.ResourceType,LogicalResourceId:z.LogicalResourceId,ResourceStatus:z.ResourceStatus,ResourceStatusReason:z.ResourceStatusReason});return q}async waitForStackWithProgress(j,q,G){let z={"stack-create-complete":["CREATE_COMPLETE"],"stack-update-complete":["UPDATE_COMPLETE"],"stack-delete-complete":["DELETE_COMPLETE"]},H=["CREATE_FAILED","ROLLBACK_FAILED","ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE"],Q=z[q],J=360,I=0,L=new Set;while(I<360)try{if(G)try{let X=[...(await this.describeStackEvents(j)).StackEvents||[]].reverse();for(let Y of X){let Z=`${Y.LogicalResourceId}-${Y.ResourceStatus}-${Y.Timestamp}`;if(!L.has(Z))L.add(Z),G({resourceId:Y.LogicalResourceId,resourceType:Y.ResourceType,status:Y.ResourceStatus,reason:Y.ResourceStatusReason,timestamp:Y.Timestamp})}}catch{}let O=await this.describeStacks({stackName:j});if(O.Stacks.length===0){if(q==="stack-delete-complete")return;await new Promise((U)=>setTimeout(U,2000)),I++;continue}let V=O.Stacks[0];if(Q.includes(V.StackStatus))return;if(V.StackStatus==="DELETE_FAILED"&&q==="stack-delete-complete"){let U=Error("Stack deletion failed - may have resources that need to be retained");throw U.code="DELETE_FAILED",U.stackStatus=V.StackStatus,U.statusReason=V.StackStatusReason,U}if(H.includes(V.StackStatus))throw Error(`Stack reached failure status: ${V.StackStatus}`);await new Promise((U)=>setTimeout(U,3000)),I++}catch(O){if(q==="stack-delete-complete"&&O.message?.includes("does not exist"))return;if(q==="stack-create-complete"&&O.message?.includes("does not exist")){await new Promise((V)=>setTimeout(V,2000)),I++;continue}throw O}throw Error(`Timeout waiting for stack to reach ${q}`)}async waitForStackComplete(j,q=120,G=5000){let z=["CREATE_COMPLETE","UPDATE_COMPLETE","DELETE_COMPLETE"],H=["CREATE_FAILED","UPDATE_FAILED","DELETE_FAILED","ROLLBACK_COMPLETE","ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED"];for(let Q=0;Q<q;Q++)try{let J=await this.describeStacks({stackName:j});if(J.Stacks.length===0)return{success:!0,status:"DELETE_COMPLETE"};let I=J.Stacks[0],L=I.StackStatus;if(z.includes(L))return{success:!0,status:L};if(H.includes(L))return{success:!1,status:L,reason:I.StackStatusReason};await new Promise((O)=>setTimeout(O,G))}catch(J){if(J.message?.includes("does not exist"))return{success:!0,status:"DELETE_COMPLETE"};throw J}return{success:!1,status:"TIMEOUT",reason:"Timeout waiting for stack operation"}}}
2
- export{$ as Uf};
@@ -1,2 +0,0 @@
1
- import{Og as v}from"./chunk-fpm59y25.js";class B{client;region;constructor(k="us-east-1",q){this.region=k,this.client=new v(void 0,{profile:q})}async getCallerIdentity(){let k=await this.client.request({service:"sts",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"Action=GetCallerIdentity&Version=2011-06-15"});if(typeof k==="string"){let w=k.match(/<Account>(\d+)<\/Account>/),x=k.match(/<UserId>([^<]+)<\/UserId>/),z=k.match(/<Arn>([^<]+)<\/Arn>/);return{Account:w?.[1],UserId:x?.[1],Arn:z?.[1]}}let q=k?.GetCallerIdentityResponse?.GetCallerIdentityResult||k?.GetCallerIdentityResult;if(q)return{Account:String(q.Account),UserId:q.UserId,Arn:q.Arn};if(k?.Account)return{Account:String(k.Account),UserId:k.UserId,Arn:k.Arn};return{Account:void 0,UserId:void 0,Arn:void 0}}}
2
- export{B as cd};
@@ -1 +0,0 @@
1
- import{Qe as L}from"./chunk-ax9mr6wm.js";var _="\x00";function X(R,E){if(R==="*"||R==="**")return!0;let D=R.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"\x01").replace(/\*/g,"[^/]*").replace(/\u0001/g,".*");return new RegExp(`^${D}$`).test(E)}function A(R,E){if(R.startsWith("*.")){let D=R.slice(1);return E.endsWith(D)&&E.length>D.length}return R===E}function W(R,E){if(R.enabled===!1)return!1;if(R.methods?.length&&!R.methods.some((D)=>D.toUpperCase()===E.method.toUpperCase()))return!1;if(R.path&&!X(R.path,E.path))return!1;if(R.host&&!A(R.host,E.host??""))return!1;return!0}function Z(R,E){let D=R.key??{source:"ip"},F=D.fallbackToIp!==!1,H;if(D.source==="ip")H=E.ip;else if(D.source==="global")H="global";else if(D.source==="host")H=E.host??"";else if(D.source==="path")H=E.path;else if(D.source==="header")H=D.name?E.headers?.[D.name.toLowerCase()]:void 0;else if(D.source==="cookie")H=D.name?E.cookies?.[D.name]:void 0;if(!H&&D.source!=="global")H=F?E.ip:"__missing__";return`${R.id}\x00${H}`}class C{clock;maxTrackedKeys;buckets=new Map;windows=new Map;rules;constructor(R,E=()=>Date.now(),D=1e5){this.clock=E;this.maxTrackedKeys=D;this.rules=[...R].sort((F,H)=>(F.priority??0)-(H.priority??0))}check(R){let E=this.clock(),D=this.rules.filter((j)=>W(j,R)),F;for(let j of D){let z=this.test(j,R,E);if(z.allowed)continue;if(!F||$(z.action)>$(F.action))F=z}if(F)return F;let H={action:"allow",allowed:!0};for(let j of D){let z=this.consume(j,R,E);if(z.remaining!=null&&(H.remaining??1/0)>z.remaining)H=z}return H}test(R,E,D){let F=Z(R,E);if((R.algorithm??"token_bucket")==="token_bucket"){let j=R.burst??R.limit,z=this.buckets.get(F),B=z?Math.min(j,z.tokens+this.refill(R,D-z.updatedAt)):j;if(B>=1)return{action:"allow",allowed:!0};return this.blocked(R,F,0,this.msPerToken(R)*(1-B),D)}let H=(this.windows.get(F)?.hits??[]).filter((j)=>j>D-R.windowMs);if(H.length<R.limit)return{action:"allow",allowed:!0};return this.blocked(R,F,0,H[0]+R.windowMs-D,D)}peek(R){let E=this.clock();for(let D of this.rules){if(!W(D,R))continue;let F=this.test(D,R,E);if(!F.allowed)return F}return{action:"allow",allowed:!0}}msPerToken(R){return R.windowMs/Math.max(1,R.limit)}refill(R,E){return Math.max(0,E)/this.msPerToken(R)}blocked(R,E,D,F,H){let j=R.action??"deny";return{action:j,allowed:j==="allow"||j==="log",ruleId:R.id,limit:R.limit,remaining:D,retryAfterMs:Math.max(0,Math.ceil(F)),resetAt:H+Math.max(0,F),key:E}}consume(R,E,D){let F=Z(R,E);if((R.algorithm??"token_bucket")==="token_bucket"){let J=R.burst??R.limit,V=this.buckets.get(F)??{tokens:J,updatedAt:D},Q=Math.min(J,V.tokens+this.refill(R,D-V.updatedAt));if(Q<1)return this.buckets.set(F,{tokens:Q,updatedAt:D}),this.blocked(R,F,0,this.msPerToken(R)*(1-Q),D);return this.evictIfNeeded(this.buckets),this.buckets.set(F,{tokens:Q-1,updatedAt:D}),{action:"allow",allowed:!0,ruleId:R.id,limit:J,remaining:Math.floor(Q-1),resetAt:D+this.msPerToken(R)*(J-(Q-1)),key:F}}let j=this.windows.get(F)??{hits:[]},z=D-R.windowMs,B=j.hits.filter((J)=>J>z);if(B.length>=R.limit)return this.windows.set(F,{hits:B}),this.blocked(R,F,0,B[0]+R.windowMs-D,D);return B.push(D),this.evictIfNeeded(this.windows),this.windows.set(F,{hits:B}),{action:"allow",allowed:!0,ruleId:R.id,limit:R.limit,remaining:R.limit-B.length,resetAt:B[0]+R.windowMs,key:F}}evictIfNeeded(R){if(R.size<this.maxTrackedKeys)return;let E=R.size-this.maxTrackedKeys+1,D=0;for(let F of R.keys())if(R.delete(F),++D>=E)break}sweep(){let R=this.clock(),E=0;for(let[D,F]of this.windows){let H=D.split("\x00")[0],j=this.rules.find((z)=>z.id===H);if(!j){this.windows.delete(D),E++;continue}if(F.hits.every((z)=>z<=R-j.windowMs))this.windows.delete(D),E++}for(let[D,F]of this.buckets){let H=D.split("\x00")[0],j=this.rules.find((z)=>z.id===H);if(!j||R-F.updatedAt>j.windowMs*2)this.buckets.delete(D),E++}return E}get trackedKeys(){return this.buckets.size+this.windows.size}}function $(R){return{allow:0,log:1,throttle:2,challenge:3,deny:4}[R]}function O(R){let E={};if(R.limit!=null)E["ratelimit-limit"]=String(R.limit);if(R.remaining!=null)E["ratelimit-remaining"]=String(R.remaining);if(R.resetAt!=null)E["ratelimit-reset"]=String(Math.max(0,Math.ceil((R.resetAt-Date.now())/1000)));if(!R.allowed&&R.retryAfterMs!=null)E["retry-after"]=String(Math.max(1,Math.ceil(R.retryAfterMs/1000)));return E}function T(){return[{id:"global-ip",limit:600,windowMs:60000,burst:100,key:{source:"ip"},action:"deny",priority:100},{id:"api-ip",limit:120,windowMs:60000,burst:30,path:"/api/**",key:{source:"ip"},action:"deny",priority:50},{id:"auth-ip",limit:10,windowMs:60000,algorithm:"sliding_window",path:"/auth/**",methods:["POST"],key:{source:"ip"},action:"challenge",priority:10}]}var G="protection.controls",U=24,N=4,P={ipRules:{allow:[],block:[]}};function Y(R,E){if(!R?.enabled)return;return new Date(R.expiresAt).getTime()>E.getTime()?R:void 0}function I(R,E){let D=Number.isFinite(R)?Number(R):E;return Math.min(U,Math.max(0.25,D))}var K=500;class S{controlPlane;options;constructor(R,E={}){this.controlPlane=R;this.options=E}now(){return this.options.now?.()??new Date}read(){let R=this.controlPlane.getSetting(G);if(!R||typeof R!=="object"||Array.isArray(R))return{...P,ipRules:{allow:[],block:[]}};let E=R;return{attackMode:E.attackMode,mitigationPause:E.mitigationPause,ipRules:{allow:Array.isArray(E.ipRules?.allow)?E.ipRules.allow:[],block:Array.isArray(E.ipRules?.block)?E.ipRules.block:[]},updatedAt:E.updatedAt}}write(R){let E={...R,updatedAt:this.now().toISOString()};return this.controlPlane.setSetting(G,E),E}raw(){return this.read()}current(){let R=this.now(),E=this.read();return{attackMode:Y(E.attackMode,R),mitigationPause:Y(E.mitigationPause,R),ipRules:E.ipRules}}enableAttackMode(R){let E=this.now(),D={enabled:!0,startedAt:E.toISOString(),expiresAt:new Date(E.getTime()+I(R.hours,N)*3600000).toISOString(),reason:R.reason.trim()||"Attack mode enabled by an operator.",actorId:R.actorId};return this.write({...this.read(),attackMode:D}),D}disableAttackMode(){let R=this.read();if(!R.attackMode?.enabled)return!1;return this.write({...R,attackMode:{...R.attackMode,enabled:!1}}),!0}pauseMitigations(R){let E=R.reason.trim();if(!E)throw Error("Pausing mitigations requires a reason: you are liable for the traffic it admits.");let D=this.now(),F={enabled:!0,startedAt:D.toISOString(),expiresAt:new Date(D.getTime()+I(R.hours,U)*3600000).toISOString(),reason:E,actorId:R.actorId};return this.write({...this.read(),mitigationPause:F}),F}resumeMitigations(){let R=this.read();if(!R.mitigationPause?.enabled)return!1;return this.write({...R,mitigationPause:{...R.mitigationPause,enabled:!1}}),!0}addIpRule(R,E){let D=E.trim();if(!L(D))throw Error(`Not a valid IP or CIDR: ${E}`);let F=this.read(),H={...F.ipRules,[R]:[...new Set([...F.ipRules[R],D])]};if(H[R].length>K)throw Error(`At most ${K} ${R} rules are supported.`);let j=R==="allow"?"block":"allow";return H[j]=H[j].filter((z)=>z!==D),this.write({...F,ipRules:H}),H}removeIpRule(R,E){let D=this.read(),F={...D.ipRules,[R]:D.ipRules[R].filter((H)=>H!==E.trim())};return this.write({...D,ipRules:F}),F}}function b(R){if(R.mitigationPause)return{attackMode:!!R.attackMode,mitigationPaused:!0,summary:`Automatic mitigation is paused until ${R.mitigationPause.expiresAt}. All traffic is being served and billed.`,expiresAt:R.mitigationPause.expiresAt};if(R.attackMode)return{attackMode:!0,mitigationPaused:!1,summary:`Attack mode is on until ${R.attackMode.expiresAt}. Every visitor is being challenged.`,expiresAt:R.attackMode.expiresAt};return{attackMode:!1,mitigationPaused:!1,summary:"Protection is in its normal posture."}}function m(R,E){if(E.mitigationPause)return R.map((D)=>({...D,enabled:!1}));if(!E.attackMode)return[...R];return R.map((D)=>({...D,action:D.action==="deny"?"deny":"challenge",burst:Math.max(1,Math.min(D.burst??D.limit,5))}))}function x(R,E){let D=[...new Set([...R.allowlist??[],...E.ipRules.allow])],F=[...new Set([...R.blocklist??[],...E.ipRules.block])];if(E.mitigationPause)return{...R,allowlist:D,blocklist:F,monitorOnly:!0};if(!E.attackMode)return{...R,allowlist:D,blocklist:F};let H=R.thresholds??{};return{...R,allowlist:D,blocklist:F,thresholds:{...H,newConnectionsPerSecond:Math.max(1,Math.floor((H.newConnectionsPerSecond??50)/5)),concurrentPerSource:Math.max(1,Math.floor((H.concurrentPerSource??100)/5))}}}function f(R,E){let D=R?.infrastructure?.compute;if(!D||D.ddos===!1)return R;let F=typeof D.ddos==="object"&&D.ddos!==null?D.ddos:{};return{...R,infrastructure:{...R.infrastructure,compute:{...D,ddos:x(F,E)}}}}export{_ as a,X as b,W as c,Z as d,C as e,O as f,T as g,G as h,U as i,N as j,S as k,b as l,m,x as n,f as o};
@@ -1,50 +0,0 @@
1
- import{Og as L}from"./chunk-fpm59y25.js";class Q{client;region;constructor(j="us-east-1"){this.region=j,this.client=new L}async createHostedZone(j){let k=j.CallerReference||`${Date.now()}-${Math.random().toString(36).slice(2)}`,F=`<?xml version="1.0" encoding="UTF-8"?>
2
- <CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
3
- <Name>${j.Name}</Name>
4
- <CallerReference>${k}</CallerReference>`;if(j.HostedZoneConfig){if(F+=`
5
- <HostedZoneConfig>`,j.HostedZoneConfig.Comment)F+=`
6
- <Comment>${j.HostedZoneConfig.Comment}</Comment>`;if(j.HostedZoneConfig.PrivateZone!==void 0)F+=`
7
- <PrivateZone>${j.HostedZoneConfig.PrivateZone}</PrivateZone>`;F+=`
8
- </HostedZoneConfig>`}if(j.VPC)F+=`
9
- <VPC>
10
- <VPCRegion>${j.VPC.VPCRegion}</VPCRegion>
11
- <VPCId>${j.VPC.VPCId}</VPCId>
12
- </VPC>`;if(j.DelegationSetId)F+=`
13
- <DelegationSetId>${j.DelegationSetId}</DelegationSetId>`;F+=`
14
- </CreateHostedZoneRequest>`;let J=await this.client.request({service:"route53",region:this.region,method:"POST",path:"/2013-04-01/hostedzone",headers:{"content-type":"application/xml"},body:F});return this.parseCreateHostedZoneResponse(J)}async listHostedZones(j){let k={};if(j?.Marker)k.marker=j.Marker;if(j?.MaxItems)k.maxitems=j.MaxItems;let F=await this.client.request({service:"route53",region:this.region,method:"GET",path:"/2013-04-01/hostedzone",queryParams:Object.keys(k).length>0?k:void 0});return this.parseListHostedZonesResponse(F)}async listHostedZonesByName(j){let k={};if(j?.DNSName)k.dnsname=j.DNSName;if(j?.HostedZoneId)k.hostedzoneid=j.HostedZoneId;if(j?.MaxItems)k.maxitems=j.MaxItems;let F=await this.client.request({service:"route53",region:this.region,method:"GET",path:"/2013-04-01/hostedzonesbyname",queryParams:Object.keys(k).length>0?k:void 0});return this.parseListHostedZonesResponse(F)}async getHostedZone(j){let k=j.Id.replace("/hostedzone/",""),F=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/hostedzone/${k}`});return this.parseGetHostedZoneResponse(F)}async deleteHostedZone(j){let k=j.Id.replace("/hostedzone/","");await this.client.request({service:"route53",region:this.region,method:"DELETE",path:`/2013-04-01/hostedzone/${k}`})}async listResourceRecordSets(j){let k=j.HostedZoneId.replace("/hostedzone/",""),F={};if(j.StartRecordName)F.name=j.StartRecordName;if(j.StartRecordType)F.type=j.StartRecordType;if(j.StartRecordIdentifier)F.identifier=j.StartRecordIdentifier;if(j.MaxItems)F.maxitems=j.MaxItems;let J=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/hostedzone/${k}/rrset`,queryParams:Object.keys(F).length>0?F:void 0});return this.parseListResourceRecordSetsResponse(J)}async changeResourceRecordSets(j){let k=j.HostedZoneId.replace("/hostedzone/",""),F=`<?xml version="1.0" encoding="UTF-8"?>
15
- <ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
16
- <ChangeBatch>`;if(j.ChangeBatch.Comment)F+=`
17
- <Comment>${this.escapeXml(j.ChangeBatch.Comment)}</Comment>`;F+=`
18
- <Changes>`;for(let H of j.ChangeBatch.Changes){if(F+=`
19
- <Change>
20
- <Action>${H.Action}</Action>
21
- <ResourceRecordSet>
22
- <Name>${H.ResourceRecordSet.Name}</Name>
23
- <Type>${H.ResourceRecordSet.Type}</Type>`,H.ResourceRecordSet.TTL!==void 0)F+=`
24
- <TTL>${H.ResourceRecordSet.TTL}</TTL>`;if(H.ResourceRecordSet.SetIdentifier)F+=`
25
- <SetIdentifier>${H.ResourceRecordSet.SetIdentifier}</SetIdentifier>`;if(H.ResourceRecordSet.Weight!==void 0)F+=`
26
- <Weight>${H.ResourceRecordSet.Weight}</Weight>`;if(H.ResourceRecordSet.Region)F+=`
27
- <Region>${H.ResourceRecordSet.Region}</Region>`;if(H.ResourceRecordSet.Failover)F+=`
28
- <Failover>${H.ResourceRecordSet.Failover}</Failover>`;if(H.ResourceRecordSet.HealthCheckId)F+=`
29
- <HealthCheckId>${H.ResourceRecordSet.HealthCheckId}</HealthCheckId>`;if(H.ResourceRecordSet.ResourceRecords&&H.ResourceRecordSet.ResourceRecords.length>0){F+=`
30
- <ResourceRecords>`;for(let K of H.ResourceRecordSet.ResourceRecords)F+=`
31
- <ResourceRecord>
32
- <Value>${this.escapeXml(K.Value)}</Value>
33
- </ResourceRecord>`;F+=`
34
- </ResourceRecords>`}if(H.ResourceRecordSet.AliasTarget)F+=`
35
- <AliasTarget>
36
- <HostedZoneId>${H.ResourceRecordSet.AliasTarget.HostedZoneId}</HostedZoneId>
37
- <DNSName>${H.ResourceRecordSet.AliasTarget.DNSName}</DNSName>
38
- <EvaluateTargetHealth>${H.ResourceRecordSet.AliasTarget.EvaluateTargetHealth}</EvaluateTargetHealth>
39
- </AliasTarget>`;if(H.ResourceRecordSet.GeoLocation){if(F+=`
40
- <GeoLocation>`,H.ResourceRecordSet.GeoLocation.ContinentCode)F+=`
41
- <ContinentCode>${H.ResourceRecordSet.GeoLocation.ContinentCode}</ContinentCode>`;if(H.ResourceRecordSet.GeoLocation.CountryCode)F+=`
42
- <CountryCode>${H.ResourceRecordSet.GeoLocation.CountryCode}</CountryCode>`;if(H.ResourceRecordSet.GeoLocation.SubdivisionCode)F+=`
43
- <SubdivisionCode>${H.ResourceRecordSet.GeoLocation.SubdivisionCode}</SubdivisionCode>`;F+=`
44
- </GeoLocation>`}F+=`
45
- </ResourceRecordSet>
46
- </Change>`}F+=`
47
- </Changes>
48
- </ChangeBatch>
49
- </ChangeResourceRecordSetsRequest>`;let J=await this.client.request({service:"route53",region:this.region,method:"POST",path:`/2013-04-01/hostedzone/${k}/rrset`,headers:{"content-type":"application/xml"},body:F});return this.parseChangeResourceRecordSetsResponse(J)}escapeXml(j){return j.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}parseCreateHostedZoneResponse(j){let k=j.CreateHostedZoneResponse||j;return{HostedZone:this.parseHostedZone(k.HostedZone),ChangeInfo:{Id:k.ChangeInfo?.Id||"",Status:k.ChangeInfo?.Status||"",SubmittedAt:k.ChangeInfo?.SubmittedAt||""},DelegationSet:this.parseDelegationSet(k.DelegationSet),Location:k.Location||""}}parseListHostedZonesResponse(j){let k=j.ListHostedZonesResponse||j.ListHostedZonesByNameResponse||j,F=k.HostedZones?.HostedZone||k.HostedZones||[];if(!Array.isArray(F))F=F?[F]:[];return{HostedZones:F.map((J)=>this.parseHostedZone(J)),IsTruncated:k.IsTruncated==="true"||k.IsTruncated===!0,MaxItems:k.MaxItems||"100",Marker:k.Marker,NextMarker:k.NextMarker}}parseGetHostedZoneResponse(j){let k=j.GetHostedZoneResponse||j;return{HostedZone:this.parseHostedZone(k.HostedZone),DelegationSet:this.parseDelegationSet(k.DelegationSet),VPCs:k.VPCs?.VPC?Array.isArray(k.VPCs.VPC)?k.VPCs.VPC:[k.VPCs.VPC]:void 0}}parseListResourceRecordSetsResponse(j){let k=j.ListResourceRecordSetsResponse||j,F=k.ResourceRecordSets?.ResourceRecordSet||k.ResourceRecordSets||[];if(!Array.isArray(F))F=F?[F]:[];return{ResourceRecordSets:F.map((J)=>this.parseResourceRecordSet(J)),IsTruncated:k.IsTruncated==="true"||k.IsTruncated===!0,MaxItems:k.MaxItems||"100",NextRecordName:k.NextRecordName,NextRecordType:k.NextRecordType,NextRecordIdentifier:k.NextRecordIdentifier}}parseChangeResourceRecordSetsResponse(j){let k=j.ChangeResourceRecordSetsResponse||j;return{ChangeInfo:{Id:k.ChangeInfo?.Id||"",Status:k.ChangeInfo?.Status||"",SubmittedAt:k.ChangeInfo?.SubmittedAt||"",Comment:k.ChangeInfo?.Comment}}}parseHostedZone(j){if(!j)return{Id:"",Name:""};return{Id:j.Id||"",Name:j.Name||"",CallerReference:j.CallerReference,Config:j.Config?{Comment:j.Config.Comment,PrivateZone:j.Config.PrivateZone==="true"||j.Config.PrivateZone===!0}:void 0,ResourceRecordSetCount:j.ResourceRecordSetCount?Number(j.ResourceRecordSetCount):void 0}}parseDelegationSet(j){if(!j)return{NameServers:[]};let k=j.NameServers?.NameServer||j.NameServers||[];if(!Array.isArray(k))k=k?[k]:[];return{Id:j.Id,CallerReference:j.CallerReference,NameServers:k}}parseResourceRecordSet(j){if(!j)return{Name:"",Type:""};let k=j.ResourceRecords?.ResourceRecord||j.ResourceRecords||[];if(!Array.isArray(k))k=k?[k]:[];return{Name:j.Name||"",Type:j.Type||"",TTL:j.TTL?Number(j.TTL):void 0,ResourceRecords:k.map((F)=>({Value:F.Value||F})),AliasTarget:j.AliasTarget?{HostedZoneId:j.AliasTarget.HostedZoneId,DNSName:j.AliasTarget.DNSName,EvaluateTargetHealth:j.AliasTarget.EvaluateTargetHealth==="true"||j.AliasTarget.EvaluateTargetHealth===!0}:void 0,SetIdentifier:j.SetIdentifier,Weight:j.Weight?Number(j.Weight):void 0,Region:j.Region,GeoLocation:j.GeoLocation,Failover:j.Failover,HealthCheckId:j.HealthCheckId}}async findHostedZoneByName(j){let k=j.endsWith(".")?j:`${j}.`;return(await this.listHostedZonesByName({DNSName:k})).HostedZones.find((H)=>H.Name===k)||null}async createARecord(j){let k=Array.isArray(j.Value)?j.Value:[j.Value];return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:"A",TTL:j.TTL||300,ResourceRecords:k.map((F)=>({Value:F}))}}]}})}async createCnameRecord(j){return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:"CNAME",TTL:j.TTL||300,ResourceRecords:[{Value:j.Value}]}}]}})}async createAliasRecord(j){return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:j.Type||"A",AliasTarget:{HostedZoneId:j.TargetHostedZoneId,DNSName:j.TargetDNSName,EvaluateTargetHealth:j.EvaluateTargetHealth??!1}}}]}})}async createTxtRecord(j){let F=(Array.isArray(j.Value)?j.Value:[j.Value]).map((J)=>{if(!J.startsWith('"'))return`"${J}"`;return J});return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:"TXT",TTL:j.TTL||300,ResourceRecords:F.map((J)=>({Value:J}))}}]}})}async createMxRecord(j){return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:"MX",TTL:j.TTL||300,ResourceRecords:j.Values.map((k)=>({Value:`${k.priority} ${k.mailServer}`}))}}]}})}async deleteRecord(j){return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"DELETE",ResourceRecordSet:j.RecordSet}]}})}async waitForChange(j,k=60,F=5000){let J=j.replace("/change/","");for(let H=0;H<k;H++){let K=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/change/${J}`});if((K.GetChangeResponse?.ChangeInfo?.Status||K.ChangeInfo?.Status)==="INSYNC")return!0;await new Promise((O)=>setTimeout(O,F))}return!1}async findOrCreateHostedZone(j){let k=j.domainName.endsWith(".")?j.domainName:`${j.domainName}.`,F=await this.findHostedZoneByName(k);if(F){let H=await this.getHostedZone({Id:F.Id});return{hostedZone:F,nameServers:H.DelegationSet.NameServers,isNew:!1}}let J=await this.createHostedZone({Name:k,HostedZoneConfig:{Comment:j.comment||`Hosted zone for ${j.domainName}`,PrivateZone:j.privateZone},VPC:j.vpc});return{hostedZone:J.HostedZone,nameServers:J.DelegationSet.NameServers,isNew:!0}}static getRootDomain(j){let k=j.replace(/\.$/,"").split(".");if(k.length<=2)return j;return k.slice(-2).join(".")}async findHostedZoneForDomain(j){let F=j.replace(/\.$/,"").split(".");for(let J=0;J<F.length-1;J++){let H=F.slice(J).join("."),K=await this.findHostedZoneByName(H);if(K)return K}return null}async ensureHostedZone(j){let k=await this.findOrCreateHostedZone({domainName:j.domainName,comment:j.comment});return{hostedZoneId:k.hostedZone.Id.replace("/hostedzone/",""),nameServers:k.nameServers,isNew:k.isNew,action:k.isNew?"created":"found"}}async setupDomainDns(j){let{domain:k,createIfNotExists:F=!0}=j,J=await this.findHostedZoneByName(k);if(J){let K=await this.getHostedZone({Id:J.Id});return{success:!0,hostedZoneId:J.Id.replace("/hostedzone/",""),nameServers:K.DelegationSet.NameServers,isNew:!1,message:`Found existing hosted zone for ${k}`}}if(!F)return{success:!1,hostedZoneId:null,nameServers:[],isNew:!1,message:`No hosted zone found for ${k} and createIfNotExists is false`};let H=await this.createHostedZone({Name:k,HostedZoneConfig:{Comment:`Created automatically by ts-cloud for ${k}`}});return{success:!0,hostedZoneId:H.HostedZone.Id.replace("/hostedzone/",""),nameServers:H.DelegationSet.NameServers,isNew:!0,message:`Created new hosted zone for ${k}. Please update your domain registrar with these name servers: ${H.DelegationSet.NameServers.join(", ")}`}}static CloudFrontHostedZoneId="Z2FDTNDATAQYW2";static S3WebsiteHostedZoneIds={"us-east-1":"Z3AQBSTGFYJSTF","us-east-2":"Z2O1EMRO9K5GLX","us-west-1":"Z2F56UZL2M1ACD","us-west-2":"Z3BJ6K6RIION7M","ap-east-1":"ZNB98KWMFR0R6","ap-south-1":"Z11RGJOFQNVJUP","ap-northeast-1":"Z2M4EHUR26P7ZW","ap-northeast-2":"Z3W03O7B5YMIYP","ap-northeast-3":"Z2YQB5RD63NC85","ap-southeast-1":"Z3O0J2DXBE1FTB","ap-southeast-2":"Z1WCIGYICN2BYD","ca-central-1":"Z1QDHH18159H29","eu-central-1":"Z21DNDUVLTQW6Q","eu-west-1":"Z1BKCTXD74EZPE","eu-west-2":"Z3GKZC51ZF0DB4","eu-west-3":"Z3R1K369G5AVDG","eu-north-1":"Z3BAZG2TWCNX0D","sa-east-1":"Z7KQH4QJS55SO"};static ALBHostedZoneIds={"us-east-1":"Z35SXDOTRQ7X7K","us-east-2":"Z3AADJGX6KTTL2","us-west-1":"Z368ELLRRE2KJ0","us-west-2":"Z1H1FL5HABSF5","ap-east-1":"Z3DQVH9N71FHZ0","ap-south-1":"ZP97RAFLXTNZK","ap-northeast-1":"Z14GRHDCWA56QT","ap-northeast-2":"ZWKZPGTI48KDX","ap-northeast-3":"Z5LXEBD8Y73MNV","ap-southeast-1":"Z1LMS91P8CMLE5","ap-southeast-2":"Z1GM3OXH4ZPM65","ca-central-1":"ZQSVJUPU6J1EY","eu-central-1":"Z215JYRZR1TBD5","eu-west-1":"Z32O12XQLNTSW2","eu-west-2":"ZHURV8PSTC4K8","eu-west-3":"Z3Q77PNBQS71R4","eu-north-1":"Z23TAZ6LKFMNIO","sa-east-1":"Z2P70J7HTTTPLU"};static APIGatewayHostedZoneIds={"us-east-1":"Z1UJRXOUMOOFQ8","us-east-2":"ZOJJZC49E0EPZ","us-west-1":"Z2MUQ32089INYE","us-west-2":"Z2OJLYMUO9EFXC","ap-east-1":"Z3FD1VL90ND7K5","ap-south-1":"Z3VO1THU9YC4UR","ap-northeast-1":"Z1YSHQZHG15GKL","ap-northeast-2":"Z20JF4UZKIW1U8","ap-northeast-3":"Z2YQB5RD63NC85","ap-southeast-1":"ZL327KTPIQFUL","ap-southeast-2":"Z2RPCDW04V8134","ca-central-1":"Z19DQILCV0OWEC","eu-central-1":"Z1U9ULNL0V5AJ3","eu-west-1":"ZLY8HYME6SFDD","eu-west-2":"ZJ5UAJN8Y3Z2Q","eu-west-3":"Z3KY65QIEKYHQQ","eu-north-1":"Z3UWIKFBOOGXPP","sa-east-1":"ZCMLWB8V5SYIT"}}
50
- export{Q as Zf};
@@ -1 +0,0 @@
1
- import{Ae as b,Be as c,Ce as d,De as e,Ee as f,Fe as g,Ge as h,He as i,Ie as j,ze as a}from"./chunk-zmegvjp8.js";import"./chunk-3gykfyq4.js";import"./chunk-ax9mr6wm.js";import"./chunk-ggn7ax8p.js";import"./chunk-ddk4rt4j.js";import"./chunk-tga3hhwk.js";import"./chunk-axhnkn5g.js";import"./chunk-h5pa5men.js";import"./chunk-fy8j3y8p.js";import"./chunk-fpm59y25.js";import"./chunk-rxcvf10f.js";import"./chunk-mh0kdzqp.js";export{a as sharedBoxProbeScript,e as serverLogSources,j as resolveServerDashboardData,i as resolveConfigOnlyServerDashboardData,g as parseServerSecurity,f as parseServerLogs,h as parseDeployHistory,c as parseBlock,b as metricsScript,d as mergeDiscoveredSites};
@@ -1 +0,0 @@
1
- import{Uf as a}from"./chunk-h5pa5men.js";import"./chunk-fpm59y25.js";import"./chunk-mh0kdzqp.js";export{a as CloudFormationClient};