@stacksjs/ts-cloud 0.16.28 → 0.16.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/aws/cloudfront.d.ts +9 -0
  2. package/dist/aws/index.js +1 -1
  3. package/dist/bin/chunk-052sk11z.js +1 -0
  4. package/dist/bin/chunk-0n0jscsr.js +1 -0
  5. package/dist/bin/{chunk-xss6yj73.js → chunk-0sht4yfg.js} +2 -2
  6. package/dist/bin/chunk-10sypz59.js +1 -0
  7. package/dist/bin/{chunk-qx05kccj.js → chunk-1chq0c2k.js} +1 -1
  8. package/dist/bin/chunk-1d4663e1.js +1 -0
  9. package/dist/bin/{chunk-k545r9bk.js → chunk-1wtkv65w.js} +2 -2
  10. package/dist/bin/chunk-223yq2z0.js +1 -0
  11. package/dist/bin/{chunk-494fg5c6.js → chunk-2q64f0df.js} +17 -15
  12. package/dist/bin/{chunk-qfgvvwmb.js → chunk-3ykx59eg.js} +3 -3
  13. package/dist/bin/chunk-4ab2bceq.js +1 -0
  14. package/dist/bin/{chunk-wsedynyb.js → chunk-573red0g.js} +6 -6
  15. package/dist/bin/chunk-5nf3fxgw.js +1 -0
  16. package/dist/bin/{chunk-0hbrkdrc.js → chunk-6hrycgbh.js} +3 -3
  17. package/dist/bin/chunk-6k5g8b1w.js +2 -0
  18. package/dist/bin/{chunk-kbwczaa8.js → chunk-7577ykbj.js} +1 -1
  19. package/dist/bin/{chunk-rfvx641h.js → chunk-8c4fnga8.js} +1 -1
  20. package/dist/bin/{chunk-9464wvf2.js → chunk-8d8tdhtx.js} +5 -5
  21. package/dist/bin/chunk-9jmt42fx.js +1 -0
  22. package/dist/bin/{chunk-c0dh5ccy.js → chunk-9nnfyqme.js} +3 -3
  23. package/dist/bin/{chunk-ffyhp5tk.js → chunk-9p7g25kx.js} +55 -55
  24. package/dist/bin/{chunk-e3tjy3wg.js → chunk-a1kpwbjg.js} +5 -5
  25. package/dist/bin/{chunk-7412q5cz.js → chunk-a3vraghd.js} +2 -2
  26. package/dist/bin/chunk-a8b2a3ab.js +1 -0
  27. package/dist/bin/{chunk-ypsgkj91.js → chunk-a9yp82q5.js} +2 -2
  28. package/dist/bin/{chunk-13htvxgc.js → chunk-bkzt5ntz.js} +1 -1
  29. package/dist/bin/chunk-ckmgwd81.js +1 -0
  30. package/dist/bin/{chunk-66f51kn2.js → chunk-dmyr6etw.js} +2 -2
  31. package/dist/bin/{chunk-st7s9k78.js → chunk-e4p6hwct.js} +5 -5
  32. package/dist/bin/{chunk-az5vvf5d.js → chunk-e6xn8g28.js} +1 -1
  33. package/dist/bin/chunk-ecxchy9q.js +1 -0
  34. package/dist/bin/chunk-ee6ssn26.js +1 -0
  35. package/dist/bin/chunk-g1krw34t.js +1 -0
  36. package/dist/bin/chunk-gcazbfsv.js +1 -0
  37. package/dist/bin/chunk-gg6vwdnn.js +1 -0
  38. package/dist/bin/chunk-gz0gahzh.js +1 -0
  39. package/dist/bin/chunk-hdkxj8p9.js +1 -0
  40. package/dist/bin/chunk-hg60j47r.js +1 -0
  41. package/dist/bin/{chunk-5810132y.js → chunk-j2yy3tth.js} +1 -1
  42. package/dist/bin/{chunk-2857cbf1.js → chunk-j8dkatkk.js} +4 -4
  43. package/dist/bin/chunk-je602ntp.js +1 -0
  44. package/dist/bin/{chunk-817q3s2p.js → chunk-jeg6vw5v.js} +4 -4
  45. package/dist/bin/{chunk-1g8gk1cb.js → chunk-jf8jp6f5.js} +3 -3
  46. package/dist/bin/chunk-jxh78anm.js +1 -0
  47. package/dist/bin/{chunk-8k87zpnp.js → chunk-k8r5zfnf.js} +14 -14
  48. package/dist/bin/{chunk-8npkajnt.js → chunk-k9d81ar0.js} +51 -51
  49. package/dist/bin/{chunk-4a8qt6e8.js → chunk-kne9dmwr.js} +102 -102
  50. package/dist/bin/chunk-mv0t7j76.js +1 -0
  51. package/dist/bin/chunk-p8f1qgz2.js +1 -0
  52. package/dist/bin/chunk-pa106cr4.js +1 -0
  53. package/dist/bin/{chunk-y5e7dmvc.js → chunk-q9tvzcr7.js} +4 -4
  54. package/dist/bin/{chunk-cgyqnbcm.js → chunk-remzfbhd.js} +5 -5
  55. package/dist/bin/chunk-rs50jra0.js +60 -0
  56. package/dist/bin/{chunk-2chec65b.js → chunk-s3mv4z3f.js} +2 -2
  57. package/dist/bin/chunk-w3815pxd.js +1 -0
  58. package/dist/bin/{chunk-s5hq7v1h.js → chunk-xtqx4v3f.js} +1 -1
  59. package/dist/bin/{chunk-kcprsn33.js → chunk-y9cdqk8c.js} +1 -1
  60. package/dist/bin/{chunk-8knkt6sd.js → chunk-yccdr4be.js} +1 -1
  61. package/dist/bin/{chunk-eshss5qy.js → chunk-yqkdyf0w.js} +2 -2
  62. package/dist/bin/{chunk-45v1azhc.js → chunk-yrq5bkxe.js} +1 -1
  63. package/dist/bin/cli.js +83 -83
  64. package/dist/bin/dashboard-server.js +1 -1
  65. package/dist/{chunk-h85wqdvr.js → chunk-10asqy6j.js} +7 -7
  66. package/dist/{chunk-twj83txn.js → chunk-26cq0zjv.js} +4 -4
  67. package/dist/chunk-27hj07fb.js +60 -0
  68. package/dist/{chunk-w23wrsa4.js → chunk-2c8pcbq8.js} +134 -134
  69. package/dist/{chunk-fvgk05df.js → chunk-3byba7sc.js} +25 -23
  70. package/dist/{chunk-6e5j40n9.js → chunk-3harnmd6.js} +2 -2
  71. package/dist/chunk-3kpnn06d.js +1 -0
  72. package/dist/{chunk-b10n1xy5.js → chunk-75bga11p.js} +4 -4
  73. package/dist/{chunk-gvybjt7y.js → chunk-89rs2afj.js} +1 -1
  74. package/dist/{chunk-wyfpz6be.js → chunk-92w1g5d9.js} +1 -1
  75. package/dist/chunk-94tb2msg.js +1 -0
  76. package/dist/{chunk-bx1znp1q.js → chunk-9g8as6sa.js} +2 -2
  77. package/dist/{chunk-49p5cx21.js → chunk-9n0q2cxj.js} +28 -28
  78. package/dist/{chunk-dygr8ewz.js → chunk-b6ar7eqc.js} +3 -3
  79. package/dist/{chunk-9mccwk6f.js → chunk-bzd8zmtg.js} +144 -144
  80. package/dist/chunk-d8wcqgpx.js +1 -0
  81. package/dist/{chunk-ys5318bg.js → chunk-dm4vt53n.js} +2 -2
  82. package/dist/{chunk-q0g0rjn3.js → chunk-f733qy2d.js} +2 -2
  83. package/dist/{chunk-njz7scff.js → chunk-ffxcn7mw.js} +1 -1
  84. package/dist/chunk-gv2m8yyg.js +1 -0
  85. package/dist/{chunk-4ka2s5d8.js → chunk-h3kkh31v.js} +67 -67
  86. package/dist/{chunk-98qx6m9h.js → chunk-m3a4brpj.js} +19 -19
  87. package/dist/{chunk-rr1qjxyj.js → chunk-m5vwh9tb.js} +1 -1
  88. package/dist/{chunk-55yda01s.js → chunk-m93g67j0.js} +4 -4
  89. package/dist/chunk-mqm1hxaw.js +2 -0
  90. package/dist/{chunk-cymsceq6.js → chunk-qjxdhb8x.js} +2 -2
  91. package/dist/{chunk-q70pfhcn.js → chunk-qrs912nk.js} +3 -3
  92. package/dist/{chunk-fjwxfwr3.js → chunk-t3yzfbe7.js} +9 -9
  93. package/dist/chunk-y37887r3.js +1 -0
  94. package/dist/{chunk-qx6nwvgn.js → chunk-yc2rm4v9.js} +1 -1
  95. package/dist/{chunk-qfqh21rq.js → chunk-zesd879q.js} +5 -5
  96. package/dist/deploy/index.js +1 -1
  97. package/dist/dns/index.js +1 -1
  98. package/dist/drivers/index.js +1 -1
  99. package/dist/index.d.ts +1 -1
  100. package/dist/index.js +36 -36
  101. package/dist/operations/index.js +1 -1
  102. package/dist/protection/index.js +1 -1
  103. package/dist/spend/index.js +1 -1
  104. package/dist/ui/404.html +1 -1
  105. package/dist/ui/accept-invitation.html +1 -1
  106. package/dist/ui/access-denied.html +1 -1
  107. package/dist/ui/account/automation.html +6 -6
  108. package/dist/ui/account/security.html +2 -2
  109. package/dist/ui/applications/compose.html +6 -6
  110. package/dist/ui/applications/new.html +1 -1
  111. package/dist/ui/data/backups.html +6 -6
  112. package/dist/ui/data/services.html +6 -6
  113. package/dist/ui/data/volumes.html +6 -6
  114. package/dist/ui/index.html +6 -6
  115. package/dist/ui/infrastructure/topology.html +6 -6
  116. package/dist/ui/integrations.html +1 -1
  117. package/dist/ui/operations/alerts.html +6 -6
  118. package/dist/ui/operations/configuration.html +6 -6
  119. package/dist/ui/operations/jobs.html +5 -5
  120. package/dist/ui/operations/maintenance.html +6 -6
  121. package/dist/ui/operations/observability.html +6 -6
  122. package/dist/ui/operations/previews.html +6 -6
  123. package/dist/ui/operations/queue.html +6 -6
  124. package/dist/ui/operations/regions.html +6 -6
  125. package/dist/ui/operations/releases.html +6 -6
  126. package/dist/ui/operations/spend.html +5 -5
  127. package/dist/ui/operations/workloads.html +6 -6
  128. package/dist/ui/security.html +1 -1
  129. package/dist/ui/server/actions.html +5 -5
  130. package/dist/ui/server/activity.html +1 -1
  131. package/dist/ui/server/capacity.html +5 -5
  132. package/dist/ui/server/database.html +6 -6
  133. package/dist/ui/server/deployments.html +5 -5
  134. package/dist/ui/server/diagnostics.html +2 -2
  135. package/dist/ui/server/firewall.html +6 -6
  136. package/dist/ui/server/fleet.html +6 -6
  137. package/dist/ui/server/logs.html +6 -6
  138. package/dist/ui/server/metrics.html +5 -5
  139. package/dist/ui/server/security.html +2 -2
  140. package/dist/ui/server/services.html +2 -2
  141. package/dist/ui/server/sites.html +6 -6
  142. package/dist/ui/server/ssh-keys.html +6 -6
  143. package/dist/ui/server/team.html +6 -6
  144. package/dist/ui/server/terminal.html +2 -2
  145. package/dist/ui/serverless/alarms.html +5 -5
  146. package/dist/ui/serverless/assets.html +2 -2
  147. package/dist/ui/serverless/cost.html +2 -2
  148. package/dist/ui/serverless/data.html +6 -6
  149. package/dist/ui/serverless/deployments.html +2 -2
  150. package/dist/ui/serverless/firewall.html +2 -2
  151. package/dist/ui/serverless/functions.html +5 -5
  152. package/dist/ui/serverless/logs.html +6 -6
  153. package/dist/ui/serverless/metrics.html +2 -2
  154. package/dist/ui/serverless/queues.html +6 -6
  155. package/dist/ui/serverless/secrets.html +6 -6
  156. package/dist/ui/serverless/traces.html +6 -6
  157. package/dist/ui/serverless.html +5 -5
  158. package/package.json +3 -3
  159. package/dist/bin/chunk-10dnawvx.js +0 -1
  160. package/dist/bin/chunk-2ar52zq0.js +0 -1
  161. package/dist/bin/chunk-4fwbwjjj.js +0 -1
  162. package/dist/bin/chunk-57f4mqzk.js +0 -1
  163. package/dist/bin/chunk-ank4fmbx.js +0 -1
  164. package/dist/bin/chunk-b4p9zknk.js +0 -1
  165. package/dist/bin/chunk-f922vrbs.js +0 -1
  166. package/dist/bin/chunk-hvd87xj9.js +0 -1
  167. package/dist/bin/chunk-jxyt009c.js +0 -1
  168. package/dist/bin/chunk-k0akp8k0.js +0 -1
  169. package/dist/bin/chunk-k6dxgzm6.js +0 -1
  170. package/dist/bin/chunk-ne5zevtf.js +0 -60
  171. package/dist/bin/chunk-qxssaa4s.js +0 -1
  172. package/dist/bin/chunk-s7gk1qx2.js +0 -1
  173. package/dist/bin/chunk-t644w5rw.js +0 -1
  174. package/dist/bin/chunk-tgke0nzb.js +0 -1
  175. package/dist/bin/chunk-twq6s0nd.js +0 -1
  176. package/dist/bin/chunk-vknq0ap2.js +0 -1
  177. package/dist/bin/chunk-x2r1zm2r.js +0 -1
  178. package/dist/bin/chunk-y7n9tcqw.js +0 -1
  179. package/dist/bin/chunk-z5ycwy38.js +0 -2
  180. package/dist/bin/chunk-za9np4pg.js +0 -1
  181. package/dist/bin/chunk-zq02x716.js +0 -1
  182. package/dist/bin/chunk-zqa6jarz.js +0 -1
  183. package/dist/bin/chunk-zrjf1pqy.js +0 -1
  184. package/dist/bin/chunk-zvt7as22.js +0 -1
  185. package/dist/chunk-2p85fnx5.js +0 -1
  186. package/dist/chunk-3q242cqb.js +0 -1
  187. package/dist/chunk-6eqx6gt8.js +0 -60
  188. package/dist/chunk-cykr6zyj.js +0 -1
  189. package/dist/chunk-h5gvh859.js +0 -1
  190. package/dist/chunk-mqscxx2z.js +0 -1
  191. package/dist/chunk-rxs4y74z.js +0 -2
@@ -142,6 +142,15 @@ export interface RawDistributionConfig {
142
142
  OriginGroups?: Record<string, any>;
143
143
  [field: string]: any;
144
144
  }
145
+ /** A parsed distribution config's origins as a list, whether it holds one or several. */
146
+ export declare function configOrigins(config: RawDistributionConfig | undefined): RawOrigin[];
147
+ /**
148
+ * The bucket behind a config's first S3 origin, read from its domain name:
149
+ * `<bucket>.s3.amazonaws.com`, `<bucket>.s3.<region>.amazonaws.com` or
150
+ * `<bucket>.s3-website-<region>.amazonaws.com`. Bucket names may contain dots,
151
+ * which the `^([^.]+)` pattern this replaces cut at the first one.
152
+ */
153
+ export declare function s3OriginBucket(config: RawDistributionConfig | undefined): string | undefined;
145
154
  /**
146
155
  * CloudFront client using direct API calls
147
156
  */
package/dist/aws/index.js CHANGED
@@ -1 +1 @@
1
- import{Ae,nr,ls,us,bu,Qa,Ha,ps,gs,Ga,tt,z,rt,se,b,ye,An,qa,Oe,Va,yn,In,Sn,vh,Th,Ny,ky,By,_y,wt,xy,Oy,Ly,$y,Rt,wh,Rh,Dh,Dt,Ph,Nh,kh,Cn,My,Fy,Uy,ir,Qy,Hy,Gy,ja,za,vu,qy,Vy,jy,sr,Bh,_h,or,nt,En,Ka,Tu,zy,wu,Ky,Pt,Wy,Jy,Xy,Yy,ae,Zy,eI,tI,rI,ar,nI,iI,sI,bn,Wa,Ja,Ru,Du,Xa,cr}from"../chunk-fjwxfwr3.js";import{Ie,it,vn,xh}from"../chunk-dygr8ewz.js";import{y}from"../chunk-fvgk05df.js";import{Le}from"../chunk-ys5318bg.js";import{K}from"../chunk-wyfpz6be.js";import{st,ce,$e,Se,Nt,wn,hs,fs,dr,lr,Rn,ur,As,ys,Is,Ss,W,Cs,Es,bs,vs,de,Ts,ws,Rs,R,ec,Dn,tc,le,pr}from"../chunk-cymsceq6.js";import{S}from"../chunk-njz7scff.js";import{Tr,we}from"../chunk-bx1znp1q.js";import{f}from"../chunk-qx6nwvgn.js";import{o}from"../chunk-q70pfhcn.js";import{Rr,di,n,l,tf}from"../chunk-55yda01s.js";export{le as ACMClient,pr as ACMDnsValidator,n as AWSClient,Ka as ApplicationAutoScalingClient,nr as AwsBackupClient,Th as BedrockAgentClient,vh as BedrockAgentRuntimeClient,Sn as BedrockClient,In as BedrockRuntimeClient,f as CloudFormationClient,y as CloudFrontClient,ye as CloudWatchLogsClient,Se as CloudflareProvider,wt as ComprehendClient,An as ConnectClient,gs as CostExplorerClient,Dn as DnsProviderFactory,Oe as DynamoDBClient,Tr as EC2Client,Le as ECRClient,tt as ECSClient,cr as EFSClient,qa as ELBv2Client,nt as ElastiCacheClient,vn as EmailClient,or as EventBridgeClient,$e as GoDaddyProvider,Ie as IAMClient,Tu as ImapServer,sr as KendraClient,b as LambdaClient,Va as OpenSearchClient,st as PROXIABLE_RECORD_TYPES,ja as PersonalizeClient,vu as PersonalizeEventsClient,za as PersonalizeRuntimeClient,Cn as PollyClient,ce as PorkbunProvider,K as RDSClient,Rt as RekognitionClient,S as Route53Client,Ga as Route53DomainsClient,W as Route53Provider,o as S3Client,it as SESClient,rt as SNSClient,se as SQSClient,we as SSMClient,Ae as STSClient,En as SchedulerClient,z as SecretsManagerClient,Pt as SmsClient,Xa as SmsVoiceClient,wu as SmtpServer,bn as SupportClient,Wa as SupportTemplates,Dt as TextractClient,yn as TranscribeClient,ir as TranslateClient,de as UnifiedDnsValidator,ar as VoiceClient,xy as analyzeSentiment,Is as applyDeclaredZoneSettings,bs as applyZoneMigration,l as buildQueryParams,di as coerceXmlValues,By as completeWithClaude,$y as containsPii,Rh as countFacesInS3Image,Yy as createDeliveryReceiptHandler,R as createDnsProvider,ws as createGoDaddyValidator,ps as createObjectStorageClient,Ts as createPorkbunValidator,iI as createRecordingHandler,Rs as createRoute53Validator,Uy as createSSML,Jy as createScheduledSmsHandler,Xy as createSmsClient,Wy as createSmsInboxHandler,Du as createSmsInfrastructure,sI as createVoiceClient,nI as createVoicemailHandler,ur as delegateZone,As as delegateZoneFromConfig,ys as describeDelegation,Ss as describeZoneSettings,tf as detectCredentialSource,ec as detectDnsProvider,wh as detectLabelsFromS3,Ly as detectLanguage,tc as dnsProviders,xh as email,Cs as exportRoute53Zone,Oy as extractEntities,Nh as extractFormsFromS3,kh as extractTablesFromS3,Ph as extractTextFromS3,Zy as formatPhoneNumber,_y as generateEmbeddings,tI as getCountryCode,qy as getRecommendations,Vy as getSimilarItems,Ru as getSmsInfrastructureStatus,Dh as isContentSafe,dr as isNameserverRegistrar,rI as isSamePhoneNumber,eI as isValidPhoneNumber,lr as isZoneHost,us as keyMatchesFilters,ky as listClaudeModels,Gy as listLanguages,Fy as listVoices,bu as migrateObjectStorage,ae as normalizePhoneNumber,Es as planZoneMigration,Nt as policyTag,Qa as providerEndpoint,wn as qualifyName,fs as reconcileDeclaredRecords,ls as remapKey,Ny as requestModelAccess,hs as resolveDeclaredRecords,Ha as resolveObjectStorage,Rr as resolveS3Endpoint,_h as retrieveForRag,Rn as sameNameservers,Bh as search,Ja as setupSmsInfrastructure,zy as startImapServer,Ky as startSmtpServer,My as textToSpeech,jy as trackEvent,Qy as translate,Hy as translateToMultiple,vs as verifyZoneParity};
1
+ import{Ae,ir,us,ps,Tu,Ha,Ga,gs,ms,qa,rt,z,nt,se,b,ye,yn,Va,Oe,ja,In,Sn,Cn,wh,Rh,By,_y,xy,Oy,Rt,Ly,$y,My,Fy,Dt,Dh,Ph,Nh,Pt,kh,Bh,_h,En,Uy,Qy,Hy,sr,Gy,qy,Vy,za,Ka,wu,jy,zy,Ky,or,xh,Oh,ar,it,bn,Wa,Ru,Wy,Du,Jy,Nt,Xy,Yy,Zy,eI,ae,tI,rI,nI,iI,cr,sI,oI,aI,vn,Ja,Xa,Pu,Nu,Ya,dr}from"../chunk-t3yzfbe7.js";import{Ie,st,Tn,Lh}from"../chunk-b6ar7eqc.js";import{Za,Le,I}from"../chunk-3byba7sc.js";import{$e}from"../chunk-dm4vt53n.js";import{K}from"../chunk-92w1g5d9.js";import{ot,ce,Me,Se,kt,Rn,fs,As,lr,ur,Dn,pr,ys,Is,Ss,Cs,W,Es,bs,vs,Ts,de,ws,Rs,Ds,R,rc,Pn,nc,le,gr}from"../chunk-qjxdhb8x.js";import{S}from"../chunk-ffxcn7mw.js";import{wr,we}from"../chunk-9g8as6sa.js";import{f}from"../chunk-yc2rm4v9.js";import{o}from"../chunk-qrs912nk.js";import{Dr,li,n,l,nf}from"../chunk-m93g67j0.js";export{le as ACMClient,gr as ACMDnsValidator,n as AWSClient,Wa as ApplicationAutoScalingClient,ir as AwsBackupClient,Rh as BedrockAgentClient,wh as BedrockAgentRuntimeClient,Cn as BedrockClient,Sn as BedrockRuntimeClient,f as CloudFormationClient,I as CloudFrontClient,ye as CloudWatchLogsClient,Se as CloudflareProvider,Rt as ComprehendClient,yn as ConnectClient,ms as CostExplorerClient,Pn as DnsProviderFactory,Oe as DynamoDBClient,wr as EC2Client,$e as ECRClient,rt as ECSClient,dr as EFSClient,Va as ELBv2Client,it as ElastiCacheClient,Tn as EmailClient,ar as EventBridgeClient,Me as GoDaddyProvider,Ie as IAMClient,Ru as ImapServer,or as KendraClient,b as LambdaClient,ja as OpenSearchClient,ot as PROXIABLE_RECORD_TYPES,za as PersonalizeClient,wu as PersonalizeEventsClient,Ka as PersonalizeRuntimeClient,En as PollyClient,ce as PorkbunProvider,K as RDSClient,Dt as RekognitionClient,S as Route53Client,qa as Route53DomainsClient,W as Route53Provider,o as S3Client,st as SESClient,nt as SNSClient,se as SQSClient,we as SSMClient,Ae as STSClient,bn as SchedulerClient,z as SecretsManagerClient,Nt as SmsClient,Ya as SmsVoiceClient,Du as SmtpServer,vn as SupportClient,Ja as SupportTemplates,Pt as TextractClient,In as TranscribeClient,sr as TranslateClient,de as UnifiedDnsValidator,cr as VoiceClient,Ly as analyzeSentiment,Ss as applyDeclaredZoneSettings,vs as applyZoneMigration,l as buildQueryParams,li as coerceXmlValues,xy as completeWithClaude,Za as configOrigins,Fy as containsPii,Ph as countFacesInS3Image,eI as createDeliveryReceiptHandler,R as createDnsProvider,Rs as createGoDaddyValidator,gs as createObjectStorageClient,ws as createPorkbunValidator,oI as createRecordingHandler,Ds as createRoute53Validator,Hy as createSSML,Yy as createScheduledSmsHandler,Zy as createSmsClient,Xy as createSmsInboxHandler,Nu as createSmsInfrastructure,aI as createVoiceClient,sI as createVoicemailHandler,pr as delegateZone,ys as delegateZoneFromConfig,Is as describeDelegation,Cs as describeZoneSettings,nf as detectCredentialSource,rc as detectDnsProvider,Dh as detectLabelsFromS3,My as detectLanguage,nc as dnsProviders,Lh as email,Es as exportRoute53Zone,$y as extractEntities,Bh as extractFormsFromS3,_h as extractTablesFromS3,kh as extractTextFromS3,tI as formatPhoneNumber,Oy as generateEmbeddings,nI as getCountryCode,jy as getRecommendations,zy as getSimilarItems,Pu as getSmsInfrastructureStatus,Nh as isContentSafe,lr as isNameserverRegistrar,iI as isSamePhoneNumber,rI as isValidPhoneNumber,ur as isZoneHost,ps as keyMatchesFilters,_y as listClaudeModels,Vy as listLanguages,Qy as listVoices,Tu as migrateObjectStorage,ae as normalizePhoneNumber,bs as planZoneMigration,kt as policyTag,Ha as providerEndpoint,Rn as qualifyName,As as reconcileDeclaredRecords,us as remapKey,By as requestModelAccess,fs as resolveDeclaredRecords,Ga as resolveObjectStorage,Dr as resolveS3Endpoint,Oh as retrieveForRag,Le as s3OriginBucket,Dn as sameNameservers,xh as search,Xa as setupSmsInfrastructure,Wy as startImapServer,Jy as startSmtpServer,Uy as textToSpeech,Ky as trackEvent,Gy as translate,qy as translateToMultiple,Ts as verifyZoneParity};
@@ -0,0 +1 @@
1
+ import{R}from"./chunk-1chq0c2k.js";import"./chunk-q9tvzcr7.js";export{R as LambdaClient};
@@ -0,0 +1 @@
1
+ import{Uu,Yl,Aa,Ia,Zl,Bu,Fu,Gt,pn,Kt,Ri,ju,mn,zo}from"./chunk-yccdr4be.js";import{Xe,Ss,sc,si,bs,lp}from"./chunk-8d8tdhtx.js";import{bd,Zi,vd,Td,Ed,yr,dp,eo}from"./chunk-573red0g.js";import{ba,va,Ta,Fl,Fo,jl,Vl,Ea,zl,Hl}from"./chunk-kne9dmwr.js";export{va as CHAIN_HEADER,pn as DEFAULT_ATTACK_MODE_HOURS,bd as DEFAULT_DDOS_THRESHOLDS,Fo as DEFAULT_RECURSION_LIMITS,ba as DEPTH_HEADER,Gt as MAX_CONTROL_HOURS,Kt as ProtectionControlStore,Uu as RATE_LIMIT_KEY_SEPARATOR,Zl as RateLimiter,Ea as RecursionGuard,Ta as TRACE_HEADER,mn as applyControlsToDdos,ju as applyControlsToRateLimits,eo as applyMitigationFactor,Fu as defaultRateLimitRules,Ri as describePosture,Xe as escapeSecLang,Fl as functionFingerprint,Yl as globMatches,sc as globToRegex,Vl as inspectInvocation,Ss as isSafePattern,Zi as isValidCidr,zo as mergeControlsIntoConfig,jl as parseChain,dp as planMitigation,zl as propagationHeaders,Bu as rateLimitHeaders,Ia as rateLimitKey,Hl as recursionBlockedResponse,yr as renderDdosInstallScript,Ed as renderNftablesRuleset,Td as renderSysctlFile,si as renderWafConfig,bs as renderWafInstallScript,Aa as ruleMatches,vd as sysctlHardening,lp as wafEventTelemetry};
@@ -1,2 +1,2 @@
1
- var M=[{index:0,id:"clients",label:"Clients"},{index:1,id:"dns",label:"DNS & TLS"},{index:2,id:"edge",label:"Edge"},{index:3,id:"routing",label:"Routing"},{index:4,id:"apps",label:"Applications"},{index:5,id:"runtime",label:"Background runtime"},{index:6,id:"data",label:"Data services"},{index:7,id:"durability",label:"Durability"}],N=[{index:0,id:"clients",label:"Clients"},{index:1,id:"dns",label:"DNS & TLS"},{index:2,id:"edge",label:"Edge"},{index:3,id:"entry",label:"Entry points"},{index:4,id:"compute",label:"Compute"},{index:5,id:"messaging",label:"Messaging & pooling"},{index:6,id:"data",label:"Data services"},{index:7,id:"durability",label:"Durability"}],P=[{match:/^redis/,kind:"cache",label:"Redis"},{match:/^(?:mysql|mariadb)/,kind:"database",label:"MySQL"},{match:/^postgres/,kind:"database",label:"PostgreSQL"},{match:/^meilisearch/,kind:"database",label:"Meilisearch"},{match:/^vitess|^vtgate/,kind:"database",label:"Vitess"},{match:/^memcached/,kind:"cache",label:"Memcached"}],j=/^(?:rpx-gateway|nginx|caddy|traefik|haproxy)$/;function e(n,u=""){let a=n==null?"":String(n).trim();return a&&a!=="-"&&a!=="—"?a:u}function F(n){return Array.isArray(n)?n.length:0}function h(n){let u=e(n).toLowerCase();if(!u)return"unknown";if(["running","live","active","available","success","ok","healthy","enabled"].includes(u))return"ok";if(["failed","stopped","unreachable","error","critical","disabled"].includes(u))return"bad";if(["configured","creating","pending","degraded","shadowed","warn","unknown"].includes(u))return"warn";return"warn"}function r(n,u,a){if(a.has(u.source)&&a.has(u.target))n.push(u)}function Wr(n,u={}){let a=[],o=[],q=[],f=n.server??{},c=Array.isArray(n.sites)?n.sites:[],L=Array.isArray(n.services)?n.services:[],k=Array.isArray(n.workers)?n.workers:[],m=n.security??{},C=!!n._serverReachable&&!n.metricsUnavailable,T="box";if(!C)q.push("The compute box could not be probed, so live service state is missing; the shape comes from your cloud config.");a.push({id:"internet",label:"Internet",kind:"internet",layer:0,status:"ok",sub:"Public traffic",facts:[],external:!0});let i=[...new Set(c.map((t)=>e(t.domain)||e(t.route).split("/")[0]).filter((t)=>t&&t!=="internal"&&t!=="loopback"))],E=Array.isArray(m.tlsCertificates)?m.tlsCertificates:[],g=E.filter((t)=>Number(t?.daysRemaining??999)<21).length;a.push({id:"dns",label:i.length===1?i[0]:"Public domains",kind:"dns",layer:1,status:g?"warn":i.length?"ok":"unknown",sub:i.length>1?`${i.length} domains`:"DNS & certificates",facts:[{label:"Domains",value:i.length?i.slice(0,6).join(", "):"none resolved"},{label:"Certificates",value:E.length?`${E.length} issued`:"none reported"},...g?[{label:"Expiring",value:`${g} within 21 days`}]:[]],href:"/server/security",external:!0});let v=m.firewall??{},w=Array.isArray(m.ports)?m.ports:[];a.push({id:"firewall",label:"Host firewall",kind:"firewall",layer:2,status:h(v.status),sub:e(v.summary,"Inbound filtering"),facts:[{label:"State",value:e(v.status,"unknown")},{label:"Open ports",value:w.length?w.map((t)=>e(t.listen)).join(", "):"not reported"}],href:"/server/firewall",group:"box"});let y=L.find((t)=>j.test(e(t.name)));a.push({id:"proxy",label:e(y?.name,"Reverse proxy"),kind:"proxy",layer:3,status:y?h(y.status):"unknown",sub:"TLS termination & routing",facts:[{label:"Service",value:e(y?.name,"not detected")},{label:"State",value:e(y?.status,C?"not running":"not probed")},{label:"Routes",value:`${c.length} site${c.length===1?"":"s"}`}],href:"/server/services",group:"box"});for(let t of c){let d=`site:${e(t.name)}`;if(!e(t.name))continue;a.push({id:d,label:e(t.name),kind:"site",layer:4,status:h(t.status),sub:e(t.runtime,"runtime"),facts:[{label:"Route",value:e(t.route,"internal")},{label:"Runtime",value:e(t.runtime,"unknown")},{label:"Delivery",value:e(t.deploy,"unknown")},{label:"TLS",value:e(t.tls,"unknown")},...t.responseMs!=null?[{label:"Response",value:`${Math.round(Number(t.responseMs))} ms`}]:[],...t.httpStatus!=null?[{label:"HTTP",value:String(t.httpStatus)}]:[]],href:"/server/sites",group:"box"})}for(let t of k){let d=`worker:${e(t.name)}`;if(!e(t.name))continue;a.push({id:d,label:e(t.name),kind:"worker",layer:5,status:h(t.status),sub:`${Number(t.processes??1)} process${Number(t.processes??1)===1?"":"es"}`,facts:[{label:"Processes",value:String(t.processes??1)},{label:"State",value:e(t.status,"unknown")},...e(t.site)?[{label:"Site",value:e(t.site)}]:[]],href:"/operations/jobs",group:"box"})}let A=n.serverScheduler??{};if(A.enabled)a.push({id:"scheduler",label:"Scheduler",kind:"scheduler",layer:5,status:"ok",sub:"Cron dispatch",facts:[{label:"Last run",value:e(A.lastRun,"unknown")}],href:"/operations/jobs",group:"box"});let l=L.map((t)=>{let d=e(t.name),s=P.find((p)=>p.match.test(d));return s?{service:t,name:d,...s}:null}).filter((t)=>!!t);for(let t of l)a.push({id:`data:${t.name}`,label:t.label,kind:t.kind,layer:6,status:h(t.service.status),sub:t.name,facts:[{label:"Unit",value:t.name},{label:"State",value:e(t.service.status,"unknown")}],href:"/data/services",group:"box"});let x=n.backup??{};if(x.enabled)a.push({id:"backup",label:"Backups",kind:"backup",layer:7,status:"ok",sub:e(x.destination,"destination"),facts:[{label:"Destination",value:e(x.destination,"unknown")},{label:"Schedule",value:e(x.schedule,"unknown")},{label:"Retention",value:`${x.retention??0} copies`},{label:"Last run",value:e(x.last,"unknown")}],href:"/data/backups"});let b=new Set(a.map((t)=>t.id));r(o,{source:"internet",target:"dns",flow:"request",label:"https"},b),r(o,{source:"dns",target:"firewall",flow:"request",label:"443/80"},b),r(o,{source:"firewall",target:"proxy",flow:"request"},b);for(let t of c){let d=`site:${e(t.name)}`;r(o,{source:"proxy",target:d,flow:"request",label:e(t.path)||void 0,status:h(t.status)},b)}for(let t of k){let d=`worker:${e(t.name)}`,s=`site:${e(t.site)}`;if(b.has(s))r(o,{source:s,target:d,flow:"async",label:"queue"},b);else r(o,{source:"proxy",target:d,flow:"async",label:"queue"},b)}for(let t of k)r(o,{source:"scheduler",target:`worker:${e(t.name)}`,flow:"async",label:"dispatch"},b);let D=[...c.map((t)=>`site:${e(t.name)}`),...k.map((t)=>`worker:${e(t.name)}`)];for(let t of l)for(let d of D)r(o,{source:d,target:`data:${t.name}`,flow:"data",label:"localhost"},b);if(l.length&&D.length)q.push("Data-service edges show co-location on the box: every process on it can reach localhost. They are not a declared per-site binding.");for(let t of l)r(o,{source:`data:${t.name}`,target:"backup",flow:"backup",label:"snapshot"},b);for(let t of c)r(o,{source:`site:${e(t.name)}`,target:"backup",flow:"backup"},b);return{mode:"server",project:e(u.project)||e(n.project?.name)||e(f.name,"project"),environment:e(u.environment)||e(n.environment,"production"),provider:e(f.provider,"unknown"),region:e(f.region,"unknown"),generatedAt:new Date().toISOString(),layers:M,groups:[{id:"box",label:e(f.name,"App server"),sub:[e(f.provider),e(f.region),e(f.ip)].filter(Boolean).join(" · ")}],nodes:a,links:o,notes:q}}function $a(n,u={}){let a=[],o=[],q=[],f=n.app??{},c=Array.isArray(n.functions)?n.functions:[],L=Array.isArray(n.queues)?n.queues:[],k=n.metrics??{};if(!c.length)q.push("No Lambda functions were read for this environment, so the compute layer is empty rather than assumed.");a.push({id:"internet",label:"Internet",kind:"internet",layer:0,status:"ok",sub:"Public traffic",facts:[],external:!0});let m=e(f.url),C=m.replace(/^https?:\/\//,"").split("/")[0];a.push({id:"dns",label:C||"Application domain",kind:"dns",layer:1,status:C?"ok":"unknown",sub:"DNS & certificates",facts:[{label:"Endpoint",value:m||"not resolved"}],external:!0});let T=n.waf;if(T)a.push({id:"waf",label:"WAF",kind:"waf",layer:2,status:h(T.status??"active"),sub:e(T.scope,"Managed rules"),facts:[{label:"Web ACL",value:e(T.name,"unnamed")},...T.blocked!=null?[{label:"Blocked (24h)",value:String(T.blocked)}]:[],{label:"Rules",value:String(F(n.wafRules))}],href:"/serverless/firewall"});let i=n.assetsInfo;if(i)a.push({id:"cdn",label:"Asset CDN",kind:"cdn",layer:2,status:"ok",sub:e(i.cdn,"CloudFront"),facts:[{label:"Distribution",value:e(i.cdn,"unknown")},{label:"Custom domain",value:e(i.customDomain,"none")}],href:"/serverless/assets"}),a.push({id:"assets",label:"Asset bucket",kind:"storage",layer:6,status:"ok",sub:e(i.bucket,"S3"),facts:[{label:"Bucket",value:e(i.bucket,"unknown")},...i.files?[{label:"Objects",value:String(i.files)}]:[],...i.sizeMb?[{label:"Size",value:`${i.sizeMb} MB`}]:[]],href:"/serverless/assets"});let E=c.find((s)=>e(s.key).startsWith("http"));a.push({id:"gateway",label:"HTTP entry point",kind:"gateway",layer:3,status:E?"ok":"unknown",sub:"Function URL / API Gateway",facts:[{label:"Endpoint",value:m||"not resolved"},{label:"Invocations (24h)",value:String(k.invocations??0)},...k.errorRatePct!=null?[{label:"Error rate",value:`${k.errorRatePct}%`}]:[]],href:"/serverless/metrics"});for(let s of c){let p=`fn:${e(s.name)}`;if(!e(s.name))continue;let S=Number(s.errors??0),R=Number(s.invocations??0);a.push({id:p,label:e(s.key,e(s.name)),kind:"function",layer:4,status:S>0?R&&S/R>0.02?"bad":"warn":R?"ok":"idle",sub:e(s.runtime,"lambda"),facts:[{label:"Function",value:e(s.name)},{label:"Memory",value:`${s.memory??0} MB`},{label:"Timeout",value:`${s.timeout??0}s`},{label:"Invocations (24h)",value:String(R)},{label:"Errors (24h)",value:String(S)},{label:"p95",value:`${s.p95??0} ms`},...s.provisioned?[{label:"Provisioned",value:e(s.provisioned)}]:[]],href:"/serverless/functions"})}for(let s of L){let p=`queue:${e(s.name)}`;if(!e(s.name))continue;let S=Number(s.dlq??0);a.push({id:p,label:e(s.name),kind:"queue",layer:5,status:S>0?"bad":Number(s.visible??0)>0?"warn":"ok",sub:"SQS",facts:[{label:"Visible",value:String(s.visible??0)},{label:"In flight",value:String(s.inFlight??0)},{label:"Processed (24h)",value:String(s.processed??0)},{label:"Dead letter",value:String(S)}],href:"/serverless/queues"})}let g=n.aurora;if(g)a.push({id:"database",label:"Aurora Serverless",kind:"database",layer:6,status:h(g.status),sub:e(g.engine,"aurora"),facts:[{label:"Cluster",value:e(g.id,"unknown")},{label:"Capacity",value:`${g.currentAcu??0} ACU (${g.minAcu??0}–${g.maxAcu??0})`},{label:"Connections",value:String(g.connections??0)}],href:"/serverless/data"});let v=n.proxy;if(v)a.push({id:"rds-proxy",label:"RDS Proxy",kind:"database",layer:5,status:h(v.status),sub:"Connection pooling",facts:[{label:"Proxy",value:e(v.name,"unknown")},{label:"Endpoint",value:e(v.endpoint,"unknown")},{label:"Pooled",value:String(v.pooledConns??0)}],href:"/serverless/data"});let w=n.redis;if(w)a.push({id:"cache",label:"ElastiCache",kind:"cache",layer:6,status:h(w.status),sub:e(w.node,"redis"),facts:[{label:"Group",value:e(w.id,"unknown")},{label:"Hit rate",value:`${w.hitRate??0}%`}],href:"/serverless/data"});let y=n.efs;if(y)a.push({id:"efs",label:"EFS",kind:"filesystem",layer:6,status:h(y.status),sub:e(y.mount,"/mnt/local"),facts:[{label:"File system",value:e(y.id,"unknown")},{label:"Mount",value:e(y.mount,"unknown")},{label:"Size",value:`${y.sizeMb??0} MB`}],href:"/data/volumes"});let A=n.scheduler??{};if(A.enabled)a.push({id:"scheduler",label:"Scheduler",kind:"scheduler",layer:3,status:"ok",sub:e(A.expression,"rate(1 minute)"),facts:[{label:"Expression",value:e(A.expression,"unknown")},{label:"Last run",value:e(A.lastRun,"unknown")}],href:"/operations/jobs"});let l=new Set(a.map((s)=>s.id)),x=l.has("waf")?"waf":"gateway";r(o,{source:"internet",target:"dns",flow:"request",label:"https"},l),r(o,{source:"dns",target:x,flow:"request"},l),r(o,{source:"dns",target:"cdn",flow:"request",label:"assets"},l),r(o,{source:"waf",target:"gateway",flow:"request",label:"allowed"},l),r(o,{source:"cdn",target:"assets",flow:"data",label:"origin"},l);let b=c.filter((s)=>e(s.key).startsWith("http")),D=c.filter((s)=>e(s.key).startsWith("queue")),t=c.filter((s)=>e(s.key).startsWith("cli"));for(let s of b)r(o,{source:"gateway",target:`fn:${e(s.name)}`,flow:"request",label:"invoke"},l);for(let s of t)r(o,{source:"scheduler",target:`fn:${e(s.name)}`,flow:"async",label:"schedule"},l);for(let s of L){for(let p of b)r(o,{source:`fn:${e(p.name)}`,target:`queue:${e(s.name)}`,flow:"async",label:"publish"},l);for(let p of D)r(o,{source:`queue:${e(s.name)}`,target:`fn:${e(p.name)}`,flow:"async",label:"consume"},l)}let d=["rds-proxy","database","cache","efs","assets"];for(let s of c){let p=`fn:${e(s.name)}`;if(l.has("rds-proxy"))r(o,{source:p,target:"rds-proxy",flow:"data",label:"pooled"},l);else r(o,{source:p,target:"database",flow:"data",label:"sql"},l);for(let S of d.filter((R)=>R!=="rds-proxy"&&R!=="database"))r(o,{source:p,target:S,flow:"data"},l)}return r(o,{source:"rds-proxy",target:"database",flow:"data",label:"sql"},l),{mode:"serverless",project:e(u.project)||e(f.name,"application"),environment:e(u.environment)||e(f.env,"production"),provider:"aws",region:e(f.region,"unknown"),generatedAt:new Date().toISOString(),layers:N,groups:[],nodes:a,links:o,notes:q}}
2
- export{Wr,$a};
1
+ var M=[{index:0,id:"clients",label:"Clients"},{index:1,id:"dns",label:"DNS & TLS"},{index:2,id:"edge",label:"Edge"},{index:3,id:"routing",label:"Routing"},{index:4,id:"apps",label:"Applications"},{index:5,id:"runtime",label:"Background runtime"},{index:6,id:"data",label:"Data services"},{index:7,id:"durability",label:"Durability"}],N=[{index:0,id:"clients",label:"Clients"},{index:1,id:"dns",label:"DNS & TLS"},{index:2,id:"edge",label:"Edge"},{index:3,id:"entry",label:"Entry points"},{index:4,id:"compute",label:"Compute"},{index:5,id:"messaging",label:"Messaging & pooling"},{index:6,id:"data",label:"Data services"},{index:7,id:"durability",label:"Durability"}],P=[{match:/^redis/,kind:"cache",label:"Redis"},{match:/^(?:mysql|mariadb)/,kind:"database",label:"MySQL"},{match:/^postgres/,kind:"database",label:"PostgreSQL"},{match:/^meilisearch/,kind:"database",label:"Meilisearch"},{match:/^vitess|^vtgate/,kind:"database",label:"Vitess"},{match:/^memcached/,kind:"cache",label:"Memcached"}],j=/^(?:rpx-gateway|nginx|caddy|traefik|haproxy)$/;function e(n,u=""){let a=n==null?"":String(n).trim();return a&&a!=="-"&&a!=="—"?a:u}function F(n){return Array.isArray(n)?n.length:0}function h(n){let u=e(n).toLowerCase();if(!u)return"unknown";if(["running","live","active","available","success","ok","healthy","enabled"].includes(u))return"ok";if(["failed","stopped","unreachable","error","critical","disabled"].includes(u))return"bad";if(["configured","creating","pending","degraded","shadowed","warn","unknown"].includes(u))return"warn";return"warn"}function r(n,u,a){if(a.has(u.source)&&a.has(u.target))n.push(u)}function Gr(n,u={}){let a=[],o=[],q=[],f=n.server??{},c=Array.isArray(n.sites)?n.sites:[],L=Array.isArray(n.services)?n.services:[],k=Array.isArray(n.workers)?n.workers:[],m=n.security??{},C=!!n._serverReachable&&!n.metricsUnavailable,T="box";if(!C)q.push("The compute box could not be probed, so live service state is missing; the shape comes from your cloud config.");a.push({id:"internet",label:"Internet",kind:"internet",layer:0,status:"ok",sub:"Public traffic",facts:[],external:!0});let i=[...new Set(c.map((t)=>e(t.domain)||e(t.route).split("/")[0]).filter((t)=>t&&t!=="internal"&&t!=="loopback"))],E=Array.isArray(m.tlsCertificates)?m.tlsCertificates:[],g=E.filter((t)=>Number(t?.daysRemaining??999)<21).length;a.push({id:"dns",label:i.length===1?i[0]:"Public domains",kind:"dns",layer:1,status:g?"warn":i.length?"ok":"unknown",sub:i.length>1?`${i.length} domains`:"DNS & certificates",facts:[{label:"Domains",value:i.length?i.slice(0,6).join(", "):"none resolved"},{label:"Certificates",value:E.length?`${E.length} issued`:"none reported"},...g?[{label:"Expiring",value:`${g} within 21 days`}]:[]],href:"/server/security",external:!0});let v=m.firewall??{},w=Array.isArray(m.ports)?m.ports:[];a.push({id:"firewall",label:"Host firewall",kind:"firewall",layer:2,status:h(v.status),sub:e(v.summary,"Inbound filtering"),facts:[{label:"State",value:e(v.status,"unknown")},{label:"Open ports",value:w.length?w.map((t)=>e(t.listen)).join(", "):"not reported"}],href:"/server/firewall",group:"box"});let y=L.find((t)=>j.test(e(t.name)));a.push({id:"proxy",label:e(y?.name,"Reverse proxy"),kind:"proxy",layer:3,status:y?h(y.status):"unknown",sub:"TLS termination & routing",facts:[{label:"Service",value:e(y?.name,"not detected")},{label:"State",value:e(y?.status,C?"not running":"not probed")},{label:"Routes",value:`${c.length} site${c.length===1?"":"s"}`}],href:"/server/services",group:"box"});for(let t of c){let d=`site:${e(t.name)}`;if(!e(t.name))continue;a.push({id:d,label:e(t.name),kind:"site",layer:4,status:h(t.status),sub:e(t.runtime,"runtime"),facts:[{label:"Route",value:e(t.route,"internal")},{label:"Runtime",value:e(t.runtime,"unknown")},{label:"Delivery",value:e(t.deploy,"unknown")},{label:"TLS",value:e(t.tls,"unknown")},...t.responseMs!=null?[{label:"Response",value:`${Math.round(Number(t.responseMs))} ms`}]:[],...t.httpStatus!=null?[{label:"HTTP",value:String(t.httpStatus)}]:[]],href:"/server/sites",group:"box"})}for(let t of k){let d=`worker:${e(t.name)}`;if(!e(t.name))continue;a.push({id:d,label:e(t.name),kind:"worker",layer:5,status:h(t.status),sub:`${Number(t.processes??1)} process${Number(t.processes??1)===1?"":"es"}`,facts:[{label:"Processes",value:String(t.processes??1)},{label:"State",value:e(t.status,"unknown")},...e(t.site)?[{label:"Site",value:e(t.site)}]:[]],href:"/operations/jobs",group:"box"})}let A=n.serverScheduler??{};if(A.enabled)a.push({id:"scheduler",label:"Scheduler",kind:"scheduler",layer:5,status:"ok",sub:"Cron dispatch",facts:[{label:"Last run",value:e(A.lastRun,"unknown")}],href:"/operations/jobs",group:"box"});let l=L.map((t)=>{let d=e(t.name),s=P.find((p)=>p.match.test(d));return s?{service:t,name:d,...s}:null}).filter((t)=>!!t);for(let t of l)a.push({id:`data:${t.name}`,label:t.label,kind:t.kind,layer:6,status:h(t.service.status),sub:t.name,facts:[{label:"Unit",value:t.name},{label:"State",value:e(t.service.status,"unknown")}],href:"/data/services",group:"box"});let x=n.backup??{};if(x.enabled)a.push({id:"backup",label:"Backups",kind:"backup",layer:7,status:"ok",sub:e(x.destination,"destination"),facts:[{label:"Destination",value:e(x.destination,"unknown")},{label:"Schedule",value:e(x.schedule,"unknown")},{label:"Retention",value:`${x.retention??0} copies`},{label:"Last run",value:e(x.last,"unknown")}],href:"/data/backups"});let b=new Set(a.map((t)=>t.id));r(o,{source:"internet",target:"dns",flow:"request",label:"https"},b),r(o,{source:"dns",target:"firewall",flow:"request",label:"443/80"},b),r(o,{source:"firewall",target:"proxy",flow:"request"},b);for(let t of c){let d=`site:${e(t.name)}`;r(o,{source:"proxy",target:d,flow:"request",label:e(t.path)||void 0,status:h(t.status)},b)}for(let t of k){let d=`worker:${e(t.name)}`,s=`site:${e(t.site)}`;if(b.has(s))r(o,{source:s,target:d,flow:"async",label:"queue"},b);else r(o,{source:"proxy",target:d,flow:"async",label:"queue"},b)}for(let t of k)r(o,{source:"scheduler",target:`worker:${e(t.name)}`,flow:"async",label:"dispatch"},b);let D=[...c.map((t)=>`site:${e(t.name)}`),...k.map((t)=>`worker:${e(t.name)}`)];for(let t of l)for(let d of D)r(o,{source:d,target:`data:${t.name}`,flow:"data",label:"localhost"},b);if(l.length&&D.length)q.push("Data-service edges show co-location on the box: every process on it can reach localhost. They are not a declared per-site binding.");for(let t of l)r(o,{source:`data:${t.name}`,target:"backup",flow:"backup",label:"snapshot"},b);for(let t of c)r(o,{source:`site:${e(t.name)}`,target:"backup",flow:"backup"},b);return{mode:"server",project:e(u.project)||e(n.project?.name)||e(f.name,"project"),environment:e(u.environment)||e(n.environment,"production"),provider:e(f.provider,"unknown"),region:e(f.region,"unknown"),generatedAt:new Date().toISOString(),layers:M,groups:[{id:"box",label:e(f.name,"App server"),sub:[e(f.provider),e(f.region),e(f.ip)].filter(Boolean).join(" · ")}],nodes:a,links:o,notes:q}}function Oa(n,u={}){let a=[],o=[],q=[],f=n.app??{},c=Array.isArray(n.functions)?n.functions:[],L=Array.isArray(n.queues)?n.queues:[],k=n.metrics??{};if(!c.length)q.push("No Lambda functions were read for this environment, so the compute layer is empty rather than assumed.");a.push({id:"internet",label:"Internet",kind:"internet",layer:0,status:"ok",sub:"Public traffic",facts:[],external:!0});let m=e(f.url),C=m.replace(/^https?:\/\//,"").split("/")[0];a.push({id:"dns",label:C||"Application domain",kind:"dns",layer:1,status:C?"ok":"unknown",sub:"DNS & certificates",facts:[{label:"Endpoint",value:m||"not resolved"}],external:!0});let T=n.waf;if(T)a.push({id:"waf",label:"WAF",kind:"waf",layer:2,status:h(T.status??"active"),sub:e(T.scope,"Managed rules"),facts:[{label:"Web ACL",value:e(T.name,"unnamed")},...T.blocked!=null?[{label:"Blocked (24h)",value:String(T.blocked)}]:[],{label:"Rules",value:String(F(n.wafRules))}],href:"/serverless/firewall"});let i=n.assetsInfo;if(i)a.push({id:"cdn",label:"Asset CDN",kind:"cdn",layer:2,status:"ok",sub:e(i.cdn,"CloudFront"),facts:[{label:"Distribution",value:e(i.cdn,"unknown")},{label:"Custom domain",value:e(i.customDomain,"none")}],href:"/serverless/assets"}),a.push({id:"assets",label:"Asset bucket",kind:"storage",layer:6,status:"ok",sub:e(i.bucket,"S3"),facts:[{label:"Bucket",value:e(i.bucket,"unknown")},...i.files?[{label:"Objects",value:String(i.files)}]:[],...i.sizeMb?[{label:"Size",value:`${i.sizeMb} MB`}]:[]],href:"/serverless/assets"});let E=c.find((s)=>e(s.key).startsWith("http"));a.push({id:"gateway",label:"HTTP entry point",kind:"gateway",layer:3,status:E?"ok":"unknown",sub:"Function URL / API Gateway",facts:[{label:"Endpoint",value:m||"not resolved"},{label:"Invocations (24h)",value:String(k.invocations??0)},...k.errorRatePct!=null?[{label:"Error rate",value:`${k.errorRatePct}%`}]:[]],href:"/serverless/metrics"});for(let s of c){let p=`fn:${e(s.name)}`;if(!e(s.name))continue;let S=Number(s.errors??0),R=Number(s.invocations??0);a.push({id:p,label:e(s.key,e(s.name)),kind:"function",layer:4,status:S>0?R&&S/R>0.02?"bad":"warn":R?"ok":"idle",sub:e(s.runtime,"lambda"),facts:[{label:"Function",value:e(s.name)},{label:"Memory",value:`${s.memory??0} MB`},{label:"Timeout",value:`${s.timeout??0}s`},{label:"Invocations (24h)",value:String(R)},{label:"Errors (24h)",value:String(S)},{label:"p95",value:`${s.p95??0} ms`},...s.provisioned?[{label:"Provisioned",value:e(s.provisioned)}]:[]],href:"/serverless/functions"})}for(let s of L){let p=`queue:${e(s.name)}`;if(!e(s.name))continue;let S=Number(s.dlq??0);a.push({id:p,label:e(s.name),kind:"queue",layer:5,status:S>0?"bad":Number(s.visible??0)>0?"warn":"ok",sub:"SQS",facts:[{label:"Visible",value:String(s.visible??0)},{label:"In flight",value:String(s.inFlight??0)},{label:"Processed (24h)",value:String(s.processed??0)},{label:"Dead letter",value:String(S)}],href:"/serverless/queues"})}let g=n.aurora;if(g)a.push({id:"database",label:"Aurora Serverless",kind:"database",layer:6,status:h(g.status),sub:e(g.engine,"aurora"),facts:[{label:"Cluster",value:e(g.id,"unknown")},{label:"Capacity",value:`${g.currentAcu??0} ACU (${g.minAcu??0}–${g.maxAcu??0})`},{label:"Connections",value:String(g.connections??0)}],href:"/serverless/data"});let v=n.proxy;if(v)a.push({id:"rds-proxy",label:"RDS Proxy",kind:"database",layer:5,status:h(v.status),sub:"Connection pooling",facts:[{label:"Proxy",value:e(v.name,"unknown")},{label:"Endpoint",value:e(v.endpoint,"unknown")},{label:"Pooled",value:String(v.pooledConns??0)}],href:"/serverless/data"});let w=n.redis;if(w)a.push({id:"cache",label:"ElastiCache",kind:"cache",layer:6,status:h(w.status),sub:e(w.node,"redis"),facts:[{label:"Group",value:e(w.id,"unknown")},{label:"Hit rate",value:`${w.hitRate??0}%`}],href:"/serverless/data"});let y=n.efs;if(y)a.push({id:"efs",label:"EFS",kind:"filesystem",layer:6,status:h(y.status),sub:e(y.mount,"/mnt/local"),facts:[{label:"File system",value:e(y.id,"unknown")},{label:"Mount",value:e(y.mount,"unknown")},{label:"Size",value:`${y.sizeMb??0} MB`}],href:"/data/volumes"});let A=n.scheduler??{};if(A.enabled)a.push({id:"scheduler",label:"Scheduler",kind:"scheduler",layer:3,status:"ok",sub:e(A.expression,"rate(1 minute)"),facts:[{label:"Expression",value:e(A.expression,"unknown")},{label:"Last run",value:e(A.lastRun,"unknown")}],href:"/operations/jobs"});let l=new Set(a.map((s)=>s.id)),x=l.has("waf")?"waf":"gateway";r(o,{source:"internet",target:"dns",flow:"request",label:"https"},l),r(o,{source:"dns",target:x,flow:"request"},l),r(o,{source:"dns",target:"cdn",flow:"request",label:"assets"},l),r(o,{source:"waf",target:"gateway",flow:"request",label:"allowed"},l),r(o,{source:"cdn",target:"assets",flow:"data",label:"origin"},l);let b=c.filter((s)=>e(s.key).startsWith("http")),D=c.filter((s)=>e(s.key).startsWith("queue")),t=c.filter((s)=>e(s.key).startsWith("cli"));for(let s of b)r(o,{source:"gateway",target:`fn:${e(s.name)}`,flow:"request",label:"invoke"},l);for(let s of t)r(o,{source:"scheduler",target:`fn:${e(s.name)}`,flow:"async",label:"schedule"},l);for(let s of L){for(let p of b)r(o,{source:`fn:${e(p.name)}`,target:`queue:${e(s.name)}`,flow:"async",label:"publish"},l);for(let p of D)r(o,{source:`queue:${e(s.name)}`,target:`fn:${e(p.name)}`,flow:"async",label:"consume"},l)}let d=["rds-proxy","database","cache","efs","assets"];for(let s of c){let p=`fn:${e(s.name)}`;if(l.has("rds-proxy"))r(o,{source:p,target:"rds-proxy",flow:"data",label:"pooled"},l);else r(o,{source:p,target:"database",flow:"data",label:"sql"},l);for(let S of d.filter((R)=>R!=="rds-proxy"&&R!=="database"))r(o,{source:p,target:S,flow:"data"},l)}return r(o,{source:"rds-proxy",target:"database",flow:"data",label:"sql"},l),{mode:"serverless",project:e(u.project)||e(f.name,"application"),environment:e(u.environment)||e(f.env,"production"),provider:"aws",region:e(f.region,"unknown"),generatedAt:new Date().toISOString(),layers:N,groups:[],nodes:a,links:o,notes:q}}
2
+ export{Gr,Oa};
@@ -0,0 +1 @@
1
+ import{Ju,Qr,qi,oe,Xu,ja,id,is,Qu,Yu,Zu,Va,Wi,os,za,Yr,gr,ep,ri,tp,Ha,od,sd,ss,qa,Wa,fr,Gi,hr,Ga,as,ni,ad,Ki,Ka,Ja,Ji,cd,Xa,Qa,Ya,Za,cs,ld,dd,rp,ud,ec,Xi,pd,md,ls,xt,ds,us,ps,tc,gd,rc,ms,np,ft,ip,nc,$t,ic,op,oc,fd,sp,Z,hd,gs,ap,Qi,ii,oi,fs,yd,Sd,cp,hs,ys}from"./chunk-k8r5zfnf.js";import"./chunk-jeg6vw5v.js";import"./chunk-kne9dmwr.js";export{ls as AnomalyConfigStore,yd as AwsSpendTransport,Sd as ComputeSpendTransport,ss as CounterTracker,Ha as DEFAULT_METER_MAPPINGS,Va as DEFAULT_PRICE_BOOK,Gi as DEFAULT_THRESHOLDS,xt as DETECTABLE_SIGNALS,qi as ENFORCEMENT_ACTIONS,Ji as ENFORCEMENT_DESCRIPTIONS,oe as ENFORCEMENT_SEVERITY,gd as FOCUS_VERSION,Qr as METERS,Ju as METER_KEYS,Xu as MICRO_CENTS,ad as MIN_PROJECTION_CONFIDENCE,fd as RecordingSpendTransport,pd as SENSITIVITY_THRESHOLDS,oi as SPEND_CYCLE_SECONDS,nc as SPEND_GATE_SETTING,ap as SPEND_LEASE_SETTING,us as SignalSource,ic as SpendCapError,$t as SpendGate,Qi as SpendLoopLease,gs as SpendNotificationRouter,ii as SpendRunner,ft as SpendService,hr as SpendStore,sp as URGENT_SPEND_EVENTS,cd as USER_VISIBLE_ACTIONS,Wa as aggregateDeltas,Xi as anomalyOptionsForSignal,op as assertSpendAllows,gr as budgetWindow,cp as compositeSpendTransport,oc as createEnforcementHandlers,ud as detectAnomalies,ec as detectLatestAnomaly,Ka as evaluateBudget,rp as ewma,od as findMapping,id as findPriceEntry,Z as formatCents,ni as formatTimeToExhaustion,Ki as governingLimitCents,hs as handleSpendRequest,ri as hourBucket,tp as hourBucketsBetween,Za as isOperationAllowed,Wi as isValidTimeZone,tc as lookbackHoursForSignal,cs as median,ld as medianAbsoluteDeviation,Ja as mergeDecisions,Zu as mergePriceBooks,qa as meterTelemetry,ps as optionsForSignal,as as percentOfLimit,Xa as planEnforcement,ep as previousBudgetWindow,is as priceUsage,Qu as priceUsageLines,Ga as projectSpend,dd as robustZScore,Yu as roundCents,md as routeMatches,Qa as runEnforcement,fr as scopeKey,ds as signalDefinition,hd as spendNotificationText,ys as spendOpenApiPaths,fs as startSpendLoop,np as streamFocusJsonl,Ya as strongestActiveAction,ja as tieredMicroCents,ms as toFocusJsonl,rc as toFocusRecords,sd as usageDeltaKey,Yr as utcInstantOfLocal,ip as zeroFill,za as zoneOffsetMs,os as zonedParts};
@@ -1,2 +1,2 @@
1
- import{u}from"./chunk-y5e7dmvc.js";import{deflateRawSync as y}from"zlib";function d(n,e){let t=typeof e==="string"?Buffer.from(e,"utf-8"):e,i=y(t),r=f(t),s=new Date,l=(s.getHours()<<11|s.getMinutes()<<5|s.getSeconds()>>1)&65535,c=(s.getFullYear()-1980<<9|s.getMonth()+1<<5|s.getDate())&65535,m=Buffer.from(n,"utf-8"),a=Buffer.alloc(30+m.length);a.writeUInt32LE(67324752,0),a.writeUInt16LE(20,4),a.writeUInt16LE(0,6),a.writeUInt16LE(8,8),a.writeUInt16LE(l,10),a.writeUInt16LE(c,12),a.writeUInt32LE(r,14),a.writeUInt32LE(i.length,18),a.writeUInt32LE(t.length,22),a.writeUInt16LE(m.length,26),a.writeUInt16LE(0,28),m.copy(a,30);let o=Buffer.alloc(46+m.length);o.writeUInt32LE(33639248,0),o.writeUInt16LE(20,4),o.writeUInt16LE(20,6),o.writeUInt16LE(0,8),o.writeUInt16LE(8,10),o.writeUInt16LE(l,12),o.writeUInt16LE(c,14),o.writeUInt32LE(r,16),o.writeUInt32LE(i.length,20),o.writeUInt32LE(t.length,24),o.writeUInt16LE(m.length,28),o.writeUInt16LE(0,30),o.writeUInt16LE(0,32),o.writeUInt16LE(0,34),o.writeUInt16LE(0,36),o.writeUInt32LE(0,38),o.writeUInt32LE(0,42),m.copy(o,46);let p=a.length+i.length,h=o.length,g=Buffer.alloc(22);return g.writeUInt32LE(101010256,0),g.writeUInt16LE(0,4),g.writeUInt16LE(0,6),g.writeUInt16LE(1,8),g.writeUInt16LE(1,10),g.writeUInt32LE(h,12),g.writeUInt32LE(p,16),g.writeUInt16LE(0,20),Buffer.concat([a,i,o,g])}function f(n){let e=[];for(let i=0;i<256;i++){let r=i;for(let s=0;s<8;s++)r=r&1?3988292384^r>>>1:r>>>1;e[i]=r}let t=4294967295;for(let i=0;i<n.length;i++)t=e[(t^n[i])&255]^t>>>8;return(t^4294967295)>>>0}class R{client;region;constructor(n="us-east-1",e){this.region=n,this.client=new u(void 0,{profile:e})}async createFunction(n){return await this.client.request({service:"lambda",region:this.region,method:"POST",path:"/2015-03-31/functions",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async getFunction(n){return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2015-03-31/functions/${encodeURIComponent(n)}`,headers:{"Content-Type":"application/json"}})}async updateFunctionCode(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2015-03-31/functions/${encodeURIComponent(e)}/code`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateFunctionCodeInline(n,e,t="index.js"){let i=d(t,e);return this.updateFunctionCode({FunctionName:n,ZipFile:i.toString("base64")})}async updateFunctionConfiguration(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2015-03-31/functions/${encodeURIComponent(e)}/configuration`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async deleteFunction(n){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2015-03-31/functions/${encodeURIComponent(n)}`,headers:{"Content-Type":"application/json"}})}async invoke(n){let{FunctionName:e,InvocationType:t="RequestResponse",Payload:i,LogType:r}=n,s={"Content-Type":"application/json","X-Amz-Invocation-Type":t};if(r)s["X-Amz-Log-Type"]=r;let l=i?typeof i==="string"?i:JSON.stringify(i):void 0,c=await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/invocations`,headers:s,body:l,returnHeaders:!0});return{StatusCode:c.statusCode||200,FunctionError:c.headers?.["x-amz-function-error"],LogResult:c.headers?.["x-amz-log-result"],Payload:typeof c.body==="string"?c.body:JSON.stringify(c.body),ExecutedVersion:c.headers?.["x-amz-executed-version"]}}async listFunctions(n){let e={};if(n?.MaxItems)e.MaxItems=String(n.MaxItems);if(n?.Marker)e.Marker=n.Marker;if(n?.FunctionVersion)e.FunctionVersion=n.FunctionVersion;return await this.client.request({service:"lambda",region:this.region,method:"GET",path:"/2015-03-31/functions",queryParams:Object.keys(e).length>0?e:void 0,headers:{"Content-Type":"application/json"}})}async addPermission(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/policy`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async removePermission(n,e){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2015-03-31/functions/${encodeURIComponent(n)}/policy/${encodeURIComponent(e)}`,headers:{"Content-Type":"application/json"}})}async publishVersion(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/versions`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async createAlias(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/aliases`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateAlias(n){let{FunctionName:e,Name:t,...i}=n;return this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2015-03-31/functions/${encodeURIComponent(e)}/aliases/${encodeURIComponent(t)}`,headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async getAlias(n,e){try{return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2015-03-31/functions/${encodeURIComponent(n)}/aliases/${encodeURIComponent(e)}`})}catch(t){if(/ResourceNotFound/i.test(String(t?.message)))return null;throw t}}async getProvisionedConcurrencyConfig(n,e){try{return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2019-09-30/functions/${encodeURIComponent(n)}/provisioned-concurrency`,queryParams:{Qualifier:e}})}catch(t){if(/ProvisionedConcurrencyConfigNotFound|ResourceNotFound/i.test(String(t?.message)))return null;throw t}}async putProvisionedConcurrencyConfig(n){let{FunctionName:e,Qualifier:t,ProvisionedConcurrentExecutions:i}=n;return this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2019-09-30/functions/${encodeURIComponent(e)}/provisioned-concurrency`,queryParams:{Qualifier:t},headers:{"Content-Type":"application/json"},body:JSON.stringify({ProvisionedConcurrentExecutions:i})})}async getFunctionConcurrency(n){try{return(await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2019-10-31/functions/${encodeURIComponent(n)}/concurrency`}))?.ReservedConcurrentExecutions??null}catch(e){if(/ResourceNotFound|ProvisionedConcurrencyConfigNotFound/i.test(String(e?.message)))return null;throw e}}async putFunctionConcurrency(n,e){await this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2019-10-31/functions/${encodeURIComponent(n)}/concurrency`,headers:{"Content-Type":"application/json"},body:JSON.stringify({ReservedConcurrentExecutions:e})})}async deleteFunctionConcurrency(n){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2019-10-31/functions/${encodeURIComponent(n)}/concurrency`})}async deleteProvisionedConcurrencyConfig(n,e){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2019-09-30/functions/${encodeURIComponent(n)}/provisioned-concurrency`,queryParams:{Qualifier:e}})}async waitForFunctionActive(n,e=60){let t=Date.now(),i=e*1000;while(Date.now()-t<i)try{let r=await this.getFunction(n),s=r.Configuration?.State;if(s==="Active")return r.Configuration;if(s==="Failed")throw Error(`Function ${n} failed: ${r.Configuration?.StateReason}`);await new Promise((l)=>setTimeout(l,2000))}catch(r){if(r.code==="ResourceNotFoundException"){await new Promise((s)=>setTimeout(s,2000));continue}throw r}throw Error(`Timeout waiting for function ${n} to become active`)}async functionExists(n){try{return await this.getFunction(n),!0}catch(e){if(e.code==="ResourceNotFoundException"||e.statusCode===404)return!1;throw e}}async createFunctionUrl(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2021-10-31/functions/${encodeURIComponent(e)}/url`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async getFunctionUrl(n){try{return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2021-10-31/functions/${encodeURIComponent(n)}/url`,headers:{"Content-Type":"application/json"}})}catch(e){if(e.statusCode===404)return null;throw e}}async deleteFunctionUrl(n){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2021-10-31/functions/${encodeURIComponent(n)}/url`,headers:{"Content-Type":"application/json"}})}async createFunctionWithCode(n){let{Code:e,Filename:t="index.js",...i}=n,r=d(t,e);return this.createFunction({...i,Code:{ZipFile:r.toString("base64")}})}async addFunctionUrlPermission(n){return this.addPermission({FunctionName:n,StatementId:"FunctionURLAllowPublicAccess",Action:"lambda:InvokeFunctionUrl",Principal:"*",FunctionUrlAuthType:"NONE"})}async publishLayerVersion(n){let{LayerName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2018-10-31/layers/${encodeURIComponent(e)}/versions`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async listLayerVersions(n,e){let t={};if(e?.CompatibleRuntime)t.CompatibleRuntime=e.CompatibleRuntime;if(e?.CompatibleArchitecture)t.CompatibleArchitecture=e.CompatibleArchitecture;if(e?.MaxItems)t.MaxItems=String(e.MaxItems);if(e?.Marker)t.Marker=e.Marker;return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2018-10-31/layers/${encodeURIComponent(n)}/versions`,queryParams:Object.keys(t).length>0?t:void 0,headers:{"Content-Type":"application/json"}})}async getLayerVersion(n,e){return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2018-10-31/layers/${encodeURIComponent(n)}/versions/${e}`,headers:{"Content-Type":"application/json"}})}async addLayerVersionPermission(n){let{LayerName:e,VersionNumber:t,...i}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2018-10-31/layers/${encodeURIComponent(e)}/versions/${t}/policy`,headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async deleteLayerVersion(n,e){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2018-10-31/layers/${encodeURIComponent(n)}/versions/${e}`,headers:{"Content-Type":"application/json"}})}}
1
+ import{u}from"./chunk-q9tvzcr7.js";import{deflateRawSync as y}from"zlib";function d(n,e){let t=typeof e==="string"?Buffer.from(e,"utf-8"):e,i=y(t),r=f(t),s=new Date,l=(s.getHours()<<11|s.getMinutes()<<5|s.getSeconds()>>1)&65535,c=(s.getFullYear()-1980<<9|s.getMonth()+1<<5|s.getDate())&65535,m=Buffer.from(n,"utf-8"),a=Buffer.alloc(30+m.length);a.writeUInt32LE(67324752,0),a.writeUInt16LE(20,4),a.writeUInt16LE(0,6),a.writeUInt16LE(8,8),a.writeUInt16LE(l,10),a.writeUInt16LE(c,12),a.writeUInt32LE(r,14),a.writeUInt32LE(i.length,18),a.writeUInt32LE(t.length,22),a.writeUInt16LE(m.length,26),a.writeUInt16LE(0,28),m.copy(a,30);let o=Buffer.alloc(46+m.length);o.writeUInt32LE(33639248,0),o.writeUInt16LE(20,4),o.writeUInt16LE(20,6),o.writeUInt16LE(0,8),o.writeUInt16LE(8,10),o.writeUInt16LE(l,12),o.writeUInt16LE(c,14),o.writeUInt32LE(r,16),o.writeUInt32LE(i.length,20),o.writeUInt32LE(t.length,24),o.writeUInt16LE(m.length,28),o.writeUInt16LE(0,30),o.writeUInt16LE(0,32),o.writeUInt16LE(0,34),o.writeUInt16LE(0,36),o.writeUInt32LE(0,38),o.writeUInt32LE(0,42),m.copy(o,46);let p=a.length+i.length,h=o.length,g=Buffer.alloc(22);return g.writeUInt32LE(101010256,0),g.writeUInt16LE(0,4),g.writeUInt16LE(0,6),g.writeUInt16LE(1,8),g.writeUInt16LE(1,10),g.writeUInt32LE(h,12),g.writeUInt32LE(p,16),g.writeUInt16LE(0,20),Buffer.concat([a,i,o,g])}function f(n){let e=[];for(let i=0;i<256;i++){let r=i;for(let s=0;s<8;s++)r=r&1?3988292384^r>>>1:r>>>1;e[i]=r}let t=4294967295;for(let i=0;i<n.length;i++)t=e[(t^n[i])&255]^t>>>8;return(t^4294967295)>>>0}class R{client;region;constructor(n="us-east-1",e){this.region=n,this.client=new u(void 0,{profile:e})}async createFunction(n){return await this.client.request({service:"lambda",region:this.region,method:"POST",path:"/2015-03-31/functions",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async getFunction(n){return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2015-03-31/functions/${encodeURIComponent(n)}`,headers:{"Content-Type":"application/json"}})}async updateFunctionCode(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2015-03-31/functions/${encodeURIComponent(e)}/code`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateFunctionCodeInline(n,e,t="index.js"){let i=d(t,e);return this.updateFunctionCode({FunctionName:n,ZipFile:i.toString("base64")})}async updateFunctionConfiguration(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2015-03-31/functions/${encodeURIComponent(e)}/configuration`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async deleteFunction(n){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2015-03-31/functions/${encodeURIComponent(n)}`,headers:{"Content-Type":"application/json"}})}async invoke(n){let{FunctionName:e,InvocationType:t="RequestResponse",Payload:i,LogType:r}=n,s={"Content-Type":"application/json","X-Amz-Invocation-Type":t};if(r)s["X-Amz-Log-Type"]=r;let l=i?typeof i==="string"?i:JSON.stringify(i):void 0,c=await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/invocations`,headers:s,body:l,returnHeaders:!0});return{StatusCode:c.statusCode||200,FunctionError:c.headers?.["x-amz-function-error"],LogResult:c.headers?.["x-amz-log-result"],Payload:typeof c.body==="string"?c.body:JSON.stringify(c.body),ExecutedVersion:c.headers?.["x-amz-executed-version"]}}async listFunctions(n){let e={};if(n?.MaxItems)e.MaxItems=String(n.MaxItems);if(n?.Marker)e.Marker=n.Marker;if(n?.FunctionVersion)e.FunctionVersion=n.FunctionVersion;return await this.client.request({service:"lambda",region:this.region,method:"GET",path:"/2015-03-31/functions",queryParams:Object.keys(e).length>0?e:void 0,headers:{"Content-Type":"application/json"}})}async addPermission(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/policy`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async removePermission(n,e){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2015-03-31/functions/${encodeURIComponent(n)}/policy/${encodeURIComponent(e)}`,headers:{"Content-Type":"application/json"}})}async publishVersion(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/versions`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async createAlias(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/aliases`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateAlias(n){let{FunctionName:e,Name:t,...i}=n;return this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2015-03-31/functions/${encodeURIComponent(e)}/aliases/${encodeURIComponent(t)}`,headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async getAlias(n,e){try{return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2015-03-31/functions/${encodeURIComponent(n)}/aliases/${encodeURIComponent(e)}`})}catch(t){if(/ResourceNotFound/i.test(String(t?.message)))return null;throw t}}async getProvisionedConcurrencyConfig(n,e){try{return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2019-09-30/functions/${encodeURIComponent(n)}/provisioned-concurrency`,queryParams:{Qualifier:e}})}catch(t){if(/ProvisionedConcurrencyConfigNotFound|ResourceNotFound/i.test(String(t?.message)))return null;throw t}}async putProvisionedConcurrencyConfig(n){let{FunctionName:e,Qualifier:t,ProvisionedConcurrentExecutions:i}=n;return this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2019-09-30/functions/${encodeURIComponent(e)}/provisioned-concurrency`,queryParams:{Qualifier:t},headers:{"Content-Type":"application/json"},body:JSON.stringify({ProvisionedConcurrentExecutions:i})})}async getFunctionConcurrency(n){try{return(await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2019-10-31/functions/${encodeURIComponent(n)}/concurrency`}))?.ReservedConcurrentExecutions??null}catch(e){if(/ResourceNotFound|ProvisionedConcurrencyConfigNotFound/i.test(String(e?.message)))return null;throw e}}async putFunctionConcurrency(n,e){await this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2019-10-31/functions/${encodeURIComponent(n)}/concurrency`,headers:{"Content-Type":"application/json"},body:JSON.stringify({ReservedConcurrentExecutions:e})})}async deleteFunctionConcurrency(n){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2019-10-31/functions/${encodeURIComponent(n)}/concurrency`})}async deleteProvisionedConcurrencyConfig(n,e){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2019-09-30/functions/${encodeURIComponent(n)}/provisioned-concurrency`,queryParams:{Qualifier:e}})}async waitForFunctionActive(n,e=60){let t=Date.now(),i=e*1000;while(Date.now()-t<i)try{let r=await this.getFunction(n),s=r.Configuration?.State;if(s==="Active")return r.Configuration;if(s==="Failed")throw Error(`Function ${n} failed: ${r.Configuration?.StateReason}`);await new Promise((l)=>setTimeout(l,2000))}catch(r){if(r.code==="ResourceNotFoundException"){await new Promise((s)=>setTimeout(s,2000));continue}throw r}throw Error(`Timeout waiting for function ${n} to become active`)}async functionExists(n){try{return await this.getFunction(n),!0}catch(e){if(e.code==="ResourceNotFoundException"||e.statusCode===404)return!1;throw e}}async createFunctionUrl(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2021-10-31/functions/${encodeURIComponent(e)}/url`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async getFunctionUrl(n){try{return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2021-10-31/functions/${encodeURIComponent(n)}/url`,headers:{"Content-Type":"application/json"}})}catch(e){if(e.statusCode===404)return null;throw e}}async deleteFunctionUrl(n){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2021-10-31/functions/${encodeURIComponent(n)}/url`,headers:{"Content-Type":"application/json"}})}async createFunctionWithCode(n){let{Code:e,Filename:t="index.js",...i}=n,r=d(t,e);return this.createFunction({...i,Code:{ZipFile:r.toString("base64")}})}async addFunctionUrlPermission(n){return this.addPermission({FunctionName:n,StatementId:"FunctionURLAllowPublicAccess",Action:"lambda:InvokeFunctionUrl",Principal:"*",FunctionUrlAuthType:"NONE"})}async publishLayerVersion(n){let{LayerName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2018-10-31/layers/${encodeURIComponent(e)}/versions`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async listLayerVersions(n,e){let t={};if(e?.CompatibleRuntime)t.CompatibleRuntime=e.CompatibleRuntime;if(e?.CompatibleArchitecture)t.CompatibleArchitecture=e.CompatibleArchitecture;if(e?.MaxItems)t.MaxItems=String(e.MaxItems);if(e?.Marker)t.Marker=e.Marker;return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2018-10-31/layers/${encodeURIComponent(n)}/versions`,queryParams:Object.keys(t).length>0?t:void 0,headers:{"Content-Type":"application/json"}})}async getLayerVersion(n,e){return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2018-10-31/layers/${encodeURIComponent(n)}/versions/${e}`,headers:{"Content-Type":"application/json"}})}async addLayerVersionPermission(n){let{LayerName:e,VersionNumber:t,...i}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2018-10-31/layers/${encodeURIComponent(e)}/versions/${t}/policy`,headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async deleteLayerVersion(n,e){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2018-10-31/layers/${encodeURIComponent(n)}/versions/${e}`,headers:{"Content-Type":"application/json"}})}}
2
2
  export{R};
@@ -0,0 +1 @@
1
+ import{g}from"./chunk-a9yp82q5.js";import"./chunk-q9tvzcr7.js";export{g as S3Client};
@@ -1,2 +1,2 @@
1
- import{u}from"./chunk-y5e7dmvc.js";import{B}from"./chunk-kcprsn33.js";var S=new Set(["A","AAAA","CNAME"]);function E(e,t=""){return e===408||e===409||e===425||e===429||e>=500||/rate limit|temporar|timed? ?out|try again/i.test(t)}async function P(e,t){let r=t?.headers.get("retry-after"),n=r===null||r===void 0?void 0:Number(r)*1000,o=Number.isFinite(n)?Math.max(0,n):Math.min(1000*2**(e-1),30000);await new Promise((s)=>setTimeout(s,o))}class Qe{name="porkbun";apiKey;secretKey;requestTimeoutMs;constructor(e,t,r=15000){this.apiKey=e,this.secretKey=t,this.requestTimeoutMs=r}async request(e,t={}){let r;for(let n=1;n<=8;n+=1){let o,s=new AbortController,i=setTimeout(()=>{s.abort(Error(`Porkbun API request timed out after ${this.requestTimeoutMs}ms`))},this.requestTimeoutMs);try{o=await fetch(`https://api.porkbun.com/api/json/v3${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apikey:this.apiKey,secretapikey:this.secretKey,...t}),signal:s.signal})}catch(c){if(r=c,n===8)throw c;await P(n);continue}finally{clearTimeout(i)}if(!o.ok){let c=await o.clone().json().then((d)=>d?.message).catch(()=>{return});if(r=Error(`Porkbun API error: ${o.status} ${o.statusText}${c?`: ${c}`:""}`),!E(o.status)||n===8)throw r;await P(n,o);continue}let a=await o.json();if(a.status==="ERROR"){if(r=Error(`Porkbun API error: ${a.message||"Unknown error"}`),!E(0,a.message)||n===8)throw r;await P(n,o);continue}return a}throw r}getSubdomain(e,t){let r=e.replace(/\.$/,""),n=t.replace(/\.$/,"");if(r===n)return"";if(r.endsWith(`.${n}`))return r.slice(0,-(n.length+1));return r}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}static ADDRESS_TYPES=new Set(["A","AAAA"]);async clearConflictingAliases(e,t){if(!Qe.ADDRESS_TYPES.has(t.type))return[];let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o=await this.listRecords(e);if(!o.success)return[`could not list records to clear ALIAS/CNAME conflicts: ${o.message??"unknown provider error"}`];let s=[];for(let i of o.records){if(i.type!=="ALIAS"&&i.type!=="CNAME")continue;if(this.getSubdomain(i.name,r)!==n)continue;let a=await this.deleteRecord(e,i);if(!a.success)s.push(`could not remove conflicting ${i.type} on ${i.name}: ${a.message??"unknown provider error"}`)}return s}async addressRecordExists(e,t){let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o=await this.listRecords(e);if(!o.success)return!0;return o.records.some((s)=>s.type===t.type&&this.getSubdomain(s.name,r)===n&&s.content===t.content)}async createRecord(e,t){try{let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o={type:t.type,content:t.content,ttl:String(t.ttl||600)};if(n)o.name=n;if((t.type==="MX"||t.type==="SRV")&&t.priority!==void 0)o.prio=String(t.priority);if(t.type==="SRV"&&t.weight!==void 0&&t.port!==void 0)o.content=`${t.weight} ${t.port} ${t.content}`;let s=await this.clearConflictingAliases(e,t),i=await this.request(`/dns/create/${r}`,o);if(Qe.ADDRESS_TYPES.has(t.type)&&!await this.addressRecordExists(e,t))return{success:!1,message:`Porkbun reported success but no ${t.type} record for ${t.name} exists${s.length>0?` (${s.join("; ")})`:""}. A conflicting ALIAS/CNAME on the same name silently voids the write.`};return{success:!0,id:i.id?.toString(),message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o=await this.listRecords(e);if(o.success){let s=o.records.find((i)=>this.getSubdomain(i.name,r)===n&&i.type===t.type);if(s?.id&&s.content===t.content&&(t.ttl===void 0||s.ttl===t.ttl)&&(t.type!=="MX"&&t.type!=="SRV"||t.priority===void 0||s.priority===t.priority))return{success:!0,id:s.id,message:"Record already up to date"};if(s?.id){let i={type:t.type,content:t.content,ttl:String(t.ttl||600)};if(n)i.name=n;if((t.type==="MX"||t.type==="SRV")&&t.priority!==void 0)i.prio=String(t.priority);if(t.type==="SRV"&&t.weight!==void 0&&t.port!==void 0)i.content=`${t.weight} ${t.port} ${t.content}`;return await this.request(`/dns/edit/${r}/${s.id}`,i),{success:!0,id:s.id,message:"Record updated successfully"}}}return this.createRecord(e,t)}catch(r){return this.createRecord(e,t)}}async deleteRecord(e,t){try{let r=this.getRootDomain(e);if("id"in t&&t.id)return await this.request(`/dns/delete/${r}/${t.id}`),{success:!0,message:"Record deleted successfully"};let n=this.getSubdomain(t.name,r),o=await this.listRecords(e);if(!o.success)return{success:!1,message:"Failed to list records"};let s=o.records.find((i)=>this.getSubdomain(i.name,r)===n&&i.type===t.type&&i.content===t.content);if(!s?.id)return{success:!1,message:"Record not found"};return await this.request(`/dns/delete/${r}/${s.id}`),{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let r=this.getRootDomain(e),n=`/dns/retrieve/${r}`;if(t)n=`/dns/retrieveByNameType/${r}/${t}`;return{success:!0,records:((await this.request(n)).records||[]).map((i)=>({id:i.id,name:i.name||r,type:i.type,content:i.content,ttl:Number.parseInt(i.ttl,10),priority:i.prio?Number.parseInt(i.prio,10):void 0}))}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){try{let t=this.getRootDomain(e);return await this.request(`/dns/retrieve/${t}`),!0}catch{return!1}}async listDomains(){try{return((await this.request("/domain/listAll")).domains||[]).map((t)=>t.domain)}catch{return[]}}async getNameServers(e){try{let t=this.getRootDomain(e);return(await this.request(`/domain/getNs/${t}`)).ns||[]}catch{return[]}}async updateNameServers(e,t){try{let r=this.getRootDomain(e);return await this.request(`/domain/updateNs/${r}`,{ns:t}),!0}catch{return!1}}}class Ot{name="godaddy";apiKey;apiSecret;baseUrl;constructor(e,t="",r="production"){this.apiKey=e,this.apiSecret=t,this.baseUrl=r==="ote"?"https://api.ote-godaddy.com":"https://api.godaddy.com"}authorization(){if(!this.apiSecret||this.apiKey.startsWith("gd_pat_"))return`Bearer ${this.apiKey}`;return`sso-key ${this.apiKey}:${this.apiSecret}`}async request(e,t,r){let n=`${this.baseUrl}${t}`,o={Authorization:this.authorization(),"Content-Type":"application/json",Accept:"application/json"},s={method:e,headers:o};if(r)s.body=JSON.stringify(r);let i=await fetch(n,s);if(i.status===204)return{};if(i.ok){let c=await i.text();if(c)return JSON.parse(c);return{}}let a=`GoDaddy API error: ${i.status} ${i.statusText}`;try{let c=await i.json();if(c.message)a=`GoDaddy API error: ${c.message}`;if(c.fields)a+=` - Fields: ${JSON.stringify(c.fields)}`}catch{}throw Error(a)}getSubdomain(e,t){let r=e.replace(/\.$/,""),n=t.replace(/\.$/,"");if(r===n)return"@";if(r.endsWith(`.${n}`))return r.slice(0,-(n.length+1));return r}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}toGoDaddyRecord(e,t){let r=this.getRootDomain(t),n=this.getSubdomain(e.name,r),o={type:e.type,name:n,data:e.content,ttl:e.ttl||600};if(e.type==="MX"&&e.priority!==void 0)o.priority=e.priority;return o}fromGoDaddyRecord(e,t){let r=this.getRootDomain(t),n=e.name;if(n==="@")n=r;else if(!n.endsWith(r))n=`${n}.${r}`;return{name:n,type:e.type,content:e.data,ttl:e.ttl,priority:e.priority}}async createRecord(e,t){try{let r=this.getRootDomain(e),n=this.toGoDaddyRecord(t,e);return await this.request("PATCH",`/v1/domains/${r}/records`,[n]),{success:!0,message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=this.getRootDomain(e),n=this.toGoDaddyRecord(t,e);return await this.request("PUT",`/v1/domains/${r}/records/${t.type}/${n.name}`,[n]),{success:!0,message:"Record upserted successfully"}}catch(r){return this.createRecord(e,t)}}async deleteRecord(e,t){try{let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o=await this.request("GET",`/v1/domains/${r}/records/${t.type}/${n}`),s=o.filter((i)=>i.data!==t.content);if(s.length===o.length)return{success:!1,message:"Record not found"};if(s.length===0)try{await this.request("DELETE",`/v1/domains/${r}/records/${t.type}/${n}`)}catch{}else await this.request("PUT",`/v1/domains/${r}/records/${t.type}/${n}`,s);return{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let r=this.getRootDomain(e),n=`/v1/domains/${r}/records`;if(t)n=`/v1/domains/${r}/records/${t}`;return{success:!0,records:(await this.request("GET",n)).map((s)=>this.fromGoDaddyRecord(s,e))}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){try{let t=this.getRootDomain(e);return await this.request("GET",`/v1/domains/${t}`),!0}catch{return!1}}async listDomains(){try{return(await this.request("GET","/v1/domains")).map((t)=>t.domain)}catch{return[]}}async getDomainDetails(e){try{let t=this.getRootDomain(e),r=await this.request("GET",`/v1/domains/${t}`);return{domain:r.domain,status:r.status,nameServers:r.nameServers,expires:r.expires}}catch{return null}}async getNameServers(e){return(await this.getDomainDetails(e))?.nameServers??[]}async updateNameServers(e,t){try{let r=this.getRootDomain(e);return await this.request("PATCH",`/v1/domains/${r}`,{nameServers:t}),!0}catch{return!1}}async checkDomainAvailability(e){try{let t=await this.request("GET",`/v1/domains/available?domain=${encodeURIComponent(e)}`);return{available:t.available,price:t.price,currency:t.currency}}catch{return{available:!1}}}}var L=["js","mjs","cjs","css","map","woff","woff2","ttf","otf","eot","png","jpg","jpeg","gif","webp","avif","svg","ico","mp4","webm","ogg","mp3","wav","pdf","wasm"],U=[{name:"x-stx-router",value:"true"}];function y(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`}function x(e){return`{${e.map(y).join(" ")}}`}function j(e){let t=`http.request.headers[${y(e.name.toLowerCase())}]`;return e.value===void 0?`len(${t}) > 0`:`any(${t}[*] == ${y(e.value)})`}function D(e){if(e.length===1)return`http.host eq ${y(e[0])}`;return`http.host in ${x(e)}`}function bs(e,t={}){if(t.enabled===!1||e.length===0)return[];let r=D(e),n=[],s=(t.bypassPaths??[]).map((q)=>`starts_with(http.request.uri.path, ${y(q)})`),a=(t.negotiatedRequestHeaders??U).map(j),c=[...s,...a],d=c.length>0?`(${c.join(" or ")})`:void 0;if(d)n.push({action:"set_cache_settings",description:"bypass cache",expression:`(${r} and ${d})`,enabled:!0,action_parameters:{cache:!1}});let g=d?`${r} and not ${d}`:r,p=t.assetExtensions??L,l=p.length>0?`lower(http.request.uri.path.extension) in ${x([...p])}`:void 0;if(l)n.push({action:"set_cache_settings",description:"cache fingerprinted assets",expression:`(${g} and ${l})`,enabled:!0,action_parameters:{cache:!0,edge_ttl:{mode:"override_origin",default:t.assetEdgeTtl??2592000},browser_ttl:{mode:"override_origin",default:t.assetBrowserTtl??31536000}}});let R=l?`(${g} and not ${l})`:`(${g})`;if(t.documentEdgeTtl===0)return n.push({action:"set_cache_settings",description:"bypass documents",expression:R,enabled:!0,action_parameters:{cache:!1}}),n;return n.push({action:"set_cache_settings",description:"cache documents",expression:R,enabled:!0,action_parameters:{cache:!0,edge_ttl:{mode:"override_origin",default:t.documentEdgeTtl??3600},browser_ttl:{mode:"override_origin",default:t.documentBrowserTtl??0}}}),n}function vs(e,t,r){if(e.length===0||!t||!r)return[];return[{action:"rewrite",description:"origin guard header",expression:`(${D(e)})`,enabled:!0,action_parameters:{headers:{[t]:{operation:"set",value:r}}}}]}var H="https://api.cloudflare.com/client/v4",T="[ts-cloud]";class Ye{name="cloudflare";apiToken;zoneCache=new Map;configuredZoneId;accountId;configuredZoneName;constructor(e,t={}){this.apiToken=e,this.configuredZoneId=t.zoneId,this.accountId=t.accountId}async request(e,t,r){let n=`${H}${t}`,o={Authorization:`Bearer ${this.apiToken}`,"Content-Type":"application/json"},s={method:e,headers:o};if(r)s.body=JSON.stringify(r);let a=await(await fetch(n,s)).json();if(!a.success){let c=a.errors.map((d)=>d.message).join(", ");throw Error(`Cloudflare API error: ${c}`)}return a}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}async resolveZone(e){let t=e.replace(/\.$/,"").toLowerCase();if(this.configuredZoneId){let i=await this.resolveConfiguredZoneName();if(i&&(t===i||t.endsWith(`.${i}`)))return{id:this.configuredZoneId,name:i}}let r=this.getRootDomain(t),n=this.zoneCache.get(r);if(n)return{id:n,name:r};let o=await this.request("GET",`/zones?name=${encodeURIComponent(r)}`);if(!o.result||o.result.length===0)throw Error(`Zone not found for domain: ${r}. `+"If the API token is scoped to a single zone, set its zone id (CLOUDFLARE_ZONE_ID) — "+"zone lookup by name needs account-wide Zone:Read.");let s=o.result[0].id;return this.zoneCache.set(r,s),{id:s,name:o.result[0].name||r}}async resolveConfiguredZoneName(){if(!this.configuredZoneId)return;if(this.configuredZoneName)return this.configuredZoneName;try{let t=(await this.request("GET",`/zones/${this.configuredZoneId}`)).result?.name?.toLowerCase();if(!t)return;return this.configuredZoneName=t,this.zoneCache.set(t,this.configuredZoneId),t}catch{return}}async getZoneId(e){return(await this.resolveZone(e)).id}getFullRecordName(e,t){let r=e.replace(/\.$/,"");if(!r||r===t||r==="@")return t;if(r.endsWith(`.${t}`))return r;return`${r}.${t}`}toCloudflareRecord(e,t,r){let n={type:e.type,name:this.getFullRecordName(e.name,t),content:e.content||e.value||"",ttl:e.ttl||1},o=r??e.proxied;if(o!==void 0&&S.has(e.type)){if(n.proxied=o,o)n.ttl=1}if(e.type==="MX"&&e.priority!==void 0)n.priority=e.priority;if(e.type==="SRV"){let s=W(e);if(s)n.data=s,delete n.content,delete n.priority;else if(e.priority!==void 0)n.priority=e.priority}return n}fromCloudflareRecord(e){return{id:e.id,name:e.name,type:e.type,content:e.content,ttl:e.ttl,priority:e.priority,proxied:e.proxied}}async createRecord(e,t){try{let r=await this.resolveZone(e),n=this.toCloudflareRecord(t,r.name);return{success:!0,id:(await this.request("POST",`/zones/${r.id}/dns_records`,n)).result.id,message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=await this.resolveZone(e),n=this.getFullRecordName(t.name,r.name),s=(await this.request("GET",`/zones/${r.id}/dns_records?type=${t.type}&name=${encodeURIComponent(n)}`)).result?.[0],i=t.proxied??s?.proxied,a=this.toCloudflareRecord(t,r.name,i);if(s)return{success:!0,id:(await this.request("PUT",`/zones/${r.id}/dns_records/${s.id}`,a)).result.id,message:"Record updated successfully"};return{success:!0,id:(await this.request("POST",`/zones/${r.id}/dns_records`,a)).result.id,message:"Record created successfully"}}catch(r){return this.createRecord(e,t)}}async deleteRecord(e,t){try{let r=await this.resolveZone(e),n=r.id,o=this.getFullRecordName(t.name,r.name),s=await this.request("GET",`/zones/${n}/dns_records?type=${t.type}&name=${encodeURIComponent(o)}`);if(!s.result||s.result.length===0)return{success:!1,message:"Record not found"};let i=s.result.find((a)=>a.content===t.content);if(!i)return{success:!1,message:"Record with matching content not found"};return await this.request("DELETE",`/zones/${n}/dns_records/${i.id}`),{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let n=`/zones/${await this.getZoneId(e)}/dns_records?per_page=100`;if(t)n+=`&type=${t}`;let o=[],s=1,i=!0;while(i){let a=await this.request("GET",`${n}&page=${s}`);if(o.push(...a.result||[]),a.result_info)i=s<a.result_info.total_pages,s++;else i=!1}return{success:!0,records:o.map((a)=>this.fromCloudflareRecord(a))}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){try{return await this.getZoneId(e),!0}catch{return!1}}async listDomains(){try{let e=[],t=1,r=!0;while(r){let n=await this.request("GET",`/zones?per_page=50&page=${t}`);if(e.push(...n.result||[]),n.result_info)r=t<n.result_info.total_pages,t++;else r=!1}return e.map((n)=>n.name)}catch{return[]}}async createZone(e,t={}){let r=e.replace(/\.$/,"").toLowerCase(),n=t.accountId??this.accountId;if(!n)throw Error(`Cannot create zone ${r}: no Cloudflare account id. Set CLOUDFLARE_ACCOUNT_ID, or pass accountId.`);let o=await this.getZoneDetails(r);if(o)return{...o,created:!1};try{let i=(await this.request("POST","/zones",{name:r,account:{id:n},jump_start:t.jumpStart??!1})).result;return this.zoneCache.set(i.name,i.id),{id:i.id,name:i.name,status:i.status,nameServers:i.name_servers??[],created:!0}}catch(s){let i=s instanceof Error?s.message:String(s);if(!/already exists|1061/i.test(i))throw s;let a=await this.getZoneDetails(r);if(!a)throw s;return{...a,created:!1}}}async getZoneDetails(e){try{let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}`);return{id:r.result.id,name:r.result.name,status:r.result.status,nameServers:r.result.name_servers,paused:r.result.paused}}catch{return null}}async listEdgeCertificateHosts(e){try{let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}/ssl/certificate_packs?per_page=50`),n=new Set;for(let o of r.result||[]){if(o.status!=="active")continue;for(let s of o.hosts||[])n.add(s.toLowerCase())}return[...n]}catch{return null}}async purgeCache(e,t){try{let r=await this.getZoneId(e),n={};if(t?.purgeEverything)n.purge_everything=!0;else{if(t?.files)n.files=t.files;if(t?.tags)n.tags=t.tags;if(t?.hosts)n.hosts=t.hosts}if(Object.keys(n).length===0)n.purge_everything=!0;return await this.request("POST",`/zones/${r}/purge_cache`,n),!0}catch{return!1}}async getRecordProxyStatus(e,t){try{let r=await this.resolveZone(e),n=r.id,o=this.getFullRecordName(t.name,r.name),s=await this.request("GET",`/zones/${n}/dns_records?type=${t.type}&name=${encodeURIComponent(o)}`);if(s.result&&s.result.length>0)return s.result.find((a)=>a.content===t.content)?.proxied??null;return null}catch{return null}}async setRecordProxyStatus(e,t,r){try{let n=await this.resolveZone(e),o=n.id,s=this.getFullRecordName(t.name,n.name),i=await this.request("GET",`/zones/${o}/dns_records?type=${t.type}&name=${encodeURIComponent(s)}`);if(!i.result||i.result.length===0)return!1;let a=i.result.find((c)=>c.content===t.content);if(!a)return!1;return await this.request("PATCH",`/zones/${o}/dns_records/${a.id}`,{proxied:r}),!0}catch{return!1}}async zoneIdFor(e){return this.getZoneId(e)}get account(){return this.accountId}async getZoneSettings(e){let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}/settings`),n={};for(let o of r.result||[])n[o.id]=o.value;return n}async applyZoneSettings(e,t){let r=await this.getZoneId(e),n=await this.getZoneSettings(e).catch(()=>({})),o=[],s=[];for(let[i,a]of Object.entries(t)){if(a===void 0)continue;let c=n[i];if(c!==void 0&&b(c,a))continue;try{await this.request("PATCH",`/zones/${r}/settings/${i}`,{value:a}),o.push({id:i,from:c,to:a})}catch(d){s.push({id:i,error:d instanceof Error?d.message:String(d)})}}return{changed:o,failed:s}}async getManagedRequestHeaders(e){let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}/managed_headers`),n={};for(let o of r.result?.managed_request_headers||[])n[o.id]=o.enabled===!0;return n}async applyManagedRequestHeaders(e,t){let r=[],n=[],o=Object.entries(t).filter(([,c])=>c!==void 0);if(o.length===0)return{changed:r,failed:n};let s=await this.getZoneId(e),i;try{i=await this.getManagedRequestHeaders(e)}catch(c){let d=c instanceof Error?c.message:String(c);for(let[g]of o)n.push({id:g,error:`could not read managed headers — ${d}`});return{changed:r,failed:n}}let a=[];for(let[c,d]of o){if(!(c in i)){n.push({id:c,error:"not a managed request header transform on this zone"});continue}if(i[c]!==d)a.push([c,d])}if(a.length===0)return{changed:r,failed:n};try{await this.request("PATCH",`/zones/${s}/managed_headers`,{managed_request_headers:a.map(([c,d])=>({id:c,enabled:d})),managed_response_headers:[]});for(let[c,d]of a)r.push({id:c,from:i[c],to:d})}catch(c){let d=c instanceof Error?c.message:String(c);for(let[g]of a)n.push({id:g,error:d})}return{changed:r,failed:n}}async getPhaseRules(e,t){let r=await this.getZoneId(e);try{return(await this.request("GET",`/zones/${r}/rulesets/phases/${t}/entrypoint`)).result?.rules||[]}catch{return[]}}async putManagedPhaseRules(e,t,r){try{let n=await this.getZoneId(e),o=await this.getPhaseRules(e,t),s=r.map((c)=>({...c,description:c.description?.startsWith(T)?c.description:`${T} ${c.description||t}`})),a=K(o,s).map(({id:c,...d})=>d);return await this.request("PUT",`/zones/${n}/rulesets/phases/${t}/entrypoint`,{rules:a}),{success:!0}}catch(n){return{success:!1,message:n instanceof Error?n.message:String(n)}}}}var N=/http\.host (?:eq "[^"]+"|in \{[^}]*\})/;function _(e){return N.test(e)?e.replace(N,"\x00hosts\x00"):null}function k(e,t){return e.replace(N,D(t))}function w(e){if(Array.isArray(e))return`[${e.map(w).join(",")}]`;if(e&&typeof e==="object")return`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>`${JSON.stringify(r)}:${w(n)}`).join(",")}}`;return JSON.stringify(e)}function F(e,t){let r=_(e.expression);return r!==null&&r===_(t.expression)&&e.action===t.action&&e.description===t.description&&(e.enabled??!0)===(t.enabled??!0)&&w(e.action_parameters)===w(t.action_parameters)}function K(e,t){let r=new Set(t.flatMap((s)=>v(s.expression))),n=(s)=>(s.description||"").startsWith(T),o=[];for(let s of e){if(!n(s)){o.push(s);continue}let i=v(s.expression);if(i.length===0){if(r.size>0)o.push(s);continue}let a=i.filter((c)=>!r.has(c));if(a.length===i.length)o.push(s);else if(a.length>0)o.push({...s,expression:k(s.expression,a)})}for(let s of t){let i=v(s.expression),a=i.length>0?o.findIndex((g)=>n(g)&&F(g,s)):-1;if(a===-1){o.push(s);continue}let c=o[a],d=[...new Set([...v(c.expression),...i])];o[a]={...c,expression:k(c.expression,d)}}return o}function v(e){let t=[];for(let r of e.matchAll(/http\.host eq "([^"]+)"/g))t.push(r[1]);for(let r of e.matchAll(/http\.host in \{([^}]*)\}/g))for(let n of r[1].matchAll(/"([^"]+)"/g))t.push(n[1]);return t}function b(e,t){if(e===t)return!0;if(typeof e!==typeof t||e===null||t===null)return!1;if(typeof e!=="object")return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;return e.every((o,s)=>b(o,t[s]))}let r=e,n=t;return Object.keys(n).every((o)=>b(r[o],n[o]))}function W(e){let t=(e.content||e.value||"").trim();if(e.weight!==void 0&&e.port!==void 0&&e.priority!==void 0&&t)return{priority:e.priority,weight:e.weight,port:e.port,target:V(t)};let r=t.split(/\s+/);if(r.length<4)return null;let[n,o,s]=r.slice(0,3).map(Number);if(![n,o,s].every(Number.isFinite))return null;return{priority:n,weight:o,port:s,target:V(r.slice(3).join(" "))}}function V(e){return e.replace(/\.$/,"")}var X=new Set(["A","AAAA","CNAME","ALIAS"]);function A(e){let t=e.trim().replace(/^"|"$/g,"").toLowerCase();if(t.startsWith("v=spf1"))return"v=spf1";if(t.startsWith("v=dmarc1"))return"v=dmarc1";return}function f(e){return e.trim().replace(/^"(.*)"$/s,"$1")}function h(e){return e.replace(/\.$/,"").toLowerCase()}function Z(e,t){let r=h(t),n=(e??"@").trim();if(!n||n==="@")return r;let o=h(n);if(o===r||o.endsWith(`.${r}`))return o;return`${o}.${r}`}function eo(e,t){return e.map((r)=>({...r,name:Z(r.name,t),proxied:r.proxied??!1}))}function Y(e,t){if(e.type!==t.type)return!1;if(h(e.name)!==h(t.name))return!1;if(X.has(t.type))return!0;if(t.type==="TXT"){let r=A(t.content);if(r)return A(f(e.content))===r;return f(e.content)===f(t.content)}return f(e.content)===f(t.content)}function J(e,t){if(f(e.content)!==f(t.content))return!1;if(t.priority!==void 0&&e.priority!==t.priority)return!1;if(t.proxied!==void 0&&e.proxied!==void 0&&e.proxied!==t.proxied)return!1;return!0}async function to(e){let{provider:t,zone:r,records:n}=e,o={outcomes:[],warnings:[]};if(n.length===0)return o;let s=await t.listRecords(r);if(!s.success)return o.warnings.push(`could not list ${r}: ${s.message||"unknown provider error"} — records not reconciled`),o;let i=s.records;for(let a of n){let c=i.filter((l)=>Y(l,a));if(c.length>0&&c.every((l)=>J(l,a))){o.outcomes.push({record:a,action:"unchanged"});continue}let d={name:a.name,type:a.type,content:a.content,ttl:a.ttl??3600,...a.priority!==void 0?{priority:a.priority}:{},...a.proxied!==void 0?{proxied:a.proxied}:{}},g=a.type==="TXT"&&A(a.content)!==void 0;if(g)for(let l of c){let R=await t.deleteRecord(r,{name:l.name,type:l.type,content:l.content});if(!R.success)o.warnings.push(`could not remove superseded ${l.type} at ${l.name}: ${R.message||"unknown error"}`)}let p=g||c.length===0?await t.createRecord(r,d):await t.upsertRecord(r,d);if(p.success)o.outcomes.push({record:a,action:c.length>0?"updated":"created"});else o.outcomes.push({record:a,action:"failed",message:p.message})}for(let a of["MX"]){let c=new Set(n.filter((d)=>d.type===a).map((d)=>h(d.name)));for(let d of c){let g=new Set(n.filter((l)=>l.type===a&&h(l.name)===d).map((l)=>f(l.content).toLowerCase())),p=i.filter((l)=>l.type===a&&h(l.name)===d&&!g.has(f(l.content).toLowerCase()));for(let l of p)o.warnings.push(`${d} has an undeclared ${a} record (${l.content}) alongside the declared one — mail will be split between them. Remove it at the provider if it is stale.`)}}return o}class Yr{name="route53";client;hostedZoneCache=new Map;providedHostedZoneId;constructor(e="us-east-1",t){this.client=new B(e),this.providedHostedZoneId=t}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}async getHostedZoneId(e){if(this.providedHostedZoneId)return this.providedHostedZoneId;let t=this.getRootDomain(e),r=this.hostedZoneCache.get(t);if(r)return r;let n=await this.client.findHostedZoneForDomain(e);if(n){let o=n.Id.replace("/hostedzone/","");return this.hostedZoneCache.set(t,o),o}return null}normalizeName(e,t){let r=e.replace(/\.$/,""),n=t.replace(/\.$/,"");if(!n||n==="@")return`${r}.`;if(n===r||n.endsWith(`.${r}`))return`${n}.`;return`${n}.${r}.`}formatValue(e){let t=e.content;if(e.type==="TXT"&&!t.startsWith('"'))t=re(t);if(e.type==="MX"&&e.priority!==void 0)t=`${e.priority} ${t}`;return t}sameValue(e,t,r){return e==="TXT"?I(t)===I(r):t===r}async currentSet(e,t,r){let o=(await this.client.listResourceRecordSets({HostedZoneId:e,StartRecordName:t,StartRecordType:r,MaxItems:"1"})).ResourceRecordSets?.[0];if(!o||o.Name.toLowerCase()!==t.toLowerCase()||o.Type!==r||o.AliasTarget||o.SetIdentifier)return null;return{ttl:o.TTL??300,values:(o.ResourceRecords??[]).map((s)=>s.Value)}}async createRecord(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,message:`No hosted zone found for domain: ${e}`};let n=this.normalizeName(e,t.name),o=this.formatValue(t),s=await this.currentSet(r,n,t.type);if(s?.values.some((c)=>this.sameValue(t.type,c,o)))return{success:!0,message:"Record already present"};let i=[...s?.values??[],o];return{success:!0,id:(await this.client.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:"Created by ts-cloud DNS provider",Changes:[{Action:s?"UPSERT":"CREATE",ResourceRecordSet:{Name:n,Type:t.type,TTL:s?.ttl??t.ttl??300,ResourceRecords:i.map((c)=>({Value:c}))}}]}})).ChangeInfo?.Id,message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,message:`No hosted zone found for domain: ${e}`};let n=this.normalizeName(e,t.name),o=this.formatValue(t);return{success:!0,id:(await this.client.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:"Upserted by ts-cloud DNS provider",Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:n,Type:t.type,TTL:t.ttl||300,ResourceRecords:[{Value:o}]}}]}})).ChangeInfo?.Id,message:"Record upserted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async deleteRecord(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,message:`No hosted zone found for domain: ${e}`};let n=this.normalizeName(e,t.name),o=this.formatValue(t),s=await this.currentSet(r,n,t.type);if(!s||!s.values.some((a)=>this.sameValue(t.type,a,o)))return{success:!0,message:"Record already absent"};let i=s.values.filter((a)=>!this.sameValue(t.type,a,o));return await this.client.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:"Deleted by ts-cloud DNS provider",Changes:[{Action:i.length>0?"UPSERT":"DELETE",ResourceRecordSet:{Name:n,Type:t.type,TTL:s.ttl,ResourceRecords:(i.length>0?i:s.values).map((a)=>({Value:a}))}}]}}),{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,records:[],message:`No hosted zone found for domain: ${e}`};let n=await this.client.listResourceRecordSets({HostedZoneId:r,StartRecordType:t}),o=[];for(let s of n.ResourceRecordSets){if(t&&s.Type!==t)continue;if(s.AliasTarget)continue;for(let i of s.ResourceRecords||[]){let a=i.Value,c;if(s.Type==="MX"){let d=a.split(" ");if(d.length>=2)c=Number.parseInt(d[0],10),a=d.slice(1).join(" ")}if(s.Type==="TXT"&&a.startsWith('"'))a=I(a);o.push({name:s.Name.replace(/\.$/,""),type:s.Type,content:a,ttl:s.TTL,priority:c})}}return{success:!0,records:o}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){return await this.getHostedZoneId(e)!==null}async listDomains(){try{return(await this.client.listHostedZones()).HostedZones.map((t)=>t.Name.replace(/\.$/,""))}catch{return[]}}getRoute53Client(){return this.client}async createAliasRecord(e){try{let t=await this.getHostedZoneId(e.domain);if(!t)return{success:!1,message:`No hosted zone found for domain: ${e.domain}`};return{success:!0,id:(await this.client.createAliasRecord({HostedZoneId:t,Name:this.normalizeName(e.domain,e.name),TargetHostedZoneId:e.targetHostedZoneId,TargetDNSName:e.targetDnsName,EvaluateTargetHealth:e.evaluateTargetHealth,Type:e.type})).ChangeInfo?.Id,message:"Alias record created successfully"}}catch(t){return{success:!1,message:t instanceof Error?t.message:"Unknown error"}}}async createCloudFrontAlias(e){return this.createAliasRecord({domain:e.domain,name:e.name,targetHostedZoneId:B.CloudFrontHostedZoneId,targetDnsName:e.cloudFrontDomainName,evaluateTargetHealth:!1})}async createAlbAlias(e){let t=B.ALBHostedZoneIds[e.region];if(!t)return{success:!1,message:`Unknown region for ALB: ${e.region}`};return this.createAliasRecord({domain:e.domain,name:e.name,targetHostedZoneId:t,targetDnsName:e.albDnsName,evaluateTargetHealth:!0})}}var O=255;function re(e){let t=[];for(let r=0;r<e.length;r+=O)t.push(e.slice(r,r+O));if(t.length===0)t.push("");return t.map((r)=>`"${r.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`).join(" ")}function I(e){if(!e.startsWith('"'))return e;let t="",r=!1;for(let n=0;n<e.length;n++){let o=e[n];if(!r){if(o==='"')r=!0;continue}if(o==="\\"&&n+1<e.length){t+=e[++n];continue}if(o==='"'){r=!1;continue}t+=o}return t}async function ro(e,t){let r=[],n,o;for(;;){let s=await e.listResourceRecordSets({HostedZoneId:t,StartRecordName:n,StartRecordType:o,MaxItems:"100"});if(r.push(...s.ResourceRecordSets),!s.IsTruncated)break;if(n=s.NextRecordName,o=s.NextRecordType,!n)break}return r}function m(e){return e.replace(/\.$/,"").toLowerCase()}function z(e){return e.replace(/\.$/,"")}function C(e){if(e.type==="SRV"&&e.weight!==void 0&&e.port!==void 0)return`${e.weight} ${e.port} ${z(e.content)}`;return z(e.content)}function ne(e){let t=e.match(/"(?:[^"\\]|\\.)*"/g);if(!t)return e;return t.map((r)=>r.slice(1,-1).replace(/\\(.)/g,"$1")).join("")}function no(e,t){let r=m(t),n=[],o=[],s=[],i=new Set;for(let a of e){let c=m(a.Name),d=a.Type;if(d==="SOA"||d==="NS"&&c===r){o.push({name:c,type:d,reason:"owned by the destination provider"});continue}if(a.SetIdentifier){o.push({name:c,type:d,reason:`routing policy record (SetIdentifier=${a.SetIdentifier}) has no equivalent — recreate by hand`}),s.push(`${d} ${c} is part of a Route53 routing policy and was NOT migrated`);continue}if(a.AliasTarget){if(i.has(c))continue;i.add(c);let g=m(a.AliasTarget.DNSName);if(n.push({name:c,type:"CNAME",content:g,ttl:300,translatedFrom:`${d} ALIAS → ${g}`}),a.AliasTarget.EvaluateTargetHealth)s.push(`${c} was an ALIAS with health evaluation enabled; the CNAME that replaces it has no health check`);continue}for(let g of a.ResourceRecords||[]){let p=se(c,d,g.Value,a.TTL);if("reason"in p){o.push({name:c,type:d,reason:p.reason}),s.push(`${d} ${c}: ${p.reason}`);continue}n.push(p)}}return{zone:r,records:n,skipped:o,warnings:s}}function se(e,t,r,n){let o={name:e,ttl:n};switch(t){case"A":case"AAAA":case"CNAME":case"PTR":return{...o,type:t==="PTR"?"CNAME":t,content:m(r)};case"TXT":return{...o,type:"TXT",content:ne(r)};case"MX":{let[s,...i]=r.trim().split(/\s+/);if(!i.length)return{reason:`malformed MX value "${r}"`};return{...o,type:"MX",content:m(i.join(" ")),priority:Number(s)}}case"SRV":{let s=r.trim().split(/\s+/);if(s.length<4)return{reason:`malformed SRV value "${r}"`};let[i,a,c]=s.slice(0,3).map(Number);return{...o,type:"SRV",content:m(s.slice(3).join(" ")),priority:i,weight:a,port:c}}case"NS":return{...o,type:"NS",content:m(r)};case"CAA":return{...o,type:"CAA",content:r.trim()};default:return{reason:`unsupported record type ${t}`}}}var oe=new Set(["TXT","MX","SRV","NS","CAA"]);async function io(e,t){let r=[],n=[],o=new Set;try{let s=await e.listRecords(t.zone);for(let i of s.records||[])o.add(`${m(i.name)}|${i.type}|${C(i)}`)}catch{}for(let s of t.records){let i={...s,proxied:!1},a=`${m(s.name)}|${s.type}|${C(s)}`;if(!oe.has(s.type)){let d=await e.upsertRecord(t.zone,i);if(d.success)r.push(s);else n.push({record:s,message:d.message||"unknown provider error"});continue}if(o.has(a)){r.push(s);continue}let c=await e.createRecord(t.zone,i);if(c.success)o.add(a),r.push(s);else n.push({record:s,message:c.message||"unknown provider error"})}return{applied:r,failed:n}}async function oo(e,t){let r=await e.listRecords(t.zone),n=[],o=[],s=new Map;for(let i of r.records||[]){let a=`${m(i.name)}|${i.type}`,c=s.get(a)??[];c.push(C(i)),s.set(a,c)}for(let i of t.records){let a=s.get(`${m(i.name)}|${i.type}`),c=C(i);if(a?.some((d)=>d===c))n.push(i);else o.push({record:i,found:a?.join(", ")})}return{matched:n,missing:o,ok:o.length===0}}class Lt{acm;dnsProvider;constructor(e,t="us-east-1"){if(this.acm=new G(t),"provider"in e)this.dnsProvider=M(e);else this.dnsProvider=e}getProvider(){return this.dnsProvider}async requestAndValidate(e){let{domainName:t,subjectAlternativeNames:r=[],waitForValidation:n=!1,maxWaitMinutes:o=30}=e,{CertificateArn:s}=await this.acm.requestCertificate({DomainName:t,SubjectAlternativeNames:r.length>0?[t,...r]:void 0,ValidationMethod:"DNS"});await this.waitForValidationOptions(s);let i=await this.acm.getDnsValidationRecords(s);for(let c of i){let d=await this.dnsProvider.upsertRecord(t,{name:c.recordName,type:c.recordType,content:c.recordValue,ttl:300});if(!d.success)console.warn(`Failed to create validation record for ${c.domainName}: ${d.message}`)}let a="pending";if(n)a=(await this.acm.waitForCertificateValidation(s,o*2,30000))?.Status==="ISSUED"?"issued":"failed";return{certificateArn:s,validationRecords:i.map((c)=>({domainName:c.domainName,recordName:c.recordName,recordType:c.recordType,recordValue:c.recordValue})),isNew:!0,status:a}}async createValidationRecords(e){let{certificateArn:t,domain:r}=e,n=[],o=await this.acm.getDnsValidationRecords(t);for(let s of o){let i=await this.dnsProvider.upsertRecord(r,{name:s.recordName,type:s.recordType,content:s.recordValue,ttl:300});if(!i.success)n.push(`Failed to create record for ${s.domainName}: ${i.message}`)}return{success:n.length===0,records:o.map((s)=>({domainName:s.domainName,recordName:s.recordName,recordType:s.recordType,recordValue:s.recordValue})),errors:n}}async deleteValidationRecords(e){let{certificateArn:t,domain:r}=e,n=[],o=await this.acm.getDnsValidationRecords(t);for(let s of o){let i=await this.dnsProvider.deleteRecord(r,{name:s.recordName,type:s.recordType,content:s.recordValue});if(!i.success)n.push(`Failed to delete record for ${s.domainName}: ${i.message}`)}return{success:n.length===0,errors:n}}async findOrCreateCertificate(e){let{domainName:t,subjectAlternativeNames:r=[],waitForValidation:n=!0,maxWaitMinutes:o}=e,s=await this.acm.findCertificateByDomain(t);if(s&&s.Status==="ISSUED"){let i=s.SubjectAlternativeNames||[s.DomainName],a=i.some((d)=>d===`*.${t}`);if(r.every((d)=>i.includes(d)||a))return{certificateArn:s.CertificateArn,validationRecords:[],isNew:!1,status:"issued"};console.log("Existing certificate doesn't cover all required SANs, requesting new certificate...")}return this.requestAndValidate({domainName:t,subjectAlternativeNames:r,waitForValidation:n,maxWaitMinutes:o})}async requestCertificateWithCommonSans(e){let{domainName:t,includeWww:r=!0,includeWildcard:n=!1,additionalSans:o=[],waitForValidation:s=!1}=e,i=[];if(r)i.push(`www.${t}`);if(n)i.push(`*.${t}`);return i.push(...o),this.requestAndValidate({domainName:t,subjectAlternativeNames:i,waitForValidation:s})}async waitForValidationOptions(e,t=30){for(let r=0;r<t;r++){let n=await this.acm.describeCertificate({CertificateArn:e});if(n.DomainValidationOptions&&n.DomainValidationOptions.length>0&&n.DomainValidationOptions[0].ResourceRecord)return;await new Promise((o)=>setTimeout(o,2000))}throw Error("Timeout waiting for DNS validation options")}async getCertificateStatus(e){let t=await this.acm.describeCertificate({CertificateArn:e});return{status:t.Status,domainValidations:(t.DomainValidationOptions||[]).map((r)=>({domain:r.DomainName,status:r.ValidationStatus||"UNKNOWN"}))}}}function M(e){switch(e.provider){case"route53":return new Yr(e.region,e.hostedZoneId);case"porkbun":return new Qe(e.apiKey,e.secretKey);case"godaddy":return new Ot(e.apiKey,e.apiSecret,e.environment);case"cloudflare":return new Ye(e.apiToken,{zoneId:e.zoneId,accountId:e.accountId});default:throw Error(`Unknown DNS provider: ${e.provider}`)}}class si{providers=new Map;configs=[];addConfig(e){return this.configs.push(e),this}addRoute53(e,t){return this.configs.push({provider:"route53",region:e,hostedZoneId:t}),this}addPorkbun(e,t){return this.configs.push({provider:"porkbun",apiKey:e,secretKey:t}),this}addGoDaddy(e,t,r){return this.configs.push({provider:"godaddy",apiKey:e,apiSecret:t,environment:r}),this}addCloudflare(e,t={}){return this.configs.push({provider:"cloudflare",apiToken:e,zoneId:t.zoneId,accountId:t.accountId}),this}loadFromEnv(){if(process.env.AWS_ACCESS_KEY_ID||process.env.AWS_PROFILE||process.env.AWS_REGION)this.addRoute53(process.env.AWS_REGION);let e=process.env.PORKBUN_API_KEY,t=process.env.PORKBUN_SECRET_KEY;if(e&&t)this.addPorkbun(e,t);let r=process.env.GODADDY_API_KEY,n=process.env.GODADDY_API_SECRET;if(r&&n){let s=process.env.GODADDY_ENVIRONMENT;this.addGoDaddy(r,n,s)}let o=process.env.CLOUDFLARE_API_TOKEN;if(o)this.addCloudflare(o,{zoneId:process.env.CLOUDFLARE_ZONE_ID,accountId:process.env.CLOUDFLARE_ACCOUNT_ID});return this}getProvider(e){let t=this.providers.get(e);if(t)return t;let r=this.configs.find((o)=>o.provider===e);if(!r)return null;let n=M(r);return this.providers.set(e,n),n}async getProviderForDomain(e){for(let t of this.configs){let r=M(t);if(await r.canManageDomain(e))return r}return null}getAllProviders(){return this.configs.map((e)=>M(e))}}var ze=new si;class G{client;region;constructor(e="us-east-1"){this.client=new u,this.region=e}async requestCertificate(e){let t={DomainName:e.DomainName,ValidationMethod:e.ValidationMethod||"DNS"};if(e.SubjectAlternativeNames)t.SubjectAlternativeNames=e.SubjectAlternativeNames;return{CertificateArn:(await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.RequestCertificate"},body:JSON.stringify(t)})).CertificateArn||""}}async describeCertificate(e){let r=(await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.DescribeCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn})})).Certificate||{};return{CertificateArn:r.CertificateArn||"",DomainName:r.DomainName||"",SubjectAlternativeNames:r.SubjectAlternativeNames,Status:r.Status||"PENDING_VALIDATION",Type:r.Type,DomainValidationOptions:r.DomainValidationOptions?.map((n)=>({DomainName:n.DomainName,ValidationDomain:n.ValidationDomain,ValidationStatus:n.ValidationStatus,ResourceRecord:n.ResourceRecord?{Name:n.ResourceRecord.Name,Type:n.ResourceRecord.Type,Value:n.ResourceRecord.Value}:void 0,ValidationMethod:n.ValidationMethod})),CreatedAt:r.CreatedAt,IssuedAt:r.IssuedAt,NotBefore:r.NotBefore,NotAfter:r.NotAfter}}async listCertificates(e){let t={};if(e?.CertificateStatuses)t.CertificateStatuses=e.CertificateStatuses;if(e?.MaxItems)t.MaxItems=e.MaxItems;if(e?.NextToken)t.NextToken=e.NextToken;let r=await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.ListCertificates"},body:JSON.stringify(t)});return{CertificateSummaryList:(r.CertificateSummaryList||[]).map((n)=>({CertificateArn:n.CertificateArn,DomainName:n.DomainName})),NextToken:r.NextToken}}async deleteCertificate(e){await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.DeleteCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn})})}async listTagsForCertificate(e){return{Tags:(await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.ListTagsForCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn})})).Tags||[]}}async addTagsToCertificate(e){await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.AddTagsToCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn,Tags:e.Tags})})}async resendValidationEmail(e){await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.ResendValidationEmail"},body:JSON.stringify({CertificateArn:e.CertificateArn,Domain:e.Domain,ValidationDomain:e.ValidationDomain})})}async findCertificateByDomain(e){let r=(await this.listCertificates({CertificateStatuses:["ISSUED"]})).CertificateSummaryList.find((n)=>n.DomainName===e||n.DomainName===`*.${e.split(".").slice(1).join(".")}`);if(!r)return null;return this.describeCertificate({CertificateArn:r.CertificateArn})}async waitForCertificateValidation(e,t=60,r=30000){for(let n=0;n<t;n++){let o=await this.describeCertificate({CertificateArn:e});if(o.Status==="ISSUED")return o;if(o.Status==="FAILED"||o.Status==="VALIDATION_TIMED_OUT")return null;await new Promise((s)=>setTimeout(s,r))}return null}async getDnsValidationRecords(e){let t=await this.describeCertificate({CertificateArn:e});if(!t.DomainValidationOptions)return[];return t.DomainValidationOptions.filter((r)=>r.ResourceRecord&&r.ValidationMethod==="DNS").map((r)=>({domainName:r.DomainName,recordName:r.ResourceRecord.Name,recordType:r.ResourceRecord.Type,recordValue:r.ResourceRecord.Value}))}async requestCertificateWithSans(e){let t=new Set;if(t.add(e.DomainName),e.IncludeWww!==!1)t.add(`www.${e.DomainName}`);if(e.IncludeWildcard)t.add(`*.${e.DomainName}`);if(e.AdditionalSans)for(let r of e.AdditionalSans)t.add(r);return this.requestCertificate({DomainName:e.DomainName,SubjectAlternativeNames:Array.from(t),ValidationMethod:"DNS"})}async isCertificateValidForDomain(e,t){let r=await this.describeCertificate({CertificateArn:e});if(r.Status!=="ISSUED")return!1;if(r.DomainName===t)return!0;if(r.DomainName?.startsWith("*.")){let n=r.DomainName.slice(2),o=t.split("."),s=n.split(".");if(o.slice(-s.length).join(".")===n)return!0}if(r.SubjectAlternativeNames)for(let n of r.SubjectAlternativeNames){if(n===t)return!0;if(n.startsWith("*.")){let o=n.slice(2),s=t.split("."),i=o.split(".");if(s.slice(-i.length).join(".")===o)return!0}}return!1}}class so{acm;route53;dnsProvider;constructor(e="us-east-1",t){if(this.acm=new G(e),this.route53=new B,t&&t.provider!=="route53")this.dnsProvider=M(t)}async requestAndValidate(e){let{domainName:t,hostedZoneId:r,subjectAlternativeNames:n=[],waitForValidation:o=!1,maxWaitMinutes:s=30}=e;if(!this.dnsProvider&&!r)throw Error("Either hostedZoneId or external DNS provider configuration is required");let{CertificateArn:i}=await this.acm.requestCertificate({DomainName:t,SubjectAlternativeNames:n.length>0?[t,...n]:void 0,ValidationMethod:"DNS"});await this.waitForValidationOptions(i);let a=await this.acm.getDnsValidationRecords(i);if(this.dnsProvider)for(let c of a){let d=await this.dnsProvider.upsertRecord(t,{name:c.recordName,type:c.recordType,content:c.recordValue,ttl:300});if(!d.success)console.warn(`Failed to create validation record for ${c.domainName}: ${d.message}`)}else if(r)for(let c of a)await this.route53.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:`ACM DNS validation for ${c.domainName}`,Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:c.recordName,Type:c.recordType,TTL:300,ResourceRecords:[{Value:c.recordValue}]}}]}});if(o){if(!await this.acm.waitForCertificateValidation(i,s*2,30000))throw Error(`Certificate validation timed out after ${s} minutes`)}return{certificateArn:i,validationRecords:a}}async waitForValidationOptions(e,t=30){for(let r=0;r<t;r++){let n=await this.acm.describeCertificate({CertificateArn:e});if(n.DomainValidationOptions&&n.DomainValidationOptions.length>0&&n.DomainValidationOptions[0].ResourceRecord)return;await new Promise((o)=>setTimeout(o,2000))}throw Error("Timeout waiting for DNS validation options")}async createValidationRecords(e){let{certificateArn:t,hostedZoneId:r,domain:n}=e;if(!this.dnsProvider&&!r)throw Error("Either hostedZoneId or external DNS provider configuration is required");let o=await this.acm.getDnsValidationRecords(t),s=[];if(this.dnsProvider){let i=n||o[0]?.domainName;for(let a of o){let c=await this.dnsProvider.upsertRecord(i,{name:a.recordName,type:a.recordType,content:a.recordValue,ttl:300});s.push({...a,changeId:c.success?c.id:void 0})}}else if(r)for(let i of o){let a=await this.route53.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:`ACM DNS validation for ${i.domainName}`,Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:i.recordName,Type:i.recordType,TTL:300,ResourceRecords:[{Value:i.recordValue}]}}]}});s.push({...i,changeId:a.ChangeInfo?.Id})}return s}async deleteValidationRecords(e){let{certificateArn:t,hostedZoneId:r,domain:n}=e,o=await this.acm.getDnsValidationRecords(t);if(this.dnsProvider){let s=n||o[0]?.domainName;for(let i of o)try{await this.dnsProvider.deleteRecord(s,{name:i.recordName,type:i.recordType,content:i.recordValue})}catch{}}else if(r)for(let s of o)try{await this.route53.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:`Cleanup ACM DNS validation for ${s.domainName}`,Changes:[{Action:"DELETE",ResourceRecordSet:{Name:s.recordName,Type:s.recordType,TTL:300,ResourceRecords:[{Value:s.recordValue}]}}]}})}catch{}}async findOrCreateCertificate(e){let{domainName:t,hostedZoneId:r,subjectAlternativeNames:n,waitForValidation:o=!0}=e;if(!this.dnsProvider&&!r)throw Error("Either hostedZoneId or external DNS provider configuration is required");let s=await this.acm.findCertificateByDomain(t);if(s&&s.Status==="ISSUED")return{certificateArn:s.CertificateArn,isNew:!1};let{certificateArn:i}=await this.requestAndValidate({domainName:t,hostedZoneId:r,subjectAlternativeNames:n,waitForValidation:o});return{certificateArn:i,isNew:!0}}hasExternalDnsProvider(){return this.dnsProvider!==void 0}getDnsProviderName(){return this.dnsProvider?.name||"route53"}}
2
- export{Qe,Ot,bs,vs,Ye,eo,to,Yr,ro,no,io,oo,G,so,Lt,M,si};
1
+ import{u}from"./chunk-q9tvzcr7.js";import{B}from"./chunk-y9cdqk8c.js";var S=new Set(["A","AAAA","CNAME"]);function E(e,t=""){return e===408||e===409||e===425||e===429||e>=500||/rate limit|temporar|timed? ?out|try again/i.test(t)}async function P(e,t){let r=t?.headers.get("retry-after"),n=r===null||r===void 0?void 0:Number(r)*1000,o=Number.isFinite(n)?Math.max(0,n):Math.min(1000*2**(e-1),30000);await new Promise((s)=>setTimeout(s,o))}class Qe{name="porkbun";apiKey;secretKey;requestTimeoutMs;constructor(e,t,r=15000){this.apiKey=e,this.secretKey=t,this.requestTimeoutMs=r}async request(e,t={}){let r;for(let n=1;n<=8;n+=1){let o,s=new AbortController,i=setTimeout(()=>{s.abort(Error(`Porkbun API request timed out after ${this.requestTimeoutMs}ms`))},this.requestTimeoutMs);try{o=await fetch(`https://api.porkbun.com/api/json/v3${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apikey:this.apiKey,secretapikey:this.secretKey,...t}),signal:s.signal})}catch(c){if(r=c,n===8)throw c;await P(n);continue}finally{clearTimeout(i)}if(!o.ok){let c=await o.clone().json().then((d)=>d?.message).catch(()=>{return});if(r=Error(`Porkbun API error: ${o.status} ${o.statusText}${c?`: ${c}`:""}`),!E(o.status)||n===8)throw r;await P(n,o);continue}let a=await o.json();if(a.status==="ERROR"){if(r=Error(`Porkbun API error: ${a.message||"Unknown error"}`),!E(0,a.message)||n===8)throw r;await P(n,o);continue}return a}throw r}getSubdomain(e,t){let r=e.replace(/\.$/,""),n=t.replace(/\.$/,"");if(r===n)return"";if(r.endsWith(`.${n}`))return r.slice(0,-(n.length+1));return r}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}static ADDRESS_TYPES=new Set(["A","AAAA"]);async clearConflictingAliases(e,t){if(!Qe.ADDRESS_TYPES.has(t.type))return[];let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o=await this.listRecords(e);if(!o.success)return[`could not list records to clear ALIAS/CNAME conflicts: ${o.message??"unknown provider error"}`];let s=[];for(let i of o.records){if(i.type!=="ALIAS"&&i.type!=="CNAME")continue;if(this.getSubdomain(i.name,r)!==n)continue;let a=await this.deleteRecord(e,i);if(!a.success)s.push(`could not remove conflicting ${i.type} on ${i.name}: ${a.message??"unknown provider error"}`)}return s}async addressRecordExists(e,t){let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o=await this.listRecords(e);if(!o.success)return!0;return o.records.some((s)=>s.type===t.type&&this.getSubdomain(s.name,r)===n&&s.content===t.content)}async createRecord(e,t){try{let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o={type:t.type,content:t.content,ttl:String(t.ttl||600)};if(n)o.name=n;if((t.type==="MX"||t.type==="SRV")&&t.priority!==void 0)o.prio=String(t.priority);if(t.type==="SRV"&&t.weight!==void 0&&t.port!==void 0)o.content=`${t.weight} ${t.port} ${t.content}`;let s=await this.clearConflictingAliases(e,t),i=await this.request(`/dns/create/${r}`,o);if(Qe.ADDRESS_TYPES.has(t.type)&&!await this.addressRecordExists(e,t))return{success:!1,message:`Porkbun reported success but no ${t.type} record for ${t.name} exists${s.length>0?` (${s.join("; ")})`:""}. A conflicting ALIAS/CNAME on the same name silently voids the write.`};return{success:!0,id:i.id?.toString(),message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o=await this.listRecords(e);if(o.success){let s=o.records.find((i)=>this.getSubdomain(i.name,r)===n&&i.type===t.type);if(s?.id&&s.content===t.content&&(t.ttl===void 0||s.ttl===t.ttl)&&(t.type!=="MX"&&t.type!=="SRV"||t.priority===void 0||s.priority===t.priority))return{success:!0,id:s.id,message:"Record already up to date"};if(s?.id){let i={type:t.type,content:t.content,ttl:String(t.ttl||600)};if(n)i.name=n;if((t.type==="MX"||t.type==="SRV")&&t.priority!==void 0)i.prio=String(t.priority);if(t.type==="SRV"&&t.weight!==void 0&&t.port!==void 0)i.content=`${t.weight} ${t.port} ${t.content}`;return await this.request(`/dns/edit/${r}/${s.id}`,i),{success:!0,id:s.id,message:"Record updated successfully"}}}return this.createRecord(e,t)}catch(r){return this.createRecord(e,t)}}async deleteRecord(e,t){try{let r=this.getRootDomain(e);if("id"in t&&t.id)return await this.request(`/dns/delete/${r}/${t.id}`),{success:!0,message:"Record deleted successfully"};let n=this.getSubdomain(t.name,r),o=await this.listRecords(e);if(!o.success)return{success:!1,message:"Failed to list records"};let s=o.records.find((i)=>this.getSubdomain(i.name,r)===n&&i.type===t.type&&i.content===t.content);if(!s?.id)return{success:!1,message:"Record not found"};return await this.request(`/dns/delete/${r}/${s.id}`),{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let r=this.getRootDomain(e),n=`/dns/retrieve/${r}`;if(t)n=`/dns/retrieveByNameType/${r}/${t}`;return{success:!0,records:((await this.request(n)).records||[]).map((i)=>({id:i.id,name:i.name||r,type:i.type,content:i.content,ttl:Number.parseInt(i.ttl,10),priority:i.prio?Number.parseInt(i.prio,10):void 0}))}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){try{let t=this.getRootDomain(e);return await this.request(`/dns/retrieve/${t}`),!0}catch{return!1}}async listDomains(){try{return((await this.request("/domain/listAll")).domains||[]).map((t)=>t.domain)}catch{return[]}}async getNameServers(e){try{let t=this.getRootDomain(e);return(await this.request(`/domain/getNs/${t}`)).ns||[]}catch{return[]}}async updateNameServers(e,t){try{let r=this.getRootDomain(e);return await this.request(`/domain/updateNs/${r}`,{ns:t}),!0}catch{return!1}}}class Ot{name="godaddy";apiKey;apiSecret;baseUrl;constructor(e,t="",r="production"){this.apiKey=e,this.apiSecret=t,this.baseUrl=r==="ote"?"https://api.ote-godaddy.com":"https://api.godaddy.com"}authorization(){if(!this.apiSecret||this.apiKey.startsWith("gd_pat_"))return`Bearer ${this.apiKey}`;return`sso-key ${this.apiKey}:${this.apiSecret}`}async request(e,t,r){let n=`${this.baseUrl}${t}`,o={Authorization:this.authorization(),"Content-Type":"application/json",Accept:"application/json"},s={method:e,headers:o};if(r)s.body=JSON.stringify(r);let i=await fetch(n,s);if(i.status===204)return{};if(i.ok){let c=await i.text();if(c)return JSON.parse(c);return{}}let a=`GoDaddy API error: ${i.status} ${i.statusText}`;try{let c=await i.json();if(c.message)a=`GoDaddy API error: ${c.message}`;if(c.fields)a+=` - Fields: ${JSON.stringify(c.fields)}`}catch{}throw Error(a)}getSubdomain(e,t){let r=e.replace(/\.$/,""),n=t.replace(/\.$/,"");if(r===n)return"@";if(r.endsWith(`.${n}`))return r.slice(0,-(n.length+1));return r}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}toGoDaddyRecord(e,t){let r=this.getRootDomain(t),n=this.getSubdomain(e.name,r),o={type:e.type,name:n,data:e.content,ttl:e.ttl||600};if(e.type==="MX"&&e.priority!==void 0)o.priority=e.priority;return o}fromGoDaddyRecord(e,t){let r=this.getRootDomain(t),n=e.name;if(n==="@")n=r;else if(!n.endsWith(r))n=`${n}.${r}`;return{name:n,type:e.type,content:e.data,ttl:e.ttl,priority:e.priority}}async createRecord(e,t){try{let r=this.getRootDomain(e),n=this.toGoDaddyRecord(t,e);return await this.request("PATCH",`/v1/domains/${r}/records`,[n]),{success:!0,message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=this.getRootDomain(e),n=this.toGoDaddyRecord(t,e);return await this.request("PUT",`/v1/domains/${r}/records/${t.type}/${n.name}`,[n]),{success:!0,message:"Record upserted successfully"}}catch(r){return this.createRecord(e,t)}}async deleteRecord(e,t){try{let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),o=await this.request("GET",`/v1/domains/${r}/records/${t.type}/${n}`),s=o.filter((i)=>i.data!==t.content);if(s.length===o.length)return{success:!1,message:"Record not found"};if(s.length===0)try{await this.request("DELETE",`/v1/domains/${r}/records/${t.type}/${n}`)}catch{}else await this.request("PUT",`/v1/domains/${r}/records/${t.type}/${n}`,s);return{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let r=this.getRootDomain(e),n=`/v1/domains/${r}/records`;if(t)n=`/v1/domains/${r}/records/${t}`;return{success:!0,records:(await this.request("GET",n)).map((s)=>this.fromGoDaddyRecord(s,e))}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){try{let t=this.getRootDomain(e);return await this.request("GET",`/v1/domains/${t}`),!0}catch{return!1}}async listDomains(){try{return(await this.request("GET","/v1/domains")).map((t)=>t.domain)}catch{return[]}}async getDomainDetails(e){try{let t=this.getRootDomain(e),r=await this.request("GET",`/v1/domains/${t}`);return{domain:r.domain,status:r.status,nameServers:r.nameServers,expires:r.expires}}catch{return null}}async getNameServers(e){return(await this.getDomainDetails(e))?.nameServers??[]}async updateNameServers(e,t){try{let r=this.getRootDomain(e);return await this.request("PATCH",`/v1/domains/${r}`,{nameServers:t}),!0}catch{return!1}}async checkDomainAvailability(e){try{let t=await this.request("GET",`/v1/domains/available?domain=${encodeURIComponent(e)}`);return{available:t.available,price:t.price,currency:t.currency}}catch{return{available:!1}}}}var L=["js","mjs","cjs","css","map","woff","woff2","ttf","otf","eot","png","jpg","jpeg","gif","webp","avif","svg","ico","mp4","webm","ogg","mp3","wav","pdf","wasm"],U=[{name:"x-stx-router",value:"true"}];function y(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`}function x(e){return`{${e.map(y).join(" ")}}`}function j(e){let t=`http.request.headers[${y(e.name.toLowerCase())}]`;return e.value===void 0?`len(${t}) > 0`:`any(${t}[*] == ${y(e.value)})`}function D(e){if(e.length===1)return`http.host eq ${y(e[0])}`;return`http.host in ${x(e)}`}function vs(e,t={}){if(t.enabled===!1||e.length===0)return[];let r=D(e),n=[],s=(t.bypassPaths??[]).map((q)=>`starts_with(http.request.uri.path, ${y(q)})`),a=(t.negotiatedRequestHeaders??U).map(j),c=[...s,...a],d=c.length>0?`(${c.join(" or ")})`:void 0;if(d)n.push({action:"set_cache_settings",description:"bypass cache",expression:`(${r} and ${d})`,enabled:!0,action_parameters:{cache:!1}});let g=d?`${r} and not ${d}`:r,p=t.assetExtensions??L,l=p.length>0?`lower(http.request.uri.path.extension) in ${x([...p])}`:void 0;if(l)n.push({action:"set_cache_settings",description:"cache fingerprinted assets",expression:`(${g} and ${l})`,enabled:!0,action_parameters:{cache:!0,edge_ttl:{mode:"override_origin",default:t.assetEdgeTtl??2592000},browser_ttl:{mode:"override_origin",default:t.assetBrowserTtl??31536000}}});let R=l?`(${g} and not ${l})`:`(${g})`;if(t.documentEdgeTtl===0)return n.push({action:"set_cache_settings",description:"bypass documents",expression:R,enabled:!0,action_parameters:{cache:!1}}),n;return n.push({action:"set_cache_settings",description:"cache documents",expression:R,enabled:!0,action_parameters:{cache:!0,edge_ttl:{mode:"override_origin",default:t.documentEdgeTtl??3600},browser_ttl:{mode:"override_origin",default:t.documentBrowserTtl??0}}}),n}function Ts(e,t,r){if(e.length===0||!t||!r)return[];return[{action:"rewrite",description:"origin guard header",expression:`(${D(e)})`,enabled:!0,action_parameters:{headers:{[t]:{operation:"set",value:r}}}}]}var H="https://api.cloudflare.com/client/v4",T="[ts-cloud]";class Ye{name="cloudflare";apiToken;zoneCache=new Map;configuredZoneId;accountId;configuredZoneName;constructor(e,t={}){this.apiToken=e,this.configuredZoneId=t.zoneId,this.accountId=t.accountId}async request(e,t,r){let n=`${H}${t}`,o={Authorization:`Bearer ${this.apiToken}`,"Content-Type":"application/json"},s={method:e,headers:o};if(r)s.body=JSON.stringify(r);let a=await(await fetch(n,s)).json();if(!a.success){let c=a.errors.map((d)=>d.message).join(", ");throw Error(`Cloudflare API error: ${c}`)}return a}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}async resolveZone(e){let t=e.replace(/\.$/,"").toLowerCase();if(this.configuredZoneId){let i=await this.resolveConfiguredZoneName();if(i&&(t===i||t.endsWith(`.${i}`)))return{id:this.configuredZoneId,name:i}}let r=this.getRootDomain(t),n=this.zoneCache.get(r);if(n)return{id:n,name:r};let o=await this.request("GET",`/zones?name=${encodeURIComponent(r)}`);if(!o.result||o.result.length===0)throw Error(`Zone not found for domain: ${r}. `+"If the API token is scoped to a single zone, set its zone id (CLOUDFLARE_ZONE_ID) — "+"zone lookup by name needs account-wide Zone:Read.");let s=o.result[0].id;return this.zoneCache.set(r,s),{id:s,name:o.result[0].name||r}}async resolveConfiguredZoneName(){if(!this.configuredZoneId)return;if(this.configuredZoneName)return this.configuredZoneName;try{let t=(await this.request("GET",`/zones/${this.configuredZoneId}`)).result?.name?.toLowerCase();if(!t)return;return this.configuredZoneName=t,this.zoneCache.set(t,this.configuredZoneId),t}catch{return}}async getZoneId(e){return(await this.resolveZone(e)).id}getFullRecordName(e,t){let r=e.replace(/\.$/,"");if(!r||r===t||r==="@")return t;if(r.endsWith(`.${t}`))return r;return`${r}.${t}`}toCloudflareRecord(e,t,r){let n={type:e.type,name:this.getFullRecordName(e.name,t),content:e.content||e.value||"",ttl:e.ttl||1},o=r??e.proxied;if(o!==void 0&&S.has(e.type)){if(n.proxied=o,o)n.ttl=1}if(e.type==="MX"&&e.priority!==void 0)n.priority=e.priority;if(e.type==="SRV"){let s=W(e);if(s)n.data=s,delete n.content,delete n.priority;else if(e.priority!==void 0)n.priority=e.priority}return n}fromCloudflareRecord(e){return{id:e.id,name:e.name,type:e.type,content:e.content,ttl:e.ttl,priority:e.priority,proxied:e.proxied}}async createRecord(e,t){try{let r=await this.resolveZone(e),n=this.toCloudflareRecord(t,r.name);return{success:!0,id:(await this.request("POST",`/zones/${r.id}/dns_records`,n)).result.id,message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=await this.resolveZone(e),n=this.getFullRecordName(t.name,r.name),s=(await this.request("GET",`/zones/${r.id}/dns_records?type=${t.type}&name=${encodeURIComponent(n)}`)).result?.[0],i=t.proxied??s?.proxied,a=this.toCloudflareRecord(t,r.name,i);if(s)return{success:!0,id:(await this.request("PUT",`/zones/${r.id}/dns_records/${s.id}`,a)).result.id,message:"Record updated successfully"};return{success:!0,id:(await this.request("POST",`/zones/${r.id}/dns_records`,a)).result.id,message:"Record created successfully"}}catch(r){return this.createRecord(e,t)}}async deleteRecord(e,t){try{let r=await this.resolveZone(e),n=r.id,o=this.getFullRecordName(t.name,r.name),s=await this.request("GET",`/zones/${n}/dns_records?type=${t.type}&name=${encodeURIComponent(o)}`);if(!s.result||s.result.length===0)return{success:!1,message:"Record not found"};let i=s.result.find((a)=>a.content===t.content);if(!i)return{success:!1,message:"Record with matching content not found"};return await this.request("DELETE",`/zones/${n}/dns_records/${i.id}`),{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let n=`/zones/${await this.getZoneId(e)}/dns_records?per_page=100`;if(t)n+=`&type=${t}`;let o=[],s=1,i=!0;while(i){let a=await this.request("GET",`${n}&page=${s}`);if(o.push(...a.result||[]),a.result_info)i=s<a.result_info.total_pages,s++;else i=!1}return{success:!0,records:o.map((a)=>this.fromCloudflareRecord(a))}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){try{return await this.getZoneId(e),!0}catch{return!1}}async listDomains(){try{let e=[],t=1,r=!0;while(r){let n=await this.request("GET",`/zones?per_page=50&page=${t}`);if(e.push(...n.result||[]),n.result_info)r=t<n.result_info.total_pages,t++;else r=!1}return e.map((n)=>n.name)}catch{return[]}}async createZone(e,t={}){let r=e.replace(/\.$/,"").toLowerCase(),n=t.accountId??this.accountId;if(!n)throw Error(`Cannot create zone ${r}: no Cloudflare account id. Set CLOUDFLARE_ACCOUNT_ID, or pass accountId.`);let o=await this.getZoneDetails(r);if(o)return{...o,created:!1};try{let i=(await this.request("POST","/zones",{name:r,account:{id:n},jump_start:t.jumpStart??!1})).result;return this.zoneCache.set(i.name,i.id),{id:i.id,name:i.name,status:i.status,nameServers:i.name_servers??[],created:!0}}catch(s){let i=s instanceof Error?s.message:String(s);if(!/already exists|1061/i.test(i))throw s;let a=await this.getZoneDetails(r);if(!a)throw s;return{...a,created:!1}}}async getZoneDetails(e){try{let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}`);return{id:r.result.id,name:r.result.name,status:r.result.status,nameServers:r.result.name_servers,paused:r.result.paused}}catch{return null}}async listEdgeCertificateHosts(e){try{let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}/ssl/certificate_packs?per_page=50`),n=new Set;for(let o of r.result||[]){if(o.status!=="active")continue;for(let s of o.hosts||[])n.add(s.toLowerCase())}return[...n]}catch{return null}}async purgeCache(e,t){try{let r=await this.getZoneId(e),n={};if(t?.purgeEverything)n.purge_everything=!0;else{if(t?.files)n.files=t.files;if(t?.tags)n.tags=t.tags;if(t?.hosts)n.hosts=t.hosts}if(Object.keys(n).length===0)n.purge_everything=!0;return await this.request("POST",`/zones/${r}/purge_cache`,n),!0}catch{return!1}}async getRecordProxyStatus(e,t){try{let r=await this.resolveZone(e),n=r.id,o=this.getFullRecordName(t.name,r.name),s=await this.request("GET",`/zones/${n}/dns_records?type=${t.type}&name=${encodeURIComponent(o)}`);if(s.result&&s.result.length>0)return s.result.find((a)=>a.content===t.content)?.proxied??null;return null}catch{return null}}async setRecordProxyStatus(e,t,r){try{let n=await this.resolveZone(e),o=n.id,s=this.getFullRecordName(t.name,n.name),i=await this.request("GET",`/zones/${o}/dns_records?type=${t.type}&name=${encodeURIComponent(s)}`);if(!i.result||i.result.length===0)return!1;let a=i.result.find((c)=>c.content===t.content);if(!a)return!1;return await this.request("PATCH",`/zones/${o}/dns_records/${a.id}`,{proxied:r}),!0}catch{return!1}}async zoneIdFor(e){return this.getZoneId(e)}get account(){return this.accountId}async getZoneSettings(e){let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}/settings`),n={};for(let o of r.result||[])n[o.id]=o.value;return n}async applyZoneSettings(e,t){let r=await this.getZoneId(e),n=await this.getZoneSettings(e).catch(()=>({})),o=[],s=[];for(let[i,a]of Object.entries(t)){if(a===void 0)continue;let c=n[i];if(c!==void 0&&b(c,a))continue;try{await this.request("PATCH",`/zones/${r}/settings/${i}`,{value:a}),o.push({id:i,from:c,to:a})}catch(d){s.push({id:i,error:d instanceof Error?d.message:String(d)})}}return{changed:o,failed:s}}async getManagedRequestHeaders(e){let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}/managed_headers`),n={};for(let o of r.result?.managed_request_headers||[])n[o.id]=o.enabled===!0;return n}async applyManagedRequestHeaders(e,t){let r=[],n=[],o=Object.entries(t).filter(([,c])=>c!==void 0);if(o.length===0)return{changed:r,failed:n};let s=await this.getZoneId(e),i;try{i=await this.getManagedRequestHeaders(e)}catch(c){let d=c instanceof Error?c.message:String(c);for(let[g]of o)n.push({id:g,error:`could not read managed headers — ${d}`});return{changed:r,failed:n}}let a=[];for(let[c,d]of o){if(!(c in i)){n.push({id:c,error:"not a managed request header transform on this zone"});continue}if(i[c]!==d)a.push([c,d])}if(a.length===0)return{changed:r,failed:n};try{await this.request("PATCH",`/zones/${s}/managed_headers`,{managed_request_headers:a.map(([c,d])=>({id:c,enabled:d})),managed_response_headers:[]});for(let[c,d]of a)r.push({id:c,from:i[c],to:d})}catch(c){let d=c instanceof Error?c.message:String(c);for(let[g]of a)n.push({id:g,error:d})}return{changed:r,failed:n}}async getPhaseRules(e,t){let r=await this.getZoneId(e);try{return(await this.request("GET",`/zones/${r}/rulesets/phases/${t}/entrypoint`)).result?.rules||[]}catch{return[]}}async putManagedPhaseRules(e,t,r){try{let n=await this.getZoneId(e),o=await this.getPhaseRules(e,t),s=r.map((c)=>({...c,description:c.description?.startsWith(T)?c.description:`${T} ${c.description||t}`})),a=K(o,s).map(({id:c,...d})=>d);return await this.request("PUT",`/zones/${n}/rulesets/phases/${t}/entrypoint`,{rules:a}),{success:!0}}catch(n){return{success:!1,message:n instanceof Error?n.message:String(n)}}}}var N=/http\.host (?:eq "[^"]+"|in \{[^}]*\})/;function _(e){return N.test(e)?e.replace(N,"\x00hosts\x00"):null}function k(e,t){return e.replace(N,D(t))}function w(e){if(Array.isArray(e))return`[${e.map(w).join(",")}]`;if(e&&typeof e==="object")return`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>`${JSON.stringify(r)}:${w(n)}`).join(",")}}`;return JSON.stringify(e)}function F(e,t){let r=_(e.expression);return r!==null&&r===_(t.expression)&&e.action===t.action&&e.description===t.description&&(e.enabled??!0)===(t.enabled??!0)&&w(e.action_parameters)===w(t.action_parameters)}function K(e,t){let r=new Set(t.flatMap((s)=>v(s.expression))),n=(s)=>(s.description||"").startsWith(T),o=[];for(let s of e){if(!n(s)){o.push(s);continue}let i=v(s.expression);if(i.length===0){if(r.size>0)o.push(s);continue}let a=i.filter((c)=>!r.has(c));if(a.length===i.length)o.push(s);else if(a.length>0)o.push({...s,expression:k(s.expression,a)})}for(let s of t){let i=v(s.expression),a=i.length>0?o.findIndex((g)=>n(g)&&F(g,s)):-1;if(a===-1){o.push(s);continue}let c=o[a],d=[...new Set([...v(c.expression),...i])];o[a]={...c,expression:k(c.expression,d)}}return o}function v(e){let t=[];for(let r of e.matchAll(/http\.host eq "([^"]+)"/g))t.push(r[1]);for(let r of e.matchAll(/http\.host in \{([^}]*)\}/g))for(let n of r[1].matchAll(/"([^"]+)"/g))t.push(n[1]);return t}function b(e,t){if(e===t)return!0;if(typeof e!==typeof t||e===null||t===null)return!1;if(typeof e!=="object")return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;return e.every((o,s)=>b(o,t[s]))}let r=e,n=t;return Object.keys(n).every((o)=>b(r[o],n[o]))}function W(e){let t=(e.content||e.value||"").trim();if(e.weight!==void 0&&e.port!==void 0&&e.priority!==void 0&&t)return{priority:e.priority,weight:e.weight,port:e.port,target:V(t)};let r=t.split(/\s+/);if(r.length<4)return null;let[n,o,s]=r.slice(0,3).map(Number);if(![n,o,s].every(Number.isFinite))return null;return{priority:n,weight:o,port:s,target:V(r.slice(3).join(" "))}}function V(e){return e.replace(/\.$/,"")}var X=new Set(["A","AAAA","CNAME","ALIAS"]);function A(e){let t=e.trim().replace(/^"|"$/g,"").toLowerCase();if(t.startsWith("v=spf1"))return"v=spf1";if(t.startsWith("v=dmarc1"))return"v=dmarc1";return}function f(e){return e.trim().replace(/^"(.*)"$/s,"$1")}function h(e){return e.replace(/\.$/,"").toLowerCase()}function Z(e,t){let r=h(t),n=(e??"@").trim();if(!n||n==="@")return r;let o=h(n);if(o===r||o.endsWith(`.${r}`))return o;return`${o}.${r}`}function to(e,t){return e.map((r)=>({...r,name:Z(r.name,t),proxied:r.proxied??!1}))}function Y(e,t){if(e.type!==t.type)return!1;if(h(e.name)!==h(t.name))return!1;if(X.has(t.type))return!0;if(t.type==="TXT"){let r=A(t.content);if(r)return A(f(e.content))===r;return f(e.content)===f(t.content)}return f(e.content)===f(t.content)}function J(e,t){if(f(e.content)!==f(t.content))return!1;if(t.priority!==void 0&&e.priority!==t.priority)return!1;if(t.proxied!==void 0&&e.proxied!==void 0&&e.proxied!==t.proxied)return!1;return!0}async function ro(e){let{provider:t,zone:r,records:n}=e,o={outcomes:[],warnings:[]};if(n.length===0)return o;let s=await t.listRecords(r);if(!s.success)return o.warnings.push(`could not list ${r}: ${s.message||"unknown provider error"} — records not reconciled`),o;let i=s.records;for(let a of n){let c=i.filter((l)=>Y(l,a));if(c.length>0&&c.every((l)=>J(l,a))){o.outcomes.push({record:a,action:"unchanged"});continue}let d={name:a.name,type:a.type,content:a.content,ttl:a.ttl??3600,...a.priority!==void 0?{priority:a.priority}:{},...a.proxied!==void 0?{proxied:a.proxied}:{}},g=a.type==="TXT"&&A(a.content)!==void 0;if(g)for(let l of c){let R=await t.deleteRecord(r,{name:l.name,type:l.type,content:l.content});if(!R.success)o.warnings.push(`could not remove superseded ${l.type} at ${l.name}: ${R.message||"unknown error"}`)}let p=g||c.length===0?await t.createRecord(r,d):await t.upsertRecord(r,d);if(p.success)o.outcomes.push({record:a,action:c.length>0?"updated":"created"});else o.outcomes.push({record:a,action:"failed",message:p.message})}for(let a of["MX"]){let c=new Set(n.filter((d)=>d.type===a).map((d)=>h(d.name)));for(let d of c){let g=new Set(n.filter((l)=>l.type===a&&h(l.name)===d).map((l)=>f(l.content).toLowerCase())),p=i.filter((l)=>l.type===a&&h(l.name)===d&&!g.has(f(l.content).toLowerCase()));for(let l of p)o.warnings.push(`${d} has an undeclared ${a} record (${l.content}) alongside the declared one — mail will be split between them. Remove it at the provider if it is stale.`)}}return o}class Zr{name="route53";client;hostedZoneCache=new Map;providedHostedZoneId;constructor(e="us-east-1",t){this.client=new B(e),this.providedHostedZoneId=t}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}async getHostedZoneId(e){if(this.providedHostedZoneId)return this.providedHostedZoneId;let t=this.getRootDomain(e),r=this.hostedZoneCache.get(t);if(r)return r;let n=await this.client.findHostedZoneForDomain(e);if(n){let o=n.Id.replace("/hostedzone/","");return this.hostedZoneCache.set(t,o),o}return null}normalizeName(e,t){let r=e.replace(/\.$/,""),n=t.replace(/\.$/,"");if(!n||n==="@")return`${r}.`;if(n===r||n.endsWith(`.${r}`))return`${n}.`;return`${n}.${r}.`}formatValue(e){let t=e.content;if(e.type==="TXT"&&!t.startsWith('"'))t=re(t);if(e.type==="MX"&&e.priority!==void 0)t=`${e.priority} ${t}`;return t}sameValue(e,t,r){return e==="TXT"?I(t)===I(r):t===r}async currentSet(e,t,r){let o=(await this.client.listResourceRecordSets({HostedZoneId:e,StartRecordName:t,StartRecordType:r,MaxItems:"1"})).ResourceRecordSets?.[0];if(!o||o.Name.toLowerCase()!==t.toLowerCase()||o.Type!==r||o.AliasTarget||o.SetIdentifier)return null;return{ttl:o.TTL??300,values:(o.ResourceRecords??[]).map((s)=>s.Value)}}async createRecord(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,message:`No hosted zone found for domain: ${e}`};let n=this.normalizeName(e,t.name),o=this.formatValue(t),s=await this.currentSet(r,n,t.type);if(s?.values.some((c)=>this.sameValue(t.type,c,o)))return{success:!0,message:"Record already present"};let i=[...s?.values??[],o];return{success:!0,id:(await this.client.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:"Created by ts-cloud DNS provider",Changes:[{Action:s?"UPSERT":"CREATE",ResourceRecordSet:{Name:n,Type:t.type,TTL:s?.ttl??t.ttl??300,ResourceRecords:i.map((c)=>({Value:c}))}}]}})).ChangeInfo?.Id,message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,message:`No hosted zone found for domain: ${e}`};let n=this.normalizeName(e,t.name),o=this.formatValue(t);return{success:!0,id:(await this.client.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:"Upserted by ts-cloud DNS provider",Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:n,Type:t.type,TTL:t.ttl||300,ResourceRecords:[{Value:o}]}}]}})).ChangeInfo?.Id,message:"Record upserted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async deleteRecord(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,message:`No hosted zone found for domain: ${e}`};let n=this.normalizeName(e,t.name),o=this.formatValue(t),s=await this.currentSet(r,n,t.type);if(!s||!s.values.some((a)=>this.sameValue(t.type,a,o)))return{success:!0,message:"Record already absent"};let i=s.values.filter((a)=>!this.sameValue(t.type,a,o));return await this.client.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:"Deleted by ts-cloud DNS provider",Changes:[{Action:i.length>0?"UPSERT":"DELETE",ResourceRecordSet:{Name:n,Type:t.type,TTL:s.ttl,ResourceRecords:(i.length>0?i:s.values).map((a)=>({Value:a}))}}]}}),{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,records:[],message:`No hosted zone found for domain: ${e}`};let n=await this.client.listResourceRecordSets({HostedZoneId:r,StartRecordType:t}),o=[];for(let s of n.ResourceRecordSets){if(t&&s.Type!==t)continue;if(s.AliasTarget)continue;for(let i of s.ResourceRecords||[]){let a=i.Value,c;if(s.Type==="MX"){let d=a.split(" ");if(d.length>=2)c=Number.parseInt(d[0],10),a=d.slice(1).join(" ")}if(s.Type==="TXT"&&a.startsWith('"'))a=I(a);o.push({name:s.Name.replace(/\.$/,""),type:s.Type,content:a,ttl:s.TTL,priority:c})}}return{success:!0,records:o}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){return await this.getHostedZoneId(e)!==null}async listDomains(){try{return(await this.client.listHostedZones()).HostedZones.map((t)=>t.Name.replace(/\.$/,""))}catch{return[]}}getRoute53Client(){return this.client}async createAliasRecord(e){try{let t=await this.getHostedZoneId(e.domain);if(!t)return{success:!1,message:`No hosted zone found for domain: ${e.domain}`};return{success:!0,id:(await this.client.createAliasRecord({HostedZoneId:t,Name:this.normalizeName(e.domain,e.name),TargetHostedZoneId:e.targetHostedZoneId,TargetDNSName:e.targetDnsName,EvaluateTargetHealth:e.evaluateTargetHealth,Type:e.type})).ChangeInfo?.Id,message:"Alias record created successfully"}}catch(t){return{success:!1,message:t instanceof Error?t.message:"Unknown error"}}}async createCloudFrontAlias(e){return this.createAliasRecord({domain:e.domain,name:e.name,targetHostedZoneId:B.CloudFrontHostedZoneId,targetDnsName:e.cloudFrontDomainName,evaluateTargetHealth:!1})}async createAlbAlias(e){let t=B.ALBHostedZoneIds[e.region];if(!t)return{success:!1,message:`Unknown region for ALB: ${e.region}`};return this.createAliasRecord({domain:e.domain,name:e.name,targetHostedZoneId:t,targetDnsName:e.albDnsName,evaluateTargetHealth:!0})}}var O=255;function re(e){let t=[];for(let r=0;r<e.length;r+=O)t.push(e.slice(r,r+O));if(t.length===0)t.push("");return t.map((r)=>`"${r.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`).join(" ")}function I(e){if(!e.startsWith('"'))return e;let t="",r=!1;for(let n=0;n<e.length;n++){let o=e[n];if(!r){if(o==='"')r=!0;continue}if(o==="\\"&&n+1<e.length){t+=e[++n];continue}if(o==='"'){r=!1;continue}t+=o}return t}async function no(e,t){let r=[],n,o;for(;;){let s=await e.listResourceRecordSets({HostedZoneId:t,StartRecordName:n,StartRecordType:o,MaxItems:"100"});if(r.push(...s.ResourceRecordSets),!s.IsTruncated)break;if(n=s.NextRecordName,o=s.NextRecordType,!n)break}return r}function m(e){return e.replace(/\.$/,"").toLowerCase()}function z(e){return e.replace(/\.$/,"")}function C(e){if(e.type==="SRV"&&e.weight!==void 0&&e.port!==void 0)return`${e.weight} ${e.port} ${z(e.content)}`;return z(e.content)}function ne(e){let t=e.match(/"(?:[^"\\]|\\.)*"/g);if(!t)return e;return t.map((r)=>r.slice(1,-1).replace(/\\(.)/g,"$1")).join("")}function io(e,t){let r=m(t),n=[],o=[],s=[],i=new Set;for(let a of e){let c=m(a.Name),d=a.Type;if(d==="SOA"||d==="NS"&&c===r){o.push({name:c,type:d,reason:"owned by the destination provider"});continue}if(a.SetIdentifier){o.push({name:c,type:d,reason:`routing policy record (SetIdentifier=${a.SetIdentifier}) has no equivalent — recreate by hand`}),s.push(`${d} ${c} is part of a Route53 routing policy and was NOT migrated`);continue}if(a.AliasTarget){if(i.has(c))continue;i.add(c);let g=m(a.AliasTarget.DNSName);if(n.push({name:c,type:"CNAME",content:g,ttl:300,translatedFrom:`${d} ALIAS → ${g}`}),a.AliasTarget.EvaluateTargetHealth)s.push(`${c} was an ALIAS with health evaluation enabled; the CNAME that replaces it has no health check`);continue}for(let g of a.ResourceRecords||[]){let p=se(c,d,g.Value,a.TTL);if("reason"in p){o.push({name:c,type:d,reason:p.reason}),s.push(`${d} ${c}: ${p.reason}`);continue}n.push(p)}}return{zone:r,records:n,skipped:o,warnings:s}}function se(e,t,r,n){let o={name:e,ttl:n};switch(t){case"A":case"AAAA":case"CNAME":case"PTR":return{...o,type:t==="PTR"?"CNAME":t,content:m(r)};case"TXT":return{...o,type:"TXT",content:ne(r)};case"MX":{let[s,...i]=r.trim().split(/\s+/);if(!i.length)return{reason:`malformed MX value "${r}"`};return{...o,type:"MX",content:m(i.join(" ")),priority:Number(s)}}case"SRV":{let s=r.trim().split(/\s+/);if(s.length<4)return{reason:`malformed SRV value "${r}"`};let[i,a,c]=s.slice(0,3).map(Number);return{...o,type:"SRV",content:m(s.slice(3).join(" ")),priority:i,weight:a,port:c}}case"NS":return{...o,type:"NS",content:m(r)};case"CAA":return{...o,type:"CAA",content:r.trim()};default:return{reason:`unsupported record type ${t}`}}}var oe=new Set(["TXT","MX","SRV","NS","CAA"]);async function oo(e,t){let r=[],n=[],o=new Set;try{let s=await e.listRecords(t.zone);for(let i of s.records||[])o.add(`${m(i.name)}|${i.type}|${C(i)}`)}catch{}for(let s of t.records){let i={...s,proxied:!1},a=`${m(s.name)}|${s.type}|${C(s)}`;if(!oe.has(s.type)){let d=await e.upsertRecord(t.zone,i);if(d.success)r.push(s);else n.push({record:s,message:d.message||"unknown provider error"});continue}if(o.has(a)){r.push(s);continue}let c=await e.createRecord(t.zone,i);if(c.success)o.add(a),r.push(s);else n.push({record:s,message:c.message||"unknown provider error"})}return{applied:r,failed:n}}async function so(e,t){let r=await e.listRecords(t.zone),n=[],o=[],s=new Map;for(let i of r.records||[]){let a=`${m(i.name)}|${i.type}`,c=s.get(a)??[];c.push(C(i)),s.set(a,c)}for(let i of t.records){let a=s.get(`${m(i.name)}|${i.type}`),c=C(i);if(a?.some((d)=>d===c))n.push(i);else o.push({record:i,found:a?.join(", ")})}return{matched:n,missing:o,ok:o.length===0}}class Lt{acm;dnsProvider;constructor(e,t="us-east-1"){if(this.acm=new G(t),"provider"in e)this.dnsProvider=M(e);else this.dnsProvider=e}getProvider(){return this.dnsProvider}async requestAndValidate(e){let{domainName:t,subjectAlternativeNames:r=[],waitForValidation:n=!1,maxWaitMinutes:o=30}=e,{CertificateArn:s}=await this.acm.requestCertificate({DomainName:t,SubjectAlternativeNames:r.length>0?[t,...r]:void 0,ValidationMethod:"DNS"});await this.waitForValidationOptions(s);let i=await this.acm.getDnsValidationRecords(s);for(let c of i){let d=await this.dnsProvider.upsertRecord(t,{name:c.recordName,type:c.recordType,content:c.recordValue,ttl:300});if(!d.success)console.warn(`Failed to create validation record for ${c.domainName}: ${d.message}`)}let a="pending";if(n)a=(await this.acm.waitForCertificateValidation(s,o*2,30000))?.Status==="ISSUED"?"issued":"failed";return{certificateArn:s,validationRecords:i.map((c)=>({domainName:c.domainName,recordName:c.recordName,recordType:c.recordType,recordValue:c.recordValue})),isNew:!0,status:a}}async createValidationRecords(e){let{certificateArn:t,domain:r}=e,n=[],o=await this.acm.getDnsValidationRecords(t);for(let s of o){let i=await this.dnsProvider.upsertRecord(r,{name:s.recordName,type:s.recordType,content:s.recordValue,ttl:300});if(!i.success)n.push(`Failed to create record for ${s.domainName}: ${i.message}`)}return{success:n.length===0,records:o.map((s)=>({domainName:s.domainName,recordName:s.recordName,recordType:s.recordType,recordValue:s.recordValue})),errors:n}}async deleteValidationRecords(e){let{certificateArn:t,domain:r}=e,n=[],o=await this.acm.getDnsValidationRecords(t);for(let s of o){let i=await this.dnsProvider.deleteRecord(r,{name:s.recordName,type:s.recordType,content:s.recordValue});if(!i.success)n.push(`Failed to delete record for ${s.domainName}: ${i.message}`)}return{success:n.length===0,errors:n}}async findOrCreateCertificate(e){let{domainName:t,subjectAlternativeNames:r=[],waitForValidation:n=!0,maxWaitMinutes:o}=e,s=await this.acm.findCertificateByDomain(t);if(s&&s.Status==="ISSUED"){let i=s.SubjectAlternativeNames||[s.DomainName],a=i.some((d)=>d===`*.${t}`);if(r.every((d)=>i.includes(d)||a))return{certificateArn:s.CertificateArn,validationRecords:[],isNew:!1,status:"issued"};console.log("Existing certificate doesn't cover all required SANs, requesting new certificate...")}return this.requestAndValidate({domainName:t,subjectAlternativeNames:r,waitForValidation:n,maxWaitMinutes:o})}async requestCertificateWithCommonSans(e){let{domainName:t,includeWww:r=!0,includeWildcard:n=!1,additionalSans:o=[],waitForValidation:s=!1}=e,i=[];if(r)i.push(`www.${t}`);if(n)i.push(`*.${t}`);return i.push(...o),this.requestAndValidate({domainName:t,subjectAlternativeNames:i,waitForValidation:s})}async waitForValidationOptions(e,t=30){for(let r=0;r<t;r++){let n=await this.acm.describeCertificate({CertificateArn:e});if(n.DomainValidationOptions&&n.DomainValidationOptions.length>0&&n.DomainValidationOptions[0].ResourceRecord)return;await new Promise((o)=>setTimeout(o,2000))}throw Error("Timeout waiting for DNS validation options")}async getCertificateStatus(e){let t=await this.acm.describeCertificate({CertificateArn:e});return{status:t.Status,domainValidations:(t.DomainValidationOptions||[]).map((r)=>({domain:r.DomainName,status:r.ValidationStatus||"UNKNOWN"}))}}}function M(e){switch(e.provider){case"route53":return new Zr(e.region,e.hostedZoneId);case"porkbun":return new Qe(e.apiKey,e.secretKey);case"godaddy":return new Ot(e.apiKey,e.apiSecret,e.environment);case"cloudflare":return new Ye(e.apiToken,{zoneId:e.zoneId,accountId:e.accountId});default:throw Error(`Unknown DNS provider: ${e.provider}`)}}class ai{providers=new Map;configs=[];addConfig(e){return this.configs.push(e),this}addRoute53(e,t){return this.configs.push({provider:"route53",region:e,hostedZoneId:t}),this}addPorkbun(e,t){return this.configs.push({provider:"porkbun",apiKey:e,secretKey:t}),this}addGoDaddy(e,t,r){return this.configs.push({provider:"godaddy",apiKey:e,apiSecret:t,environment:r}),this}addCloudflare(e,t={}){return this.configs.push({provider:"cloudflare",apiToken:e,zoneId:t.zoneId,accountId:t.accountId}),this}loadFromEnv(){if(process.env.AWS_ACCESS_KEY_ID||process.env.AWS_PROFILE||process.env.AWS_REGION)this.addRoute53(process.env.AWS_REGION);let e=process.env.PORKBUN_API_KEY,t=process.env.PORKBUN_SECRET_KEY;if(e&&t)this.addPorkbun(e,t);let r=process.env.GODADDY_API_KEY,n=process.env.GODADDY_API_SECRET;if(r&&n){let s=process.env.GODADDY_ENVIRONMENT;this.addGoDaddy(r,n,s)}let o=process.env.CLOUDFLARE_API_TOKEN;if(o)this.addCloudflare(o,{zoneId:process.env.CLOUDFLARE_ZONE_ID,accountId:process.env.CLOUDFLARE_ACCOUNT_ID});return this}getProvider(e){let t=this.providers.get(e);if(t)return t;let r=this.configs.find((o)=>o.provider===e);if(!r)return null;let n=M(r);return this.providers.set(e,n),n}async getProviderForDomain(e){for(let t of this.configs){let r=M(t);if(await r.canManageDomain(e))return r}return null}getAllProviders(){return this.configs.map((e)=>M(e))}}var ze=new ai;class G{client;region;constructor(e="us-east-1"){this.client=new u,this.region=e}async requestCertificate(e){let t={DomainName:e.DomainName,ValidationMethod:e.ValidationMethod||"DNS"};if(e.SubjectAlternativeNames)t.SubjectAlternativeNames=e.SubjectAlternativeNames;return{CertificateArn:(await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.RequestCertificate"},body:JSON.stringify(t)})).CertificateArn||""}}async describeCertificate(e){let r=(await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.DescribeCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn})})).Certificate||{};return{CertificateArn:r.CertificateArn||"",DomainName:r.DomainName||"",SubjectAlternativeNames:r.SubjectAlternativeNames,Status:r.Status||"PENDING_VALIDATION",Type:r.Type,DomainValidationOptions:r.DomainValidationOptions?.map((n)=>({DomainName:n.DomainName,ValidationDomain:n.ValidationDomain,ValidationStatus:n.ValidationStatus,ResourceRecord:n.ResourceRecord?{Name:n.ResourceRecord.Name,Type:n.ResourceRecord.Type,Value:n.ResourceRecord.Value}:void 0,ValidationMethod:n.ValidationMethod})),CreatedAt:r.CreatedAt,IssuedAt:r.IssuedAt,NotBefore:r.NotBefore,NotAfter:r.NotAfter}}async listCertificates(e){let t={};if(e?.CertificateStatuses)t.CertificateStatuses=e.CertificateStatuses;if(e?.MaxItems)t.MaxItems=e.MaxItems;if(e?.NextToken)t.NextToken=e.NextToken;let r=await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.ListCertificates"},body:JSON.stringify(t)});return{CertificateSummaryList:(r.CertificateSummaryList||[]).map((n)=>({CertificateArn:n.CertificateArn,DomainName:n.DomainName})),NextToken:r.NextToken}}async deleteCertificate(e){await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.DeleteCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn})})}async listTagsForCertificate(e){return{Tags:(await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.ListTagsForCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn})})).Tags||[]}}async addTagsToCertificate(e){await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.AddTagsToCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn,Tags:e.Tags})})}async resendValidationEmail(e){await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.ResendValidationEmail"},body:JSON.stringify({CertificateArn:e.CertificateArn,Domain:e.Domain,ValidationDomain:e.ValidationDomain})})}async findCertificateByDomain(e){let r=(await this.listCertificates({CertificateStatuses:["ISSUED"]})).CertificateSummaryList.find((n)=>n.DomainName===e||n.DomainName===`*.${e.split(".").slice(1).join(".")}`);if(!r)return null;return this.describeCertificate({CertificateArn:r.CertificateArn})}async waitForCertificateValidation(e,t=60,r=30000){for(let n=0;n<t;n++){let o=await this.describeCertificate({CertificateArn:e});if(o.Status==="ISSUED")return o;if(o.Status==="FAILED"||o.Status==="VALIDATION_TIMED_OUT")return null;await new Promise((s)=>setTimeout(s,r))}return null}async getDnsValidationRecords(e){let t=await this.describeCertificate({CertificateArn:e});if(!t.DomainValidationOptions)return[];return t.DomainValidationOptions.filter((r)=>r.ResourceRecord&&r.ValidationMethod==="DNS").map((r)=>({domainName:r.DomainName,recordName:r.ResourceRecord.Name,recordType:r.ResourceRecord.Type,recordValue:r.ResourceRecord.Value}))}async requestCertificateWithSans(e){let t=new Set;if(t.add(e.DomainName),e.IncludeWww!==!1)t.add(`www.${e.DomainName}`);if(e.IncludeWildcard)t.add(`*.${e.DomainName}`);if(e.AdditionalSans)for(let r of e.AdditionalSans)t.add(r);return this.requestCertificate({DomainName:e.DomainName,SubjectAlternativeNames:Array.from(t),ValidationMethod:"DNS"})}async isCertificateValidForDomain(e,t){let r=await this.describeCertificate({CertificateArn:e});if(r.Status!=="ISSUED")return!1;if(r.DomainName===t)return!0;if(r.DomainName?.startsWith("*.")){let n=r.DomainName.slice(2),o=t.split("."),s=n.split(".");if(o.slice(-s.length).join(".")===n)return!0}if(r.SubjectAlternativeNames)for(let n of r.SubjectAlternativeNames){if(n===t)return!0;if(n.startsWith("*.")){let o=n.slice(2),s=t.split("."),i=o.split(".");if(s.slice(-i.length).join(".")===o)return!0}}return!1}}class ao{acm;route53;dnsProvider;constructor(e="us-east-1",t){if(this.acm=new G(e),this.route53=new B,t&&t.provider!=="route53")this.dnsProvider=M(t)}async requestAndValidate(e){let{domainName:t,hostedZoneId:r,subjectAlternativeNames:n=[],waitForValidation:o=!1,maxWaitMinutes:s=30}=e;if(!this.dnsProvider&&!r)throw Error("Either hostedZoneId or external DNS provider configuration is required");let{CertificateArn:i}=await this.acm.requestCertificate({DomainName:t,SubjectAlternativeNames:n.length>0?[t,...n]:void 0,ValidationMethod:"DNS"});await this.waitForValidationOptions(i);let a=await this.acm.getDnsValidationRecords(i);if(this.dnsProvider)for(let c of a){let d=await this.dnsProvider.upsertRecord(t,{name:c.recordName,type:c.recordType,content:c.recordValue,ttl:300});if(!d.success)console.warn(`Failed to create validation record for ${c.domainName}: ${d.message}`)}else if(r)for(let c of a)await this.route53.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:`ACM DNS validation for ${c.domainName}`,Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:c.recordName,Type:c.recordType,TTL:300,ResourceRecords:[{Value:c.recordValue}]}}]}});if(o){if(!await this.acm.waitForCertificateValidation(i,s*2,30000))throw Error(`Certificate validation timed out after ${s} minutes`)}return{certificateArn:i,validationRecords:a}}async waitForValidationOptions(e,t=30){for(let r=0;r<t;r++){let n=await this.acm.describeCertificate({CertificateArn:e});if(n.DomainValidationOptions&&n.DomainValidationOptions.length>0&&n.DomainValidationOptions[0].ResourceRecord)return;await new Promise((o)=>setTimeout(o,2000))}throw Error("Timeout waiting for DNS validation options")}async createValidationRecords(e){let{certificateArn:t,hostedZoneId:r,domain:n}=e;if(!this.dnsProvider&&!r)throw Error("Either hostedZoneId or external DNS provider configuration is required");let o=await this.acm.getDnsValidationRecords(t),s=[];if(this.dnsProvider){let i=n||o[0]?.domainName;for(let a of o){let c=await this.dnsProvider.upsertRecord(i,{name:a.recordName,type:a.recordType,content:a.recordValue,ttl:300});s.push({...a,changeId:c.success?c.id:void 0})}}else if(r)for(let i of o){let a=await this.route53.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:`ACM DNS validation for ${i.domainName}`,Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:i.recordName,Type:i.recordType,TTL:300,ResourceRecords:[{Value:i.recordValue}]}}]}});s.push({...i,changeId:a.ChangeInfo?.Id})}return s}async deleteValidationRecords(e){let{certificateArn:t,hostedZoneId:r,domain:n}=e,o=await this.acm.getDnsValidationRecords(t);if(this.dnsProvider){let s=n||o[0]?.domainName;for(let i of o)try{await this.dnsProvider.deleteRecord(s,{name:i.recordName,type:i.recordType,content:i.recordValue})}catch{}}else if(r)for(let s of o)try{await this.route53.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:`Cleanup ACM DNS validation for ${s.domainName}`,Changes:[{Action:"DELETE",ResourceRecordSet:{Name:s.recordName,Type:s.recordType,TTL:300,ResourceRecords:[{Value:s.recordValue}]}}]}})}catch{}}async findOrCreateCertificate(e){let{domainName:t,hostedZoneId:r,subjectAlternativeNames:n,waitForValidation:o=!0}=e;if(!this.dnsProvider&&!r)throw Error("Either hostedZoneId or external DNS provider configuration is required");let s=await this.acm.findCertificateByDomain(t);if(s&&s.Status==="ISSUED")return{certificateArn:s.CertificateArn,isNew:!1};let{certificateArn:i}=await this.requestAndValidate({domainName:t,hostedZoneId:r,subjectAlternativeNames:n,waitForValidation:o});return{certificateArn:i,isNew:!0}}hasExternalDnsProvider(){return this.dnsProvider!==void 0}getDnsProviderName(){return this.dnsProvider?.name||"route53"}}
2
+ export{Qe,Ot,vs,Ts,Ye,to,ro,Zr,no,io,oo,so,G,ao,Lt,M,ai};
@@ -0,0 +1 @@
1
+ import{mc,Sp}from"./chunk-3ykx59eg.js";import"./chunk-y9cdqk8c.js";import"./chunk-a9yp82q5.js";import"./chunk-q9tvzcr7.js";export{mc as EmailClient,Sp as email};