@stacksjs/ts-cloud 0.16.17 → 0.16.19

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 (191) hide show
  1. package/dist/aws/index.js +1 -1
  2. package/dist/bin/{chunk-r2vrq2gr.js → chunk-0f1qpmd6.js} +5 -5
  3. package/dist/bin/chunk-0h6cggyt.js +1 -0
  4. package/dist/bin/{chunk-8af2sky9.js → chunk-0trtkv9g.js} +4 -4
  5. package/dist/bin/{chunk-30jk87p4.js → chunk-148x1zq8.js} +2 -2
  6. package/dist/bin/{chunk-e7kqxsqh.js → chunk-1j8b1d58.js} +1 -1
  7. package/dist/bin/chunk-28ztnqjk.js +1 -0
  8. package/dist/bin/chunk-2g2zrtjs.js +2 -0
  9. package/dist/bin/{chunk-xenj3py3.js → chunk-2mv692y4.js} +5 -5
  10. package/dist/bin/chunk-3ay4kfaw.js +1 -0
  11. package/dist/bin/{chunk-grs2cwm7.js → chunk-3n733cgx.js} +2 -2
  12. package/dist/bin/{chunk-z4rx32w4.js → chunk-48x0wc2g.js} +3 -3
  13. package/dist/bin/chunk-4cs098d1.js +1 -0
  14. package/dist/bin/{chunk-s5br13d9.js → chunk-4sa22raw.js} +60 -60
  15. package/dist/bin/chunk-52fhq35h.js +1 -0
  16. package/dist/bin/{chunk-fren71ry.js → chunk-5a7sxtwn.js} +1 -1
  17. package/dist/bin/{chunk-g8yaztb1.js → chunk-6d8chxyr.js} +3 -3
  18. package/dist/bin/{chunk-rt51mrj9.js → chunk-6kx50dyc.js} +2 -2
  19. package/dist/bin/chunk-6se7ygxa.js +1 -0
  20. package/dist/bin/chunk-72g1hr4z.js +1 -0
  21. package/dist/bin/chunk-7thhxyzy.js +1 -0
  22. package/dist/bin/{chunk-dp2fsnpe.js → chunk-8jbkphmg.js} +7 -7
  23. package/dist/bin/{chunk-g954ew3x.js → chunk-90102shh.js} +1 -1
  24. package/dist/bin/{chunk-dg918k6w.js → chunk-9vmtm7nq.js} +1 -1
  25. package/dist/bin/chunk-apnhhfkj.js +2 -0
  26. package/dist/bin/chunk-c7vxdwth.js +1 -0
  27. package/dist/bin/{chunk-kymrvq47.js → chunk-djjj62c0.js} +2 -2
  28. package/dist/bin/{chunk-znfh0mx7.js → chunk-dmdg23a5.js} +1 -1
  29. package/dist/bin/{chunk-etvcw9we.js → chunk-dyh0vndw.js} +1 -1
  30. package/dist/bin/chunk-e0c3agf2.js +1 -0
  31. package/dist/bin/{chunk-bxfnhnqd.js → chunk-e24bscb0.js} +15 -15
  32. package/dist/bin/chunk-e55fdn0r.js +92 -0
  33. package/dist/bin/{chunk-frbwzrx4.js → chunk-egn33pr9.js} +1 -1
  34. package/dist/bin/{chunk-q6cayjpr.js → chunk-ehb9mpt8.js} +112 -112
  35. package/dist/bin/chunk-gf7yavs5.js +1 -0
  36. package/dist/bin/chunk-gp5w7e4c.js +1 -0
  37. package/dist/bin/{chunk-850n63e0.js → chunk-h1rb8qvt.js} +2 -2
  38. package/dist/bin/chunk-hagakkgm.js +1 -0
  39. package/dist/bin/chunk-hr3vbg6y.js +1 -0
  40. package/dist/bin/chunk-hyb5v8wr.js +1 -0
  41. package/dist/bin/{chunk-va9y882b.js → chunk-k7wh1wr5.js} +1 -1
  42. package/dist/bin/{chunk-afzrsjmc.js → chunk-mx9ppkmn.js} +4 -4
  43. package/dist/bin/{chunk-98m9rbpk.js → chunk-mxvekmdx.js} +126 -126
  44. package/dist/bin/chunk-ndddd2ft.js +3 -0
  45. package/dist/bin/{chunk-0znhykt9.js → chunk-ngyqqy6d.js} +5 -5
  46. package/dist/bin/chunk-nqb1faqj.js +1 -0
  47. package/dist/bin/chunk-p831sptd.js +1 -0
  48. package/dist/bin/chunk-qxx1a51w.js +1 -0
  49. package/dist/bin/{chunk-6wc8a9cs.js → chunk-rbtt23vx.js} +3 -3
  50. package/dist/bin/chunk-sh248v2y.js +1 -0
  51. package/dist/bin/chunk-swfmx4f8.js +1 -0
  52. package/dist/bin/{chunk-evtcxme1.js → chunk-t10e32an.js} +7 -7
  53. package/dist/bin/{chunk-jq36fh46.js → chunk-vjkyj3xy.js} +1 -1
  54. package/dist/bin/chunk-w8k1gyzr.js +1 -0
  55. package/dist/bin/chunk-wagzxm7z.js +1 -0
  56. package/dist/bin/{chunk-36aywmsq.js → chunk-x63yz8xg.js} +1 -1
  57. package/dist/bin/chunk-xdxk6baf.js +1 -0
  58. package/dist/bin/chunk-y286zhty.js +1 -0
  59. package/dist/bin/{chunk-gn745j0p.js → chunk-ys5n5c84.js} +4 -4
  60. package/dist/bin/{chunk-94pvxv17.js → chunk-z1dtdw3j.js} +5 -5
  61. package/dist/bin/cli.js +275 -275
  62. package/dist/bin/dashboard-server.js +1 -1
  63. package/dist/chunk-07rjctzz.js +1 -0
  64. package/dist/{chunk-1ayadqry.js → chunk-2m262b2n.js} +14 -14
  65. package/dist/{chunk-nz3ygqjb.js → chunk-31tvc877.js} +1 -1
  66. package/dist/{chunk-hasa64d4.js → chunk-3m9ghthh.js} +2 -2
  67. package/dist/chunk-4j8ef0pe.js +1 -0
  68. package/dist/{chunk-4bcf62qk.js → chunk-5255nr93.js} +90 -90
  69. package/dist/{chunk-mytcpvg5.js → chunk-5far81q7.js} +2 -2
  70. package/dist/chunk-6kcmbymp.js +1 -0
  71. package/dist/{chunk-6jzg0gtw.js → chunk-7xnwa0s8.js} +4 -4
  72. package/dist/chunk-9asn5fpt.js +92 -0
  73. package/dist/{chunk-2vr8rqg8.js → chunk-9wmer0zx.js} +1 -1
  74. package/dist/{chunk-ynjfj2rt.js → chunk-bcy9z4ks.js} +162 -162
  75. package/dist/{chunk-enhddb1a.js → chunk-bxrzsth8.js} +2 -2
  76. package/dist/chunk-dak9hfrd.js +1 -0
  77. package/dist/{chunk-2ht2ve4t.js → chunk-e52me1c6.js} +1 -1
  78. package/dist/{chunk-z13hksc9.js → chunk-e8e1h2h9.js} +2 -2
  79. package/dist/{chunk-84w9n41b.js → chunk-g6g33pt9.js} +7 -7
  80. package/dist/{chunk-m1x32x81.js → chunk-hyeeqga9.js} +5 -5
  81. package/dist/{chunk-3rh4m6ag.js → chunk-k53agv2m.js} +1 -1
  82. package/dist/{chunk-nca98yaf.js → chunk-kczzc599.js} +25 -25
  83. package/dist/{chunk-f3hhmec2.js → chunk-ptq9v346.js} +1 -1
  84. package/dist/{chunk-ygrxsjcz.js → chunk-qcaqc5b8.js} +2 -2
  85. package/dist/{chunk-81yetzg2.js → chunk-r1wpwfff.js} +7 -7
  86. package/dist/{chunk-pn8bczhy.js → chunk-srrscggm.js} +5 -5
  87. package/dist/{chunk-6m18fz5f.js → chunk-v2p7c7s4.js} +325 -325
  88. package/dist/{chunk-a9pqpqrh.js → chunk-vs0qrm09.js} +1 -1
  89. package/dist/{chunk-x3xs6qvx.js → chunk-w9jhyy09.js} +4 -4
  90. package/dist/{chunk-r2v44ba2.js → chunk-z3wynefj.js} +19 -19
  91. package/dist/chunk-z4xzd43p.js +1 -0
  92. package/dist/{chunk-590gwv9d.js → chunk-zx8ecz8b.js} +4 -4
  93. package/dist/deploy/index.d.ts +1 -0
  94. package/dist/deploy/index.js +1 -1
  95. package/dist/deploy/storage-failover.d.ts +54 -0
  96. package/dist/dns/index.js +1 -1
  97. package/dist/drivers/index.js +1 -1
  98. package/dist/drivers/shared/cloudfront-origin.d.ts +9 -2
  99. package/dist/generators/infrastructure.d.ts +9 -1
  100. package/dist/index.d.ts +1 -1
  101. package/dist/index.js +48 -48
  102. package/dist/operations/index.js +1 -1
  103. package/dist/protection/index.js +1 -1
  104. package/dist/spend/index.js +1 -1
  105. package/dist/ui/404.html +1 -1
  106. package/dist/ui/accept-invitation.html +1 -1
  107. package/dist/ui/access-denied.html +1 -1
  108. package/dist/ui/account/automation.html +6 -6
  109. package/dist/ui/account/security.html +2 -2
  110. package/dist/ui/applications/compose.html +6 -6
  111. package/dist/ui/applications/new.html +1 -1
  112. package/dist/ui/data/backups.html +6 -6
  113. package/dist/ui/data/services.html +6 -6
  114. package/dist/ui/data/volumes.html +6 -6
  115. package/dist/ui/index.html +6 -6
  116. package/dist/ui/infrastructure/topology.html +6 -6
  117. package/dist/ui/integrations.html +2 -2
  118. package/dist/ui/operations/alerts.html +6 -6
  119. package/dist/ui/operations/configuration.html +6 -6
  120. package/dist/ui/operations/jobs.html +6 -6
  121. package/dist/ui/operations/maintenance.html +6 -6
  122. package/dist/ui/operations/observability.html +6 -6
  123. package/dist/ui/operations/previews.html +6 -6
  124. package/dist/ui/operations/queue.html +6 -6
  125. package/dist/ui/operations/regions.html +6 -6
  126. package/dist/ui/operations/releases.html +6 -6
  127. package/dist/ui/operations/spend.html +6 -6
  128. package/dist/ui/operations/workloads.html +6 -6
  129. package/dist/ui/security.html +2 -2
  130. package/dist/ui/server/actions.html +6 -6
  131. package/dist/ui/server/activity.html +1 -1
  132. package/dist/ui/server/capacity.html +6 -6
  133. package/dist/ui/server/database.html +6 -6
  134. package/dist/ui/server/deployments.html +6 -6
  135. package/dist/ui/server/diagnostics.html +2 -2
  136. package/dist/ui/server/firewall.html +6 -6
  137. package/dist/ui/server/fleet.html +6 -6
  138. package/dist/ui/server/logs.html +6 -6
  139. package/dist/ui/server/metrics.html +6 -6
  140. package/dist/ui/server/security.html +2 -2
  141. package/dist/ui/server/services.html +2 -2
  142. package/dist/ui/server/sites.html +5 -5
  143. package/dist/ui/server/ssh-keys.html +6 -6
  144. package/dist/ui/server/team.html +6 -6
  145. package/dist/ui/server/terminal.html +2 -2
  146. package/dist/ui/serverless/alarms.html +6 -6
  147. package/dist/ui/serverless/assets.html +2 -2
  148. package/dist/ui/serverless/cost.html +2 -2
  149. package/dist/ui/serverless/data.html +6 -6
  150. package/dist/ui/serverless/deployments.html +2 -2
  151. package/dist/ui/serverless/firewall.html +1 -1
  152. package/dist/ui/serverless/functions.html +6 -6
  153. package/dist/ui/serverless/logs.html +6 -6
  154. package/dist/ui/serverless/metrics.html +2 -2
  155. package/dist/ui/serverless/queues.html +6 -6
  156. package/dist/ui/serverless/secrets.html +6 -6
  157. package/dist/ui/serverless/traces.html +6 -6
  158. package/dist/ui/serverless.html +5 -5
  159. package/package.json +3 -3
  160. package/dist/bin/chunk-1aqrfqbz.js +0 -1
  161. package/dist/bin/chunk-1k1dyh5k.js +0 -92
  162. package/dist/bin/chunk-71rdf1sw.js +0 -1
  163. package/dist/bin/chunk-75kmf1ke.js +0 -1
  164. package/dist/bin/chunk-7q37vt87.js +0 -1
  165. package/dist/bin/chunk-8r0gvent.js +0 -1
  166. package/dist/bin/chunk-925xkkf9.js +0 -1
  167. package/dist/bin/chunk-am4recks.js +0 -1
  168. package/dist/bin/chunk-az3emrhh.js +0 -1
  169. package/dist/bin/chunk-btfh77e4.js +0 -1
  170. package/dist/bin/chunk-bxy657va.js +0 -1
  171. package/dist/bin/chunk-d5sd5xtt.js +0 -1
  172. package/dist/bin/chunk-fbhf8kh5.js +0 -1
  173. package/dist/bin/chunk-g0z3a0wx.js +0 -1
  174. package/dist/bin/chunk-hn961k5f.js +0 -3
  175. package/dist/bin/chunk-m2kr333s.js +0 -2
  176. package/dist/bin/chunk-mtbav1sg.js +0 -1
  177. package/dist/bin/chunk-pk2xwzke.js +0 -1
  178. package/dist/bin/chunk-sbhbne4d.js +0 -1
  179. package/dist/bin/chunk-sd0twb8d.js +0 -1
  180. package/dist/bin/chunk-va8pr0ch.js +0 -1
  181. package/dist/bin/chunk-vwa96q94.js +0 -1
  182. package/dist/bin/chunk-y6vnwk4e.js +0 -1
  183. package/dist/bin/chunk-y7w98fc1.js +0 -1
  184. package/dist/bin/chunk-yw65b70x.js +0 -1
  185. package/dist/bin/chunk-z65rp2mn.js +0 -1
  186. package/dist/chunk-3jrvr0pv.js +0 -1
  187. package/dist/chunk-ajwt2hzh.js +0 -1
  188. package/dist/chunk-fw9hk0xt.js +0 -92
  189. package/dist/chunk-mcxmdch0.js +0 -1
  190. package/dist/chunk-wqhhvh3k.js +0 -1
  191. package/dist/chunk-xhn2v84m.js +0 -1
@@ -1,92 +0,0 @@
1
- import{Sr,n}from"./chunk-590gwv9d.js";import{Me}from"./chunk-enhddb1a.js";import*as l from"node:crypto";import{readFileSync as D}from"node:fs";import{readdir as U}from"node:fs/promises";import{join as L}from"node:path";function kt(e){if(e){let i=R(e);if(!i)throw Error(`AWS profile '${e}' not found in ~/.aws/credentials`);return i}let t=process.env.AWS_ACCESS_KEY_ID,s=process.env.AWS_SECRET_ACCESS_KEY;if(t&&s)return{accessKeyId:t,secretAccessKey:s,sessionToken:process.env.AWS_SESSION_TOKEN};return R(process.env.AWS_PROFILE||"default")??{accessKeyId:"",secretAccessKey:""}}function R(e){let{existsSync:t,readFileSync:s}=Me("node:fs"),{homedir:i}=Me("node:os"),{join:r}=Me("node:path"),o=process.env.AWS_SHARED_CREDENTIALS_FILE||r(i(),".aws","credentials");if(!t(o))return null;let c=s(o,"utf-8"),g=null,d,u,y;for(let h of c.split(`
2
- `)){let m=h.trim();if(!m||m.startsWith("#")||m.startsWith(";"))continue;let p=m.match(/^\[([^\]]+)\]$/);if(p){if(g===e&&d&&u)return{accessKeyId:d,secretAccessKey:u,sessionToken:y};g=p[1],d=void 0,u=void 0,y=void 0;continue}if(g===e){let[b,...S]=m.split("="),f=S.join("=").trim();switch(b.trim().toLowerCase()){case"aws_access_key_id":d=f;break;case"aws_secret_access_key":u=f;break;case"aws_session_token":y=f;break}}}if(g===e&&d&&u)return{accessKeyId:d,secretAccessKey:u,sessionToken:y};return null}function B(e){let{buffer:t,byteOffset:s,byteLength:i}=e;if(t instanceof ArrayBuffer)return t.slice(s,s+i);let r=new ArrayBuffer(i);return new Uint8Array(r).set(new Uint8Array(e)),r}class a{client;region;explicitProfile;endpoint;endpointProtocol="https";forcePathStyle;explicitCredentials;constructor(e="us-east-1",t,s){let i=typeof e==="string"?s:e,r=typeof e==="string"?e:e.region??"us-east-1",o=typeof e==="string"?t:e.profile,c=i?.endpoint?Sr({region:r,path:"/",endpoint:i.endpoint}):void 0;this.region=r,this.explicitProfile=o,this.endpoint=c?.host,this.endpointProtocol=c?.protocol??"https",this.forcePathStyle=i?.forcePathStyle,this.explicitCredentials=i?.credentials,this.client=new n(i?.credentials,{profile:o,endpoint:i?.endpoint,forcePathStyle:i?.forcePathStyle})}getCredentials(){if(this.explicitCredentials?.accessKeyId&&this.explicitCredentials.secretAccessKey)return this.explicitCredentials;let e=kt(this.explicitProfile);if(e.accessKeyId&&e.secretAccessKey)return e;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(e){return this.forcePathStyle?this.s3BaseHost():`${e}.${this.s3BaseHost()}`}objectPath(e,t){return this.forcePathStyle?`/${e}/${t}`:`/${t}`}objectUrl(e,t){return`${this.endpointProtocol}://${this.s3VirtualHost(e)}${this.objectPath(e,t)}`}async listBuckets(){let e=await this.client.request({service:"s3",region:this.region,method:"GET",path:"/"}),t=[],i=(e?.ListAllMyBucketsResult??e)?.Buckets?.Bucket;if(i){let r=Array.isArray(i)?i:[i];for(let o of r)t.push({Name:o.Name,CreationDate:o.CreationDate})}return{Buckets:t}}async createBucket(e,t){let s={};if(t?.acl)s["x-amz-acl"]=t.acl;let i;if(this.region!=="us-east-1"&&!this.endpoint)i=`<?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>`,s["Content-Type"]="application/xml";await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,headers:s,body:i})}async deleteBucket(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`})}async emptyAndDeleteBucket(e){let t=!0;while(t){let s=await this.listAllObjects({bucket:e});if(s.length===0){t=!1;break}let i=s.map((r)=>r.Key);for(let r=0;r<i.length;r+=1000){let o=i.slice(r,r+1000);await this.deleteObjects(e,o)}}await this.deleteBucket(e)}async listAllObjects(e){let t=[],s;do{let i={"list-type":"2","max-keys":"1000"};if(e.prefix)i.prefix=e.prefix;if(s)i["continuation-token"]=s;let r=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e.bucket}`,queryParams:i}),o=r?.ListBucketResult??r,c=o?.Contents;if(c){let d=Array.isArray(c)?c:[c];for(let u of d)t.push({Key:u.Key,LastModified:u.LastModified||"",Size:Number.parseInt(u.Size||"0"),ETag:u.ETag})}let g=o?.IsTruncated;s=g==="true"||g===!0?o?.NextContinuationToken:void 0}while(s);return t}async list(e){let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e.bucket}`}),s=[],r=(t?.ListBucketResult??t)?.Contents;if(r){let o=Array.isArray(r)?r:[r];for(let c of o){if(e.prefix&&!c.Key?.startsWith(e.prefix))continue;if(s.push({Key:c.Key||"",LastModified:c.LastModified||"",Size:Number.parseInt(c.Size||"0"),ETag:c.ETag}),e.maxKeys&&s.length>=e.maxKeys)break}}return s}async putObject(e){let t={};if(e.acl)t["x-amz-acl"]=e.acl;if(e.cacheControl)t["Cache-Control"]=e.cacheControl;if(e.contentType)t["Content-Type"]=e.contentType;if(e.metadata)for(let[r,o]of Object.entries(e.metadata))t[`x-amz-meta-${r}`]=o;let s=e.key.split("/").map((r)=>encodeURIComponent(r)).join("/"),i=e.body instanceof Uint8Array&&!Buffer.isBuffer(e.body)?Buffer.from(e.body):e.body;if(Buffer.isBuffer(i)||i instanceof Uint8Array){let r=Buffer.isBuffer(i)?i:Buffer.from(i),{accessKeyId:o,secretAccessKey:c,sessionToken:g}=this.getCredentials(),d=this.s3VirtualHost(e.bucket),u=this.objectPath(e.bucket,s),y=this.objectUrl(e.bucket,s),h=new Date,m=h.toISOString().replace(/[:-]|\.\d{3}/g,""),p=h.toISOString().slice(0,10).replace(/-/g,""),b=l.createHash("sha256").update(r).digest("hex"),S={host:d,"x-amz-date":m,"x-amz-content-sha256":b,...t};if(g)S["x-amz-security-token"]=g;let f=Object.keys(S).sort().map((P)=>`${P.toLowerCase()}:${S[P].trim()}
6
- `).join(""),k=Object.keys(S).sort().map((P)=>P.toLowerCase()).join(";"),T=["PUT",u,"",f,k,b].join(`
7
- `),w="AWS4-HMAC-SHA256",C=`${p}/${this.region}/s3/aws4_request`,q=[w,m,C,l.createHash("sha256").update(T).digest("hex")].join(`
8
- `),j=l.createHmac("sha256",`AWS4${c}`).update(p).digest(),I=l.createHmac("sha256",j).update(this.region).digest(),H=l.createHmac("sha256",I).update("s3").digest(),E=l.createHmac("sha256",H).update("aws4_request").digest(),v=l.createHmac("sha256",E).update(q).digest("hex"),A=`${w} Credential=${o}/${C}, SignedHeaders=${k}, Signature=${v}`,x=await fetch(y,{method:"PUT",headers:{...S,Authorization:A},body:B(r)});if(!x.ok){let P=await x.text();throw Error(`S3 PUT failed: ${x.status} ${P}`)}return}await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${s}`,bucket:e.bucket,headers:t,body:e.body})}async getObject(e,t){let s=t.split("/").map((r)=>encodeURIComponent(r)).join("/");return await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${s}`,bucket:e,rawResponse:!0})}async getObjectBytes(e,t){let{accessKeyId:s,secretAccessKey:i,sessionToken:r}=this.getCredentials(),o=this.s3VirtualHost(e),c=t.split("/").map((P)=>encodeURIComponent(P)).join("/"),g=this.objectPath(e,c),d=this.objectUrl(e,c),u=new Date,y=u.toISOString().replace(/[:-]|\.\d{3}/g,""),h=u.toISOString().slice(0,10).replace(/-/g,""),m=l.createHash("sha256").update("").digest("hex"),p={host:o,"x-amz-date":y,"x-amz-content-sha256":m};if(r)p["x-amz-security-token"]=r;let b=Object.keys(p).sort().map((P)=>`${P.toLowerCase()}:${p[P].trim()}
9
- `).join(""),S=Object.keys(p).sort().map((P)=>P.toLowerCase()).join(";"),f=["GET",g,"",b,S,m].join(`
10
- `),k="AWS4-HMAC-SHA256",T=`${h}/${this.region}/s3/aws4_request`,w=[k,y,T,l.createHash("sha256").update(f).digest("hex")].join(`
11
- `),C=l.createHmac("sha256",`AWS4${i}`).update(h).digest(),q=l.createHmac("sha256",C).update(this.region).digest(),j=l.createHmac("sha256",q).update("s3").digest(),I=l.createHmac("sha256",j).update("aws4_request").digest(),H=l.createHmac("sha256",I).update(w).digest("hex"),E=`${k} Credential=${s}/${T}, SignedHeaders=${S}, Signature=${H}`,v=await fetch(d,{method:"GET",headers:{...p,Authorization:E}});if(!v.ok){let P=await v.text();throw Error(`S3 GET failed: ${v.status} ${P}`)}let A=await v.arrayBuffer(),x=v.headers.get("content-length");return{body:new Uint8Array(A),contentType:v.headers.get("content-type")??void 0,contentLength:x?Number.parseInt(x,10):void 0}}async copyObject(e){let t={"x-amz-copy-source":`/${e.sourceBucket}/${e.sourceKey}`};if(e.metadataDirective)t["x-amz-metadata-directive"]=e.metadataDirective;if(e.contentType)t["Content-Type"]=e.contentType;if(e.metadata)for(let[s,i]of Object.entries(e.metadata))t[`x-amz-meta-${s}`]=i;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e.destinationBucket}/${e.destinationKey}`,headers:t})}async deleteObject(e,t){let s=t.split("/").map((i)=>encodeURIComponent(i)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${s}`,bucket:e})}async deleteObjects(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
12
- <Delete>
13
- ${t.map((r)=>`<Object><Key>${r}</Key></Object>`).join(`
14
- `)}
15
- </Delete>`,i=l.createHash("md5").update(s).digest("base64");await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${e}`,queryParams:{delete:""},body:s,headers:{"Content-Type":"application/xml","Content-MD5":i}})}async bucketExists(e){try{return await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${e}`}),!0}catch{return!1}}async copy(e){let t=D(e.source);await this.putObject({bucket:e.bucket,key:e.key,body:t,acl:e.acl,cacheControl:e.cacheControl,contentType:e.contentType,metadata:e.metadata})}async sync(e){let t=await this.listFilesRecursive(e.source);for(let s of t){if(e.exclude&&e.exclude.some((o)=>s.includes(o)))continue;if(e.include&&!e.include.some((o)=>s.includes(o)))continue;let i=s.substring(e.source.length+1),r=e.prefix?`${e.prefix}/${i}`:i;if(!e.dryRun){let o=D(s);await this.putObject({bucket:e.bucket,key:r,body:o,acl:e.acl,cacheControl:e.cacheControl,contentType:e.contentType,metadata:e.metadata})}}}async delete(e,t){await this.deleteObject(e,t)}async deletePrefix(e,t){let i=(await this.list({bucket:e,prefix:t})).map((r)=>r.Key);if(i.length>0)await this.deleteObjects(e,i)}async getBucketSize(e,t){return(await this.list({bucket:e,prefix:t})).reduce((i,r)=>i+r.Size,0)}async listFilesRecursive(e){let t=[],s=await U(e,{withFileTypes:!0});for(let i of s){let r=L(e,i.name);if(i.isDirectory()){let o=await this.listFilesRecursive(r);t.push(...o)}else t.push(r)}return t}async putBucketPolicy(e,t){let{accessKeyId:s,secretAccessKey:i,sessionToken:r}=this.getCredentials(),o=this.s3BaseHost(),c=typeof t==="string"?t:JSON.stringify(t),g=new Date,d=g.toISOString().replace(/[:-]|\.\d{3}/g,""),u=g.toISOString().slice(0,10).replace(/-/g,""),y=l.createHash("sha256").update(c).digest("hex"),h="/"+e,m="policy=",p={host:o,"x-amz-date":d,"x-amz-content-sha256":y,"content-type":"application/json"};if(r)p["x-amz-security-token"]=r;let b=Object.keys(p).sort().map((x)=>`${x.toLowerCase()}:${p[x].trim()}
16
- `).join(""),S=Object.keys(p).sort().map((x)=>x.toLowerCase()).join(";"),f=["PUT",h,"policy=",b,S,y].join(`
17
- `),k="AWS4-HMAC-SHA256",T=`${u}/${this.region}/s3/aws4_request`,w=[k,d,T,l.createHash("sha256").update(f).digest("hex")].join(`
18
- `),C=l.createHmac("sha256","AWS4"+i).update(u).digest(),q=l.createHmac("sha256",C).update(this.region).digest(),j=l.createHmac("sha256",q).update("s3").digest(),I=l.createHmac("sha256",j).update("aws4_request").digest(),H=l.createHmac("sha256",I).update(w).digest("hex"),E=`${k} Credential=${s}/${T}, SignedHeaders=${S}, Signature=${H}`,v=`${this.endpointProtocol}://${o}${h}?policy=`,A=await fetch(v,{method:"PUT",headers:{...p,Authorization:E},body:c});if(!A.ok){let x=await A.text();throw Error(`Failed to put bucket policy: ${A.status} ${x}`)}}async getBucketPolicy(e){let{accessKeyId:t,secretAccessKey:s,sessionToken:i}=this.getCredentials(),r=this.s3BaseHost(),o=new Date,c=o.toISOString().replace(/[:-]|\.\d{3}/g,""),g=o.toISOString().slice(0,10).replace(/-/g,""),d=l.createHash("sha256").update("").digest("hex"),u="/"+e,y="policy=",h={host:r,"x-amz-date":c,"x-amz-content-sha256":d};if(i)h["x-amz-security-token"]=i;let m=Object.keys(h).sort().map((A)=>`${A.toLowerCase()}:${h[A].trim()}
19
- `).join(""),p=Object.keys(h).sort().map((A)=>A.toLowerCase()).join(";"),b=["GET",u,"policy=",m,p,d].join(`
20
- `),S="AWS4-HMAC-SHA256",f=`${g}/${this.region}/s3/aws4_request`,k=[S,c,f,l.createHash("sha256").update(b).digest("hex")].join(`
21
- `),T=l.createHmac("sha256","AWS4"+s).update(g).digest(),w=l.createHmac("sha256",T).update(this.region).digest(),C=l.createHmac("sha256",w).update("s3").digest(),q=l.createHmac("sha256",C).update("aws4_request").digest(),j=l.createHmac("sha256",q).update(k).digest("hex"),I=`${S} Credential=${t}/${f}, SignedHeaders=${p}, Signature=${j}`,H=`${this.endpointProtocol}://${r}${u}?policy=`,E=await fetch(H,{method:"GET",headers:{...h,Authorization:I}});if(E.status===404)return null;if(!E.ok){let A=await E.text();throw Error(`Failed to get bucket policy: ${E.status} ${A}`)}let v=await E.text();return JSON.parse(v)}async deleteBucketPolicy(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{policy:""}})}async headBucket(e){try{return{exists:!0,region:(await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${e}`,returnHeaders:!0}))?.headers?.["x-amz-bucket-region"]}}catch(t){if(t.statusCode===404)return{exists:!1};throw t}}async headObject(e,t){try{let s=await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${e}/${t}`,returnHeaders:!0});return{ContentLength:s?.headers?.["content-length"]?parseInt(s.headers["content-length"]):void 0,ContentType:s?.headers?.["content-type"],ETag:s?.headers?.etag,LastModified:s?.headers?.["last-modified"]}}catch(s){if(s.statusCode===404)return null;throw s}}async getObjectBuffer(e,t){let s=await this.getObject(e,t);return Buffer.from(s)}async getObjectJson(e,t){let s=await this.getObject(e,t);return JSON.parse(s)}async putObjectJson(e,t,s,i){await this.putObject({bucket:e,key:t,body:JSON.stringify(s),contentType:"application/json",...i})}async getBucketVersioning(e){return{Status:(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{versioning:""}}))?.VersioningConfiguration?.Status}}async putBucketVersioning(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
22
- <VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
23
- <Status>${t}</Status>
24
- </VersioningConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{versioning:""},headers:{"Content-Type":"application/xml"},body:s})}async getBucketLifecycleConfiguration(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{lifecycle:""}}))?.LifecycleConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketLifecycleConfiguration(e,t){let i=`<?xml version="1.0" encoding="UTF-8"?>
25
- <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
26
- ${t.map((r)=>{let o=`<Rule><ID>${r.ID}</ID><Status>${r.Status}</Status>`;if(r.Filter)o+=`<Filter><Prefix>${r.Filter.Prefix||""}</Prefix></Filter>`;else o+="<Filter><Prefix></Prefix></Filter>";if(r.Expiration){if(r.Expiration.Days)o+=`<Expiration><Days>${r.Expiration.Days}</Days></Expiration>`;else if(r.Expiration.Date)o+=`<Expiration><Date>${r.Expiration.Date}</Date></Expiration>`}if(r.Transitions)for(let c of r.Transitions)o+=`<Transition><Days>${c.Days}</Days><StorageClass>${c.StorageClass}</StorageClass></Transition>`;if(r.NoncurrentVersionExpiration)o+=`<NoncurrentVersionExpiration><NoncurrentDays>${r.NoncurrentVersionExpiration.NoncurrentDays}</NoncurrentDays></NoncurrentVersionExpiration>`;return o+="</Rule>",o}).join("")}
27
- </LifecycleConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{lifecycle:""},headers:{"Content-Type":"application/xml"},body:i})}async deleteBucketLifecycleConfiguration(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{lifecycle:""}})}async getBucketCors(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{cors:""}}))?.CORSConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketCors(e,t){let i=`<?xml version="1.0" encoding="UTF-8"?>
28
- <CORSConfiguration>
29
- ${t.map((r)=>{let o="<CORSRule>";for(let c of r.AllowedOrigins)o+=`<AllowedOrigin>${c}</AllowedOrigin>`;for(let c of r.AllowedMethods)o+=`<AllowedMethod>${c}</AllowedMethod>`;if(r.AllowedHeaders)for(let c of r.AllowedHeaders)o+=`<AllowedHeader>${c}</AllowedHeader>`;if(r.ExposeHeaders)for(let c of r.ExposeHeaders)o+=`<ExposeHeader>${c}</ExposeHeader>`;if(r.MaxAgeSeconds)o+=`<MaxAgeSeconds>${r.MaxAgeSeconds}</MaxAgeSeconds>`;return o+="</CORSRule>",o}).join("")}
30
- </CORSConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{cors:""},headers:{"Content-Type":"application/xml"},body:i})}async deleteBucketCors(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{cors:""}})}async getBucketEncryption(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{encryption:""}}))?.ServerSideEncryptionConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketEncryption(e,t,s){let i=`<ApplyServerSideEncryptionByDefault><SSEAlgorithm>${t}</SSEAlgorithm>`;if(s)i+=`<KMSMasterKeyID>${s}</KMSMasterKeyID>`;i+="</ApplyServerSideEncryptionByDefault>";let r=`<?xml version="1.0" encoding="UTF-8"?>
31
- <ServerSideEncryptionConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
32
- <Rule>${i}</Rule>
33
- </ServerSideEncryptionConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{encryption:""},headers:{"Content-Type":"application/xml"},body:r})}async deleteBucketEncryption(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{encryption:""}})}async getBucketTagging(e){try{let s=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!s)return[];return Array.isArray(s)?s:[s]}catch(t){if(t.statusCode===404)return[];throw t}}async putBucketTagging(e,t){let i=`<?xml version="1.0" encoding="UTF-8"?>
34
- <Tagging>
35
- <TagSet>${t.map((r)=>`<Tag><Key>${r.Key}</Key><Value>${r.Value}</Value></Tag>`).join("")}</TagSet>
36
- </Tagging>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{tagging:""},headers:{"Content-Type":"application/xml"},body:i})}async deleteBucketTagging(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{tagging:""}})}async getObjectTagging(e,t){try{let i=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}/${t}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!i)return[];return Array.isArray(i)?i:[i]}catch(s){if(s.statusCode===404)return[];throw s}}async putObjectTagging(e,t,s){let r=`<?xml version="1.0" encoding="UTF-8"?>
37
- <Tagging>
38
- <TagSet>${s.map((o)=>`<Tag><Key>${o.Key}</Key><Value>${o.Value}</Value></Tag>`).join("")}</TagSet>
39
- </Tagging>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}/${t}`,queryParams:{tagging:""},headers:{"Content-Type":"application/xml"},body:r})}async deleteObjectTagging(e,t){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}/${t}`,queryParams:{tagging:""}})}async getBucketAcl(e){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{acl:""}}))?.AccessControlPolicy}async putBucketAcl(e,t){await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{acl:""},headers:{"x-amz-acl":t}})}async getObjectAcl(e,t){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}/${t}`,queryParams:{acl:""}}))?.AccessControlPolicy}async putObjectAcl(e,t,s){await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}/${t}`,queryParams:{acl:""},headers:{"x-amz-acl":s}})}async getBucketLocation(e){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{location:""}}))?.LocationConstraint||"us-east-1"}async getBucketLogging(e){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{logging:""}}))?.BucketLoggingStatus}async putBucketLogging(e,t,s){let i=`<?xml version="1.0" encoding="UTF-8"?>
40
- <BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
41
- <LoggingEnabled>
42
- <TargetBucket>${t}</TargetBucket>
43
- <TargetPrefix>${s}</TargetPrefix>
44
- </LoggingEnabled>
45
- </BucketLoggingStatus>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{logging:""},headers:{"Content-Type":"application/xml"},body:i})}async getBucketNotificationConfiguration(e){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{notification:""}}))?.NotificationConfiguration}async putBucketNotificationConfiguration(e,t){let s="";if(t.LambdaFunctionConfigurations)for(let r of t.LambdaFunctionConfigurations){if(s+="<CloudFunctionConfiguration>",r.Id)s+=`<Id>${r.Id}</Id>`;s+=`<CloudFunction>${r.LambdaFunctionArn}</CloudFunction>`;for(let o of r.Events)s+=`<Event>${o}</Event>`;if(r.Filter?.Key?.FilterRules){s+="<Filter><S3Key>";for(let o of r.Filter.Key.FilterRules)s+=`<FilterRule><Name>${o.Name}</Name><Value>${o.Value}</Value></FilterRule>`;s+="</S3Key></Filter>"}s+="</CloudFunctionConfiguration>"}if(t.TopicConfigurations)for(let r of t.TopicConfigurations){if(s+="<TopicConfiguration>",r.Id)s+=`<Id>${r.Id}</Id>`;s+=`<Topic>${r.TopicArn}</Topic>`;for(let o of r.Events)s+=`<Event>${o}</Event>`;s+="</TopicConfiguration>"}if(t.QueueConfigurations)for(let r of t.QueueConfigurations){if(s+="<QueueConfiguration>",r.Id)s+=`<Id>${r.Id}</Id>`;s+=`<Queue>${r.QueueArn}</Queue>`;for(let o of r.Events)s+=`<Event>${o}</Event>`;s+="</QueueConfiguration>"}let i=`<?xml version="1.0" encoding="UTF-8"?>
46
- <NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
47
- ${s}
48
- </NotificationConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{notification:""},headers:{"Content-Type":"application/xml"},body:i})}async getBucketWebsite(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{website:""}}))?.WebsiteConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketWebsite(e,t){let s="";if(t.RedirectAllRequestsTo)s=`<RedirectAllRequestsTo>
49
- <HostName>${t.RedirectAllRequestsTo.HostName}</HostName>
50
- ${t.RedirectAllRequestsTo.Protocol?`<Protocol>${t.RedirectAllRequestsTo.Protocol}</Protocol>`:""}
51
- </RedirectAllRequestsTo>`;else if(s=`<IndexDocument><Suffix>${t.IndexDocument}</Suffix></IndexDocument>`,t.ErrorDocument)s+=`<ErrorDocument><Key>${t.ErrorDocument}</Key></ErrorDocument>`;let i=`<?xml version="1.0" encoding="UTF-8"?>
52
- <WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
53
- ${s}
54
- </WebsiteConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{website:""},headers:{"Content-Type":"application/xml"},body:i})}async deleteBucketWebsite(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{website:""}})}async getBucketReplication(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{replication:""}}))?.ReplicationConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async deleteBucketReplication(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{replication:""}})}async getPublicAccessBlock(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{publicAccessBlock:""}}))?.PublicAccessBlockConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putPublicAccessBlock(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
55
- <PublicAccessBlockConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
56
- <BlockPublicAcls>${t.BlockPublicAcls??!0}</BlockPublicAcls>
57
- <IgnorePublicAcls>${t.IgnorePublicAcls??!0}</IgnorePublicAcls>
58
- <BlockPublicPolicy>${t.BlockPublicPolicy??!0}</BlockPublicPolicy>
59
- <RestrictPublicBuckets>${t.RestrictPublicBuckets??!0}</RestrictPublicBuckets>
60
- </PublicAccessBlockConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{publicAccessBlock:""},headers:{"Content-Type":"application/xml"},body:s})}async deletePublicAccessBlock(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{publicAccessBlock:""}})}generatePresignedGetUrl(e,t,s=3600){let{accessKeyId:i,secretAccessKey:r}=this.getCredentials(),o=this.s3VirtualHost(e),c=new Date,g=c.toISOString().replace(/[:-]|\.\d{3}/g,""),d=c.toISOString().slice(0,10).replace(/-/g,""),u=`${d}/${this.region}/s3/aws4_request`,y=`${i}/${u}`,h=t.split("/").map((C)=>encodeURIComponent(C)).join("/"),m=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":y,"X-Amz-Date":g,"X-Amz-Expires":s.toString(),"X-Amz-SignedHeaders":"host"}),p=["GET",this.objectPath(e,h),m.toString(),`host:${o}
61
- `,"host","UNSIGNED-PAYLOAD"].join(`
62
- `),b=["AWS4-HMAC-SHA256",g,u,l.createHash("sha256").update(p).digest("hex")].join(`
63
- `),S=l.createHmac("sha256",`AWS4${r}`).update(d).digest(),f=l.createHmac("sha256",S).update(this.region).digest(),k=l.createHmac("sha256",f).update("s3").digest(),T=l.createHmac("sha256",k).update("aws4_request").digest(),w=l.createHmac("sha256",T).update(b).digest("hex");return m.append("X-Amz-Signature",w),`${this.endpointProtocol}://${o}${this.objectPath(e,h)}?${m.toString()}`}generatePresignedPutUrl(e,t,s,i=3600){let{accessKeyId:r,secretAccessKey:o}=this.getCredentials(),c=this.s3VirtualHost(e),g=new Date,d=g.toISOString().replace(/[:-]|\.\d{3}/g,""),u=g.toISOString().slice(0,10).replace(/-/g,""),y=`${u}/${this.region}/s3/aws4_request`,h=`${r}/${y}`,m=t.split("/").map((q)=>encodeURIComponent(q)).join("/"),p=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":h,"X-Amz-Date":d,"X-Amz-Expires":i.toString(),"X-Amz-SignedHeaders":"content-type;host"}),b=["PUT",this.objectPath(e,m),p.toString(),`content-type:${s}
64
- host:${c}
65
- `,"content-type;host","UNSIGNED-PAYLOAD"].join(`
66
- `),S=["AWS4-HMAC-SHA256",d,y,l.createHash("sha256").update(b).digest("hex")].join(`
67
- `),f=l.createHmac("sha256",`AWS4${o}`).update(u).digest(),k=l.createHmac("sha256",f).update(this.region).digest(),T=l.createHmac("sha256",k).update("s3").digest(),w=l.createHmac("sha256",T).update("aws4_request").digest(),C=l.createHmac("sha256",w).update(S).digest("hex");return p.append("X-Amz-Signature",C),`${this.endpointProtocol}://${c}${this.objectPath(e,m)}?${p.toString()}`}async createMultipartUpload(e,t,s){let i={};if(s?.contentType)i["Content-Type"]=s.contentType;if(s?.metadata)for(let[g,d]of Object.entries(s.metadata))i[`x-amz-meta-${g}`]=d;let r=t.split("/").map((g)=>encodeURIComponent(g)).join("/"),o=await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${r}`,bucket:e,queryParams:{uploads:""},headers:i});return{UploadId:(o?.InitiateMultipartUploadResult??o)?.UploadId}}async uploadPart(e,t,s,i,r){let{accessKeyId:o,secretAccessKey:c,sessionToken:g}=this.getCredentials(),d=this.s3VirtualHost(e),u=t.split("/").map((K)=>encodeURIComponent(K)).join("/"),y=this.objectPath(e,u),h=`${this.objectUrl(e,u)}?partNumber=${i}&uploadId=${encodeURIComponent(s)}`,m=new Date,p=m.toISOString().replace(/[:-]|\.\d{3}/g,""),b=m.toISOString().slice(0,10).replace(/-/g,""),S=l.createHash("sha256").update(r).digest("hex"),f={host:d,"x-amz-date":p,"x-amz-content-sha256":S};if(g)f["x-amz-security-token"]=g;let k=Object.keys(f).sort().map((K)=>`${K.toLowerCase()}:${f[K].trim()}
68
- `).join(""),T=Object.keys(f).sort().map((K)=>K.toLowerCase()).join(";"),w=["PUT",y,`partNumber=${i}&uploadId=${encodeURIComponent(s)}`,k,T,S].join(`
69
- `),C="AWS4-HMAC-SHA256",q=`${b}/${this.region}/s3/aws4_request`,j=[C,p,q,l.createHash("sha256").update(w).digest("hex")].join(`
70
- `),I=l.createHmac("sha256",`AWS4${c}`).update(b).digest(),H=l.createHmac("sha256",I).update(this.region).digest(),E=l.createHmac("sha256",H).update("s3").digest(),v=l.createHmac("sha256",E).update("aws4_request").digest(),A=l.createHmac("sha256",v).update(j).digest("hex"),x=`${C} Credential=${o}/${q}, SignedHeaders=${T}, Signature=${A}`,P=await fetch(h,{method:"PUT",headers:{...f,Authorization:x},body:B(r)});if(!P.ok){let K=await P.text();throw Error(`Upload part failed: ${P.status} ${K}`)}return{ETag:P.headers.get("etag")||""}}async completeMultipartUpload(e,t,s,i){let r=t.split("/").map((g)=>encodeURIComponent(g)).join("/"),c=`<?xml version="1.0" encoding="UTF-8"?>
71
- <CompleteMultipartUpload>${i.sort((g,d)=>g.PartNumber-d.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:`/${r}`,bucket:e,queryParams:{uploadId:s},headers:{"Content-Type":"application/xml"},body:c})}async abortMultipartUpload(e,t,s){let i=t.split("/").map((r)=>encodeURIComponent(r)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${i}`,bucket:e,queryParams:{uploadId:s}})}async listMultipartUploads(e){let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:"/",bucket:e,queryParams:{uploads:""}}),s=(t?.ListMultipartUploadsResult??t)?.Upload;if(!s)return[];return(Array.isArray(s)?s:[s]).map((r)=>({Key:r.Key,UploadId:r.UploadId,Initiated:r.Initiated}))}async restoreObject(e,t,s,i="Standard"){let r=`<?xml version="1.0" encoding="UTF-8"?>
72
- <RestoreRequest>
73
- <Days>${s}</Days>
74
- <GlacierJobParameters>
75
- <Tier>${i}</Tier>
76
- </GlacierJobParameters>
77
- </RestoreRequest>`;await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${e}/${t}`,queryParams:{restore:""},headers:{"Content-Type":"application/xml"},body:r})}async selectObjectContent(e,t,s,i,r="JSON"){let o="";if(i==="CSV")o="<CSV><FileHeaderInfo>USE</FileHeaderInfo></CSV>";else if(i==="JSON")o="<JSON><Type>DOCUMENT</Type></JSON>";else o="<Parquet/>";let c="";if(r==="CSV")c="<CSV/>";else c="<JSON/>";let g=`<?xml version="1.0" encoding="UTF-8"?>
78
- <SelectObjectContentRequest>
79
- <Expression>${s}</Expression>
80
- <ExpressionType>SQL</ExpressionType>
81
- <InputSerialization>${o}</InputSerialization>
82
- <OutputSerialization>${c}</OutputSerialization>
83
- </SelectObjectContentRequest>`;return await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${e}/${t}`,queryParams:{select:"","select-type":"2"},headers:{"Content-Type":"application/xml"},body:g,rawResponse:!0})}async getSignedUrl(e){let{bucket:t,key:s,expiresIn:i=3600,operation:r="getObject"}=e,{accessKeyId:o,secretAccessKey:c,sessionToken:g}=this.getCredentials(),d=new Date,u=d.toISOString().replace(/[:-]|\.\d{3}/g,""),y=d.toISOString().slice(0,10).replace(/-/g,""),h=this.s3VirtualHost(t),m=r==="putObject"?"PUT":"GET",p="AWS4-HMAC-SHA256",b=`${y}/${this.region}/s3/aws4_request`,f={"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":`${o}/${b}`,"X-Amz-Date":u,"X-Amz-Expires":i.toString(),"X-Amz-SignedHeaders":"host"};if(g)f["X-Amz-Security-Token"]=g;let T=Object.keys(f).sort().map((O)=>`${encodeURIComponent(O)}=${encodeURIComponent(f[O])}`).join("&"),w=s.split("/").map((O)=>encodeURIComponent(O)).join("/"),C=this.objectPath(t,w),q=`host:${h}
84
- `,H=[m,C,T,q,"host","UNSIGNED-PAYLOAD"].join(`
85
- `),E=["AWS4-HMAC-SHA256",u,b,l.createHash("sha256").update(H).digest("hex")].join(`
86
- `),v=l.createHmac("sha256",`AWS4${c}`).update(y).digest(),A=l.createHmac("sha256",v).update(this.region).digest(),x=l.createHmac("sha256",A).update("s3").digest(),P=l.createHmac("sha256",x).update("aws4_request").digest(),K=l.createHmac("sha256",P).update(E).digest("hex");return`${this.endpointProtocol}://${h}${C}?${T}&X-Amz-Signature=${K}`}async listObjects(e){let{bucket:t,prefix:s,maxKeys:i=1000,continuationToken:r}=e,o={"list-type":"2","max-keys":i.toString()};if(s)o.prefix=s;if(r)o["continuation-token"]=r;let c=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${t}`,queryParams:o}),g=[],d=c?.ListBucketResult??c;if(d?.Contents){let u=Array.isArray(d.Contents)?d.Contents:[d.Contents];for(let y of u)g.push({Key:y.Key||"",LastModified:y.LastModified||"",Size:Number.parseInt(y.Size||"0"),ETag:y.ETag})}return{objects:g,nextContinuationToken:d?.NextContinuationToken}}async emptyBucket(e){let t=0,s=await this.listAllObjects({bucket:e});if(s.length>0)for(let i=0;i<s.length;i+=1000){let o=s.slice(i,i+1000).map((c)=>c.Key);await this.deleteObjects(e,o),t+=o.length}try{let i,r;do{let o=await this.listObjectVersions({bucket:e,keyMarker:i,versionIdMarker:r,maxKeys:1000}),c=[];if(o.versions)for(let g of o.versions)c.push({Key:g.Key,VersionId:g.VersionId});if(o.deleteMarkers)for(let g of o.deleteMarkers)c.push({Key:g.Key,VersionId:g.VersionId});if(c.length>0)await this.deleteObjectVersions(e,c),t+=c.length;i=o.nextKeyMarker,r=o.nextVersionIdMarker}while(i)}catch{}return{deletedCount:t}}async listObjectVersions(e){let{bucket:t,prefix:s,keyMarker:i,versionIdMarker:r,maxKeys:o=1000}=e,c={versions:"","max-keys":o.toString()};if(s)c.prefix=s;if(i)c["key-marker"]=i;if(r)c["version-id-marker"]=r;let g=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${t}`,queryParams:c}),d=[],u=[];if(g.Version){let y=Array.isArray(g.Version)?g.Version:[g.Version];for(let h of y)d.push({Key:h.Key,VersionId:h.VersionId,IsLatest:h.IsLatest==="true"})}if(g.DeleteMarker){let y=Array.isArray(g.DeleteMarker)?g.DeleteMarker:[g.DeleteMarker];for(let h of y)u.push({Key:h.Key,VersionId:h.VersionId,IsLatest:h.IsLatest==="true"})}return{versions:d,deleteMarkers:u,nextKeyMarker:g.NextKeyMarker,nextVersionIdMarker:g.NextVersionIdMarker}}async deleteObjectVersions(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
87
- <Delete>
88
- <Quiet>true</Quiet>
89
- ${t.map((r)=>`<Object><Key>${r.Key}</Key>${r.VersionId?`<VersionId>${r.VersionId}</VersionId>`:""}</Object>`).join(`
90
- `)}
91
- </Delete>`,i=l.createHash("md5").update(s).digest("base64");await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${e}`,queryParams:{delete:""},body:s,headers:{"Content-Type":"application/xml","Content-MD5":i}})}}
92
- export{kt,a};
@@ -1 +0,0 @@
1
- import{Ba}from"./chunk-6jzg0gtw.js";import"./chunk-mytcpvg5.js";import"./chunk-590gwv9d.js";import"./chunk-6m18fz5f.js";export{Ba as buildAndPushServerlessImage};
@@ -1 +0,0 @@
1
- import{Sr,n,l,Bh}from"./chunk-590gwv9d.js";export{n as AWSClient,l as buildQueryParams,Bh as detectCredentialSource,Sr as resolveS3Endpoint};
@@ -1 +0,0 @@
1
- import{An,uh}from"./chunk-81yetzg2.js";import"./chunk-2vr8rqg8.js";import"./chunk-fw9hk0xt.js";import"./chunk-590gwv9d.js";export{An as EmailClient,uh as email};