@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.
- package/dist/aws/index.js +1 -1
- package/dist/bin/chunk-0djsffn6.js +1 -0
- package/dist/bin/chunk-0t3sev1j.js +1 -0
- package/dist/bin/chunk-0y89hs67.js +6 -0
- package/dist/bin/chunk-21gggxvf.js +2 -0
- package/dist/bin/chunk-26cj89s6.js +1 -0
- package/dist/bin/chunk-35xstvnq.js +1 -0
- package/dist/bin/chunk-41yqpdv7.js +2 -0
- package/dist/bin/chunk-4a85nk2q.js +92 -0
- package/dist/bin/{chunk-rxcvf10f.js → chunk-4a97kbk1.js} +129 -129
- package/dist/bin/chunk-4kbhbfq8.js +34 -0
- package/dist/bin/chunk-4vdv41nh.js +70 -0
- package/dist/bin/chunk-67jsyn0g.js +111 -0
- package/dist/bin/chunk-6tct7e89.js +1 -0
- package/dist/bin/chunk-6vjrts39.js +1 -0
- package/dist/bin/chunk-7v5ff3vc.js +1 -0
- package/dist/bin/chunk-80nra92y.js +1 -0
- package/dist/bin/chunk-9mydnqr6.js +2 -0
- package/dist/bin/chunk-9rsn48qg.js +3 -0
- package/dist/bin/chunk-a2t1e5yb.js +1 -0
- package/dist/bin/chunk-akbfefwq.js +1 -0
- package/dist/bin/chunk-b704nznp.js +1 -0
- package/dist/bin/chunk-c1j9v7ee.js +2 -0
- package/dist/bin/chunk-cjz36ths.js +1 -0
- package/dist/bin/chunk-cxd5cevb.js +2 -0
- package/dist/bin/chunk-dbv8w56s.js +50 -0
- package/dist/bin/chunk-dxchg0g1.js +1 -0
- package/dist/bin/{chunk-tx0tqq2k.js → chunk-e1bfd1yv.js} +6 -6
- package/dist/bin/chunk-fpcghdr3.js +585 -0
- package/dist/bin/chunk-ftse39wf.js +9 -0
- package/dist/bin/chunk-g0ewbkbq.js +1 -0
- package/dist/bin/chunk-gskbezam.js +141 -0
- package/dist/bin/chunk-gvs85t2j.js +1 -0
- package/dist/bin/chunk-hej39dwr.js +2 -0
- package/dist/bin/chunk-jce28gnz.js +2 -0
- package/dist/bin/chunk-kbtrr0c3.js +1 -0
- package/dist/bin/chunk-khrye4x9.js +1 -0
- package/dist/bin/{chunk-mh0kdzqp.js → chunk-ks4ewy1s.js} +1 -1
- package/dist/bin/chunk-mbnwt3r5.js +2 -0
- package/dist/bin/chunk-md2k3n21.js +37 -0
- package/dist/bin/chunk-memfxrcn.js +1 -0
- package/dist/bin/chunk-mwgxyc0z.js +44 -0
- package/dist/bin/chunk-neampxq1.js +4 -0
- package/dist/bin/chunk-nkpf91d3.js +1 -0
- package/dist/bin/chunk-nmkm1f68.js +2 -0
- package/dist/bin/chunk-nyc2jxd8.js +2 -0
- package/dist/bin/chunk-pqr8jqnd.js +1 -0
- package/dist/bin/chunk-q182t9ba.js +3 -0
- package/dist/bin/chunk-r6x7beew.js +60 -0
- package/dist/bin/chunk-rfqk5xym.js +1 -0
- package/dist/bin/{chunk-etrb03mt.js → chunk-ww770qpn.js} +30 -30
- package/dist/bin/chunk-wy20ztb6.js +1 -0
- package/dist/bin/chunk-wzepfqf4.js +512 -0
- package/dist/bin/chunk-xcqmwphz.js +1 -0
- package/dist/bin/chunk-xev7qr2h.js +3 -0
- package/dist/bin/chunk-y3rm37z1.js +6 -0
- package/dist/bin/chunk-zejwh9cy.js +6 -0
- package/dist/bin/chunk-zwwnt4x1.js +1 -0
- package/dist/bin/cli.js +431 -418
- package/dist/bin/dashboard-server.js +1 -1
- package/dist/{chunk-dskvqt67.js → chunk-0hj552t7.js} +127 -127
- package/dist/chunk-1ypkh8g6.js +5 -0
- package/dist/chunk-2m09t0c0.js +60 -0
- package/dist/chunk-7fkyfh65.js +1 -0
- package/dist/chunk-7xpxzbkr.js +442 -0
- package/dist/chunk-8e0az001.js +2 -0
- package/dist/chunk-b10cbk8z.js +44 -0
- package/dist/chunk-gk58959n.js +6 -0
- package/dist/chunk-h1rc94df.js +114 -0
- package/dist/chunk-hbhxk5a0.js +4 -0
- package/dist/chunk-hz7k9ymh.js +1 -0
- package/dist/chunk-kj7gzdj6.js +1 -0
- package/dist/chunk-ky5c6t5y.js +2 -0
- package/dist/chunk-mch30cyc.js +1 -0
- package/dist/chunk-n04a3bgf.js +1 -0
- package/dist/chunk-nnqxmh7f.js +34 -0
- package/dist/chunk-p6vszgc2.js +92 -0
- package/dist/chunk-q2njk4hx.js +141 -0
- package/dist/chunk-qjk1v1gs.js +50 -0
- package/dist/chunk-qtp90j44.js +2 -0
- package/dist/chunk-r5natbed.js +37 -0
- package/dist/chunk-rcxq9aaa.js +704 -0
- package/dist/{chunk-gahsdmxf.js → chunk-s3rpd72x.js} +52 -52
- package/dist/{chunk-xt3s24vr.js → chunk-spx89gaw.js} +1 -1
- package/dist/chunk-t0kh8haz.js +2 -0
- package/dist/chunk-vz95qy3n.js +1 -0
- package/dist/deploy/attach-credentials.d.ts +4 -8
- package/dist/deploy/index.js +1 -1
- package/dist/dns/cloudflare.d.ts +27 -0
- package/dist/dns/godaddy.d.ts +18 -1
- package/dist/dns/index.d.ts +2 -0
- package/dist/dns/index.js +1 -1
- package/dist/dns/zone-migration.d.ts +92 -0
- package/dist/dns/zone-migration.test.d.ts +1 -0
- package/dist/drivers/hetzner/driver.d.ts +8 -1
- package/dist/drivers/index.js +1 -1
- package/dist/drivers/shared/app-updates.d.ts +36 -0
- package/dist/drivers/shared/compute-provision.d.ts +14 -2
- package/dist/drivers/shared/db-provision.d.ts +3 -2
- package/dist/drivers/shared/mail-provision.d.ts +116 -0
- package/dist/drivers/shared/mail-provision.test.d.ts +1 -0
- package/dist/drivers/shared/managed-services-probe.d.ts +47 -0
- package/dist/drivers/shared/managed-services-probe.test.d.ts +1 -0
- package/dist/drivers/shared/package-manager.d.ts +1 -0
- package/dist/drivers/shared/remote-failure.d.ts +21 -0
- package/dist/drivers/shared/remote-failure.test.d.ts +1 -0
- package/dist/drivers/shared/sqlite-shared-path.d.ts +50 -0
- package/dist/drivers/shared/sqlite-shared-path.test.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +92 -89
- package/dist/operations/plan.d.ts +136 -0
- package/dist/operations/plan.test.d.ts +1 -0
- package/dist/operations/server-rename.d.ts +84 -0
- package/dist/operations/server-rename.test.d.ts +1 -0
- package/dist/operations/site-move.d.ts +263 -0
- package/dist/operations/site-move.test.d.ts +1 -0
- package/dist/protection/index.js +1 -1
- package/dist/push/index.js +1 -1
- package/dist/spend/index.js +1 -1
- package/dist/ui/404.html +1 -1
- package/dist/ui/accept-invitation.html +1 -1
- package/dist/ui/access-denied.html +1 -1
- package/dist/ui/account/automation.html +6 -6
- package/dist/ui/account/security.html +2 -2
- package/dist/ui/applications/compose.html +6 -6
- package/dist/ui/applications/new.html +2 -2
- package/dist/ui/data/backups.html +80 -80
- package/dist/ui/data/services.html +78 -78
- package/dist/ui/data/volumes.html +50 -50
- package/dist/ui/index.html +50 -50
- package/dist/ui/infrastructure/topology.html +118 -118
- package/dist/ui/integrations.html +2 -2
- package/dist/ui/operations/alerts.html +48 -48
- package/dist/ui/operations/configuration.html +6 -6
- package/dist/ui/operations/jobs.html +75 -75
- package/dist/ui/operations/maintenance.html +6 -6
- package/dist/ui/operations/observability.html +82 -82
- package/dist/ui/operations/previews.html +6 -6
- package/dist/ui/operations/queue.html +6 -6
- package/dist/ui/operations/regions.html +6 -6
- package/dist/ui/operations/releases.html +6 -6
- package/dist/ui/operations/spend.html +54 -54
- package/dist/ui/operations/workloads.html +104 -104
- package/dist/ui/security.html +2 -2
- package/dist/ui/server/actions.html +56 -56
- package/dist/ui/server/activity.html +1 -1
- package/dist/ui/server/capacity.html +6 -6
- package/dist/ui/server/database.html +106 -106
- package/dist/ui/server/deployments.html +50 -50
- package/dist/ui/server/diagnostics.html +2 -2
- package/dist/ui/server/firewall.html +76 -76
- package/dist/ui/server/fleet.html +34 -34
- package/dist/ui/server/logs.html +24 -24
- package/dist/ui/server/metrics.html +112 -112
- package/dist/ui/server/security.html +2 -2
- package/dist/ui/server/services.html +27 -27
- package/dist/ui/server/sites.html +120 -120
- package/dist/ui/server/ssh-keys.html +52 -52
- package/dist/ui/server/team.html +144 -144
- package/dist/ui/server/terminal.html +15 -15
- package/dist/ui/serverless/alarms.html +52 -52
- package/dist/ui/serverless/assets.html +27 -27
- package/dist/ui/serverless/cost.html +2 -2
- package/dist/ui/serverless/data.html +36 -36
- package/dist/ui/serverless/deployments.html +27 -27
- package/dist/ui/serverless/firewall.html +1 -1
- package/dist/ui/serverless/functions.html +40 -40
- package/dist/ui/serverless/logs.html +24 -24
- package/dist/ui/serverless/metrics.html +2 -2
- package/dist/ui/serverless/queues.html +48 -48
- package/dist/ui/serverless/secrets.html +51 -51
- package/dist/ui/serverless/traces.html +6 -6
- package/dist/ui/serverless.html +53 -53
- package/dist/ui-src/src/charts.ts +17499 -12662
- package/dist/ui-src/src/topology.ts +2 -2
- package/package.json +3 -3
- package/dist/bin/chunk-00kg80qg.js +0 -1
- package/dist/bin/chunk-09nwf2gy.js +0 -34
- package/dist/bin/chunk-1k5kszjp.js +0 -111
- package/dist/bin/chunk-21e0mavm.js +0 -1
- package/dist/bin/chunk-271gk1n2.js +0 -6
- package/dist/bin/chunk-2empps47.js +0 -2
- package/dist/bin/chunk-38pq971s.js +0 -2
- package/dist/bin/chunk-3gykfyq4.js +0 -37
- package/dist/bin/chunk-3vqfexc4.js +0 -70
- package/dist/bin/chunk-4vrqm9h0.js +0 -2
- package/dist/bin/chunk-598yf4bs.js +0 -1
- package/dist/bin/chunk-5ectjq0b.js +0 -1
- package/dist/bin/chunk-5erkxpt7.js +0 -512
- package/dist/bin/chunk-5mrtzemj.js +0 -1
- package/dist/bin/chunk-5n9fmabb.js +0 -1
- package/dist/bin/chunk-9knpg30y.js +0 -1
- package/dist/bin/chunk-9pvsff8g.js +0 -1
- package/dist/bin/chunk-ax9mr6wm.js +0 -44
- package/dist/bin/chunk-axhnkn5g.js +0 -2
- package/dist/bin/chunk-c1vcdgvr.js +0 -1
- package/dist/bin/chunk-ctd2vg9w.js +0 -2
- package/dist/bin/chunk-dbgffky8.js +0 -1
- package/dist/bin/chunk-ddk4rt4j.js +0 -6
- package/dist/bin/chunk-dwr30vbv.js +0 -1
- package/dist/bin/chunk-e0rkrq70.js +0 -1
- package/dist/bin/chunk-e3xrwh9z.js +0 -1
- package/dist/bin/chunk-fhc6ntvd.js +0 -2
- package/dist/bin/chunk-fpm59y25.js +0 -6
- package/dist/bin/chunk-fvbxvq6b.js +0 -1
- package/dist/bin/chunk-fy8j3y8p.js +0 -92
- package/dist/bin/chunk-fz21b57w.js +0 -1
- package/dist/bin/chunk-gavvf0pg.js +0 -141
- package/dist/bin/chunk-ggn7ax8p.js +0 -4
- package/dist/bin/chunk-gpe2prkm.js +0 -1
- package/dist/bin/chunk-h5pa5men.js +0 -2
- package/dist/bin/chunk-hm08xdxf.js +0 -2
- package/dist/bin/chunk-hzgz13nf.js +0 -1
- package/dist/bin/chunk-j703btc5.js +0 -50
- package/dist/bin/chunk-k9t9wvms.js +0 -1
- package/dist/bin/chunk-m669wtgr.js +0 -1
- package/dist/bin/chunk-m7dgskt1.js +0 -1
- package/dist/bin/chunk-mr0atd2s.js +0 -2
- package/dist/bin/chunk-mz0wbbsj.js +0 -3
- package/dist/bin/chunk-ngcyftm2.js +0 -1
- package/dist/bin/chunk-p66ptpmr.js +0 -2
- package/dist/bin/chunk-qk9qgepa.js +0 -1
- package/dist/bin/chunk-rytk89az.js +0 -60
- package/dist/bin/chunk-tga3hhwk.js +0 -6
- package/dist/bin/chunk-vek8a0w6.js +0 -1
- package/dist/bin/chunk-vm3q5gf2.js +0 -3
- package/dist/bin/chunk-y7s5r8y6.js +0 -3
- package/dist/bin/chunk-yv9sth30.js +0 -1
- package/dist/bin/chunk-zmegvjp8.js +0 -581
- package/dist/chunk-0ccta6z6.js +0 -6
- package/dist/chunk-0k1cs6pp.js +0 -1
- package/dist/chunk-1egjn203.js +0 -704
- package/dist/chunk-2wx29qga.js +0 -5
- package/dist/chunk-5m5rqmv7.js +0 -1
- package/dist/chunk-8ea5022g.js +0 -114
- package/dist/chunk-8xqn3c0w.js +0 -2
- package/dist/chunk-b4esxhmw.js +0 -2
- package/dist/chunk-b8e5wzwn.js +0 -44
- package/dist/chunk-bggt4n6e.js +0 -2
- package/dist/chunk-cwkg37rs.js +0 -37
- package/dist/chunk-gnv3r2jg.js +0 -1
- package/dist/chunk-hg3c48cp.js +0 -34
- package/dist/chunk-m5azeva3.js +0 -2
- package/dist/chunk-r3qf56b3.js +0 -92
- package/dist/chunk-sdqa9ghv.js +0 -141
- package/dist/chunk-svrvvcm7.js +0 -1
- package/dist/chunk-v0p3hpc3.js +0 -60
- package/dist/chunk-wdzjbecg.js +0 -50
- package/dist/chunk-ww8k3g7j.js +0 -1
- package/dist/chunk-xmqfc62w.js +0 -1
- package/dist/chunk-xrebj679.js +0 -435
- package/dist/chunk-y21zk0pn.js +0 -4
package/dist/aws/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$d as
|
|
1
|
+
import{$d as ea,$e as eb,Ae as Fa,Be as Ga,Ce as Ha,De as Ia,Ee as Ja,Fe as Ka,Ge as La,He as Ma,Ie as Na,Jd as k,Je as Oa,Kd as l,Ke as Pa,Ld as m,Le as Qa,Md as n,Me as Ra,Nd as o,Ne as Sa,Od as p,Oe as Ta,Pd as q,Pe as Ua,Qd as r,Qe as Va,Rd as t,Re as Wa,Sd as w,Se as Xa,Td as V,Te as Ya,Ud as X,Ue as Za,Vd as Y,Ve as _a,Wd as Z,We as $a,Xd as _,Xe as ab,Yd as aa,Ye as bb,Zd as ba,Ze as cb,_d as ca,_e as db,ae as fa,af as fb,be as ga,bf as gb,ce as ha,cf as hb,de as ia,df as ib,ee as ja,ef as jb,fe as ka,ff as kb,ge as la,gf as lb,he as ma,hf as mb,ie as na,if as nb,je as oa,jf as ob,ke as pa,kf as pb,le as qa,lf as qb,me as ra,mf as rb,ne as sa,nf as sb,oe as ta,pe as ua,qe as va,re as wa,se as xa,te as ya,ue as za,ve as Aa,we as Ba,xe as Ca,ye as Da,ze as Ea}from"../chunk-h1rc94df.js";import{of as e,pf as h,qf as i,rf as j}from"../chunk-nnqxmh7f.js";import{sf as v}from"../chunk-q2njk4hx.js";import{tf as U}from"../chunk-ky5c6t5y.js";import{uf as da}from"../chunk-t0kh8haz.js";import{Af as B,Bf as C,Cf as D,Df as E,Ef as F,Ff as G,Gf as H,Hf as I,If as J,Jf as K,Kf as L,Lf as M,Mf as N,Nf as O,Of as P,Pf as Q,Qf as R,Rf as S,Sf as T,vf as x,wf as y,xf as z,zf as A}from"../chunk-qtp90j44.js";import{Tf as f}from"../chunk-qjk1v1gs.js";import{Sh as u,Th as W}from"../chunk-hbhxk5a0.js";import{Uh as s}from"../chunk-8e0az001.js";import{Wh as g}from"../chunk-p6vszgc2.js";import{Xh as a,Yh as b,Zh as c,_h as d}from"../chunk-gk58959n.js";import"../chunk-spx89gaw.js";export{S as ACMClient,T as ACMDnsValidator,b as AWSClient,Wa as ApplicationAutoScalingClient,l as AwsBackupClient,ka as BedrockAgentClient,ja as BedrockAgentRuntimeClient,ia as BedrockClient,ha as BedrockRuntimeClient,s as CloudFormationClient,v as CloudFrontClient,aa as CloudWatchLogsClient,A as CloudflareProvider,pa as ComprehendClient,ba as ConnectClient,t as CostExplorerClient,Q as DnsProviderFactory,ea as DynamoDBClient,u as EC2Client,U as ECRClient,V as ECSClient,sb as EFSClient,ca as ELBv2Client,Ua as ElastiCacheClient,i as EmailClient,Ta as EventBridgeClient,z as GoDaddyProvider,e as IAMClient,Xa as ImapServer,Qa as KendraClient,_ as LambdaClient,fa as OpenSearchClient,x as PROXIABLE_RECORD_TYPES,Ka as PersonalizeClient,Ma as PersonalizeEventsClient,La as PersonalizeRuntimeClient,Ca as PollyClient,y as PorkbunProvider,da as RDSClient,ua as RekognitionClient,f as Route53Client,w as Route53DomainsClient,F as Route53Provider,g as S3Client,h as SESClient,Y as SNSClient,Z as SQSClient,W as SSMClient,k as STSClient,Va as SchedulerClient,X as SecretsManagerClient,$a as SmsClient,Za as SmtpServer,nb as SupportClient,ob as SupportTemplates,ya as TextractClient,ga as TranscribeClient,Ga as TranslateClient,K as UnifiedDnsValidator,jb as VoiceClient,qa as analyzeSentiment,I as applyZoneMigration,c as buildQueryParams,na as completeWithClaude,ta as containsPii,wa as countFacesInS3Image,db as createDeliveryReceiptHandler,O as createDnsProvider,M as createGoDaddyValidator,r as createObjectStorageClient,L as createPorkbunValidator,lb as createRecordingHandler,N as createRoute53Validator,Fa as createSSML,bb as createScheduledSmsHandler,cb as createSmsClient,ab as createSmsInboxHandler,rb as createSmsInfrastructure,mb as createVoiceClient,kb as createVoicemailHandler,d as detectCredentialSource,P as detectDnsProvider,va as detectLabelsFromS3,sa as detectLanguage,R as dnsProviders,j as email,G as exportRoute53Zone,ra as extractEntities,Aa as extractFormsFromS3,Ba as extractTablesFromS3,za as extractTextFromS3,fb as formatPhoneNumber,oa as generateEmbeddings,hb as getCountryCode,Na as getRecommendations,Oa as getSimilarItems,qb as getSmsInfrastructureStatus,xa as isContentSafe,ib as isSamePhoneNumber,gb as isValidPhoneNumber,n as keyMatchesFilters,ma as listClaudeModels,Ja as listLanguages,Ea as listVoices,o as migrateObjectStorage,eb as normalizePhoneNumber,H as planZoneMigration,B as policyTag,p as providerEndpoint,C as qualifyName,E as reconcileDeclaredRecords,m as remapKey,la as requestModelAccess,D as resolveDeclaredRecords,q as resolveObjectStorage,a as resolveS3Endpoint,Sa as retrieveForRag,Ra as search,pb as setupSmsInfrastructure,Ya as startImapServer,_a as startSmtpServer,Da as textToSpeech,Pa as trackEvent,Ha as translate,Ia as translateToMultiple,J as verifyZoneParity};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ne as a,Oe as b,Pe as c,Qe as d,Re as e,Se as f,Te as g,Ue as h,Ve as i,We as j}from"./chunk-fpcghdr3.js";import"./chunk-md2k3n21.js";import"./chunk-mwgxyc0z.js";import"./chunk-neampxq1.js";import"./chunk-zejwh9cy.js";import"./chunk-ftse39wf.js";import"./chunk-nyc2jxd8.js";import"./chunk-21gggxvf.js";import"./chunk-4a85nk2q.js";import"./chunk-0y89hs67.js";import"./chunk-4a97kbk1.js";import"./chunk-ks4ewy1s.js";export{d as mergeDiscoveredSites,b as metricsScript,c as parseBlock,h as parseDeployHistory,f as parseServerLogs,g as parseServerSecurity,i as resolveConfigOnlyServerDashboardData,j as resolveServerDashboardData,e as serverLogSources,a as sharedBoxProbeScript};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{wd as a,xd as b,yd as c,zd as d}from"./chunk-9rsn48qg.js";import"./chunk-ftse39wf.js";import"./chunk-4a97kbk1.js";import"./chunk-ks4ewy1s.js";export{b as getComputeDeployHistory,d as restoreDatabaseBackup,a as rollbackComputeSite,c as runComputeRecipe};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import*as _ from"node:crypto";import{existsSync as V,readFileSync as Y}from"node:fs";import{homedir as W}from"node:os";import{join as B}from"node:path";var j={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"},z={nbsp:" ",copy:"©",reg:"®",trade:"™",euro:"€",pound:"£",yen:"¥",cent:"¢",deg:"°",micro:"µ",middot:"·",bull:"•",hellip:"…",prime:"′",Prime:"″",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",ndash:"–",mdash:"—",iexcl:"¡",iquest:"¿",sect:"§",para:"¶",dagger:"†",Dagger:"‡",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",times:"×",divide:"÷",plusmn:"±",ne:"≠",le:"≤",ge:"≥",infin:"∞",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",equiv:"≡",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜"};class D{customEntities={};useHtmlEntities;constructor(t=!1){this.useHtmlEntities=t}addEntity(t,e){this.customEntities[t]=e}decodeEntities(t){let e=t.indexOf("&");if(e===-1)return t;let r=t.length,i="",s=0;while(e!==-1&&e<r){if(e>s)i+=t.substring(s,e);let n=t.indexOf(";",e+1);if(n===-1||n-e>32){i+="&",s=e+1,e=t.indexOf("&",s);continue}let a=t.substring(e+1,n);if(a.charCodeAt(0)===35){let o=a.length,d=0,p=!1;if(o>2&&(a.charCodeAt(1)===120||a.charCodeAt(1)===88)){p=!0;for(let g=2;g<o;g++){let h=a.charCodeAt(g);if(h>=48&&h<=57)d=d<<4|h-48;else if(h>=65&&h<=70)d=d<<4|h-55;else if(h>=97&&h<=102)d=d<<4|h-87;else{p=!1;break}}}else if(o>1){p=!0;for(let g=1;g<o;g++){let h=a.charCodeAt(g);if(h>=48&&h<=57)d=d*10+(h-48);else{p=!1;break}}}if(p)i+=String.fromCodePoint(d);else i+=t.substring(e,n+1)}else{let o=this.customEntities[a];if(o===void 0){let d=a.length;if(d>=2&&d<=4){let p=a.charCodeAt(0);if(p===108&&d===2&&a.charCodeAt(1)===116)o="<";else if(p===103&&d===2&&a.charCodeAt(1)===116)o=">";else if(p===97&&d===3&&a.charCodeAt(1)===109&&a.charCodeAt(2)===112)o="&";else if(p===113&&d===4)o=a==="quot"?'"':void 0;else if(p===97&&d===4)o=a==="apos"?"'":void 0}if(o===void 0)o=j[a]??(this.useHtmlEntities?z[a]:void 0)}if(o!==void 0)i+=o;else i+=t.substring(e,n+1)}s=n+1,e=t.indexOf("&",s)}if(s<r)i+=t.substring(s);return i}}var w=[];w[38]="&";w[60]="<";w[62]=">";w[34]=""";w[39]="'";var H={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,alwaysCreateTextNode:!1,trimValues:!0,parseTagValue:!0,parseAttributeValue:!1,processEntities:!0,htmlEntities:!1,commentPropName:!1,cdataPropName:!1,piPropName:!1,preserveOrder:!1,stopNodes:[],unpairedTags:[],isArray:void 0,tagValueProcessor:void 0,attributeValueProcessor:void 0,updateTag:void 0,numberParseOptions:{hex:!0,leadingZeros:!0,scientific:!0},ignorePiTags:!1,transformAttributeName:void 0,transformTagName:void 0,ignoreDeclaration:!1};function N(t){return t===32||t===9||t===10||t===13}function P(t){return t>=65&&t<=90||t>=97&&t<=122||t===95||t===58||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=767||t>=880&&t<=893||t>=895&&t<=8191||t>=8204&&t<=8205||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533}function k(t){return P(t)||t===45||t===46||t>=48&&t<=57||t===183||t>=768&&t<=879||t>=8255&&t<=8256}var L=/^0x[\da-fA-F]+$/,X=/^[+-]?\d+(\.\d+)?[eE][+-]?\d+$/,M=/^[+-]?(\d+\.?\d*|\.\d+)$/;function v(t,e){return t.charCodeAt(e)===91&&t.charCodeAt(e+1)===67&&t.charCodeAt(e+2)===68&&t.charCodeAt(e+3)===65&&t.charCodeAt(e+4)===84&&t.charCodeAt(e+5)===65&&t.charCodeAt(e+6)===91}function I(t,e){let r=t.charCodeAt(e),i=t.charCodeAt(e+1),s=t.charCodeAt(e+2),n=t.charCodeAt(e+3),a=t.charCodeAt(e+4),o=t.charCodeAt(e+5),d=t.charCodeAt(e+6);return(r===68||r===100)&&(i===79||i===111)&&(s===67||s===99)&&(n===84||n===116)&&(a===89||a===121)&&(o===80||o===112)&&(d===69||d===101)}function G(t,e,r){if(e>=r||!P(t.charCodeAt(e)))return e;e++;while(e<r&&k(t.charCodeAt(e)))e++;return e}class O{options;entityDecoder;unpairedSet;exactStopNodes;wildcardStopSuffixes;needsJPath;_ignoreAttributes=!0;_textNodeName="#text";_commentPropName=!1;_cdataPropName=!1;_piPropName=!1;_alwaysCreateTextNode=!1;_trimValues=!0;_processEntities=!0;_parseTagValue=!0;_parseAttributeValue=!1;_removeNSPrefix=!1;_attrPrefix="@_";_attrsGroupName=!1;_ignorePiTags=!1;_ignoreDeclaration=!1;constructor(t){this.options={...H,...t},this.entityDecoder=new D(this.options.htmlEntities),this.unpairedSet=new Set(this.options.unpairedTags),this.exactStopNodes=new Set,this.wildcardStopSuffixes=[];for(let e of this.options.stopNodes)if(e.startsWith("*."))this.wildcardStopSuffixes.push(e.substring(2));else this.exactStopNodes.add(e);this._ignoreAttributes=this.options.ignoreAttributes,this._textNodeName=this.options.textNodeName,this._commentPropName=this.options.commentPropName,this._cdataPropName=this.options.cdataPropName,this._piPropName=this.options.piPropName,this._alwaysCreateTextNode=this.options.alwaysCreateTextNode,this._trimValues=this.options.trimValues,this._processEntities=this.options.processEntities,this._parseTagValue=this.options.parseTagValue,this._parseAttributeValue=this.options.parseAttributeValue,this._removeNSPrefix=this.options.removeNSPrefix,this._attrPrefix=this.options.attributeNamePrefix,this._attrsGroupName=this.options.attributesGroupName,this._ignorePiTags=this.options.ignorePiTags,this._ignoreDeclaration=this.options.ignoreDeclaration,this.needsJPath=this.options.stopNodes.length>0||this.options.isArray!==void 0||this.options.updateTag!==void 0||this.options.tagValueProcessor!==void 0||this.options.attributeValueProcessor!==void 0}addEntity(t,e){this.entityDecoder.addEntity(t,e)}parse(t){if(t instanceof Uint8Array)t=new TextDecoder().decode(t);let e=t;if(this.options.preserveOrder)return this.parseOrdered(e);return this.parseUnordered(e)}parseUnordered(t){let e={},r=t.length,i=0;if(r>0&&t.charCodeAt(0)===65279)i=1;return i=this.parseChildren(t,i,r,e,"",[]),e}parseOrdered(t){let e=t.length,r=0;if(e>0&&t.charCodeAt(0)===65279)r=1;let i=[];return this.parseChildrenOrdered(t,r,e,i,""),i}readTagName(t,e,r){return G(t,e,r)}extractTagName(t,e,r){let i=t.substring(e,r);if(this._removeNSPrefix){let s=i.indexOf(":");if(s!==-1)i=i.substring(s+1)}if(this.options.transformTagName)i=this.options.transformTagName(i);return i}parseAttributes(t,e,r,i,s){let n=0,a=this._removeNSPrefix,o=this.options.transformAttributeName,d=this._trimValues,p=this._processEntities,g=this.options.attributeValueProcessor;while(e<r){let h=t.charCodeAt(e);while(h===32||h===9||h===10||h===13){if(e++,e>=r)break;h=t.charCodeAt(e)}if(e>=r)break;if(h===62||h===47)break;let m=e;if(!P(h))break;e++;while(e<r&&k(t.charCodeAt(e)))e++;let f=t.substring(m,e);if(a){let A=f.indexOf(":");if(A!==-1)f=f.substring(A+1)}if(o)f=o(f);while(e<r&&N(t.charCodeAt(e)))e++;if(e<r&&t.charCodeAt(e)===61){e++;while(e<r&&N(t.charCodeAt(e)))e++;if(e>=r)break;let A=t.charCodeAt(e);if(A===34||A===39){e++;let b=e;while(e<r&&t.charCodeAt(e)!==A)e++;let u=t.substring(b,e);if(d&&u.length>0){let c=u.charCodeAt(0),l=u.charCodeAt(u.length-1);if(c<=32||l<=32)u=u.trim()}if(p)u=this.entityDecoder.decodeEntities(u);if(g)u=g(f,u,i)??u;if(s[f]=u,n++,e<r)e++}}else s[f]="true",n++}return n>0?-e-1:e}processTagValue(t,e,r,i,s){if(this._trimValues){let n=t.length;if(n>0){let a=t.charCodeAt(0),o=t.charCodeAt(n-1);if(a<=32||o<=32)t=t.trim()}}if(this._processEntities)t=this.entityDecoder.decodeEntities(t);if(this.options.tagValueProcessor){let n=this.options.tagValueProcessor(e,t,r,i,s);if(n!==void 0)t=n}if(!t)return t;if(this._parseTagValue)return this.parseValue(t);return t}parseValue(t){if(t==="true")return!0;if(t==="false")return!1;if(!t)return t;let e=t.charCodeAt(0);if(!(e>=48&&e<=57||e===43||e===45||e===46))return t;let i=this.options.numberParseOptions;if(i.skipLike?.test(t))return t;if(i.hex&&e===48&&L.test(t))return Number.parseInt(t,16);if(t.length>1&&e===48&&t.charCodeAt(1)!==46){if(i.leadingZeros)return t}if(i.scientific&&X.test(t)){let s=Number(t);if(!Number.isNaN(s))return s}if(M.test(t)){let s=Number(t);if(!Number.isNaN(s))return s}return t}parseAttributeValue(t){if(!this._parseAttributeValue)return t;return this.parseValue(t)}isStopNode(t){if(this.exactStopNodes.has(t))return!0;for(let e of this.wildcardStopSuffixes)if(t.endsWith(`.${e}`)||t===e)return!0;return!1}readStopNodeContent(t,e,r,i){let s=`</${i}`,n=t.indexOf(s,e);if(n===-1)return{content:t.substring(e),pos:r};let a=t.substring(e,n),o=n+s.length;while(o<r&&t.charCodeAt(o)!==62)o++;if(o<r)o++;return{content:a,pos:o}}addToObj(t,e,r,i,s,n){let a=t[e];if(a!==void 0)if(!Array.isArray(a))t[e]=[a,r];else a.push(r);else if(this.options.isArray?.(e,i,s,n))t[e]=[r];else t[e]=r}flushText(t,e,r,i){if(!t&&!e)return;let s=this._textNodeName;if(e){let n=t;if(n&&this._processEntities)n=this.entityDecoder.decodeEntities(n);let a=e+n;if(this._trimValues&&a.length>0){let o=a.charCodeAt(0),d=a.charCodeAt(a.length-1);if(o<=32||d<=32)a=a.trim()}if(this.options.tagValueProcessor){let o=this.options.tagValueProcessor(s,a,r,!1,!0);if(o!==void 0)a=o}if(a){let o=this._parseTagValue?this.parseValue(a):a;if(o!==void 0&&o!=="")this.addToObj(i,s,o,r,!0,!1)}}else{let n=this.processTagValue(t,s,r,!1,!0);if(n!==void 0&&n!=="")this.addToObj(i,s,n,r,!0,!1)}}parseChildren(t,e,r,i,s,n){let a="",o="",d=this.needsJPath;while(e<r){if(t.charCodeAt(e)!==60){let c=e;e++;while(e<r&&t.charCodeAt(e)!==60)e++;if(!a)a=t.substring(c,e);else a+=t.substring(c,e);continue}if(e+1>=r)break;let g=t.charCodeAt(e+1);if(g===33&&e+3<r&&t.charCodeAt(e+2)===45&&t.charCodeAt(e+3)===45){if(a||o)this.flushText(a,o,s,i),a="",o="";e+=4;let c=t.indexOf("-->",e);if(c===-1){e=r;break}if(this._commentPropName){let l=t.substring(e,c);this.addToObj(i,this._commentPropName,l,s,!0,!1)}e=c+3;continue}if(g===33&&e+8<r&&v(t,e+2)){e+=9;let c=t.indexOf("]]>",e);if(c===-1){e=r;break}let l=t.substring(e,c);if(this._cdataPropName)this.flushText(a,o,s,i),a="",o="",this.addToObj(i,this._cdataPropName,l,s,!0,!1);else{if(a){let C=a;if(this._processEntities)C=this.entityDecoder.decodeEntities(C);o+=C,a=""}o+=l}e=c+3;continue}if(g===33&&e+9<r&&I(t,e+2)){e+=9;let c=1;while(e<r&&c>0){let l=t.charCodeAt(e);if(l===60)c++;else if(l===62)c--;e++}continue}if(g===63){e+=2;let c=e;while(e<r&&!N(t.charCodeAt(e))&&t.charCodeAt(e)!==63)e++;let l=t.substring(c,e),C=t.indexOf("?>",e);if(C===-1){e=r;break}let y=t.substring(e,C).trim();if(l==="xml"){if(!this._ignoreDeclaration&&this._piPropName){let S=this.parsePiAttributes(y);this.addToObj(i,this._piPropName,{[l]:S},s,!0,!1)}}else if(!this._ignorePiTags&&this._piPropName)this.addToObj(i,this._piPropName,{[l]:y},s,!0,!1);e=C+2;continue}if(g===47){if(a||o)this.flushText(a,o,s,i),a="",o="";e+=2;let c=e,l=this.readTagName(t,e,r),C=this.extractTagName(t,c,l);e=l;while(e<r&&N(t.charCodeAt(e)))e++;if(e<r&&t.charCodeAt(e)===62)e++;if(n.length>0&&n[n.length-1]===C){n.pop();continue}return e}if(a||o)this.flushText(a,o,s,i),a="",o="";e++;let h=e,m=this.readTagName(t,e,r),f=this.extractTagName(t,h,m);if(!f){e=m+1;continue}e=m;let A=d?s?`${s}.${f}`:f:"",b={},u=!1;if(!this._ignoreAttributes){let c=this.parseAttributes(t,e,r,A,b);if(c<0)e=-c-1,u=!0;else e=c}else while(e<r){let c=t.charCodeAt(e);if(c===62||c===47)break;if(c===34||c===39){e++;while(e<r&&t.charCodeAt(e)!==c)e++}e++}if(this.options.updateTag){if(this.options.updateTag(f,A,b)===!1){while(e<r&&N(t.charCodeAt(e)))e++;if(e<r&&t.charCodeAt(e)===47)e+=2;else if(e<r&&t.charCodeAt(e)===62){e++;let l=`</${f}>`,C=t.indexOf(l,e);if(C!==-1)e=C+l.length}continue}}while(e<r&&N(t.charCodeAt(e)))e++;if(e<r&&t.charCodeAt(e)===47){if(e+=2,u||this._alwaysCreateTextNode){let c={};if(u)this.applyAttributes(c,b,A);if(this._alwaysCreateTextNode)c[this._textNodeName]="";this.addToObj(i,f,c,A,!0,!1)}else this.addToObj(i,f,"",A,!0,!1);continue}if(e<r&&t.charCodeAt(e)===62){if(e++,this.unpairedSet.has(f)){if(u){let y={};this.applyAttributes(y,b,A),this.addToObj(i,f,y,A,!0,!1)}else this.addToObj(i,f,"",A,!0,!1);n.push(f);continue}if(this.exactStopNodes.size>0||this.wildcardStopSuffixes.length>0){if(this.isStopNode(A)){let y=this.readStopNodeContent(t,e,r,f),S={};if(u)this.applyAttributes(S,b,A);if(y.content)S[this._textNodeName]=y.content;this.addToObj(i,f,S,A,!0,!1),e=y.pos;continue}}let c={};if(u)this.applyAttributes(c,b,A);e=this.parseChildren(t,e,r,c,A,n);let l=this._textNodeName,C=c[l];if(!u&&!this._alwaysCreateTextNode){let y=!0;for(let S in c)if(S!==l){y=!1;break}if(y){this.addToObj(i,f,C!==void 0?C:"",A,!0,!1);continue}}this.addToObj(i,f,c,A,!1,!1)}}if(a||o)this.flushText(a,o,s,i);return e}parseChildrenOrdered(t,e,r,i,s){let n="",a=this.needsJPath;while(e<r){if(t.charCodeAt(e)!==60){let u=e;e++;while(e<r&&t.charCodeAt(e)!==60)e++;if(!n)n=t.substring(u,e);else n+=t.substring(u,e);continue}if(e+1>=r)break;let d=t.charCodeAt(e+1);if(d===33&&e+3<r&&t.charCodeAt(e+2)===45&&t.charCodeAt(e+3)===45){if(n){let c=this.processTagValue(n,this._textNodeName,s,!1,!0);if(c!==void 0&&c!=="")i.push({[this._textNodeName]:c});n=""}e+=4;let u=t.indexOf("-->",e);if(u===-1){e=r;break}if(this._commentPropName)i.push({[this._commentPropName]:[{[this._textNodeName]:t.substring(e,u)}]});e=u+3;continue}if(d===33&&e+8<r&&v(t,e+2)){e+=9;let u=t.indexOf("]]>",e);if(u===-1){e=r;break}let c=t.substring(e,u);if(this._cdataPropName){if(n){let l=this.processTagValue(n,this._textNodeName,s,!1,!0);if(l!==void 0&&l!=="")i.push({[this._textNodeName]:l});n=""}i.push({[this._cdataPropName]:[{[this._textNodeName]:c}]})}else n+=c;e=u+3;continue}if(d===33&&e+9<r&&I(t,e+2)){e+=9;let u=1;while(e<r&&u>0){let c=t.charCodeAt(e);if(c===60)u++;else if(c===62)u--;e++}continue}if(d===63){e+=2;let u=t.indexOf("?>",e);if(u===-1){e=r;break}e=u+2;continue}if(d===47){if(n){let c=this.processTagValue(n,this._textNodeName,s,!1,!0);if(c!==void 0&&c!=="")i.push({[this._textNodeName]:c});n=""}e+=2,e=this.readTagName(t,e,r);while(e<r&&N(t.charCodeAt(e)))e++;if(e<r&&t.charCodeAt(e)===62)e++;return e}if(n){let u=this.processTagValue(n,this._textNodeName,s,!1,!0);if(u!==void 0&&u!=="")i.push({[this._textNodeName]:u});n=""}e++;let p=e,g=this.readTagName(t,e,r),h=this.extractTagName(t,p,g);if(!h){e=g+1;continue}e=g;let m=a?s?`${s}.${h}`:h:"",f={},A=!1;if(!this._ignoreAttributes){let u=this.parseAttributes(t,e,r,m,f);if(u<0)e=-u-1,A=!0;else e=u}else while(e<r){let u=t.charCodeAt(e);if(u===62||u===47)break;if(u===34||u===39){e++;while(e<r&&t.charCodeAt(e)!==u)e++}e++}while(e<r&&N(t.charCodeAt(e)))e++;let b={[h]:[]};if(A){b[":@"]={};for(let c in f)b[":@"][this._attrPrefix+c]=this.parseAttributeValue(f[c])}if(e<r&&t.charCodeAt(e)===47){e+=2,i.push(b);continue}if(e<r&&t.charCodeAt(e)===62)e++,e=this.parseChildrenOrdered(t,e,r,b[h],m),i.push(b)}if(n){let o=this.processTagValue(n,this._textNodeName,s,!1,!0);if(o!==void 0&&o!=="")i.push({[this._textNodeName]:o})}return e}applyAttributes(t,e,r){let i=this._attrPrefix;if(this._attrsGroupName){let s={};for(let n in e)s[i+n]=this.parseAttributeValue(e[n]);t[this._attrsGroupName]=s}else for(let s in e)t[i+s]=this.parseAttributeValue(e[s])}parsePiAttributes(t){let e={},r=0,i=t.length;while(r<i){while(r<i&&N(t.charCodeAt(r)))r++;if(r>=i)break;let s=r;while(r<i&&!N(t.charCodeAt(r))&&t.charCodeAt(r)!==61)r++;let n=t.substring(s,r);if(!n)break;while(r<i&&N(t.charCodeAt(r)))r++;if(r<i&&t.charCodeAt(r)===61){r++;while(r<i&&N(t.charCodeAt(r)))r++;if(r<i){let a=t.charCodeAt(r);if(a===34||a===39){r++;let o=r;while(r<i&&t.charCodeAt(r)!==a)r++;if(e[n]=t.substring(o,r),r<i)r++}}}}return e}}function R(t){let e=t.endpoint||`s3.${t.region}.amazonaws.com`,r=new URL(/^https?:\/\//i.test(e)?e:`https://${e}`);if(r.protocol!=="http:"&&r.protocol!=="https:"||r.pathname!=="/"&&r.pathname!==""||r.search||r.hash||r.username||r.password)throw Error("S3 endpoint must be an HTTP(S) origin without a path");let i=r.protocol.slice(0,-1),s=r.host;if(!t.bucket)return{protocol:i,host:s,path:t.path};if(t.forcePathStyle){let n=t.path==="/"?`/${t.bucket}`:`/${t.bucket}${t.path}`;return{protocol:i,host:s,path:n}}return{protocol:i,host:`${t.bucket}.${s}`,path:t.path}}class J{credentials;config;cache;xmlParser;constructor(t,e){this.config={maxRetries:3,retryDelay:1000,cacheEnabled:!0,defaultCacheTTL:60000,...e},this.credentials=t||this.loadCredentials(),this.cache=new Map,this.xmlParser=new O({ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",parseAttributeValue:!0,trimValues:!0})}loadCredentials(){let t=process.env.AWS_ACCESS_KEY_ID,e=process.env.AWS_SECRET_ACCESS_KEY,r=process.env.AWS_SESSION_TOKEN;if(t&&e)return{accessKeyId:t,secretAccessKey:e,sessionToken:r};let i=this.loadCredentialsFromFile();if(i)return i;return{accessKeyId:"",secretAccessKey:""}}loadCredentialsFromFile(){let t=this.config?.profile||process.env.AWS_PROFILE||"default",e=process.env.AWS_SHARED_CREDENTIALS_FILE||B(W(),".aws","credentials");if(!V(e))return null;try{let r=Y(e,"utf-8"),i=this.parseCredentialsFile(r,t);if(i.accessKeyId&&i.secretAccessKey)return i}catch{}return null}parseCredentialsFile(t,e){let r=t.split(`
|
|
2
|
+
`),i="",s="",n="",a;for(let o of r){let d=o.trim();if(!d||d.startsWith("#"))continue;let p=d.match(/^\[([^\]]+)\]$/);if(p){i=p[1];continue}if(i===e){let[g,...h]=d.split("="),m=h.join("=").trim();if(g.trim()==="aws_access_key_id")s=m;else if(g.trim()==="aws_secret_access_key")n=m;else if(g.trim()==="aws_session_token")a=m}}return{accessKeyId:s,secretAccessKey:n,sessionToken:a}}ec2CredentialsCache;async getCredentials(){let t=process.env.AWS_ACCESS_KEY_ID,e=process.env.AWS_SECRET_ACCESS_KEY;if(t&&e)return{accessKeyId:t,secretAccessKey:e,sessionToken:process.env.AWS_SESSION_TOKEN};let r=this.loadCredentialsFromFile();if(r)return r;if(this.ec2CredentialsCache){let i=Date.now();if(this.ec2CredentialsCache.expiration>i+300000)return this.ec2CredentialsCache.credentials}try{let s=await(await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"21600"}})).text(),a=await(await fetch("http://169.254.169.254/latest/meta-data/iam/security-credentials/",{headers:{"X-aws-ec2-metadata-token":s}})).text(),d=await(await fetch(`http://169.254.169.254/latest/meta-data/iam/security-credentials/${a}`,{headers:{"X-aws-ec2-metadata-token":s}})).json(),p={accessKeyId:d.AccessKeyId,secretAccessKey:d.SecretAccessKey,sessionToken:d.Token};return this.ec2CredentialsCache={credentials:p,expiration:new Date(d.Expiration).getTime()},p}catch(i){throw Error("AWS credentials not found. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables, or run on an EC2 instance with an IAM role.")}}async request(t){if(t.method==="GET"&&this.config.cacheEnabled&&t.cacheKey){let i=this.getFromCache(t.cacheKey);if(i!==null)return i}let e=t.retries??this.config.maxRetries??3,r=null;for(let i=0;i<=e;i++)try{let s=await this.makeRequest(t);if(t.method==="GET"&&this.config.cacheEnabled&&t.cacheKey)this.setInCache(t.cacheKey,s,t.cacheTTL??this.config.defaultCacheTTL??60000);return s}catch(s){if(r=s,!this.shouldRetry(s))throw s;if(i===e)throw s;let a=this.calculateRetryDelay(i);await this.sleep(a)}throw r||Error("Request failed after retries")}async makeRequest(t){let e=t.credentials||(this.credentials?.accessKeyId?this.credentials:await this.getCredentials());if(!e||!e.accessKeyId||!e.secretAccessKey)throw Error("AWS credentials not provided");let r=this.buildUrl(t),i=this.signRequest(t,e),s=await fetch(r,{method:t.method,headers:i,body:t.body}),n=await s.text();if(!s.ok)throw this.parseError(n,s.status,s.headers);if(!n||n.trim()===""){if(t.returnHeaders)return{body:null,headers:this.headersToObject(s.headers)};return null}if(t.rawResponse){if(t.returnHeaders)return{body:n,headers:this.headersToObject(s.headers)};return n}let a;if(n.startsWith("<"))a=this.parseXmlResponse(n);else try{a=JSON.parse(n)}catch{a=n}if(t.returnHeaders)return{body:a,headers:this.headersToObject(s.headers)};return a}headersToObject(t){let e={};return t.forEach((r,i)=>{e[i]=r}),e}buildUrl(t){let{service:e,region:r,queryParams:i}=t,{path:s}=t,n,a="https";if(e==="s3"){let d=R({region:r,path:s,bucket:t.bucket,endpoint:this.config.endpoint,forcePathStyle:this.config.forcePathStyle});a=d.protocol,n=d.host,s=d.path}else if(e==="cloudfront")n="cloudfront.amazonaws.com";else if(e==="iam")n="iam.amazonaws.com";else if(e==="route53")n="route53.amazonaws.com";else if(e==="route53domains")n="route53domains.us-east-1.amazonaws.com";else if(e==="ecr")n=`api.ecr.${r}.amazonaws.com`;else if(e==="ses")n=`email.${r}.amazonaws.com`;else n=`${e}.${r}.amazonaws.com`;let o=`${a}://${n}${s}`;if(i&&Object.keys(i).length>0){let d=Object.keys(i).map((p)=>`${this.uriEncode(p)}=${this.uriEncode(i[p])}`).join("&");o+=`?${d}`}return o}signRequest(t,e){let{service:r,region:i,method:s,queryParams:n,body:a}=t,{path:o}=t,d=new Date,p=this.getAmzDate(d),g=this.getDateStamp(d),h;if(r==="s3"){let E=R({region:i,path:o,bucket:t.bucket,endpoint:this.config.endpoint,forcePathStyle:this.config.forcePathStyle});h=E.host,o=E.path}else if(r==="cloudfront")h="cloudfront.amazonaws.com";else if(r==="iam")h="iam.amazonaws.com";else if(r==="route53")h="route53.amazonaws.com";else if(r==="route53domains")h="route53domains.us-east-1.amazonaws.com";else if(r==="ecr")h=`api.ecr.${i}.amazonaws.com`;else if(r==="ses")h=`email.${i}.amazonaws.com`;else h=`${r}.${i}.amazonaws.com`;let m={host:h,"x-amz-date":p,...t.headers||{}};if(e.sessionToken)m["x-amz-security-token"]=e.sessionToken;if(a){if(!Object.keys(m).some((T)=>T.toLowerCase()==="content-type"))m["content-type"]="application/x-www-form-urlencoded";m["content-length"]=Buffer.byteLength(a).toString()}let f=this.sha256(a||"");m["x-amz-content-sha256"]=f;let A=o,b=n?Object.keys(n).sort().map((E)=>`${this.uriEncode(E)}=${this.uriEncode(n[E])}`).join("&"):"",u=Object.keys(m).sort((E,T)=>E.toLowerCase().localeCompare(T.toLowerCase())),c=u.map((E)=>`${E.toLowerCase()}:${m[E].trim()}
|
|
3
|
+
`).join(""),l=u.map((E)=>E.toLowerCase()).join(";"),C=[s,A,b,c,l,f].join(`
|
|
4
|
+
`),y="AWS4-HMAC-SHA256",S=r;if(r==="email")S="ses";let x=`${g}/${i}/${S}/aws4_request`,K=[y,p,x,this.sha256(C)].join(`
|
|
5
|
+
`),F=this.getSignatureKey(e.secretAccessKey,g,i,S),q=this.hmac(F,K),U=`${y} Credential=${e.accessKeyId}/${x}, SignedHeaders=${l}, Signature=${q}`;return{...m,Authorization:U}}getAmzDate(t){return t.toISOString().replace(/[:-]|\.\d{3}/g,"")}getDateStamp(t){return t.toISOString().slice(0,10).replace(/-/g,"")}uriEncode(t){return encodeURIComponent(t).replace(/[!'()*]/g,(e)=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}sha256(t){return _.createHash("sha256").update(t,"utf8").digest("hex")}hmac(t,e){return _.createHmac("sha256",t).update(e,"utf8").digest("hex")}getSignatureKey(t,e,r,i){let s=_.createHmac("sha256",`AWS4${t}`).update(e).digest(),n=_.createHmac("sha256",s).update(r).digest(),a=_.createHmac("sha256",n).update(i).digest();return _.createHmac("sha256",a).update("aws4_request").digest()}parseXmlResponse(t){try{let e=this.xmlParser.parse(t);if(e.ErrorResponse)throw this.createErrorFromXml(e.ErrorResponse.Error);let r=Object.keys(e);if(r.length===1)return e[r[0]];return e}catch(e){if(e.code||e.statusCode)throw e;return{}}}parseError(t,e,r){let i=Error();if(i.statusCode=e,i.requestId=r.get("x-amzn-requestid")||r.get("x-amz-request-id")||void 0,t.startsWith("<"))try{let s=this.xmlParser.parse(t);if(s.ErrorResponse?.Error){let n=s.ErrorResponse.Error;return i.code=n.Code,i.message=`AWS Error [${n.Code}]: ${n.Message||"Unknown error"}`,i.type=n.Type,i}if(s.Error)return i.code=s.Error.Code,i.message=`AWS Error [${s.Error.Code}]: ${s.Error.Message||"Unknown error"}`,i}catch{}try{let s=JSON.parse(t);if(s.__type||s.code)return i.code=s.__type||s.code,i.message=`AWS Error [${i.code}]: ${s.message||s.Message||"Unknown error"}`,i}catch{}return i.message=`AWS API Error (${e}): ${t}`,i}createErrorFromXml(t){let e=Error();return e.code=t.Code,e.message=`AWS Error [${t.Code}]: ${t.Message||"Unknown error"}`,e.type=t.Type,e}isRetryableError(t){return["RequestTimeout","RequestTimeoutException","PriorRequestNotComplete","ConnectionError","ThrottlingException","Throttling","TooManyRequestsException","ProvisionedThroughputExceededException","RequestLimitExceeded","BandwidthLimitExceeded","SlowDown","ServiceUnavailable","ServiceUnavailableException","InternalError","InternalFailure","InternalServerError","InternalServiceException","TransientError","TransientFailure","IDPCommunicationErrorException","NetworkError","ConnectionRefusedException","EC2ThrottledException","503 Slow Down","500 InternalError"].includes(t)}isRetryableStatusCode(t){return t>=500||t===429}shouldRetry(t){if(t.name==="FetchError"||t.name==="TypeError"||t.code==="ECONNRESET")return!0;if(t.code&&this.isRetryableError(t.code))return!0;if(t.statusCode&&this.isRetryableStatusCode(t.statusCode))return!0;if(t.statusCode&&t.statusCode>=400&&t.statusCode<500&&t.statusCode!==429)return!1;if(t.statusCode)return!1;return!0}calculateRetryDelay(t){let e=this.config.retryDelay??1000,r=30000,i=Math.min(e*2**t,30000),s=Math.random()*0.3*i;return i+s}sleep(t){return new Promise((e)=>setTimeout(e,t))}getFromCache(t){let e=this.cache.get(t);if(!e)return null;if(Date.now()>e.expires)return this.cache.delete(t),null;return e.data}setInCache(t,e,r){this.cache.set(t,{data:e,expires:Date.now()+r})}clearCache(){this.cache.clear()}clearExpiredCache(){let t=Date.now();for(let[e,r]of this.cache.entries())if(t>r.expires)this.cache.delete(e)}}function ie(t){let e={};for(let[r,i]of Object.entries(t)){if(i===void 0||i===null)continue;if(Array.isArray(i))i.forEach((s,n)=>{e[`${r}.${n+1}`]=String(s)});else if(typeof i==="object")for(let[s,n]of Object.entries(i))e[`${r}.${s}`]=String(n);else e[r]=String(i)}return e}function se(){let t=process.env.AWS_ACCESS_KEY_ID,e=process.env.AWS_SECRET_ACCESS_KEY,r=t==="",i=e==="";if(t&&e)return{source:"env",emptyEnvKey:r,emptyEnvSecret:i,description:"environment variables (AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY)"};let s=process.env.AWS_PROFILE||"default",n=process.env.AWS_SHARED_CREDENTIALS_FILE||B(W(),".aws","credentials");if(V(n))return{source:"file",profile:s,emptyEnvKey:r,emptyEnvSecret:i,description:`~/.aws/credentials (profile: ${s})`};return{source:"ec2",emptyEnvKey:r,emptyEnvSecret:i,description:"EC2 instance metadata service (IMDSv2)"}}
|
|
6
|
+
export{R as bh,J as ch,ie as dh,se as eh};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ch as g}from"./chunk-0y89hs67.js";class p{client;region;constructor(e="us-east-1",t){this.region=e,this.client=new g(void 0,{profile:t})}async createStack(e){let t={Action:"CreateStack",StackName:e.stackName,Version:"2010-05-15"};if(e.templateBody)t.TemplateBody=e.templateBody;else if(e.templateUrl)t.TemplateURL=e.templateUrl;else throw Error("Either templateBody or templateUrl must be provided");if(e.parameters)e.parameters.forEach((a,r)=>{t[`Parameters.member.${r+1}.ParameterKey`]=a.ParameterKey,t[`Parameters.member.${r+1}.ParameterValue`]=a.ParameterValue});if(e.capabilities)e.capabilities.forEach((a,r)=>{t[`Capabilities.member.${r+1}`]=a});if(e.roleArn)t.RoleARN=e.roleArn;if(e.tags)e.tags.forEach((a,r)=>{t[`Tags.member.${r+1}.Key`]=a.Key,t[`Tags.member.${r+1}.Value`]=a.Value});if(e.timeoutInMinutes)t.TimeoutInMinutes=e.timeoutInMinutes;if(e.onFailure)t.OnFailure=e.onFailure;let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{StackId:s.StackId||s.CreateStackResult?.StackId}}async updateStack(e){let t={Action:"UpdateStack",StackName:e.stackName,Version:"2010-05-15"};if(e.templateBody)t.TemplateBody=e.templateBody;else if(e.templateUrl)t.TemplateURL=e.templateUrl;if(e.parameters)e.parameters.forEach((a,r)=>{if(t[`Parameters.member.${r+1}.ParameterKey`]=a.ParameterKey,a.UsePreviousValue)t[`Parameters.member.${r+1}.UsePreviousValue`]="true";else t[`Parameters.member.${r+1}.ParameterValue`]=a.ParameterValue});if(e.capabilities)e.capabilities.forEach((a,r)=>{t[`Capabilities.member.${r+1}`]=a});if(e.roleArn)t.RoleARN=e.roleArn;if(e.tags)e.tags.forEach((a,r)=>{t[`Tags.member.${r+1}.Key`]=a.Key,t[`Tags.member.${r+1}.Value`]=a.Value});let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{StackId:s.StackId||s.UpdateStackResult?.StackId}}async deleteStack(e,t,s){let a={Action:"DeleteStack",StackName:e,Version:"2010-05-15"};if(t)a.RoleARN=t;if(s&&s.length>0)s.forEach((r,m)=>{a[`RetainResources.member.${m+1}`]=r});await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(a).toString()})}async describeStacks(e={}){let t={Action:"DescribeStacks",Version:"2010-05-15"};if(e.stackName)t.StackName=e.stackName;let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{Stacks:this.parseStacksResponse(s)}}async describeStackEvents(e){let t={Action:"DescribeStackEvents",StackName:e,Version:"2010-05-15"},s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{StackEvents:this.parseStackEvents(s)}}async listStackResources(e){let t={Action:"ListStackResources",StackName:e,Version:"2010-05-15"},a=(await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()}))?.ListStackResourcesResult?.StackResourceSummaries?.member,r=[];if(a)r=Array.isArray(a)?a:[a];return{StackResourceSummaries:r}}async waitForStack(e,t){let s={"stack-create-complete":["CREATE_COMPLETE"],"stack-update-complete":["UPDATE_COMPLETE"],"stack-delete-complete":["DELETE_COMPLETE"]},a=["CREATE_FAILED","ROLLBACK_FAILED","ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE"],r=s[t],m=360,i=0;while(i<360)try{let c=await this.describeStacks({stackName:e});if(c.Stacks.length===0){if(t==="stack-delete-complete")return;if(i%10===0)console.log(`[waitForStack] Attempt ${i}: Stack not visible yet`);await new Promise((o)=>setTimeout(o,2000)),i++;continue}let n=c.Stacks[0];if(i%10===0)console.log(`[waitForStack] Attempt ${i}: Status = ${n.StackStatus}${n.StackStatusReason?` (${n.StackStatusReason})`:""}`);if(r.includes(n.StackStatus))return;if((t==="stack-create-complete"||t==="stack-update-complete")&&(n.StackStatus==="DELETE_IN_PROGRESS"||n.StackStatus==="DELETE_COMPLETE")){console.log("[waitForStack] Stack is being deleted (creation/update failed)");let o="";try{let u=await this.describeStackEvents(e);console.log("[waitForStack] Stack events (most recent first):");for(let l of u.StackEvents.slice(0,15))if(l.ResourceStatus.includes("FAILED")||l.ResourceStatusReason){if(console.log(` ${l.LogicalResourceId}: ${l.ResourceStatus} - ${l.ResourceStatusReason||"No reason provided"}`),l.ResourceStatus.includes("FAILED")&&l.ResourceStatusReason&&!o)o=l.ResourceStatusReason}}catch{}let S=o||n.StackStatusReason||"Check CloudFormation console for details.";throw Error(`Stack creation/update failed - stack is being deleted. Reason: ${S}`)}if(n.StackStatus==="DELETE_FAILED"&&t==="stack-delete-complete"){let o=Error("Stack deletion failed - may have resources that need to be retained");throw o.code="DELETE_FAILED",o.stackStatus=n.StackStatus,o.statusReason=n.StackStatusReason,o}if(a.includes(n.StackStatus))throw Error(`Stack reached failure status: ${n.StackStatus}`);await new Promise((o)=>setTimeout(o,5000)),i++}catch(c){if(t==="stack-delete-complete"&&c.message?.includes("does not exist"))return;if(t==="stack-create-complete"&&c.message?.includes("does not exist")){if(i%10===0)console.log(`[waitForStack] Attempt ${i}: Stack does not exist (error), retrying...`);await new Promise((n)=>setTimeout(n,2000)),i++;continue}throw console.log(`[waitForStack] Unexpected error: ${c.message}`),c}throw console.log(`[waitForStack] Timeout after ${i} attempts`),Error(`Timeout waiting for stack to reach ${t}`)}async validateTemplate(e){let t={Action:"ValidateTemplate",TemplateBody:e,Version:"2010-05-15"};return await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()})}async listStacks(e){let t={Action:"ListStacks",Version:"2010-05-15"};if(e)e.forEach((c,n)=>{t[`StackStatusFilter.member.${n+1}`]=c});let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()}),a=s.ListStacksResponse||s,r=a.ListStacksResult||a,m=r.StackSummaries?.member||r.StackSummaries||[];return{StackSummaries:(Array.isArray(m)?m:m?[m]:[]).map((c)=>({StackId:c.StackId||"",StackName:c.StackName||"",TemplateDescription:c.TemplateDescription,CreationTime:c.CreationTime||"",LastUpdatedTime:c.LastUpdatedTime,DeletionTime:c.DeletionTime,StackStatus:c.StackStatus||""}))}}async createChangeSet(e){let t={Action:"CreateChangeSet",StackName:e.stackName,ChangeSetName:e.changeSetName,Version:"2010-05-15"};if(e.templateBody)t.TemplateBody=e.templateBody;else if(e.templateUrl)t.TemplateURL=e.templateUrl;if(e.parameters)e.parameters.forEach((a,r)=>{t[`Parameters.member.${r+1}.ParameterKey`]=a.ParameterKey,t[`Parameters.member.${r+1}.ParameterValue`]=a.ParameterValue});if(e.capabilities)e.capabilities.forEach((a,r)=>{t[`Capabilities.member.${r+1}`]=a});if(e.changeSetType)t.ChangeSetType=e.changeSetType;let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{Id:s.Id,StackId:s.StackId}}async describeChangeSet(e,t){let s={Action:"DescribeChangeSet",StackName:e,ChangeSetName:t,Version:"2010-05-15"};return await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(s).toString()})}async executeChangeSet(e,t){let s={Action:"ExecuteChangeSet",StackName:e,ChangeSetName:t,Version:"2010-05-15"};await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(s).toString()})}async deleteChangeSet(e,t){let s={Action:"DeleteChangeSet",StackName:e,ChangeSetName:t,Version:"2010-05-15"};await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(s).toString()})}async getStackOutputs(e){let t=await this.describeStacks({stackName:e});if(!t.Stacks||t.Stacks.length===0)throw Error(`Stack ${e} not found`);let s=t.Stacks[0],a={};if(s.Outputs)for(let r of s.Outputs)a[r.OutputKey]=r.OutputValue;return a}async getTemplate(e){let t={Action:"GetTemplate",StackName:e,Version:"2010-05-15"},s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{TemplateBody:s?.GetTemplateResult?.TemplateBody||s?.TemplateBody||""}}parseStacksResponse(e){let t=[],s=e?.DescribeStacksResult?.Stacks?.member||e?.Stacks?.member||e?.Stacks||e;if(s&&!Array.isArray(s))s=[s];if(Array.isArray(s)){for(let a of s)if(a.StackId||a.StackName){let r;if(a.Outputs?.member)r=(Array.isArray(a.Outputs.member)?a.Outputs.member:[a.Outputs.member]).map((i)=>({OutputKey:i.OutputKey,OutputValue:i.OutputValue,Description:i.Description,ExportName:i.ExportName}));t.push({StackId:a.StackId,StackName:a.StackName,StackStatus:a.StackStatus,CreationTime:a.CreationTime,LastUpdatedTime:a.LastUpdatedTime,StackStatusReason:a.StackStatusReason,Outputs:r})}}else if(e.StackId)t.push({StackId:e.StackId,StackName:e.StackName,StackStatus:e.StackStatus,CreationTime:e.CreationTime,LastUpdatedTime:e.LastUpdatedTime});return t}parseStackEvents(e){let t=[],s=e?.DescribeStackEventsResult?.StackEvents?.member||e?.StackEvents?.member||e?.StackEvents||[];if(s&&!Array.isArray(s))s=[s];for(let a of s)if(a.LogicalResourceId)t.push({Timestamp:a.Timestamp,ResourceType:a.ResourceType,LogicalResourceId:a.LogicalResourceId,ResourceStatus:a.ResourceStatus,ResourceStatusReason:a.ResourceStatusReason});return t}async waitForStackWithProgress(e,t,s){let a={"stack-create-complete":["CREATE_COMPLETE"],"stack-update-complete":["UPDATE_COMPLETE"],"stack-delete-complete":["DELETE_COMPLETE"]},r=["CREATE_FAILED","ROLLBACK_FAILED","ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE"],m=a[t],i=360,c=0,n=new Set;while(c<360)try{if(s)try{let l=[...(await this.describeStackEvents(e)).StackEvents||[]].reverse();for(let k of l){let d=`${k.LogicalResourceId}-${k.ResourceStatus}-${k.Timestamp}`;if(!n.has(d))n.add(d),s({resourceId:k.LogicalResourceId,resourceType:k.ResourceType,status:k.ResourceStatus,reason:k.ResourceStatusReason,timestamp:k.Timestamp})}}catch{}let o=await this.describeStacks({stackName:e});if(o.Stacks.length===0){if(t==="stack-delete-complete")return;await new Promise((u)=>setTimeout(u,2000)),c++;continue}let S=o.Stacks[0];if(m.includes(S.StackStatus))return;if(S.StackStatus==="DELETE_FAILED"&&t==="stack-delete-complete"){let u=Error("Stack deletion failed - may have resources that need to be retained");throw u.code="DELETE_FAILED",u.stackStatus=S.StackStatus,u.statusReason=S.StackStatusReason,u}if(r.includes(S.StackStatus))throw Error(`Stack reached failure status: ${S.StackStatus}`);await new Promise((u)=>setTimeout(u,3000)),c++}catch(o){if(t==="stack-delete-complete"&&o.message?.includes("does not exist"))return;if(t==="stack-create-complete"&&o.message?.includes("does not exist")){await new Promise((S)=>setTimeout(S,2000)),c++;continue}throw o}throw Error(`Timeout waiting for stack to reach ${t}`)}async waitForStackComplete(e,t=120,s=5000){let a=["CREATE_COMPLETE","UPDATE_COMPLETE","DELETE_COMPLETE"],r=["CREATE_FAILED","UPDATE_FAILED","DELETE_FAILED","ROLLBACK_COMPLETE","ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED"];for(let m=0;m<t;m++)try{let i=await this.describeStacks({stackName:e});if(i.Stacks.length===0)return{success:!0,status:"DELETE_COMPLETE"};let c=i.Stacks[0],n=c.StackStatus;if(a.includes(n))return{success:!0,status:n};if(r.includes(n))return{success:!1,status:n,reason:c.StackStatusReason};await new Promise((o)=>setTimeout(o,s))}catch(i){if(i.message?.includes("does not exist"))return{success:!0,status:"DELETE_COMPLETE"};throw i}return{success:!1,status:"TIMEOUT",reason:"Timeout waiting for stack operation"}}}
|
|
2
|
+
export{p as ig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{kf as a,lf as b,mf as c,nf as d,of as e,pf as f,qf as g,rf as h,sf as i,tf as j}from"./chunk-zejwh9cy.js";import"./chunk-4a97kbk1.js";import"./chunk-ks4ewy1s.js";export{a as MANAGEMENT_DASHBOARD_SITE,j as buildManagementDashboardArtifact,b as dashboardCredentialsFile,h as ensureManagementDashboard,d as liveStageDir,i as managementDashboardSiteNames,c as resolveDashboardAuth,e as resolveDashboardVersion,g as resolveUiSource,f as stageLiveDashboardRoot};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as y,b as z,c as A,d as B,e as C,f as D,g as E,h as F,i as G,j as H,k as I,l as J,m as K,n as L,o as M}from"./chunk-nkpf91d3.js";import{$e as w,Xe as s,Ye as t,Ze as u,_e as v,af as x}from"./chunk-md2k3n21.js";import{bf as k,cf as l,df as m,ef as n,ff as o,gf as p,hf as q,if as r}from"./chunk-mwgxyc0z.js";import{Ao as d,Bo as e,Co as f,Do as g,Eo as h,Fo as i,Go as j,xo as a,yo as b,zo as c}from"./chunk-4a97kbk1.js";import"./chunk-ks4ewy1s.js";export{b as CHAIN_HEADER,H as DEFAULT_ATTACK_MODE_HOURS,k as DEFAULT_DDOS_THRESHOLDS,e as DEFAULT_RECURSION_LIMITS,a as DEPTH_HEADER,G as MAX_CONTROL_HOURS,F as PROTECTION_SETTING,I as ProtectionControlStore,y as RATE_LIMIT_KEY_SEPARATOR,C as RateLimiter,h as RecursionGuard,c as TRACE_HEADER,L as applyControlsToDdos,K as applyControlsToRateLimits,r as applyMitigationFactor,E as defaultRateLimitRules,J as describePosture,s as escapeSecLang,d as functionFingerprint,z as globMatches,u as globToRegex,g as inspectInvocation,t as isSafePattern,l as isValidCidr,M as mergeControlsIntoConfig,f as parseChain,q as planMitigation,i as propagationHeaders,D as rateLimitHeaders,B as rateLimitKey,j as recursionBlockedResponse,p as renderDdosInstallScript,o as renderNftablesRuleset,n as renderSysctlFile,v as renderWafConfig,w as renderWafInstallScript,A as ruleMatches,m as sysctlHardening,x as wafEventTelemetry};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import{bh as U,ch as L}from"./chunk-0y89hs67.js";import{np as K}from"./chunk-ks4ewy1s.js";import*as c from"node:crypto";import{readFileSync as D}from"node:fs";import{readdir as z}from"node:fs/promises";import{join as M}from"node:path";function R(e){if(e){let r=O(e);if(!r)throw Error(`AWS profile '${e}' not found in ~/.aws/credentials`);return r}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 O(process.env.AWS_PROFILE||"default")??{accessKeyId:"",secretAccessKey:""}}function O(e){let{existsSync:t,readFileSync:s}=K("node:fs"),{homedir:r}=K("node:os"),{join:n}=K("node:path"),i=process.env.AWS_SHARED_CREDENTIALS_FILE||n(r(),".aws","credentials");if(!t(i))return null;let o=s(i,"utf-8"),a=null,g,l,u;for(let d of o.split(`
|
|
2
|
+
`)){let y=d.trim();if(!y||y.startsWith("#")||y.startsWith(";"))continue;let h=y.match(/^\[([^\]]+)\]$/);if(h){if(a===e&&g&&l)return{accessKeyId:g,secretAccessKey:l,sessionToken:u};a=h[1],g=void 0,l=void 0,u=void 0;continue}if(a===e){let[S,...m]=y.split("="),p=m.join("=").trim();switch(S.trim().toLowerCase()){case"aws_access_key_id":g=p;break;case"aws_secret_access_key":l=p;break;case"aws_session_token":u=p;break}}}if(a===e&&g&&l)return{accessKeyId:g,secretAccessKey:l,sessionToken:u};return null}function B(e){let{buffer:t,byteOffset:s,byteLength:r}=e;if(t instanceof ArrayBuffer)return t.slice(s,s+r);let n=new ArrayBuffer(r);return new Uint8Array(n).set(new Uint8Array(e)),n}class V{client;region;explicitProfile;endpoint;endpointProtocol="https";forcePathStyle;explicitCredentials;constructor(e="us-east-1",t,s){let r=typeof e==="string"?s:e,n=typeof e==="string"?e:e.region??"us-east-1",i=typeof e==="string"?t:e.profile,o=r?.endpoint?U({region:n,path:"/",endpoint:r.endpoint}):void 0;this.region=n,this.explicitProfile=i,this.endpoint=o?.host,this.endpointProtocol=o?.protocol??"https",this.forcePathStyle=r?.forcePathStyle,this.explicitCredentials=r?.credentials,this.client=new L(r?.credentials,{profile:i,endpoint:r?.endpoint,forcePathStyle:r?.forcePathStyle})}getCredentials(){if(this.explicitCredentials?.accessKeyId&&this.explicitCredentials.secretAccessKey)return this.explicitCredentials;let e=R(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=[],r=(e?.ListAllMyBucketsResult??e)?.Buckets?.Bucket;if(r){let n=Array.isArray(r)?r:[r];for(let i of n)t.push({Name:i.Name,CreationDate:i.CreationDate})}return{Buckets:t}}async createBucket(e,t){let s={};if(t?.acl)s["x-amz-acl"]=t.acl;let r;if(this.region!=="us-east-1"&&!this.endpoint)r=`<?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:r})}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 r=s.map((n)=>n.Key);for(let n=0;n<r.length;n+=1000){let i=r.slice(n,n+1000);await this.deleteObjects(e,i)}}await this.deleteBucket(e)}async listAllObjects(e){let t=[],s;do{let r={"list-type":"2","max-keys":"1000"};if(e.prefix)r.prefix=e.prefix;if(s)r["continuation-token"]=s;let n=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e.bucket}`,queryParams:r}),i=n?.ListBucketResult??n,o=i?.Contents;if(o){let g=Array.isArray(o)?o:[o];for(let l of g)t.push({Key:l.Key,LastModified:l.LastModified||"",Size:Number.parseInt(l.Size||"0"),ETag:l.ETag})}let a=i?.IsTruncated;s=a==="true"||a===!0?i?.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=[],n=(t?.ListBucketResult??t)?.Contents;if(n){let i=Array.isArray(n)?n:[n];for(let o of i){if(e.prefix&&!o.Key?.startsWith(e.prefix))continue;if(s.push({Key:o.Key||"",LastModified:o.LastModified||"",Size:Number.parseInt(o.Size||"0"),ETag:o.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[n,i]of Object.entries(e.metadata))t[`x-amz-meta-${n}`]=i;let s=e.key.split("/").map((n)=>encodeURIComponent(n)).join("/"),r=e.body instanceof Uint8Array&&!Buffer.isBuffer(e.body)?Buffer.from(e.body):e.body;if(Buffer.isBuffer(r)||r instanceof Uint8Array){let n=Buffer.isBuffer(r)?r:Buffer.from(r),{accessKeyId:i,secretAccessKey:o,sessionToken:a}=this.getCredentials(),g=this.s3VirtualHost(e.bucket),l=this.objectPath(e.bucket,s),u=this.objectUrl(e.bucket,s),d=new Date,y=d.toISOString().replace(/[:-]|\.\d{3}/g,""),h=d.toISOString().slice(0,10).replace(/-/g,""),S=c.createHash("sha256").update(n).digest("hex"),m={host:g,"x-amz-date":y,"x-amz-content-sha256":S,...t};if(a)m["x-amz-security-token"]=a;let p=Object.keys(m).sort().map((f)=>`${f.toLowerCase()}:${m[f].trim()}
|
|
6
|
+
`).join(""),C=Object.keys(m).sort().map((f)=>f.toLowerCase()).join(";"),P=["PUT",l,"",p,C,S].join(`
|
|
7
|
+
`),k="AWS4-HMAC-SHA256",b=`${h}/${this.region}/s3/aws4_request`,v=[k,y,b,c.createHash("sha256").update(P).digest("hex")].join(`
|
|
8
|
+
`),q=c.createHmac("sha256",`AWS4${o}`).update(h).digest(),H=c.createHmac("sha256",q).update(this.region).digest(),E=c.createHmac("sha256",H).update("s3").digest(),w=c.createHmac("sha256",E).update("aws4_request").digest(),x=c.createHmac("sha256",w).update(v).digest("hex"),T=`${k} Credential=${i}/${b}, SignedHeaders=${C}, Signature=${x}`,A=await fetch(u,{method:"PUT",headers:{...m,Authorization:T},body:B(n)});if(!A.ok){let f=await A.text();throw Error(`S3 PUT failed: ${A.status} ${f}`)}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((n)=>encodeURIComponent(n)).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:r,sessionToken:n}=this.getCredentials(),i=this.s3VirtualHost(e),o=t.split("/").map((f)=>encodeURIComponent(f)).join("/"),a=this.objectPath(e,o),g=this.objectUrl(e,o),l=new Date,u=l.toISOString().replace(/[:-]|\.\d{3}/g,""),d=l.toISOString().slice(0,10).replace(/-/g,""),y=c.createHash("sha256").update("").digest("hex"),h={host:i,"x-amz-date":u,"x-amz-content-sha256":y};if(n)h["x-amz-security-token"]=n;let S=Object.keys(h).sort().map((f)=>`${f.toLowerCase()}:${h[f].trim()}
|
|
9
|
+
`).join(""),m=Object.keys(h).sort().map((f)=>f.toLowerCase()).join(";"),p=["GET",a,"",S,m,y].join(`
|
|
10
|
+
`),C="AWS4-HMAC-SHA256",P=`${d}/${this.region}/s3/aws4_request`,k=[C,u,P,c.createHash("sha256").update(p).digest("hex")].join(`
|
|
11
|
+
`),b=c.createHmac("sha256",`AWS4${r}`).update(d).digest(),v=c.createHmac("sha256",b).update(this.region).digest(),q=c.createHmac("sha256",v).update("s3").digest(),H=c.createHmac("sha256",q).update("aws4_request").digest(),E=c.createHmac("sha256",H).update(k).digest("hex"),w=`${C} Credential=${s}/${P}, SignedHeaders=${m}, Signature=${E}`,x=await fetch(g,{method:"GET",headers:{...h,Authorization:w}});if(!x.ok){let f=await x.text();throw Error(`S3 GET failed: ${x.status} ${f}`)}let T=await x.arrayBuffer(),A=x.headers.get("content-length");return{body:new Uint8Array(T),contentType:x.headers.get("content-type")??void 0,contentLength:A?Number.parseInt(A,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,r]of Object.entries(e.metadata))t[`x-amz-meta-${s}`]=r;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((r)=>encodeURIComponent(r)).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((n)=>`<Object><Key>${n}</Key></Object>`).join(`
|
|
14
|
+
`)}
|
|
15
|
+
</Delete>`,r=c.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":r}})}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((i)=>s.includes(i)))continue;if(e.include&&!e.include.some((i)=>s.includes(i)))continue;let r=s.substring(e.source.length+1),n=e.prefix?`${e.prefix}/${r}`:r;if(!e.dryRun){let i=D(s);await this.putObject({bucket:e.bucket,key:n,body:i,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 r=(await this.list({bucket:e,prefix:t})).map((n)=>n.Key);if(r.length>0)await this.deleteObjects(e,r)}async getBucketSize(e,t){return(await this.list({bucket:e,prefix:t})).reduce((r,n)=>r+n.Size,0)}async listFilesRecursive(e){let t=[],s=await z(e,{withFileTypes:!0});for(let r of s){let n=M(e,r.name);if(r.isDirectory()){let i=await this.listFilesRecursive(n);t.push(...i)}else t.push(n)}return t}async putBucketPolicy(e,t){let{accessKeyId:s,secretAccessKey:r,sessionToken:n}=this.getCredentials(),i=this.s3BaseHost(),o=typeof t==="string"?t:JSON.stringify(t),a=new Date,g=a.toISOString().replace(/[:-]|\.\d{3}/g,""),l=a.toISOString().slice(0,10).replace(/-/g,""),u=c.createHash("sha256").update(o).digest("hex"),d="/"+e,y="policy=",h={host:i,"x-amz-date":g,"x-amz-content-sha256":u,"content-type":"application/json"};if(n)h["x-amz-security-token"]=n;let S=Object.keys(h).sort().map((A)=>`${A.toLowerCase()}:${h[A].trim()}
|
|
16
|
+
`).join(""),m=Object.keys(h).sort().map((A)=>A.toLowerCase()).join(";"),p=["PUT",d,"policy=",S,m,u].join(`
|
|
17
|
+
`),C="AWS4-HMAC-SHA256",P=`${l}/${this.region}/s3/aws4_request`,k=[C,g,P,c.createHash("sha256").update(p).digest("hex")].join(`
|
|
18
|
+
`),b=c.createHmac("sha256","AWS4"+r).update(l).digest(),v=c.createHmac("sha256",b).update(this.region).digest(),q=c.createHmac("sha256",v).update("s3").digest(),H=c.createHmac("sha256",q).update("aws4_request").digest(),E=c.createHmac("sha256",H).update(k).digest("hex"),w=`${C} Credential=${s}/${P}, SignedHeaders=${m}, Signature=${E}`,x=`${this.endpointProtocol}://${i}${d}?policy=`,T=await fetch(x,{method:"PUT",headers:{...h,Authorization:w},body:o});if(!T.ok){let A=await T.text();throw Error(`Failed to put bucket policy: ${T.status} ${A}`)}}async getBucketPolicy(e){let{accessKeyId:t,secretAccessKey:s,sessionToken:r}=this.getCredentials(),n=this.s3BaseHost(),i=new Date,o=i.toISOString().replace(/[:-]|\.\d{3}/g,""),a=i.toISOString().slice(0,10).replace(/-/g,""),g=c.createHash("sha256").update("").digest("hex"),l="/"+e,u="policy=",d={host:n,"x-amz-date":o,"x-amz-content-sha256":g};if(r)d["x-amz-security-token"]=r;let y=Object.keys(d).sort().map((T)=>`${T.toLowerCase()}:${d[T].trim()}
|
|
19
|
+
`).join(""),h=Object.keys(d).sort().map((T)=>T.toLowerCase()).join(";"),S=["GET",l,"policy=",y,h,g].join(`
|
|
20
|
+
`),m="AWS4-HMAC-SHA256",p=`${a}/${this.region}/s3/aws4_request`,C=[m,o,p,c.createHash("sha256").update(S).digest("hex")].join(`
|
|
21
|
+
`),P=c.createHmac("sha256","AWS4"+s).update(a).digest(),k=c.createHmac("sha256",P).update(this.region).digest(),b=c.createHmac("sha256",k).update("s3").digest(),v=c.createHmac("sha256",b).update("aws4_request").digest(),q=c.createHmac("sha256",v).update(C).digest("hex"),H=`${m} Credential=${t}/${p}, SignedHeaders=${h}, Signature=${q}`,E=`${this.endpointProtocol}://${n}${l}?policy=`,w=await fetch(E,{method:"GET",headers:{...d,Authorization:H}});if(w.status===404)return null;if(!w.ok){let T=await w.text();throw Error(`Failed to get bucket policy: ${w.status} ${T}`)}let x=await w.text();return JSON.parse(x)}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,r){await this.putObject({bucket:e,key:t,body:JSON.stringify(s),contentType:"application/json",...r})}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 r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
25
|
+
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
26
|
+
${t.map((n)=>{let i=`<Rule><ID>${n.ID}</ID><Status>${n.Status}</Status>`;if(n.Filter)i+=`<Filter><Prefix>${n.Filter.Prefix||""}</Prefix></Filter>`;else i+="<Filter><Prefix></Prefix></Filter>";if(n.Expiration){if(n.Expiration.Days)i+=`<Expiration><Days>${n.Expiration.Days}</Days></Expiration>`;else if(n.Expiration.Date)i+=`<Expiration><Date>${n.Expiration.Date}</Date></Expiration>`}if(n.Transitions)for(let o of n.Transitions)i+=`<Transition><Days>${o.Days}</Days><StorageClass>${o.StorageClass}</StorageClass></Transition>`;if(n.NoncurrentVersionExpiration)i+=`<NoncurrentVersionExpiration><NoncurrentDays>${n.NoncurrentVersionExpiration.NoncurrentDays}</NoncurrentDays></NoncurrentVersionExpiration>`;return i+="</Rule>",i}).join("")}
|
|
27
|
+
</LifecycleConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{lifecycle:""},headers:{"Content-Type":"application/xml"},body:r})}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 r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
28
|
+
<CORSConfiguration>
|
|
29
|
+
${t.map((n)=>{let i="<CORSRule>";for(let o of n.AllowedOrigins)i+=`<AllowedOrigin>${o}</AllowedOrigin>`;for(let o of n.AllowedMethods)i+=`<AllowedMethod>${o}</AllowedMethod>`;if(n.AllowedHeaders)for(let o of n.AllowedHeaders)i+=`<AllowedHeader>${o}</AllowedHeader>`;if(n.ExposeHeaders)for(let o of n.ExposeHeaders)i+=`<ExposeHeader>${o}</ExposeHeader>`;if(n.MaxAgeSeconds)i+=`<MaxAgeSeconds>${n.MaxAgeSeconds}</MaxAgeSeconds>`;return i+="</CORSRule>",i}).join("")}
|
|
30
|
+
</CORSConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{cors:""},headers:{"Content-Type":"application/xml"},body:r})}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 r=`<ApplyServerSideEncryptionByDefault><SSEAlgorithm>${t}</SSEAlgorithm>`;if(s)r+=`<KMSMasterKeyID>${s}</KMSMasterKeyID>`;r+="</ApplyServerSideEncryptionByDefault>";let n=`<?xml version="1.0" encoding="UTF-8"?>
|
|
31
|
+
<ServerSideEncryptionConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
32
|
+
<Rule>${r}</Rule>
|
|
33
|
+
</ServerSideEncryptionConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{encryption:""},headers:{"Content-Type":"application/xml"},body:n})}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 r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
34
|
+
<Tagging>
|
|
35
|
+
<TagSet>${t.map((n)=>`<Tag><Key>${n.Key}</Key><Value>${n.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:r})}async deleteBucketTagging(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{tagging:""}})}async getObjectTagging(e,t){try{let r=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}/${t}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!r)return[];return Array.isArray(r)?r:[r]}catch(s){if(s.statusCode===404)return[];throw s}}async putObjectTagging(e,t,s){let n=`<?xml version="1.0" encoding="UTF-8"?>
|
|
37
|
+
<Tagging>
|
|
38
|
+
<TagSet>${s.map((i)=>`<Tag><Key>${i.Key}</Key><Value>${i.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:n})}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 r=`<?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:r})}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 n of t.LambdaFunctionConfigurations){if(s+="<CloudFunctionConfiguration>",n.Id)s+=`<Id>${n.Id}</Id>`;s+=`<CloudFunction>${n.LambdaFunctionArn}</CloudFunction>`;for(let i of n.Events)s+=`<Event>${i}</Event>`;if(n.Filter?.Key?.FilterRules){s+="<Filter><S3Key>";for(let i of n.Filter.Key.FilterRules)s+=`<FilterRule><Name>${i.Name}</Name><Value>${i.Value}</Value></FilterRule>`;s+="</S3Key></Filter>"}s+="</CloudFunctionConfiguration>"}if(t.TopicConfigurations)for(let n of t.TopicConfigurations){if(s+="<TopicConfiguration>",n.Id)s+=`<Id>${n.Id}</Id>`;s+=`<Topic>${n.TopicArn}</Topic>`;for(let i of n.Events)s+=`<Event>${i}</Event>`;s+="</TopicConfiguration>"}if(t.QueueConfigurations)for(let n of t.QueueConfigurations){if(s+="<QueueConfiguration>",n.Id)s+=`<Id>${n.Id}</Id>`;s+=`<Queue>${n.QueueArn}</Queue>`;for(let i of n.Events)s+=`<Event>${i}</Event>`;s+="</QueueConfiguration>"}let r=`<?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:r})}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 r=`<?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:r})}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:r,secretAccessKey:n}=this.getCredentials(),i=this.s3VirtualHost(e),o=new Date,a=o.toISOString().replace(/[:-]|\.\d{3}/g,""),g=o.toISOString().slice(0,10).replace(/-/g,""),l=`${g}/${this.region}/s3/aws4_request`,u=`${r}/${l}`,d=t.split("/").map((b)=>encodeURIComponent(b)).join("/"),y=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":u,"X-Amz-Date":a,"X-Amz-Expires":s.toString(),"X-Amz-SignedHeaders":"host"}),h=["GET",this.objectPath(e,d),y.toString(),`host:${i}
|
|
61
|
+
`,"host","UNSIGNED-PAYLOAD"].join(`
|
|
62
|
+
`),S=["AWS4-HMAC-SHA256",a,l,c.createHash("sha256").update(h).digest("hex")].join(`
|
|
63
|
+
`),m=c.createHmac("sha256",`AWS4${n}`).update(g).digest(),p=c.createHmac("sha256",m).update(this.region).digest(),C=c.createHmac("sha256",p).update("s3").digest(),P=c.createHmac("sha256",C).update("aws4_request").digest(),k=c.createHmac("sha256",P).update(S).digest("hex");return y.append("X-Amz-Signature",k),`${this.endpointProtocol}://${i}${this.objectPath(e,d)}?${y.toString()}`}generatePresignedPutUrl(e,t,s,r=3600){let{accessKeyId:n,secretAccessKey:i}=this.getCredentials(),o=this.s3VirtualHost(e),a=new Date,g=a.toISOString().replace(/[:-]|\.\d{3}/g,""),l=a.toISOString().slice(0,10).replace(/-/g,""),u=`${l}/${this.region}/s3/aws4_request`,d=`${n}/${u}`,y=t.split("/").map((v)=>encodeURIComponent(v)).join("/"),h=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":d,"X-Amz-Date":g,"X-Amz-Expires":r.toString(),"X-Amz-SignedHeaders":"content-type;host"}),S=["PUT",this.objectPath(e,y),h.toString(),`content-type:${s}
|
|
64
|
+
host:${o}
|
|
65
|
+
`,"content-type;host","UNSIGNED-PAYLOAD"].join(`
|
|
66
|
+
`),m=["AWS4-HMAC-SHA256",g,u,c.createHash("sha256").update(S).digest("hex")].join(`
|
|
67
|
+
`),p=c.createHmac("sha256",`AWS4${i}`).update(l).digest(),C=c.createHmac("sha256",p).update(this.region).digest(),P=c.createHmac("sha256",C).update("s3").digest(),k=c.createHmac("sha256",P).update("aws4_request").digest(),b=c.createHmac("sha256",k).update(m).digest("hex");return h.append("X-Amz-Signature",b),`${this.endpointProtocol}://${o}${this.objectPath(e,y)}?${h.toString()}`}async createMultipartUpload(e,t,s){let r={};if(s?.contentType)r["Content-Type"]=s.contentType;if(s?.metadata)for(let[a,g]of Object.entries(s.metadata))r[`x-amz-meta-${a}`]=g;let n=t.split("/").map((a)=>encodeURIComponent(a)).join("/"),i=await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${n}`,bucket:e,queryParams:{uploads:""},headers:r});return{UploadId:(i?.InitiateMultipartUploadResult??i)?.UploadId}}async uploadPart(e,t,s,r,n){let{accessKeyId:i,secretAccessKey:o,sessionToken:a}=this.getCredentials(),g=this.s3VirtualHost(e),l=t.split("/").map((j)=>encodeURIComponent(j)).join("/"),u=this.objectPath(e,l),d=`${this.objectUrl(e,l)}?partNumber=${r}&uploadId=${encodeURIComponent(s)}`,y=new Date,h=y.toISOString().replace(/[:-]|\.\d{3}/g,""),S=y.toISOString().slice(0,10).replace(/-/g,""),m=c.createHash("sha256").update(n).digest("hex"),p={host:g,"x-amz-date":h,"x-amz-content-sha256":m};if(a)p["x-amz-security-token"]=a;let C=Object.keys(p).sort().map((j)=>`${j.toLowerCase()}:${p[j].trim()}
|
|
68
|
+
`).join(""),P=Object.keys(p).sort().map((j)=>j.toLowerCase()).join(";"),k=["PUT",u,`partNumber=${r}&uploadId=${encodeURIComponent(s)}`,C,P,m].join(`
|
|
69
|
+
`),b="AWS4-HMAC-SHA256",v=`${S}/${this.region}/s3/aws4_request`,q=[b,h,v,c.createHash("sha256").update(k).digest("hex")].join(`
|
|
70
|
+
`),H=c.createHmac("sha256",`AWS4${o}`).update(S).digest(),E=c.createHmac("sha256",H).update(this.region).digest(),w=c.createHmac("sha256",E).update("s3").digest(),x=c.createHmac("sha256",w).update("aws4_request").digest(),T=c.createHmac("sha256",x).update(q).digest("hex"),A=`${b} Credential=${i}/${v}, SignedHeaders=${P}, Signature=${T}`,f=await fetch(d,{method:"PUT",headers:{...p,Authorization:A},body:B(n)});if(!f.ok){let j=await f.text();throw Error(`Upload part failed: ${f.status} ${j}`)}return{ETag:f.headers.get("etag")||""}}async completeMultipartUpload(e,t,s,r){let n=t.split("/").map((a)=>encodeURIComponent(a)).join("/"),o=`<?xml version="1.0" encoding="UTF-8"?>
|
|
71
|
+
<CompleteMultipartUpload>${r.sort((a,g)=>a.PartNumber-g.PartNumber).map((a)=>`<Part><PartNumber>${a.PartNumber}</PartNumber><ETag>${a.ETag}</ETag></Part>`).join("")}</CompleteMultipartUpload>`;await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${n}`,bucket:e,queryParams:{uploadId:s},headers:{"Content-Type":"application/xml"},body:o})}async abortMultipartUpload(e,t,s){let r=t.split("/").map((n)=>encodeURIComponent(n)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${r}`,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((n)=>({Key:n.Key,UploadId:n.UploadId,Initiated:n.Initiated}))}async restoreObject(e,t,s,r="Standard"){let n=`<?xml version="1.0" encoding="UTF-8"?>
|
|
72
|
+
<RestoreRequest>
|
|
73
|
+
<Days>${s}</Days>
|
|
74
|
+
<GlacierJobParameters>
|
|
75
|
+
<Tier>${r}</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:n})}async selectObjectContent(e,t,s,r,n="JSON"){let i="";if(r==="CSV")i="<CSV><FileHeaderInfo>USE</FileHeaderInfo></CSV>";else if(r==="JSON")i="<JSON><Type>DOCUMENT</Type></JSON>";else i="<Parquet/>";let o="";if(n==="CSV")o="<CSV/>";else o="<JSON/>";let a=`<?xml version="1.0" encoding="UTF-8"?>
|
|
78
|
+
<SelectObjectContentRequest>
|
|
79
|
+
<Expression>${s}</Expression>
|
|
80
|
+
<ExpressionType>SQL</ExpressionType>
|
|
81
|
+
<InputSerialization>${i}</InputSerialization>
|
|
82
|
+
<OutputSerialization>${o}</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:a,rawResponse:!0})}async getSignedUrl(e){let{bucket:t,key:s,expiresIn:r=3600,operation:n="getObject"}=e,{accessKeyId:i,secretAccessKey:o,sessionToken:a}=this.getCredentials(),g=new Date,l=g.toISOString().replace(/[:-]|\.\d{3}/g,""),u=g.toISOString().slice(0,10).replace(/-/g,""),d=this.s3VirtualHost(t),y=n==="putObject"?"PUT":"GET",h="AWS4-HMAC-SHA256",S=`${u}/${this.region}/s3/aws4_request`,p={"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":`${i}/${S}`,"X-Amz-Date":l,"X-Amz-Expires":r.toString(),"X-Amz-SignedHeaders":"host"};if(a)p["X-Amz-Security-Token"]=a;let P=Object.keys(p).sort().map((I)=>`${encodeURIComponent(I)}=${encodeURIComponent(p[I])}`).join("&"),k=s.split("/").map((I)=>encodeURIComponent(I)).join("/"),b=this.objectPath(t,k),v=`host:${d}
|
|
84
|
+
`,E=[y,b,P,v,"host","UNSIGNED-PAYLOAD"].join(`
|
|
85
|
+
`),w=["AWS4-HMAC-SHA256",l,S,c.createHash("sha256").update(E).digest("hex")].join(`
|
|
86
|
+
`),x=c.createHmac("sha256",`AWS4${o}`).update(u).digest(),T=c.createHmac("sha256",x).update(this.region).digest(),A=c.createHmac("sha256",T).update("s3").digest(),f=c.createHmac("sha256",A).update("aws4_request").digest(),j=c.createHmac("sha256",f).update(w).digest("hex");return`${this.endpointProtocol}://${d}${b}?${P}&X-Amz-Signature=${j}`}async listObjects(e){let{bucket:t,prefix:s,maxKeys:r=1000,continuationToken:n}=e,i={"list-type":"2","max-keys":r.toString()};if(s)i.prefix=s;if(n)i["continuation-token"]=n;let o=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${t}`,queryParams:i}),a=[],g=o?.ListBucketResult??o;if(g?.Contents){let l=Array.isArray(g.Contents)?g.Contents:[g.Contents];for(let u of l)a.push({Key:u.Key||"",LastModified:u.LastModified||"",Size:Number.parseInt(u.Size||"0"),ETag:u.ETag})}return{objects:a,nextContinuationToken:g?.NextContinuationToken}}async emptyBucket(e){let t=0,s=await this.listAllObjects({bucket:e});if(s.length>0)for(let r=0;r<s.length;r+=1000){let i=s.slice(r,r+1000).map((o)=>o.Key);await this.deleteObjects(e,i),t+=i.length}try{let r,n;do{let i=await this.listObjectVersions({bucket:e,keyMarker:r,versionIdMarker:n,maxKeys:1000}),o=[];if(i.versions)for(let a of i.versions)o.push({Key:a.Key,VersionId:a.VersionId});if(i.deleteMarkers)for(let a of i.deleteMarkers)o.push({Key:a.Key,VersionId:a.VersionId});if(o.length>0)await this.deleteObjectVersions(e,o),t+=o.length;r=i.nextKeyMarker,n=i.nextVersionIdMarker}while(r)}catch{}return{deletedCount:t}}async listObjectVersions(e){let{bucket:t,prefix:s,keyMarker:r,versionIdMarker:n,maxKeys:i=1000}=e,o={versions:"","max-keys":i.toString()};if(s)o.prefix=s;if(r)o["key-marker"]=r;if(n)o["version-id-marker"]=n;let a=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${t}`,queryParams:o}),g=[],l=[];if(a.Version){let u=Array.isArray(a.Version)?a.Version:[a.Version];for(let d of u)g.push({Key:d.Key,VersionId:d.VersionId,IsLatest:d.IsLatest==="true"})}if(a.DeleteMarker){let u=Array.isArray(a.DeleteMarker)?a.DeleteMarker:[a.DeleteMarker];for(let d of u)l.push({Key:d.Key,VersionId:d.VersionId,IsLatest:d.IsLatest==="true"})}return{versions:g,deleteMarkers:l,nextKeyMarker:a.NextKeyMarker,nextVersionIdMarker:a.NextVersionIdMarker}}async deleteObjectVersions(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
|
|
87
|
+
<Delete>
|
|
88
|
+
<Quiet>true</Quiet>
|
|
89
|
+
${t.map((n)=>`<Object><Key>${n.Key}</Key>${n.VersionId?`<VersionId>${n.VersionId}</VersionId>`:""}</Object>`).join(`
|
|
90
|
+
`)}
|
|
91
|
+
</Delete>`,r=c.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":r}})}}
|
|
92
|
+
export{R as og,V as pg};
|