cf 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_meta/agent-context.json +26 -21
- package/dist/_meta/commands.json +7696 -18100
- package/dist/_meta/schemas.json +6411 -13925
- package/dist/{abuse-reports-dMIfUJ8v.mjs → abuse-reports-Dy76QPNP.mjs} +1 -1
- package/dist/{accounts-Kx1epdA1.mjs → accounts-CjtZ8x1z.mjs} +2 -2
- package/dist/{acm-Utu252kC.mjs → acm-C2lYIWs1.mjs} +1 -1
- package/dist/{addressing-CBq7Z7Vq.mjs → addressing-CHFK6uxW.mjs} +1 -1
- package/dist/{agent-context-BGTU299M.mjs → agent-context-CgGCT0xU.mjs} +1 -1
- package/dist/{ai-DOOKLPkG.mjs → ai-DS3i-I1a.mjs} +1 -1
- package/dist/{ai-gateway-Cj1T3avF.mjs → ai-gateway-RIsegO2x.mjs} +1 -1
- package/dist/ai-search-Dcj4BauG.mjs +7 -0
- package/dist/{ai_gateway-C3fH22C0.mjs → ai_gateway-w7YwfcPE.mjs} +1 -1
- package/dist/{alerting-CqmEIaKn.mjs → alerting-Bk85NNf5.mjs} +1 -1
- package/dist/{analytics-Dv-X8x7D.mjs → analytics-CkhhhZWZ.mjs} +1 -1
- package/dist/{analytics_engine-DdXVR8z2.mjs → analytics_engine-B7qgDJCA.mjs} +1 -1
- package/dist/{api-gateway-CNv0IHTU.mjs → api-gateway-CWdR4Ne7.mjs} +1 -1
- package/dist/{argo-CX_A4kcn.mjs → argo-DnJRVnGX.mjs} +1 -1
- package/dist/artifacts-BVWKiJUl.mjs +4 -0
- package/dist/{audit-logs-BfBf3oo-.mjs → audit-logs-DjTstbzL.mjs} +1 -1
- package/dist/auth-BqDOIrKX.mjs +150 -0
- package/dist/auth-DKkSwnxh.mjs +5 -0
- package/dist/billing-3rEqF83h.mjs +2 -0
- package/dist/{bot-management-CFvtVx62.mjs → bot-management-CJxD1pqi.mjs} +1 -1
- package/dist/{botnet-feed-B-M4Yu0W.mjs → botnet-feed-MG91D7BR.mjs} +1 -1
- package/dist/{brand-protection-D05Eg-_6.mjs → brand-protection-CK7gJi06.mjs} +1 -1
- package/dist/browser-rendering-Rae0AUt0.mjs +4 -0
- package/dist/{build-DYkGW4dh.mjs → build-BE4o4imx.mjs} +131 -131
- package/dist/{cache-DsoW6Xwv.mjs → cache-B7pRbpTy.mjs} +1 -1
- package/dist/{calls-CZbO7TyR.mjs → calls-DXRWsZ8n.mjs} +3 -3
- package/dist/{certificate-authorities-D2yr7_3t.mjs → certificate-authorities-BR3gXBLs.mjs} +1 -1
- package/dist/chunk-6IEM75FG-U3L9fKgi.mjs +2 -0
- package/dist/{client-certificates-MJcDsTId.mjs → client-certificates-B0ebLJdk.mjs} +1 -1
- package/dist/{cloud-connector-DWOrN2eM.mjs → cloud-connector-BOjaggJk.mjs} +1 -1
- package/dist/{cloudforce-one-2Bhz8YdW.mjs → cloudforce-one-B6HYfk5Z.mjs} +1 -1
- package/dist/{completions-BwRpZQVn.mjs → completions-D_9WsLG7.mjs} +1 -1
- package/dist/config-7CBz8Xm0.mjs +2 -0
- package/dist/{connectivity-BX8C7tvK.mjs → connectivity-welFvZ7X.mjs} +1 -1
- package/dist/connector-interrupts-DTV3F-50.mjs +2 -0
- package/dist/connector-telemetry-events-kDqb_AGm.mjs +2 -0
- package/dist/connector-telemetry-snapshots-DC-wD75E.mjs +2 -0
- package/dist/connectors-3vjrdFLB.mjs +3 -0
- package/dist/content-scanning-CnW2A0pv.mjs +4 -0
- package/dist/{context-DGlHRGWM.mjs → context-CONbNKO-.mjs} +1 -1
- package/dist/{custom-certificates-aAiEguR7.mjs → custom-certificates-CnYh6Yi-.mjs} +1 -1
- package/dist/{custom-hostnames-AG5yBHIi.mjs → custom-hostnames-C2upqZso.mjs} +1 -1
- package/dist/{custom-nameservers-D1DtlRue.mjs → custom-nameservers-BGkAD_PZ.mjs} +1 -1
- package/dist/{custom-pages-DQCi2plU.mjs → custom-pages-5fCSP8in.mjs} +1 -1
- package/dist/{d1-DbnYhw45.mjs → d1-CyiRbZZn.mjs} +1 -1
- package/dist/data-security-Casx4OS_.mjs +6 -0
- package/dist/{dcv-delegation-CHspSzTI.mjs → dcv-delegation-DVYO10oA.mjs} +1 -1
- package/dist/{deploy-CQial3kN.mjs → deploy-KBRFIatG.mjs} +1 -1
- package/dist/{dev-B38LfCTl.mjs → dev-pPazzZvt.mjs} +1 -1
- package/dist/{diagnostics-BJQGjVJn.mjs → diagnostics-BqYDoDfw.mjs} +1 -1
- package/dist/{dispatch-namespaces-DmHvoBOg.mjs → dispatch-namespaces-Cz2rajnP.mjs} +1 -1
- package/dist/{dist-AIcZFk0U.mjs → dist-DA54ZQu0.mjs} +7 -7
- package/dist/dist-DpDjsWWn.mjs +306 -0
- package/dist/{dns-VMhQSr5n.mjs → dns-62t95Xif.mjs} +1 -1
- package/dist/{dns-firewall-B4DVXFBQ.mjs → dns-firewall-Coy8d47t.mjs} +1 -1
- package/dist/{durable-objects-CTboySEo.mjs → durable-objects-BSuRERkw.mjs} +1 -1
- package/dist/{email-routing-tIR2SFu-.mjs → email-routing-BDUYYeV3.mjs} +1 -1
- package/dist/{email-security-Ca1id3rZ.mjs → email-security-ChHA6eqQ.mjs} +1 -1
- package/dist/{email-sending-DwWKc5jC.mjs → email-sending-CVrRqn6S.mjs} +1 -1
- package/dist/{filters-A4dg_a68.mjs → filters-qJpU9uAS.mjs} +1 -1
- package/dist/{firewall-DWPQgYd9.mjs → firewall-C3DDwfwh.mjs} +1 -1
- package/dist/{fraud-BMkSsJGU.mjs → fraud-DY3YXFVf.mjs} +1 -1
- package/dist/{google-tag-gateway-BGD49nRC.mjs → google-tag-gateway-B00MHDfB.mjs} +1 -1
- package/dist/{healthchecks-CtIfrFql.mjs → healthchecks-Drvb79v0.mjs} +1 -1
- package/dist/{hostnames-BiomxukN.mjs → hostnames-BdAQo1Mr.mjs} +1 -1
- package/dist/{hyperdrive-Da104VaQ.mjs → hyperdrive-99OJV9nl.mjs} +1 -1
- package/dist/{iam-BIGKo0WW.mjs → iam-BRbpg3lN.mjs} +1 -1
- package/dist/images-D1jI3r3O.mjs +7 -0
- package/dist/index.mjs +1 -1
- package/dist/{intel-CY6_79v8.mjs → intel-C3ajLpXd.mjs} +1 -1
- package/dist/{ips-K4bzaGqd.mjs → ips-B6JETVOY.mjs} +1 -1
- package/dist/{keyless-certificates-CZC-L8gM.mjs → keyless-certificates-C4MZ4xnf.mjs} +1 -1
- package/dist/{kv-8o27w_pY.mjs → kv-CSWoD9ks.mjs} +1 -1
- package/dist/{leaked-credential-checks-qLzRyu85.mjs → leaked-credential-checks-Dgs2oKm9.mjs} +2 -2
- package/dist/{load-balancers-DtG8nj25.mjs → load-balancers-Du1tNuUt.mjs} +1 -1
- package/dist/{logpush-4L0njy1d.mjs → logpush-SuJyO-uX.mjs} +1 -1
- package/dist/{logs-B_Yp95hv.mjs → logs-DcDNRPRl.mjs} +1 -1
- package/dist/{magic-cloud-networking-CSOM3EM-.mjs → magic-cloud-networking-D-T0RCvi.mjs} +1 -1
- package/dist/{magic-network-monitoring-BnwvM4-I.mjs → magic-network-monitoring-CqtvOePQ.mjs} +1 -1
- package/dist/{magic-transit-CXDyvhxq.mjs → magic-transit-BTbkhBtF.mjs} +32 -33
- package/dist/{managed-transforms-D15yVbZx.mjs → managed-transforms-CfUBSz9p.mjs} +1 -1
- package/dist/{mtls-certificates-D8k0AXWK.mjs → mtls-certificates-Cf1O8c2E.mjs} +1 -1
- package/dist/{network-interconnects-rrr7red3.mjs → network-interconnects-DsiNytOU.mjs} +1 -1
- package/dist/{observability-DWvpqnQJ.mjs → observability-CLqZ7OSi.mjs} +1 -1
- package/dist/open-YWOUIZ5Y-BpqIuBsR.mjs +4 -0
- package/dist/{organizations-T77D50Sq.mjs → organizations-aRi1bhFC.mjs} +2 -2
- package/dist/{origin-ca-certificates-DXIvD8H5.mjs → origin-ca-certificates-BB4H89a_.mjs} +1 -1
- package/dist/{origin-post-quantum-encryption-C8oOczyV.mjs → origin-post-quantum-encryption-DurP3PXG.mjs} +1 -1
- package/dist/{origin-tls-client-auth-CaVW1Ztp.mjs → origin-tls-client-auth-CnQNy9-l.mjs} +1 -1
- package/dist/{output-BJFNwj7b.mjs → output-CUxZRM5A.mjs} +1 -1
- package/dist/{page-rules-CjZPTMQX.mjs → page-rules-CYqtPU1p.mjs} +1 -1
- package/dist/{page-shield-D5RRNJCY.mjs → page-shield-D8l9ZMUl.mjs} +1 -1
- package/dist/{pages-CWJtJnL0.mjs → pages-ChurJ2H7.mjs} +1 -1
- package/dist/{pipelines-B0L_7j9e.mjs → pipelines-CeyujvRf.mjs} +1 -1
- package/dist/{progress-CrCGTq7N.mjs → progress-Cent9Lsg.mjs} +1 -1
- package/dist/{queues-CN6DPhRR.mjs → queues-Rf_n11Cx.mjs} +1 -1
- package/dist/{r2-DQIcyRtA.mjs → r2-BtuTO3vQ.mjs} +1 -1
- package/dist/{r2-data-catalog-Bbo93TJx.mjs → r2-data-catalog-Debz38kv.mjs} +1 -1
- package/dist/radar-CzGM92uM.mjs +2 -0
- package/dist/{rate-limits-DcrQV6Ar.mjs → rate-limits-Bbk7HxP7.mjs} +1 -1
- package/dist/{raw-fetch-Dlccg0Tr.mjs → raw-fetch-DnbAMFBp.mjs} +1 -1
- package/dist/{realtime-kit-CaquuVOE.mjs → realtime-kit-CivLpkpg.mjs} +1 -1
- package/dist/{registrar-Ko-xZemf.mjs → registrar-8IeA5DKd.mjs} +1 -1
- package/dist/{request-tracers-DOW_reTJ.mjs → request-tracers-D1aH4NmL.mjs} +1 -1
- package/dist/{resource-sharing-D7TX0JV0.mjs → resource-sharing-B-Pcto7-.mjs} +3 -3
- package/dist/{resource-tagging-C3qtLzCz.mjs → resource-tagging-Bpb6Qq1M.mjs} +1 -1
- package/dist/{rules-BXRADHL5.mjs → rules-B10XWY10.mjs} +1 -1
- package/dist/{rulesets-CBgpeSvJ.mjs → rulesets-lYczEcJp.mjs} +1 -1
- package/dist/{rum-BjPptTUP.mjs → rum-B5GUKa4I.mjs} +3 -3
- package/dist/{schema-D16TgWBg.mjs → schema-hefO-tzo.mjs} +1 -1
- package/dist/{schema-validation-Dgv_opM3.mjs → schema-validation-DTq517Em.mjs} +1 -1
- package/dist/{scim-DdSEr4kZ.mjs → scim-BiLfOQ89.mjs} +1 -1
- package/dist/{secrets-store-7BfyvJLb.mjs → secrets-store-CBX0dvHL.mjs} +1 -1
- package/dist/{security-center-DAy6AKtT.mjs → security-center-AVpTOBK3.mjs} +1 -1
- package/dist/{security-txt-xAMb7K6Y.mjs → security-txt-DVlh8y9l.mjs} +1 -1
- package/dist/{session-COHHdS7A.mjs → session-CsvPYFj8.mjs} +2 -2
- package/dist/shared-0bwWVDLo.mjs +2 -0
- package/dist/{smart-shield-TeWZFnH2.mjs → smart-shield-DblHIce0.mjs} +1 -1
- package/dist/{snippets-CCSsCXVs.mjs → snippets-DrpqSXYC.mjs} +1 -1
- package/dist/{spawn-DcppKGI5.mjs → spawn-DK7pott_.mjs} +1 -1
- package/dist/{spectrum-CTTZID8u.mjs → spectrum-CnrG0jIC.mjs} +2 -2
- package/dist/speed-BzRY3Xlh.mjs +4 -0
- package/dist/{src-BW6vfAwE.mjs → src-D9_Gq68b.mjs} +10 -10
- package/dist/{ssl-BWA2LdwC.mjs → ssl-Cp6tQkZH.mjs} +1 -1
- package/dist/stream-CGTRN4ZN.mjs +14 -0
- package/dist/{tenants-Bd7NGQ_m.mjs → tenants-o_M62Y1n.mjs} +1 -1
- package/dist/{token-validation-DAgtFOvs.mjs → token-validation-Ca5AGEns.mjs} +1 -1
- package/dist/{tools-DXQmfFuE.mjs → tools-DtNNmO6l.mjs} +1 -1
- package/dist/{turnstile-cfdaO4ca.mjs → turnstile-l7mo9BWL.mjs} +2 -2
- package/dist/{ui-D4KtlMh9.mjs → ui-B97lRnOv.mjs} +1 -1
- package/dist/{url-normalization-B5RN4nLD.mjs → url-normalization-D1CogSIG.mjs} +1 -1
- package/dist/{url-scanner-BrZ1L9OC.mjs → url-scanner-BnJHJqcz.mjs} +1 -1
- package/dist/{user-CAo-yCJA.mjs → user-CiyYZ69X.mjs} +2 -2
- package/dist/{vectorize-C7_oQlaI.mjs → vectorize-D3LgMLOn.mjs} +1 -1
- package/dist/{versions-CUwWJWmy.mjs → versions-B6E8WQyA.mjs} +1 -1
- package/dist/{waiting-rooms-Dln5ICg5.mjs → waiting-rooms-Bhy_nuV3.mjs} +1 -1
- package/dist/{web3-HQJRm38W.mjs → web3-DlHE0CZc.mjs} +1 -1
- package/dist/{workers-Dg7ddG2Q.mjs → workers-DRAkU6YR.mjs} +1 -1
- package/dist/{workers-builds-AVfx8IyL.mjs → workers-builds-BmNjiHDZ.mjs} +1 -1
- package/dist/{workflows-VquuSh2J.mjs → workflows-z6oapEJs.mjs} +1 -1
- package/dist/{zaraz-xYSWIV4P.mjs → zaraz-CyzfYOEU.mjs} +1 -1
- package/dist/{zero-trust-CP96wnSh.mjs → zero-trust-fyyIelWx.mjs} +44 -44
- package/dist/zero_trust-BAhlNkjo.mjs +3 -0
- package/dist/{zones-BSgmZ9WC.mjs → zones-MSULnDwW.mjs} +4 -4
- package/package.json +4 -4
- package/dist/ai-search-CQF_Sn7d.mjs +0 -7
- package/dist/auth-SyWhMmPu.mjs +0 -6
- package/dist/auth-ffdf9yR0.mjs +0 -135
- package/dist/autorag-BuGhGTeZ.mjs +0 -2
- package/dist/billing-PoG81XaQ.mjs +0 -2
- package/dist/browser-rendering-xu8F_Rrv.mjs +0 -4
- package/dist/config-DYzlVxcB.mjs +0 -2
- package/dist/content-scanning-r6uzMO1r.mjs +0 -4
- package/dist/data-security-D_EtYBfo.mjs +0 -6
- package/dist/dist-DNBSHor6.mjs +0 -301
- package/dist/images-BO8FbDAa.mjs +0 -5
- package/dist/radar-Bxb0WX8V.mjs +0 -2
- package/dist/shared-AGtpXwwL.mjs +0 -2
- package/dist/speed-CuzTE0AL.mjs +0 -4
- package/dist/stream-GFsIZ-pP.mjs +0 -14
- /package/dist/{body-parser-DKa8Ipg1.mjs → body-parser-CBpeIUns.mjs} +0 -0
- /package/dist/{cli-types-CRIDdDw3.mjs → cli-types-CMNMD1V7.mjs} +0 -0
- /package/dist/{input-validation-zEO81MWN.mjs → input-validation-CTqtyiY9.mjs} +0 -0
- /package/dist/{lib-Eu1wXxuh.mjs → lib-B6xvCJjc.mjs} +0 -0
- /package/dist/{local-VJaJ3BZ1.mjs → local-D8bhHUMK.mjs} +0 -0
- /package/dist/{metadata-5VwHPW6C.mjs → metadata-jh2EIan8.mjs} +0 -0
- /package/dist/{resolve-4-OSeHlK.mjs → resolve-D1mG0REg.mjs} +0 -0
- /package/dist/{theme-BklJDrb2.mjs → theme-CFHr0Dh9.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{D as e,E as t,S as n,T as r,i,n as a}from"./auth-ffdf9yR0.mjs";import{n as o,t as s}from"./body-parser-DKa8Ipg1.mjs";import{t as c}from"./output-BJFNwj7b.mjs";import{n as l,t as u}from"./progress-CrCGTq7N.mjs";import{n as d,t as f}from"./input-validation-zEO81MWN.mjs";import{t as p}from"./cli-types-CRIDdDw3.mjs";function ee(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`get`,describe:`Gets the current API Shield configuration settings for a zone, including validation behavior and enforcement mode.`,builder:ee,handler:async e=>{let t={normalize:e.normalize};if(e.dryRun){l({command:`cf api-gateway configurations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.configurations.get({zone_id:i,...t})),{successLabel:`Loaded`})}};function m(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const h={command:`update`,describe:`Updates API Shield configuration settings for a zone. Can modify validation strictness, enforcement mode, and other global settings.`,builder:m,handler:async e=>{let t={normalize:e.normalize};if(e.dryRun){l({command:`cf api-gateway configurations update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});if(e.zoneId=i,e.body){let n=o(e.body);new URLSearchParams(Object.entries(t).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),c(await u(`Updating`,async()=>r.apiGateway.configurations.update({body:n,zone_id:i,...t})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},g={command:`configurations`,describe:`API Shield configuration — authentication requirements and session identifiers`,builder:e=>e.command(te).command(h).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function _(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`get`,describe:`Retrieve the most up to date view of discovered operations, rendered as OpenAPI schemas`,builder:_,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway discovery get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});e.zoneId=r,c(await u(`Loading`,async()=>t.apiGateway.discovery.get({zone_id:r})),{successLabel:`Loaded`})}};function y(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const b={command:`bulk-edit`,describe:"Update the `state` on one or more discovered operations",builder:y,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway discovery operations bulk-edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.bulkEdit({body:n,zone_id:r})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function x(e){return e.positional(`discovery-id`,{type:`string`,description:`Discovery ID of a discovered operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const S={command:`edit <discovery-id>`,describe:"Update the `state` on a discovered operation",builder:x,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway discovery operations edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations/${e[`discovery-id`]==null?`<discovery-id>`:encodeURIComponent(String(e[`discovery-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"discovery-id":String(e[`discovery-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.edit({...n,zone_id:r,discovery_id:e[`discovery-id`]})),{successLabel:`Updated`});return}c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.edit({zone_id:r,discovery_id:e[`discovery-id`]})),{successLabel:`Updated`})}};function C(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`host`,`method`,`endpoint`,`traffic_stats.requests`,`traffic_stats.last_updated`]}).option(`diff`,{type:`boolean`,description:"When `true`, only return API Discovery results that are not saved into API Shield Endpoint Management"}).option(`origin`,{type:`string`,description:"Filter results to only include discovery results sourced from a particular discovery engine\n * `ML` - Discovered operations that were sourced using ML API Discovery\n * `SessionIdentifier` - Discovered operations that were sourced using Session Identifier API Discovery",choices:[`ML`,`SessionIdentifier`,`LabelDiscovery`]}).option(`state`,{type:`string`,description:"Filter results to only include discovery results in a particular state. States are as follows\n * `review` - Discovered operations that are not saved into API Shield Endpoint Management\n * `saved` - Discovered operations that are already saved into API Shield Endpoint Management\n * `ignored` - Discovered operations that have been marked as ignored",choices:[`review`,`saved`,`ignored`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const w={command:`list`,describe:`Retrieve the most up to date view of discovered operations`,builder:p(C),handler:async e=>{let t={page:e.page,per_page:e[`per-page`],host:e.host,method:e.method,endpoint:e.endpoint,direction:e.direction,order:e.order,diff:e.diff,origin:e.origin,state:e.state};if(e.dryRun){l({command:`cf api-gateway discovery operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.discovery.operations.list({zone_id:i,...t})),{successLabel:`Loaded`})}},T={command:`operations`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(b).command(S).command(w).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},E={command:`discovery`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(v).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`hosts`,{type:`string`,array:!0,description:`List of hosts to be targeted in the expression`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const O={command:`create`,describe:`Creates an expression template fallthrough rule for API Shield. Used for configuring default behavior when no other expression templates match.`,builder:D,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway expression-template fallthrough create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/expression-template/fallthrough`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({hosts:e.hosts}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.expressionTemplate.fallthrough.create({...n,zone_id:r})),{successLabel:`Created`});return}if(e.hosts===void 0)throw Error(`--hosts is required (or pass --body with this field set).`);let i=s({hosts:e.hosts});c(await u(`Creating`,async()=>t.apiGateway.expressionTemplate.fallthrough.create({...i,zone_id:r})),{successLabel:`Created`})}},k={command:`fallthrough`,describe:`Reusable expression templates for API Gateway rule configurations`,builder:e=>e.command(O).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},A={command:`expression-template`,describe:`Operations for expression-template`,builder:e=>e.command(k).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function j(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`name`,`description`,`created_at`,`last_updated`,`mapped_resources.operations`]}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`source`,{type:`string`,description:`Filter for labels with source`,choices:[`user`,`managed`]}).option(`filter`,{type:`string`,description:`Filter for labels where the name or description matches using substring match`}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`list`,describe:`Retrieve all labels`,builder:p(j),handler:async e=>{let t={page:e.page,per_page:e[`per-page`],order:e.order,direction:e.direction,source:e.source,filter:e.filter,with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.labels.list({zone_id:i,...t})),{successLabel:`Loaded`})}};function N(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`get <name>`,describe:`Retrieve managed label`,builder:N,handler:async e=>{let t={with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels managed get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/managed/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.labels.managed.get({zone_id:i,name:e.name,...t})),{successLabel:`Loaded`})}};function F(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const I={command:`update <name>`,describe:`Replace all operations(s) attached to a managed label`,builder:F,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels managed resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/managed/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}/resources/operation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.managed.resources.operation.update({body:n,zone_id:r,name:e.name})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},L={command:`operation`,describe:`Labels operations`,builder:e=>e.command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},R={command:`resources`,describe:`Operations for labels.managed.resources`,builder:e=>e.command(L).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},z={command:`managed`,describe:`Labels operations`,builder:e=>e.command(P).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function B(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const V={command:`bulk-create`,describe:`Create user labels`,builder:B,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels user bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.labels.user.bulkCreate({body:n,zone_id:r})),{successLabel:`Created`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function H(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const U={command:`bulk-delete`,describe:`Delete user labels`,builder:H,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels user bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
|
|
2
|
+
import{D as e,E as t,S as n,T as r,i,n as a}from"./auth-BqDOIrKX.mjs";import{n as o,t as s}from"./body-parser-CBpeIUns.mjs";import{t as c}from"./output-CUxZRM5A.mjs";import{n as l,t as u}from"./progress-Cent9Lsg.mjs";import{n as d,t as f}from"./input-validation-CTqtyiY9.mjs";import{t as p}from"./cli-types-CMNMD1V7.mjs";function ee(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`get`,describe:`Gets the current API Shield configuration settings for a zone, including validation behavior and enforcement mode.`,builder:ee,handler:async e=>{let t={normalize:e.normalize};if(e.dryRun){l({command:`cf api-gateway configurations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.configurations.get({zone_id:i,...t})),{successLabel:`Loaded`})}};function m(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const h={command:`update`,describe:`Updates API Shield configuration settings for a zone. Can modify validation strictness, enforcement mode, and other global settings.`,builder:m,handler:async e=>{let t={normalize:e.normalize};if(e.dryRun){l({command:`cf api-gateway configurations update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});if(e.zoneId=i,e.body){let n=o(e.body);new URLSearchParams(Object.entries(t).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),c(await u(`Updating`,async()=>r.apiGateway.configurations.update({body:n,zone_id:i,...t})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},g={command:`configurations`,describe:`API Shield configuration — authentication requirements and session identifiers`,builder:e=>e.command(te).command(h).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function _(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`get`,describe:`Retrieve the most up to date view of discovered operations, rendered as OpenAPI schemas`,builder:_,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway discovery get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});e.zoneId=r,c(await u(`Loading`,async()=>t.apiGateway.discovery.get({zone_id:r})),{successLabel:`Loaded`})}};function y(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const b={command:`bulk-edit`,describe:"Update the `state` on one or more discovered operations",builder:y,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway discovery operations bulk-edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.bulkEdit({body:n,zone_id:r})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function x(e){return e.positional(`discovery-id`,{type:`string`,description:`Discovery ID of a discovered operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const S={command:`edit <discovery-id>`,describe:"Update the `state` on a discovered operation",builder:x,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway discovery operations edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations/${e[`discovery-id`]==null?`<discovery-id>`:encodeURIComponent(String(e[`discovery-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"discovery-id":String(e[`discovery-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.edit({...n,zone_id:r,discovery_id:e[`discovery-id`]})),{successLabel:`Updated`});return}c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.edit({zone_id:r,discovery_id:e[`discovery-id`]})),{successLabel:`Updated`})}};function C(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`host`,`method`,`endpoint`,`traffic_stats.requests`,`traffic_stats.last_updated`]}).option(`diff`,{type:`boolean`,description:"When `true`, only return API Discovery results that are not saved into API Shield Endpoint Management"}).option(`origin`,{type:`string`,description:"Filter results to only include discovery results sourced from a particular discovery engine\n * `ML` - Discovered operations that were sourced using ML API Discovery\n * `SessionIdentifier` - Discovered operations that were sourced using Session Identifier API Discovery",choices:[`ML`,`SessionIdentifier`,`LabelDiscovery`]}).option(`state`,{type:`string`,description:"Filter results to only include discovery results in a particular state. States are as follows\n * `review` - Discovered operations that are not saved into API Shield Endpoint Management\n * `saved` - Discovered operations that are already saved into API Shield Endpoint Management\n * `ignored` - Discovered operations that have been marked as ignored",choices:[`review`,`saved`,`ignored`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const w={command:`list`,describe:`Retrieve the most up to date view of discovered operations`,builder:p(C),handler:async e=>{let t={page:e.page,per_page:e[`per-page`],host:e.host,method:e.method,endpoint:e.endpoint,direction:e.direction,order:e.order,diff:e.diff,origin:e.origin,state:e.state};if(e.dryRun){l({command:`cf api-gateway discovery operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.discovery.operations.list({zone_id:i,...t})),{successLabel:`Loaded`})}},T={command:`operations`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(b).command(S).command(w).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},E={command:`discovery`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(v).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`hosts`,{type:`string`,array:!0,description:`List of hosts to be targeted in the expression`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const O={command:`create`,describe:`Creates an expression template fallthrough rule for API Shield. Used for configuring default behavior when no other expression templates match.`,builder:D,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway expression-template fallthrough create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/expression-template/fallthrough`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({hosts:e.hosts}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.expressionTemplate.fallthrough.create({...n,zone_id:r})),{successLabel:`Created`});return}if(e.hosts===void 0)throw Error(`--hosts is required (or pass --body with this field set).`);let i=s({hosts:e.hosts});c(await u(`Creating`,async()=>t.apiGateway.expressionTemplate.fallthrough.create({...i,zone_id:r})),{successLabel:`Created`})}},k={command:`fallthrough`,describe:`Reusable expression templates for API Gateway rule configurations`,builder:e=>e.command(O).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},A={command:`expression-template`,describe:`Operations for expression-template`,builder:e=>e.command(k).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function j(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`name`,`description`,`created_at`,`last_updated`,`mapped_resources.operations`]}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`source`,{type:`string`,description:`Filter for labels with source`,choices:[`user`,`managed`]}).option(`filter`,{type:`string`,description:`Filter for labels where the name or description matches using substring match`}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`list`,describe:`Retrieve all labels`,builder:p(j),handler:async e=>{let t={page:e.page,per_page:e[`per-page`],order:e.order,direction:e.direction,source:e.source,filter:e.filter,with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.labels.list({zone_id:i,...t})),{successLabel:`Loaded`})}};function N(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`get <name>`,describe:`Retrieve managed label`,builder:N,handler:async e=>{let t={with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels managed get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/managed/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.labels.managed.get({zone_id:i,name:e.name,...t})),{successLabel:`Loaded`})}};function F(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const I={command:`update <name>`,describe:`Replace all operations(s) attached to a managed label`,builder:F,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels managed resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/managed/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}/resources/operation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.managed.resources.operation.update({body:n,zone_id:r,name:e.name})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},L={command:`operation`,describe:`Labels operations`,builder:e=>e.command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},R={command:`resources`,describe:`Operations for labels.managed.resources`,builder:e=>e.command(L).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},z={command:`managed`,describe:`Labels operations`,builder:e=>e.command(P).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function B(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const V={command:`bulk-create`,describe:`Create user labels`,builder:B,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels user bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.labels.user.bulkCreate({body:n,zone_id:r})),{successLabel:`Created`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function H(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const U={command:`bulk-delete`,describe:`Delete user labels`,builder:H,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels user bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
|
|
3
3
|
`);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.labels.user.bulkDelete({body:n,zone_id:i})),{successLabel:`Deleted`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function W(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const G={command:`delete <name>`,describe:`Delete user label`,builder:W,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels user delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`none`});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
|
|
4
4
|
`);return}c(await u(`Deleting`,async()=>t.apiGateway.labels.user.delete({zone_id:i,name:e.name})),{successLabel:`Deleted`})}};function K(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`description`,{type:`string`,description:`The description of the label`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const q={command:`edit <name>`,describe:`Update certain fields on a label`,builder:K,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels user edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?s({description:d(e.description,`description`,`text`)}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.user.edit({...n,zone_id:r,name:e.name})),{successLabel:`Updated`});return}let i=s({description:d(e.description,`description`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.labels.user.edit({...i,zone_id:r,name:e.name})),{successLabel:`Updated`})}};function J(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Y={command:`get <name>`,describe:`Retrieve user label`,builder:J,handler:async e=>{let t={with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels user get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.labels.user.get({zone_id:i,name:e.name,...t})),{successLabel:`Loaded`})}};function X(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Z={command:`update <name>`,describe:`Replace all operations(s) attached to a user label`,builder:X,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels user resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}/resources/operation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.user.resources.operation.update({body:n,zone_id:r,name:e.name})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Q={command:`operation`,describe:`Labels operations`,builder:e=>e.command(Z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ne={command:`resources`,describe:`Operations for labels.user.resources`,builder:e=>e.command(Q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function re(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`description`,{type:`string`,description:`The description of the label`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ie={command:`update <name>`,describe:`Update all fields on a label`,builder:re,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway labels user update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?s({description:d(e.description,`description`,`text`)}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.user.update({...n,zone_id:r,name:e.name})),{successLabel:`Updated`});return}let i=s({description:d(e.description,`description`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.labels.user.update({...i,zone_id:r,name:e.name})),{successLabel:`Updated`})}},ae={command:`user`,describe:`Labels operations`,builder:e=>e.command(V).command(U).command(G).command(q).command(Y).command(ie).command(ne).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},oe={command:`labels`,describe:`Labels operations`,builder:e=>e.command(M).command(z).command(ae).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function se(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ce={command:`bulk-create`,describe:`Add one or more operations to a zone. Endpoints can contain path variables. Host, method, endpoint will be normalized to a canoncial form when creating an operation and must be unique on the zone. Inserting an operation that matches an existing one will return the record of the already existing operation and update its last_updated date.`,builder:se,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway operations bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.operations.bulkCreate({body:n,zone_id:r})),{successLabel:`Created`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function le(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ue={command:`bulk-delete`,describe:`Bulk removes multiple API operations from API Shield endpoint management in a single request. Efficient for cleaning up unused endpoints.`,builder:le,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway operations bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
|
|
5
5
|
`);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.operations.bulkDelete({body:n,zone_id:i})),{successLabel:`Deleted`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function de(e){return e.option(`endpoint`,{type:`string`,description:`The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/.`}).option(`host`,{type:`string`,description:`RFC3986-compliant host.`}).option(`method`,{type:`string`,description:`The HTTP method used to access the endpoint.`,choices:[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const fe={command:`create`,describe:`Add one operation to a zone. Endpoints can contain path variables. Host, method, endpoint will be normalized to a canoncial form when creating an operation and must be unique on the zone. Inserting an operation that matches an existing one will return the record of the already existing operation and update its last_updated date.`,builder:de,handler:async r=>{if(r.dryRun){l({command:`cf api-gateway operations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${r.zone??r.zoneId??`<zone>`}/api_gateway/operations/item`,pathParams:{"zone-id":String(r.zone??r[`zone-id`]??``)},bodyKind:`json`,body:r.body===void 0?s({endpoint:d(r.endpoint,`endpoint`,`text`),host:d(r.host,`host`,`text`),method:d(r.method,`method`,`text`)}):o(r.body)});return}let i=await a(r),f=await n({zone:r.zone},i,{quiet:r.quiet});if(r.zoneId=f,r.body){let e=o(r.body);c(await u(`Creating`,async()=>i.apiGateway.operations.create({body:e,zone_id:f})),{successLabel:`Created`});return}r.endpoint===void 0&&(r.endpoint=await e(`endpoint`,`The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/.`)),r.host===void 0&&(r.host=await e(`host`,`RFC3986-compliant host.`)),r.method===void 0&&(r.method=await t(`method`,`The HTTP method used to access the endpoint.`,[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]));let p=s({endpoint:d(r.endpoint,`endpoint`,`text`),host:d(r.host,`host`,`text`),method:d(r.method,`method`,`text`)});c(await u(`Creating`,async()=>i.apiGateway.operations.create({body:p,zone_id:f})),{successLabel:`Created`})}};function pe(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const me={command:`delete <operation-id>`,describe:`Removes a single API operation from API Shield endpoint management. The operation will no longer be tracked or protected by API Shield rules.`,builder:pe,handler:async e=>{if(e.dryRun){l({command:`cf api-gateway operations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`none`});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{E as e,S as t,n}from"./auth-
|
|
2
|
+
import{E as e,S as t,n}from"./auth-BqDOIrKX.mjs";import{n as r,t as i}from"./body-parser-CBpeIUns.mjs";import{t as a}from"./output-CUxZRM5A.mjs";import{n as o,t as s}from"./progress-Cent9Lsg.mjs";import{n as c}from"./input-validation-CTqtyiY9.mjs";function l(e){return e.option(`value`,{type:`string`,description:`Specifies the enablement value of Argo Smart Routing.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Configures the enablement of Argo Smart Routing.`})}const u={command:`edit`,describe:`Configures the value of the Argo Smart Routing enablement setting.`,builder:l,handler:async l=>{if(l.dryRun){o({command:`cf argo smart-routing edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zone??l.zoneId??`<zone>`}/argo/smart_routing`,pathParams:{"zone-id":String(l.zone??l[`zone-id`]??``)},bodyKind:`json`,body:l.body===void 0?i({value:c(l.value,`value`,`text`)}):r(l.body)});return}let u=await n(l),d=await t({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=r(l.body);a(await s(`Updating`,async()=>u.argo.smartRouting.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await e(`value`,`Specifies the enablement value of Argo Smart Routing.`,[`on`,`off`]));let f=i({value:c(l.value,`value`,`text`)});a(await s(`Updating`,async()=>u.argo.smartRouting.edit({...f,zone_id:d})),{successLabel:`Updated`})}};function d(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const f={command:`get`,describe:`Retrieves the value of Argo Smart Routing enablement setting.`,builder:d,handler:async e=>{if(e.dryRun){o({command:`cf argo smart-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/argo/smart_routing`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,a(await s(`Loading`,async()=>r.argo.smartRouting.get({zone_id:i})),{successLabel:`Loaded`})}},p={command:`smart-routing`,describe:`Route traffic through the fastest network paths to your origin using real-time latency data`,builder:e=>e.command(u).command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function m(e){return e.option(`value`,{type:`string`,description:`Enables Tiered Caching.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Update enablement of Tiered Caching.`})}const h={command:`edit`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:m,handler:async l=>{if(l.dryRun){o({command:`cf argo tiered-caching edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zone??l.zoneId??`<zone>`}/argo/tiered_caching`,pathParams:{"zone-id":String(l.zone??l[`zone-id`]??``)},bodyKind:`json`,body:l.body===void 0?i({value:c(l.value,`value`,`text`)}):r(l.body)});return}let u=await n(l),d=await t({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=r(l.body);a(await s(`Updating`,async()=>u.argo.tieredCaching.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await e(`value`,`Enables Tiered Caching.`,[`on`,`off`]));let f=i({value:c(l.value,`value`,`text`)});a(await s(`Updating`,async()=>u.argo.tieredCaching.edit({...f,zone_id:d})),{successLabel:`Updated`})}};function g(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:g,handler:async e=>{if(e.dryRun){o({command:`cf argo tiered-caching get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/argo/tiered_caching`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,a(await s(`Loading`,async()=>r.argo.tieredCaching.get({zone_id:i})),{successLabel:`Loaded`})}},v={command:`tiered-caching`,describe:`Reduce origin load by having upper-tier data centers serve cache misses before reaching your origin`,builder:e=>e.command(h).command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},y={command:`argo`,describe:`Network optimization features that speed up and improve reliability of traffic to your origins`,builder:e=>e.command(p).command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{C as e,T as t,_ as n,n as r}from"./auth-BqDOIrKX.mjs";import{t as i}from"./output-CUxZRM5A.mjs";import{n as a,t as o}from"./progress-Cent9Lsg.mjs";import{t as s}from"./local-D8bhHUMK.mjs";import{t as c}from"./cli-types-CMNMD1V7.mjs";import{n as l,t as u}from"./raw-fetch-DnbAMFBp.mjs";function d(e){return e.positional(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const f={command:`artifactsNamespacesGet <namespace>`,describe:`Returns an Artifacts namespace summary.`,builder:d,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsNamespacesGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}`,pathParams:{namespace:String(t.namespace??``)},bodyKind:`none`});return}let c=await r(t),l=t.local?s:await n(c);t.accountId=l,i(await o(`Loading`,async()=>c.artifacts.namespaces.artifactsNamespacesGet({account_id:l,namespace:t.namespace})),{successLabel:`Loaded`})}};function p(e){return e.option(`limit`,{type:`number`,description:`Limit`}).option(`cursor`,{type:`string`,description:`Cursor`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const m={command:`artifactsNamespacesList`,describe:`Lists Artifacts namespaces for an account.`,builder:p,handler:async t=>{let c={limit:t.limit,cursor:t.cursor};if(t.dryRun){a({command:`cf artifacts namespaces artifactsNamespacesList`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(t),u=t.local?s:await n(l);t.accountId=u,i(await o(`Loading`,async()=>l.artifacts.namespaces.artifactsNamespacesList({account_id:u,...c})),{successLabel:`Loaded`})}};function h(e){return e.positional(`hash`,{type:`string`,description:`40-character lowercase hexadecimal Git object hash.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const g={command:`artifactsReposBlobGet <hash>`,describe:`Returns raw bytes for an immutable Git blob object. Blob responses are cacheable forever by hash.`,builder:h,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposBlobGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/blob/${t.hash==null?`<hash>`:encodeURIComponent(String(t.hash))}`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``),hash:String(t.hash??``)},bodyKind:`none`});return}let i=await r(t),c=t.local?s:await n(i);t.accountId=c;let d=await o(`Loading`,async()=>u(`/accounts/${c}/artifacts/namespaces/${encodeURIComponent(String(t.namespace))}/repos/${encodeURIComponent(String(t.name))}/blob/${encodeURIComponent(String(t.hash))}`,{method:`GET`,localEndpoint:t.local?t.localEndpoint:void 0}));l(t.text===!0?d.toString(`utf-8`):d)}};function _(e){return e.positional(`hash`,{type:`string`,description:`40-character lowercase hexadecimal Git object hash.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`artifactsReposCommitGet <hash>`,describe:`Returns decoded metadata for an immutable Git commit object. Commit responses are cacheable forever by hash.`,builder:_,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposCommitGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/commit/${t.hash==null?`<hash>`:encodeURIComponent(String(t.hash))}`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``),hash:String(t.hash??``)},bodyKind:`none`});return}let c=await r(t),l=t.local?s:await n(c);t.accountId=l,i(await o(`Loading`,async()=>c.artifacts.namespaces.artifactsReposCommitGet({account_id:l,namespace:t.namespace,name:t.name,hash:t.hash})),{successLabel:`Loaded`})}};function y(e){return e.positional(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`artifactsReposCreate <namespace>`,describe:`Creates a Git-compatible Artifacts repository in a namespace.`,builder:y,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposCreate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos`,pathParams:{namespace:String(t.namespace??``)},bodyKind:`none`});return}let c=await r(t),l=t.local?s:await n(c);t.accountId=l,i(await o(`Creating`,async()=>c.artifacts.namespaces.artifactsReposCreate({account_id:l,namespace:t.namespace})),{successLabel:`Created`})}};function x(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const S={command:`artifactsReposDelete <name>`,describe:`Deletes a repository and schedules cleanup of its backing data.`,builder:x,handler:async c=>{if(c.dryRun){a({command:`cf artifacts namespaces artifactsReposDelete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${c.namespace==null?`<namespace>`:encodeURIComponent(String(c.namespace))}/repos/${c.name==null?`<name>`:encodeURIComponent(String(c.name))}`,pathParams:{namespace:String(c.namespace??``),name:String(c.name??``)},bodyKind:`none`});return}let l=await r(c),u=c.local?s:await n(l);if(c.accountId=u,!await t({force:!!c.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}i(await o(`Deleting`,async()=>l.artifacts.namespaces.artifactsReposDelete({account_id:u,namespace:c.namespace,name:c.name})),{successLabel:`Deleted`})}};function C(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`ref`,{type:`string`,description:`Git ref, branch, tag, or commit hash.`,demandOption:!0}).option(`path`,{type:`string`,description:`File path.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const w={command:`artifactsReposFileGet <name>`,describe:`Returns raw bytes for a file resolved by ref and path.`,builder:C,handler:async t=>{let i={ref:t.ref,path:t.path};if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposFileGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/file`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``)},query:i,bodyKind:`none`});return}let c=await r(t),d=t.local?s:await n(c);t.accountId=d;let f=new URLSearchParams(Object.entries(i).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),p=await o(`Loading`,async()=>u(`/accounts/${d}/artifacts/namespaces/${encodeURIComponent(String(t.namespace))}/repos/${encodeURIComponent(String(t.name))}/file${f?`?`+f:``}`,{method:`GET`,localEndpoint:t.local?t.localEndpoint:void 0}));l(t.text===!0?p.toString(`utf-8`):p)}};function T(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const E={command:`artifactsReposFork <name>`,describe:`Forks a source repository into a new repository.`,builder:T,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposFork`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/fork`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``)},bodyKind:`none`});return}let c=await r(t),l=t.local?s:await n(c);t.accountId=l,i(await o(`Creating`,async()=>c.artifacts.namespaces.artifactsReposFork({account_id:l,namespace:t.namespace,name:t.name})),{successLabel:`Created`})}};function D(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`artifactsReposGet <name>`,describe:`Returns repository metadata.`,builder:D,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``)},bodyKind:`none`});return}let c=await r(t),l=t.local?s:await n(c);t.accountId=l,i(await o(`Loading`,async()=>c.artifacts.namespaces.artifactsReposGet({account_id:l,namespace:t.namespace,name:t.name})),{successLabel:`Loaded`})}};function k(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`artifactsReposImport <name>`,describe:`Imports an HTTPS Git repository into an Artifacts repository.`,builder:k,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposImport`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/import`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``)},bodyKind:`none`});return}let c=await r(t),l=t.local?s:await n(c);t.accountId=l,i(await o(`Creating`,async()=>c.artifacts.namespaces.artifactsReposImport({account_id:l,namespace:t.namespace,name:t.name})),{successLabel:`Created`})}};function j(e){return e.positional(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`limit`,{type:`number`,description:`Limit`}).option(`cursor`,{type:`string`,description:`Cursor`}).option(`search`,{type:`string`,description:`Search`}).option(`sort`,{type:`string`,description:`Sort`,choices:[`created_at`,`updated_at`,`last_push_at`,`name`]}).option(`direction`,{type:`string`,description:`Direction`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`artifactsReposList <namespace>`,describe:`Lists repositories in a namespace.`,builder:c(j),handler:async t=>{let c={limit:t.limit,cursor:t.cursor,search:t.search,sort:t.sort,direction:t.direction};if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposList`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos`,pathParams:{namespace:String(t.namespace??``)},query:c,bodyKind:`none`});return}let l=await r(t),u=t.local?s:await n(l);t.accountId=u,i(await o(`Loading`,async()=>l.artifacts.namespaces.artifactsReposList({account_id:u,namespace:t.namespace,...c})),{successLabel:`Loaded`})}};function N(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`ref`,{type:`string`,description:`Git ref, branch, tag, or commit hash. Defaults to HEAD.`}).option(`limit`,{type:`number`,description:`Limit`}).option(`offset`,{type:`number`,description:`Offset`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`artifactsReposLogGet <name>`,describe:`Returns commit metadata walking backwards from a ref, branch, tag, or HEAD.`,builder:N,handler:async t=>{let c={ref:t.ref,limit:t.limit,offset:t.offset};if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposLogGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/log`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``)},query:c,bodyKind:`none`});return}let l=await r(t),u=t.local?s:await n(l);t.accountId=u,i(await o(`Loading`,async()=>l.artifacts.namespaces.artifactsReposLogGet({account_id:u,namespace:t.namespace,name:t.name,...c})),{successLabel:`Loaded`})}};function F(e){return e.positional(`path`,{type:`string`,description:`File path. May contain slashes.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`ref`,{type:`string`,description:`Git ref, branch, tag, or 40-character commit hash.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const I={command:`artifactsReposRawGet <path>`,describe:`Returns file bytes resolved by ref and path, with a sniffed content type and browser-safe response headers.`,builder:F,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposRawGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/raw/${t.ref==null?`<ref>`:encodeURIComponent(String(t.ref))}/${t.path==null?`<path>`:encodeURIComponent(String(t.path))}`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``),ref:String(t.ref??``),path:String(t.path??``)},bodyKind:`none`});return}let i=await r(t),c=t.local?s:await n(i);t.accountId=c;let d=await o(`Loading`,async()=>u(`/accounts/${c}/artifacts/namespaces/${encodeURIComponent(String(t.namespace))}/repos/${encodeURIComponent(String(t.name))}/raw/${encodeURIComponent(String(t.ref))}/${encodeURIComponent(String(t.path))}`,{method:`GET`,localEndpoint:t.local?t.localEndpoint:void 0}));l(t.text===!0?d.toString(`utf-8`):d)}};function L(e){return e.positional(`hash`,{type:`string`,description:`40-character lowercase hexadecimal Git object hash.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const R={command:`artifactsReposTreeGet <hash>`,describe:`Returns decoded entries for an immutable Git tree object. Tree responses are cacheable forever by hash.`,builder:L,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsReposTreeGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/tree/${t.hash==null?`<hash>`:encodeURIComponent(String(t.hash))}`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``),hash:String(t.hash??``)},bodyKind:`none`});return}let c=await r(t),l=t.local?s:await n(c);t.accountId=l,i(await o(`Loading`,async()=>c.artifacts.namespaces.artifactsReposTreeGet({account_id:l,namespace:t.namespace,name:t.name,hash:t.hash})),{successLabel:`Loaded`})}};function z(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`state`,{type:`string`,description:`State`,choices:[`active`,`expired`,`revoked`,`all`]}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const B={command:`artifactsRepoTokensList <name>`,describe:`Lists tokens for a repository.`,builder:c(z),handler:async t=>{let c={state:t.state,page:t.page,per_page:t[`per-page`]};if(t.dryRun){a({command:`cf artifacts namespaces artifactsRepoTokensList`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/repos/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/tokens`,pathParams:{namespace:String(t.namespace??``),name:String(t.name??``)},query:c,bodyKind:`none`});return}let l=await r(t),u=t.local?s:await n(l);t.accountId=u,i(await o(`Loading`,async()=>l.artifacts.namespaces.artifactsRepoTokensList({account_id:u,namespace:t.namespace,name:t.name,...c})),{successLabel:`Loaded`})}};function V(e){return e.positional(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const H={command:`artifactsTokensCreate <namespace>`,describe:`Creates a scoped Git token for a repository.`,builder:V,handler:async t=>{if(t.dryRun){a({command:`cf artifacts namespaces artifactsTokensCreate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${t.namespace==null?`<namespace>`:encodeURIComponent(String(t.namespace))}/tokens`,pathParams:{namespace:String(t.namespace??``)},bodyKind:`none`});return}let c=await r(t),l=t.local?s:await n(c);t.accountId=l,i(await o(`Creating`,async()=>c.artifacts.namespaces.artifactsTokensCreate({account_id:l,namespace:t.namespace})),{successLabel:`Created`})}};function U(e){return e.positional(`id`,{type:`string`,description:`Token ID. Must match /^[0-9a-z]{16}$/.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const W={command:`artifactsTokensRevoke <id>`,describe:`Revokes an Artifacts repository token.`,builder:U,handler:async c=>{if(c.dryRun){a({command:`cf artifacts namespaces artifactsTokensRevoke`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${c.namespace==null?`<namespace>`:encodeURIComponent(String(c.namespace))}/tokens/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{namespace:String(c.namespace??``),id:String(c.id??``)},bodyKind:`none`});return}let l=await r(c),u=c.local?s:await n(l);if(c.accountId=u,!await t({force:!!c.force})){process.stderr.write(`Aborted.
|
|
4
|
+
`);return}i(await o(`Deleting`,async()=>l.artifacts.namespaces.artifactsTokensRevoke({account_id:u,namespace:c.namespace,id:c.id})),{successLabel:`Deleted`})}},G={command:`namespaces`,describe:`Operations for namespaces`,builder:e=>e.command(f).command(m).command(B).command(g).command(v).command(b).command(S).command(w).command(E).command(O).command(A).command(M).command(P).command(I).command(R).command(H).command(W).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},K={command:`artifacts`,describe:`artifacts`,builder:e=>e.command(G).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{K as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{C as e,_ as t,n}from"./auth-
|
|
2
|
+
import{C as e,_ as t,n}from"./auth-BqDOIrKX.mjs";import{t as r}from"./output-CUxZRM5A.mjs";import{n as i,t as a}from"./progress-Cent9Lsg.mjs";import{t as o}from"./local-D8bhHUMK.mjs";import{t as s}from"./cli-types-CMNMD1V7.mjs";function c(e){return e.option(`id`,{type:`string`,description:`Finds a specific log by its ID.`}).option(`export`,{type:`boolean`,description:`Indicates that this request is an export of logs in CSV format.`}).option(`action-type`,{type:`string`,description:`Filters by the action type.`}).option(`actor-ip`,{type:`string`,description:`Filters by the IP address of the request that made the change by specific IP address or valid CIDR Range.`}).option(`actor-email`,{type:`string`,description:`Filters by the email address of the actor that made the change.`}).option(`since`,{type:`string`,description:"Limits the returned results to logs newer than the specified date. A `full-date` that conforms to RFC3339."}).option(`before`,{type:`string`,description:"Limits the returned results to logs older than the specified date. A `full-date` that conforms to RFC3339."}).option(`zone-name`,{type:`string`,description:`Filters by the name of the zone associated to the change.`}).option(`direction`,{type:`string`,description:`Changes the direction of the chronological sorting.`,choices:[`desc`,`asc`]}).option(`per-page`,{type:`number`,description:`Sets the number of results to return per page.`}).option(`page`,{type:`number`,description:`Defines which page of results to return.`}).option(`hide-user-logs`,{type:`boolean`,description:`Indicates whether or not to hide user level audit logs.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const l={command:`list`,describe:`Gets a list of audit logs for an account. Can be filtered by who made the change, on which zone, and the timeframe of the change.`,builder:s(c),handler:async s=>{let c={id:s.id,export:s.export,"action.type":s[`action-type`],"actor.ip":s[`actor-ip`],"actor.email":s[`actor-email`],since:s.since,before:s.before,"zone.name":s[`zone-name`],direction:s.direction,per_page:s[`per-page`],page:s.page,hide_user_logs:s[`hide-user-logs`]};if(s.dryRun){i({command:`cf audit-logs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/audit_logs`,pathParams:{},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await t(l);s.accountId=u,r(await a(`Loading`,async()=>l.auditLogs.list({account_id:u,...c})),{successLabel:`Loaded`})}},u={command:`audit-logs`,describe:`Immutable audit trail of actions taken by account members — who changed what and when`,builder:e=>e.command(l).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{u as default};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{o as e}from"./chunk-DH-VkVmc.mjs";import{a as t,i as n,o as r,r as i,s as a,t as o}from"./session-CsvPYFj8.mjs";import{$ as s,A as c,B as l,I as u,L as d,M as f,P as p,S as m,W as h,Z as ee,_ as g,a as te,et as _,g as v,j as ne,m as y,s as re,t as b,v as ie}from"./dist-DpDjsWWn.mjs";import{n as x,t as S}from"./theme-CFHr0Dh9.mjs";import{i as C,n as w,r as ae}from"./config-7CBz8Xm0.mjs";import{c as oe,f as se,h as T,i as E,m as D,o as ce,r as le,s as ue,t as de}from"./dist-DA54ZQu0.mjs";import{n as fe,t as pe}from"./resolve-D1mG0REg.mjs";import{createRequire as me}from"node:module";import{chmodSync as he,existsSync as O,mkdirSync as k,readFileSync as ge,readdirSync as _e,rmSync as A,unlinkSync as ve,writeFileSync as j}from"node:fs";import ye from"node:assert";import"node:os";import M,{dirname as be,join as xe}from"node:path";import{spawnSync as Se}from"node:child_process";import{createCipheriv as Ce,createDecipheriv as we,createHash as Te,randomBytes as Ee,webcrypto as De}from"node:crypto";import Oe from"node:http";import{TextEncoder as ke}from"node:util";import Ae,{URLSearchParams as je}from"node:url";import"node:process";import{execSync as Me}from"child_process";import Ne from"os";var Pe=Object.defineProperty,N=(e,t)=>Pe(e,`name`,{value:t,configurable:!0}),P=d(),Fe=!1;function F(e){let{configOverride:t,warningLogger:n,storage:r}=e,{oauth_token:i,refresh_token:a,expiration_time:o,scopes:s,api_token:c}=t??r.read()??{};return i?{accessToken:{value:i,expiry:o??`2000-01-01:00:00:00+00:00`},refreshToken:{value:a??``},scopes:s}:c?(!Fe&&n&&(Fe=!0,n.warn(`It looks like you have used Wrangler v1's \`config\` command to login with an API token
|
|
3
|
+
from ${t===void 0?r.path():`in-memory config`}.
|
|
4
|
+
This is no longer supported in the current version of Wrangler.
|
|
5
|
+
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\` environment variable.`)),{deprecatedApiToken:c}):{}}N(F,`readStoredAuthState`);var Ie=m({variableName:`CLOUDFLARE_API_TOKEN`,deprecatedName:`CF_API_TOKEN`}),Le=m({variableName:`CLOUDFLARE_API_KEY`,deprecatedName:`CF_API_KEY`}),Re=m({variableName:`CLOUDFLARE_EMAIL`,deprecatedName:`CF_EMAIL`});function ze(e){if(e?.allowGlobalAuthKey??!0){let e=Le(),t=Re();if(e&&t)return{authKey:e,authEmail:t}}let t=Ie();if(t)return{apiToken:t}}N(ze,`getAuthFromEnv`);function Be(e){let t=ze(e);if(t)return t;let n=F({storage:e.storage,warningLogger:e.warningLogger});if(n.deprecatedApiToken)return{apiToken:n.deprecatedApiToken};if(n.accessToken?.value)return{apiToken:n.accessToken.value}}N(Be,`getAPIToken`);function Ve(e){let t=Be(e);if(!t)throw new h(`No API token found.`,{telemetryMessage:`user auth missing api token`});return t}N(Ve,`requireApiToken`);var I=m({variableName:`WRANGLER_AUTH_DOMAIN`,defaultValue:N(()=>g()===`staging`?`dash.staging.cloudflare.com`:`dash.cloudflare.com`,`defaultValue`)}),He=m({variableName:`WRANGLER_AUTH_URL`,defaultValue:N(()=>`https://${I()}/oauth2/auth`,`defaultValue`)}),Ue=m({variableName:`WRANGLER_TOKEN_URL`,defaultValue:N(()=>`https://${I()}/oauth2/token`,`defaultValue`)}),We=m({variableName:`WRANGLER_REVOKE_URL`,defaultValue:N(()=>`https://${I()}/oauth2/revoke`,`defaultValue`)}),Ge=m({variableName:`CLOUDFLARE_ACCOUNT_ID`,deprecatedName:`CF_ACCOUNT_ID`}),Ke=m({variableName:`CLOUDFLARE_ACCESS_CLIENT_ID`}),qe=m({variableName:`CLOUDFLARE_ACCESS_CLIENT_SECRET`}),Je=m({variableName:`WRANGLER_CF_AUTHORIZATION_TOKEN`}),Ye=y({variableName:`CLOUDFLARE_AUTH_USE_KEYRING`}),L={},R=new Map;function Xe(){for(let e of Object.keys(L))delete L[e];R.clear()}N(Xe,`clearAccessCaches`);async function Ze(e,t){if(t.debug(`Checking if domain has Access enabled:`,e),R.has(e))return t.debug(`Using cached Access switch for:`,e,R.get(e)),R.get(e)??!1;t.debug(`Access switch not cached for:`,e);try{let n=new AbortController,r=setTimeout(()=>{n.abort()},1e3),i=await(0,P.fetch)(`https://${e}`,{redirect:`manual`,signal:n.signal});clearTimeout(r);let a=!!(i.status===302&&i.headers.get(`location`)?.includes(`cloudflareaccess.com`));return t.debug(`Caching access switch for:`,e),R.set(e,a),a}catch{return R.set(e,!1),!1}}N(Ze,`domainUsesAccess`);async function Qe(e,t){let n=t.logger,r=t.isNonInteractiveOrCI,i=Ke(),a=qe();if(i&&a){n.debug(`Using Access Service Token headers for domain:`,e);let t={"CF-Access-Client-Id":i,"CF-Access-Client-Secret":a};return L[e]=t,t}if((i!==void 0||a!==void 0)&&n.warn(`Both CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET must be set to use Access Service Token authentication. Only ${i===void 0?`CLOUDFLARE_ACCESS_CLIENT_SECRET`:`CLOUDFLARE_ACCESS_CLIENT_ID`} was found.`),!await Ze(e,n))return{};if(n.debug(`Getting Access headers for domain:`,e),L[e])return n.debug(`Using cached Access headers for domain:`,e),L[e];if(r())throw new h(`The domain "${e}" is behind Cloudflare Access, but no Access Service Token credentials were found and the current environment is non-interactive.
|
|
6
|
+
Set the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET environment variables to authenticate with an Access Service Token.
|
|
7
|
+
See https://developers.cloudflare.com/cloudflare-one/access-controls/service-credentials/service-tokens/`,{telemetryMessage:`user access missing service token non interactive`});n.debug(`Spawning cloudflared to get Access token for domain:`);let o=Se(`cloudflared`,[`access`,`login`,e]);if(o.error)throw new h("To use Wrangler with Cloudflare Access, please install `cloudflared` from https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation",{telemetryMessage:`user access missing cloudflared`});let s=o.stdout.toString();n.debug(`cloudflared output:`,s);let c=s.match(/fetched your token:\n\n(.*)/m);if(c&&c.length>=2){let t={Cookie:`CF_Authorization=${c[1]}`};return L[e]=t,n.debug(`Caching Access headers for domain:`,e),t}throw Error(`Failed to authenticate with Cloudflare Access`)}N(Qe,`getAccessHeaders`);async function $e(e){let t=Je();return t===void 0?Qe(I(),e):(e.logger.debug(`Using WRANGLER_CF_AUTHORIZATION_TOKEN from environment`),{Cookie:`CF_Authorization=${t}`})}N($e,`getCloudflareAccessHeaders`);var et=96,tt=32,nt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~`;function rt(e){let t=btoa(e);return t=t.replace(/\+/g,`-`),t=t.replace(/\//g,`_`),t=t.replace(/=/g,``),t}N(rt,`base64urlEncode`);async function it(){let e=new Uint32Array(et);De.getRandomValues(e);let t=rt(Array.from(e).map(e=>nt[e%nt.length]).join(``)),n=await De.subtle.digest(`SHA-256`,new ke().encode(t)),r=new Uint8Array(n),i=``,a=r.byteLength;for(let e=0;e<a;e++)i+=String.fromCharCode(r[e]);return{codeChallenge:rt(i),codeVerifier:t}}N(it,`generatePKCECodes`);var at=N(({authUrl:e,clientId:t,scopes:n,stateQueryParam:r,codeChallenge:i,redirectUri:a})=>e+`?response_type=code&client_id=${encodeURIComponent(t)}&redirect_uri=${encodeURIComponent(a)}&scope=${encodeURIComponent([...n,`offline_access`].join(` `))}&state=${r}&code_challenge=${encodeURIComponent(i)}&code_challenge_method=S256`,`generateAuthUrl`);function ot(e){let t=new Uint32Array(e);return De.getRandomValues(t),Array.from(t).map(e=>nt[e%nt.length]).join(``)}N(ot,`generateRandomState`);var st=64e6;function ct(e,t,n){let r=Array(t+1),i=Te(`sha256`).update(e).digest();r[0]=i;for(let e=0;e<t;e++){for(let e=0;e<n;e++)i=Te(`sha256`).update(i).digest();r[e+1]=i}return r}N(ct,`solvePow`);function lt(e){return Buffer.concat(e).toString(`base64`)}N(lt,`encodeCheckpoints`);function ut(e){let t=ct(Buffer.from(e.seed,`base64url`),e.k,e.g);return{challengeToken:e.challengeToken,solution:{checkpoints:lt(t)}}}N(ut,`solveChallenge`);var z={termsOfService:`https://www.cloudflare.com/terms/`,privacyPolicy:`https://www.cloudflare.com/privacypolicy/`},dt=`You must accept Cloudflare's Terms of Service (${z.termsOfService}) and Privacy Policy (${z.privacyPolicy}) in order to continue. By typing "yes", you agree to these terms. Type "yes" to continue.`,ft=`Continuing means you accept Cloudflare's Terms of Service (${z.termsOfService}) and Privacy Policy (${z.privacyPolicy}).`,pt=`You must accept Cloudflare's Terms of Service (${z.termsOfService}) and Privacy Policy (${z.privacyPolicy}) to use --temporary.`;function mt(){return`${v(b)}/provisioning/previews`}N(mt,`getTemporaryPreviewUrl`);function ht(){return`${mt()}/challenge`}N(ht,`getTemporaryPreviewChallengeUrl`);function gt(e){let t=Date.parse(e);return!Number.isNaN(t)&&t>Date.now()}N(gt,`isFutureTimestamp`);function _t(e){let t=e.read();if(t&&!(!t.account?.id||!t.account?.apiToken||!t.account?.name||!t.claim?.url||!gt(t.account?.expiresAt??``)||!gt(t.claim?.expiresAt??``)))return t}N(_t,`getCachedTemporaryPreviewAccount`);async function vt(e){let t=await(0,P.fetch)(ht(),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok)throw new l(`Failed to request a proof-of-work challenge (${t.status} ${t.statusText}).`,{telemetryMessage:`deploy temporary account challenge failed`});let n;try{n=await t.json()}catch{throw new l(`Failed to request a proof-of-work challenge. Received an invalid response (${t.status} ${t.statusText}).`,{telemetryMessage:`deploy temporary account challenge invalid response`})}let{challengeToken:r,seed:i,k:a,g:o}=n.result??{};if(r===void 0||i===void 0||a===void 0||o===void 0)throw new l(`Failed to request a proof-of-work challenge because the response was missing required fields.`,{telemetryMessage:`deploy temporary account challenge incomplete`});if(!Number.isInteger(a)||!Number.isInteger(o)||a<=0||o<=0||a*o>st||Buffer.from(i,`base64url`).length!==32)throw new l(`The proof-of-work challenge is not supported by this version of Wrangler.`,{telemetryMessage:`deploy temporary account challenge difficulty unsupported`});return e.log(`Solving proof-of-work challenge…`),ut({challengeToken:r,seed:i,k:a,g:o})}N(vt,`requestPowSolution`);async function yt(e){let t=await vt(e),n=await(0,P.fetch)(mt(),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({termsOfService:z.termsOfService,privacyPolicy:z.privacyPolicy,acceptTermsOfService:`yes`,challengeToken:t.challengeToken,solution:t.solution})});if(!n.ok)throw new l(`Failed to create a temporary preview account (${n.status} ${n.statusText}).`,{telemetryMessage:`deploy temporary account create failed`});let r;try{r=await n.json()}catch{throw new l(`Failed to create a temporary preview account. Received an invalid response (${n.status} ${n.statusText}).`,{telemetryMessage:`deploy temporary account invalid response`})}let i=r.result,a=i?.account?.id,o=i?.account?.name,s=i?.account?.apiToken,c=i?.account?.expiresAt,u=i?.claim?.url,d=i?.claim?.expiresAt;if(a===void 0||o===void 0||s===void 0||c===void 0||u===void 0||d===void 0)throw new l(`Failed to create a temporary preview account because the response was missing required fields.`,{telemetryMessage:`deploy temporary account response incomplete`});return{account:{id:a,name:o,apiToken:s,expiresAt:c},claim:{url:u,expiresAt:d}}}N(yt,`createTemporaryPreviewAccount`);async function bt(e){let t=_t(e.storage);if(t)return{account:t,cached:!0};if(!await e.prompt(dt,ft))throw new h(pt,{telemetryMessage:`user temporary terms not accepted`});let n=await yt(e.logger);return e.storage.write(n),{account:n,cached:!1}}N(bt,`getOrCreateTemporaryPreviewAccount`);function xt(e){var t=[...arguments].slice(1),n=Array.from(typeof e==`string`?[e]:e);n[n.length-1]=n[n.length-1].replace(/\r?\n([\t ]*)$/,``);var r=n.reduce(function(e,t){var n=t.match(/\n([\t ]+|(?!\s).)/g);return n?e.concat(n.map(function(e){return e.match(/[\t ]/g)?.length??0})):e},[]);if(r.length){var i=RegExp(`
|
|
8
|
+
[ ]{`+Math.min.apply(Math,r)+`}`,`g`);n=n.map(function(e){return e.replace(i,`
|
|
9
|
+
`)})}n[0]=n[0].replace(/^\r?\n/,``);var a=n[0];return t.forEach(function(e,t){var r=a.match(/(?:^|\n)( *)$/),i=r?r[1]:``,o=e;typeof e==`string`&&e.includes(`
|
|
10
|
+
`)&&(o=String(e).split(`
|
|
11
|
+
`).map(function(e,t){return t===0?e:``+i+e}).join(`
|
|
12
|
+
`)),a+=o+n[t+1]}),a}N(xt,`dedent`);var St=xt,B=class extends h{static{N(this,`ErrorOAuth2`)}code;description;uri;toString(){return`ErrorOAuth2`}},Ct=class extends B{static{N(this,`ErrorUnknown`)}toString(){return`ErrorUnknown`}},wt=class extends B{static{N(this,`ErrorNoAuthCode`)}toString(){return`ErrorNoAuthCode`}},Tt=class extends B{static{N(this,`ErrorInvalidReturnedStateParam`)}toString(){return`ErrorInvalidReturnedStateParam`}},Et=class extends B{static{N(this,`ErrorInvalidJson`)}toString(){return`ErrorInvalidJson`}},Dt=class extends B{static{N(this,`ErrorInvalidScope`)}toString(){return`ErrorInvalidScope`}},Ot=class extends B{static{N(this,`ErrorInvalidRequest`)}toString(){return`ErrorInvalidRequest`}},kt=class extends B{static{N(this,`ErrorInvalidToken`)}toString(){return`ErrorInvalidToken`}},At=class extends B{static{N(this,`ErrorAuthenticationGrant`)}toString(){return`ErrorAuthenticationGrant`}},jt=class extends At{static{N(this,`ErrorUnauthorizedClient`)}toString(){return`ErrorUnauthorizedClient`}},Mt=class extends At{static{N(this,`ErrorAccessDenied`)}toString(){return`ErrorAccessDenied`}},Nt=class extends At{static{N(this,`ErrorUnsupportedResponseType`)}toString(){return`ErrorUnsupportedResponseType`}},Pt=class extends At{static{N(this,`ErrorServerError`)}toString(){return`ErrorServerError`}},Ft=class extends At{static{N(this,`ErrorTemporarilyUnavailable`)}toString(){return`ErrorTemporarilyUnavailable`}},It=class extends B{static{N(this,`ErrorAccessTokenResponse`)}toString(){return`ErrorAccessTokenResponse`}},Lt=class extends It{static{N(this,`ErrorInvalidClient`)}toString(){return`ErrorInvalidClient`}},Rt=class extends It{static{N(this,`ErrorInvalidGrant`)}toString(){return`ErrorInvalidGrant`}},zt=class extends It{static{N(this,`ErrorUnsupportedGrantType`)}toString(){return`ErrorUnsupportedGrantType`}};function Bt(e,t,n){let r=`OAuth error: ${e}`;return t&&(r+=`
|
|
13
|
+
${t}`),n&&(r+=`
|
|
14
|
+
See: ${n}`),r}N(Bt,`formatOAuthErrorMessage`);function Vt(e,t,n){let r=Bt(e,t,n),i;switch(e){case`invalid_request`:i=new Ot(r,{telemetryMessage:`user oauth invalid request`});break;case`invalid_grant`:i=new Rt(r,{telemetryMessage:`user oauth invalid grant`});break;case`unauthorized_client`:i=new jt(r,{telemetryMessage:`user oauth unauthorized client`});break;case`access_denied`:i=new Mt(r,{telemetryMessage:`user oauth access denied`});break;case`unsupported_response_type`:i=new Nt(r,{telemetryMessage:`user oauth unsupported response type`});break;case`invalid_scope`:i=new Dt(r,{telemetryMessage:`user oauth invalid scope`});break;case`server_error`:i=new Pt(r,{telemetryMessage:`user oauth server error`});break;case`temporarily_unavailable`:i=new Ft(r,{telemetryMessage:`user oauth temporarily unavailable`});break;case`invalid_client`:i=new Lt(r,{telemetryMessage:`user oauth invalid client`});break;case`unsupported_grant_type`:i=new zt(r,{telemetryMessage:`user oauth unsupported grant type`});break;case`invalid_json`:i=new Et(r,{telemetryMessage:`user oauth invalid json`});break;case`invalid_token`:i=new kt(r,{telemetryMessage:`user oauth invalid token`});break;default:i=new Ct(r,{telemetryMessage:`user oauth unknown error`});break}return i.code=e,i.description=t,i.uri=n,i}N(Vt,`toErrorClass`);function Ht(e,t,n){if(e.error)throw Vt(Array.isArray(e.error)?e.error[0]:e.error,Array.isArray(e.error_description)?e.error_description[0]:e.error_description,Array.isArray(e.error_uri)?e.error_uri[0]:e.error_uri);let r=e.code;if(!r)return!1;if(e.state!==t.stateQueryParam)throw n.warn(`Received query string parameter doesn't match the one sent! Possible malicious activity somewhere.`),new Tt(``,{telemetryMessage:`user oauth invalid returned state`});return ye(!Array.isArray(r)),t.authorizationCode=r,t.hasAuthCodeBeenExchangedForAccessToken=!1,!0}N(Ht,`isReturningFromAuthServer`);async function Ut(e,t,n,r,i){let{codeChallenge:a,codeVerifier:o}=await it(),s=i.generateRandomState(tt);return Object.assign(r,{codeChallenge:a,codeVerifier:o,stateQueryParam:s}),i.generateAuthUrl({authUrl:He(),clientId:t,scopes:e,stateQueryParam:s,codeChallenge:a,redirectUri:n})}N(Ut,`getAuthURL`);async function Wt(e,t,n,r){let i=F({warningLogger:e,storage:r}).refreshToken;i||e.warn(`No refresh token is present.`);let a=await Kt(new URLSearchParams({grant_type:`refresh_token`,refresh_token:i?.value??``,client_id:n}),e,t);if(a.status>=400){let t;try{t=await qt(a,e)}catch(t){e.error(t)}throw t===void 0?new Ct(`Failed to parse Error from exchangeRefreshTokenForAccessToken`,{telemetryMessage:`user oauth refresh token exchange parse error`}):typeof t==`string`?Error(t):t}else try{let t=await qt(a,e);if(`error`in t)throw t.error;let{access_token:n,expires_in:r,refresh_token:o,scope:s}=t;return{token:{value:n,expiry:new Date(Date.now()+r*1e3).toISOString()},scopes:s?s.split(` `):[],refreshToken:o?{value:o}:i}}catch(e){throw typeof e==`string`?Vt(e):e}}N(Wt,`exchangeRefreshTokenForAccessToken`);async function Gt(e,t,n,r,i){let{authorizationCode:a,codeVerifier:o=``}=e;o?a||t.warn(`No authorization grant code is being passed.`):t.warn(`No code verifier is being sent.`);let s=await Kt(new URLSearchParams({grant_type:`authorization_code`,code:a??``,redirect_uri:i,client_id:r,code_verifier:o}),t,n);if(!s.ok){let{error:e}=await qt(s,t);throw e===`invalid_grant`&&t.log(`Expired! Auth code or refresh token needs to be renewed.`),Vt(e)}let c=await qt(s,t);if(`error`in c)throw Vt(c.error);let{access_token:l,expires_in:u,refresh_token:d,scope:f}=c;return e.hasAuthCodeBeenExchangedForAccessToken=!0,{token:{value:l,expiry:new Date(Date.now()+u*1e3).toISOString()},scopes:f?f.split(` `):[],refreshToken:d?{value:d}:void 0}}N(Gt,`exchangeAuthCodeForAccessToken`);async function Kt(e,t,n){let r={"Content-Type":`application/x-www-form-urlencoded`};if(t.debug(`fetching auth token`,`grant_type=${e.get(`grant_type`)??`<unknown>`}`),await Ze(I(),t)){t.debug(`Using Cloudflare Access to get an access token for the auth request`);let e=await $e({logger:t,isNonInteractiveOrCI:n});Object.assign(r,e)}t.debug(`Fetching auth token from`,Ue());try{let n=await(0,P.fetch)(Ue(),{method:`POST`,body:e.toString(),headers:r});return n.ok||t.debug(`Failed to fetch auth token:`,n.status,n.statusText),n}catch(e){throw t.debug(`Failed to fetch auth token:`,e),e}}N(Kt,`fetchAuthToken`);async function qt(e,t){let n=await e.text();try{return JSON.parse(n)}catch(r){throw n.match(/<!DOCTYPE html>/)&&(t.error(`The body of the response was HTML rather than JSON. Check the debug logs to see the full body of the response.`),n.match(/challenge-platform/)&&t.error(`It looks like you might have hit a bot challenge page. This may be transient but if not, please contact Cloudflare to find out what can be done. When you contact Cloudflare, please provide your Ray ID: ${e.headers.get(`cf-ray`)}`)),t.debug(`Full body of response
|
|
15
|
+
|
|
16
|
+
`,n),Error(`Invalid JSON in response: status: ${e.status} ${e.statusText}`,{cause:r})}}N(qt,`getJSONFromResponse`);async function Jt(e,t,n,r){let i=await Ut(e.scopes,e.clientId,e.redirectUri,t,r),a=new URL(e.redirectUri).pathname,o,s,c=new Promise((e,t)=>{s=setTimeout(()=>{o.close(),clearTimeout(s),t(new h(`Timed out waiting for authorization code, please try again.`,{telemetryMessage:`user oauth authorization timeout`}))},12e4)}),l=new Promise((r,i)=>{o=Oe.createServer(async(c,l)=>{function u(e,t){clearTimeout(s),l.writableEnded||l.end(),o.close(n=>{t||n?i(t||n):(ye(e),r(e))})}N(u,`finish`);function d(e){let t=N(e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),`escape`),n=`<!doctype html>
|
|
17
|
+
<html lang="en">
|
|
18
|
+
<head>
|
|
19
|
+
<meta charset="utf-8" />
|
|
20
|
+
<title>Wrangler login failed</title>
|
|
21
|
+
<style>
|
|
22
|
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; max-width: 720px; margin: 4rem auto; padding: 0 1rem; color: #1f2933; line-height: 1.5; }
|
|
23
|
+
h1 { color: #c12d3f; }
|
|
24
|
+
code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
|
|
25
|
+
p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
|
|
26
|
+
</style>
|
|
27
|
+
</head>
|
|
28
|
+
<body>
|
|
29
|
+
<h1>Wrangler login failed</h1>
|
|
30
|
+
<p>The Cloudflare OAuth provider returned an error.</p>
|
|
31
|
+
${e.code?`<p>Code: <code>${t(e.code)}</code></p>`:``}
|
|
32
|
+
${e.description?`<p class="detail">${t(e.description)}</p>`:``}
|
|
33
|
+
<p>You can close this tab and return to your terminal for more details.</p>
|
|
34
|
+
</body>
|
|
35
|
+
</html>`;l.writeHead(400,{"Content-Type":`text/html; charset=utf-8`}),l.end(n)}N(d,`renderErrorPage`),ye(c.url,`This request doesn't have a URL`);let{pathname:f,query:p}=Ae.parse(c.url,!0);if(c.method!==`GET`)return l.end(`OK`);switch(f){case a:{let r=!1;try{r=Ht(p,t,n.logger)}catch(t){if(t instanceof Mt){l.writeHead(307,{Location:e.denied.url}),l.end(()=>{u(null,new h(e.denied.error,{telemetryMessage:`user oauth consent denied`}))});return}let n=t;d({code:n.code,description:n.description??n.message}),u(null,n);return}if(!r){let e=`The Cloudflare OAuth provider did not return an authorisation code.`;d({description:e}),u(null,new wt(e,{telemetryMessage:`user oauth missing auth code`}));return}try{let r=await Gt(t,n.logger,n.isNonInteractiveOrCI,e.clientId,e.redirectUri);l.writeHead(307,{Location:e.granted.url}),l.end(()=>{u(r)})}catch(e){let t=e,n=t instanceof B;d({code:n?t.code:void 0,description:(n?t.description:void 0)??t.message??`Failed to exchange the authorisation code for an access token.`}),u(null,t)}return}}});let c=new URL(e.redirectUri),l=Number(c.port||(c.protocol===`https:`?443:80));(c.hostname!==e.callbackHost||l!==e.callbackPort)&&(n.logger.log(`Temporary login server listening on ${e.callbackHost}:${e.callbackPort}`),n.logger.log(`Note that the OAuth login page will always redirect to \`${e.redirectUri}\`.
|
|
36
|
+
If you have changed the callback host or port because you are running in a container, then ensure that you have port forwarding set up correctly.`)),o.once(`error`,t=>{clearTimeout(s),t.code===`EADDRINUSE`?i(new h(`The OAuth callback server could not bind to ${e.callbackHost}:${e.callbackPort} because the port is already in use. Stop the process using that port or pass a different \`--callback-port\`.`,{telemetryMessage:`user oauth callback port in use`})):i(t)}),o.listen(e.callbackPort,e.callbackHost)});return e.browser?(n.logger.log(`Opening a link in your default browser: ${i}`),await n.openInBrowser(i)):n.logger.log(`Visit this link to authenticate: ${i}`),Promise.race([c,l])}N(Jt,`getOauthToken`);function Yt(e){let t={},n={generateAuthUrl:e.generateAuthUrl??at,generateRandomState:e.generateRandomState??ot},r=`default`;function i(t){return e.storageFactory(t??r)}N(i,`getStorage`);let a=N(()=>typeof e.clientId==`function`?e.clientId():e.clientId,`getClientId`),o=e.consent,s=!1,c,l=new URL(e.redirectUri),u=l.hostname,d=Number(l.port);async function f(r){if(e.hasEnvCredentials())return e.logger.error(`You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log in via OAuth.`),!1;let s=ie(r.complianceConfig);if(s===`fedramp_high`)throw new h(St`
|
|
37
|
+
OAuth login is not supported in the \`${s}\` compliance region.
|
|
38
|
+
Please use a Cloudflare API token (\`CLOUDFLARE_API_TOKEN\` environment variable) or remove the ${r.complianceConfig?.compliance_region?"`compliance_region` configuration property":"`CLOUDFLARE_API_ENVIRONMENT` environment variable"}.
|
|
39
|
+
`,{telemetryMessage:`user login unsupported compliance region`});e.logger.log(`Attempting to login via OAuth...`);let c=await Jt({browser:r.browser??!0,scopes:r.scopes,clientId:a(),redirectUri:e.redirectUri,denied:o.denied,granted:o.granted,callbackHost:r.callbackHost??u,callbackPort:r.callbackPort??d},t,e,n);return i(r.profile).write({oauth_token:c.token?.value??``,expiration_time:c.token?.expiry,refresh_token:c.refreshToken?.value,scopes:c.scopes}),e.logger.log(`Successfully logged in.`),x(),e.purgeOnLoginOrLogout?.(),!0}N(f,`login`);function p(t){if(e.hasEnvCredentials())return!1;let{accessToken:n}=F({warningLogger:e.logger,storage:i(t)});return!!(n&&new Date>=new Date(n.expiry))}N(p,`isRefreshNeeded`);async function m(t){let n=i(t);try{let{token:{value:t,expiry:r}={value:``,expiry:``},refreshToken:{value:i}={},scopes:o}=await Wt(e.logger,e.isNonInteractiveOrCI,a(),n);return n.write({oauth_token:t,expiration_time:r,refresh_token:i,scopes:o}),!0}catch(t){return e.logger.debug(`Token refresh failed: ${t instanceof Error?t.message:String(t)}`),!1}}N(m,`refreshToken`);async function ee(t){if(e.hasEnvCredentials())return{loggedIn:!0};let n=F({warningLogger:e.logger,storage:i(t.profile)});return!n.accessToken&&!n.deprecatedApiToken?e.isNonInteractiveOrCI()?{loggedIn:!1,reason:`no-credentials-non-interactive`}:await f(t)?{loggedIn:!0}:{loggedIn:!1,reason:`no-credentials-login-failed`}:p(t.profile)?await m(t.profile)?{loggedIn:!0}:e.isNonInteractiveOrCI()?{loggedIn:!1,reason:`token-expired-non-interactive`}:await f(t)?{loggedIn:!0}:{loggedIn:!1,reason:`token-expired-login-failed`}:{loggedIn:!0}}N(ee,`loginOrRefreshIfRequired`);async function g(t){let n=x();if(e.hasEnvCredentials()){e.logger.log(`You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log out.`);return}let r=F({warningLogger:e.logger,storage:i(t)}).refreshToken;if(!r){e.logger.log(n?`Cleared temporary preview account.`:`Not logged in, exiting...`);return}let o=`client_id=${encodeURIComponent(a())}&token_type_hint=refresh_token&token=${encodeURIComponent(r.value||``)}`;await(await(0,P.fetch)(We(),{method:`POST`,body:o,headers:{"Content-Type":`application/x-www-form-urlencoded`}})).text(),i(t).clear(),e.logger.log(`Successfully logged out.`),e.purgeOnLoginOrLogout?.()}N(g,`logout`);async function te(){let t=F({warningLogger:e.logger,storage:i()});if(t.accessToken){if(t.accessToken&&new Date>=new Date(t.accessToken.expiry)){if(!await m())return;t=F({warningLogger:e.logger,storage:i()})}return t.accessToken?.value}}N(te,`getOAuthTokenFromLocalState`);function _(){return c?{apiToken:c.account.apiToken}:Be({storage:i(),warningLogger:e.logger,allowGlobalAuthKey:e.allowGlobalAuthKey})}N(_,`getAPITokenInternal`);function v(){return c?{apiToken:c.account.apiToken}:Ve({storage:i(),warningLogger:e.logger,allowGlobalAuthKey:e.allowGlobalAuthKey})}N(v,`requireApiTokenInternal`);function ne(t){s=t&&e.temporary!==void 0,c=void 0}N(ne,`setTemporaryAllowed`);function y(){return s}N(y,`isTemporaryAllowed`);function re(){return c}N(re,`getActiveTemporaryAccount`);async function b(){if(!e.temporary)throw new h(`Temporary preview accounts are not supported by this CLI.`,{telemetryMessage:`user temporary account unsupported`});let t=await bt({...e.temporary,logger:e.logger});return c=t.account,t}N(b,`activateTemporaryAccount`);function x(){return c=void 0,e.temporary?.storage.clear()??!1}N(x,`clearTemporaryAccount`);function S(e){r=e}N(S,`setProfile`);function C(){return r}N(C,`getActiveProfile`);function w(){return F({warningLogger:e.logger,storage:i()}).scopes}return N(w,`getScopes`),{setProfile:S,getActiveProfile:C,login:f,logout:g,loginOrRefreshIfRequired:ee,getOAuthTokenFromLocalState:te,getAPIToken:_,requireApiToken:v,getScopes:w,setTemporaryAllowed:ne,isTemporaryAllowed:y,getActiveTemporaryAccount:re,activateTemporaryAccount:b}}N(Yt,`createOAuthFlow`);var Xt=[`default`,`staging`];function Zt(e){let t={read(){return e.bindings.read()},write(t){e.bindings.write(t)},activate(t,n){let r=M.resolve(n),i=e.bindings.read();i[r]=t,e.bindings.write(i)},deactivate(t){let n=M.resolve(t),r=e.bindings.read(),i=r[n];if(i===void 0){let e=en(n,r);throw e?new h(`No profile is directly bound to "${$t(n)}". The active profile "${e.profile}" is bound at "${$t(e.dir)}". Run \`wrangler auth deactivate\` from that directory instead.`,{telemetryMessage:`auth deactivate wrong directory`}):new h(`No profile is bound to "${$t(n)}". Nothing to deactivate.`,{telemetryMessage:`auth deactivate no binding`})}delete r[n],e.bindings.write(r);let a=en(n,r);return a?{removedProfile:i,newResolution:{profile:a.profile,source:`inherited from ${a.dir}`}}:e.configs.exists(`default`)?{removedProfile:i,newResolution:{profile:`default`,source:`default profile`}}:{removedProfile:i,newResolution:{profile:void 0,source:`no profile`}}},getProfileForDirectory(t){return en(t,e.bindings.read())?.profile},getBindingsForProfile(t){return Object.entries(e.bindings.read()).filter(([,e])=>e===t).map(([e])=>e)},removeAllBindingsForProfile(t){let n=e.bindings.read(),r=[];for(let[e,i]of Object.entries(n))i===t&&(r.push(e),delete n[e]);return r.length>0&&e.bindings.write(n),r}};return{configs:e.configs,bindings:t,resolve(e){return e.profile?e.profile===`default`?`default`:(Qt(e.profile),e.profile):t.getProfileForDirectory(e.cwd)||`default`}}}N(Zt,`createProfileStore`);function Qt(e){if(Xt.includes(e.toLowerCase()))throw new h(`"${e}" is a reserved profile name. Use \`wrangler login\` and \`wrangler logout\` to manage the default profile, which applies as a global fallback.`,{telemetryMessage:`auth profile reserved name`});if(!/^[a-zA-Z0-9_-]+$/.test(e))throw new h(`Invalid profile name "${e}". Profile names may only contain alphanumeric characters, hyphens, and underscores.`,{telemetryMessage:`auth profile invalid name`})}N(Qt,`validateProfileName`);function $t(e){return M.relative(process.cwd(),e)||`.`}N($t,`formatDirectoryForUserError`);function en(e,t){let n=M.resolve(e),r=Object.entries(t).sort(([e],[t])=>t.length-e.length);for(let[e,t]of r)if(n===e||n.startsWith(e)&&n[e.length]===M.sep)return{profile:t,dir:e}}N(en,`getProfileForDirectoryFromBindings`);function tn(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}N(tn,`getLineColFromPtr`);function nn(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
|
|
40
|
+
`,e===t&&(i+=` `.repeat(a+n+2),i+=`^
|
|
41
|
+
`))}return i}N(nn,`makeCodeBlock`);var V=class extends Error{static{N(this,`TomlError`)}line;column;codeblock;constructor(e,t){let[n,r]=tn(t.toml,t.ptr),i=nn(t.toml,n,r);super(`Invalid TOML document: ${e}
|
|
42
|
+
|
|
43
|
+
${i}`,t),this.line=n,this.column=r,this.codeblock=i}};function rn(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}N(rn,`isEscaped`);function an(e,t=0,n=e.length){let r=e.indexOf(`
|
|
44
|
+
`,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}N(an,`indexOfNewline`);function on(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
|
|
45
|
+
`)return n;if(r===`\r`&&e[n+1]===`
|
|
46
|
+
`)return n+1;if(r<` `&&r!==` `||r===``)throw new V(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}N(on,`skipComment`);function H(e,t,n,r){let i;for(;(i=e[t])===` `||i===` `||!n&&(i===`
|
|
47
|
+
`||i===`\r`&&e[t+1]===`
|
|
48
|
+
`);)t++;return r||i!==`#`?t:H(e,on(e,t),n)}N(H,`skipVoid`);function sn(e,t,n,r,i=!1){if(!r)return t=an(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=an(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
|
|
49
|
+
`||t===`\r`&&e[a+1]===`
|
|
50
|
+
`))return a}throw new V(`cannot find end of structure`,{toml:e,ptr:t})}N(sn,`skipUntil`);function cn(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do t=e.indexOf(r,++t);while(t>-1&&n!==`'`&&rn(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}N(cn,`getStringEnd`);var ln=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i,un=class e extends Date{static{N(this,`TomlDate`)}#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(ln);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}},dn=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,fn=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,pn=/^[+-]?0[0-9_]/,mn=/^[0-9a-f]{4,8}$/i,hn={b:`\b`,t:` `,n:`
|
|
51
|
+
`,f:`\f`,r:`\r`,'"':`"`,"\\":`\\`};function gn(e,t=0,n=e.length){let r=e[t]===`'`,i=e[t++]===e[t]&&e[t]===e[t+1];i&&(n-=2,e[t+=2]===`\r`&&t++,e[t]===`
|
|
52
|
+
`&&t++);let a=0,o,s=``,c=t;for(;t<n-1;){let n=e[t++];if(n===`
|
|
53
|
+
`||n===`\r`&&e[t]===`
|
|
54
|
+
`){if(!i)throw new V(`newlines are not allowed in strings`,{toml:e,ptr:t-1})}else if(n<` `&&n!==` `||n===``)throw new V(`control characters are not allowed in strings`,{toml:e,ptr:t-1});if(o){if(o=!1,n===`u`||n===`U`){let r=e.slice(t,t+=n===`u`?4:8);if(!mn.test(r))throw new V(`invalid unicode escape`,{toml:e,ptr:a});try{s+=String.fromCodePoint(parseInt(r,16))}catch{throw new V(`invalid unicode escape`,{toml:e,ptr:a})}}else if(i&&(n===`
|
|
55
|
+
`||n===` `||n===` `||n===`\r`)){if(t=H(e,t-1,!0),e[t]!==`
|
|
56
|
+
`&&e[t]!==`\r`)throw new V(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:a});t=H(e,t)}else if(n in hn)s+=hn[n];else throw new V(`unrecognized escape sequence`,{toml:e,ptr:a});c=t}else !r&&n===`\\`&&(a=t-1,o=!0,s+=e.slice(c,a))}return s+e.slice(c,n-1)}N(gn,`parseString`);function _n(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=dn.test(e);if(i||fn.test(e)){if(pn.test(e))throw new V(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new V(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new V(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new un(e);if(!a.isValid())throw new V(`invalid value`,{toml:t,ptr:n});return a}N(_n,`parseValue`);function vn(e,t,n,r){let i=e.slice(t,n),a=i.indexOf(`#`);a>-1&&(on(e,a),i=i.slice(0,a));let o=i.trimEnd();if(!r){let n=i.indexOf(`
|
|
57
|
+
`,o.length);if(n>-1)throw new V(`newlines are not allowed in inline tables`,{toml:e,ptr:t+n})}return[o,a]}N(vn,`sliceAndTrimEndOf`);function yn(e,t,n,r,i){if(r===0)throw new V(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?Cn(e,t,r,i):Sn(e,t,r,i),c=n?sn(e,s,`,`,n):s;if(s-c&&n===`}`){let t=an(e,s,c);if(t>-1)throw new V(`newlines are not allowed in inline tables`,{toml:e,ptr:t})}return[o,c]}let o;if(a===`"`||a===`'`){o=cn(e,t);let r=gn(e,t,o);if(n){if(o=H(e,o,n!==`]`),e[o]&&e[o]!==`,`&&e[o]!==n&&e[o]!==`
|
|
58
|
+
`&&e[o]!==`\r`)throw new V(`unexpected character encountered`,{toml:e,ptr:o});o+=+(e[o]===`,`)}return[r,o]}o=sn(e,t,`,`,n);let s=vn(e,t,o-+(e[o-1]===`,`),n===`]`);if(!s[0])throw new V(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=H(e,t+s[1]),o+=+(e[o]===`,`)),[_n(s[0],e,t,i),o]}N(yn,`extractValue`);var bn=/^[a-zA-Z0-9-_]+[ \t]*$/;function xn(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new V(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `)if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new V(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let s=cn(e,t);if(s<0)throw new V(`unfinished string encountered`,{toml:e,ptr:t});r=e.indexOf(`.`,s);let c=e.slice(s,r<0||r>a?a:r),l=an(c);if(l>-1)throw new V(`newlines are not allowed in keys`,{toml:e,ptr:t+r+l});if(c.trimStart())throw new V(`found extra tokens after the string part`,{toml:e,ptr:s});if(a<s&&(a=e.indexOf(n,s),a<0))throw new V(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(gn(e,t,s))}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!bn.test(n))throw new V(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}while(r+1&&r<a);return[i,H(e,a+1,!0,!0)]}N(xn,`parseKey`);function Sn(e,t,n,r){let i={},a=new Set,o,s=0;for(t++;(o=e[t++])!==`}`&&o;){let c={toml:e,ptr:t-1};if(o===`
|
|
59
|
+
`)throw new V(`newlines are not allowed in inline tables`,c);if(o===`#`)throw new V(`inline tables cannot contain comments`,c);if(o===`,`)throw new V(`expected key-value, found comma`,c);if(o!==` `&&o!==` `){let o,c=i,l=!1,[u,d]=xn(e,t-1);for(let n=0;n<u.length;n++){if(n&&(c=l?c[o]:c[o]={}),o=u[n],(l=Object.hasOwn(c,o))&&(typeof c[o]!=`object`||a.has(c[o])))throw new V(`trying to redefine an already defined value`,{toml:e,ptr:t});!l&&o===`__proto__`&&Object.defineProperty(c,o,{enumerable:!0,configurable:!0,writable:!0})}if(l)throw new V(`trying to redefine an already defined value`,{toml:e,ptr:t});let[f,p]=yn(e,d,`}`,n-1,r);a.add(f),c[o]=f,t=p,s=e[t-1]===`,`?t-1:0}}if(s)throw new V(`trailing commas are not allowed in inline tables`,{toml:e,ptr:s});if(!o)throw new V(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}N(Sn,`parseInlineTable`);function Cn(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new V(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=on(e,t);else if(a!==` `&&a!==` `&&a!==`
|
|
60
|
+
`&&a!==`\r`){let a=yn(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new V(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}N(Cn,`parseArray`);function wn(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}N(wn,`peekTable`);function Tn(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=H(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=xn(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new V(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=wn(n[0],r,i,t?2:1);if(!c)throw new V(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=xn(e,s),i=wn(r[0],a,o,0);if(!i)throw new V(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=yn(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=H(e,s,!0),e[s]&&e[s]!==`
|
|
61
|
+
`&&e[s]!==`\r`)throw new V(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=H(e,s)}return r}N(Tn,`parse`);var En=/^[a-z0-9-_]+$/i;function U(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}N(U,`extendedTypeOf`);function Dn(e){for(let t=0;t<e.length;t++)if(U(e[t])!==`object`)return!1;return e.length!=0}N(Dn,`isArrayOfTables`);function On(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}N(On,`formatString`);function kn(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:r&&Number.isInteger(e)?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return On(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return An(e,n,r);if(t===`array`)return jn(e,n,r)}N(kn,`stringifyValue`);function An(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=En.test(o)?o:On(o),i+=` = `,i+=kn(e[o],U(e[o]),t-1,n)}return i+` }`}N(An,`stringifyInlineTable`);function jn(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=kn(e[i],U(e[i]),t-1,n)}return r+` ]`}N(jn,`stringifyArray`);function Mn(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
|
|
62
|
+
`}[[${t}]]
|
|
63
|
+
`,i+=Nn(0,e[a],t,n,r);return i}N(Mn,`stringifyArrayTable`);function Nn(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=U(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=En.test(c)?c:On(c);if(e===`array`&&Dn(t[c]))o+=(o&&`
|
|
64
|
+
`)+Mn(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
|
|
65
|
+
`)+Nn(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=kn(t[c],e,r,i),a+=`
|
|
66
|
+
`}}return e&&(a||!o)&&(a=a?`[${e}]
|
|
67
|
+
${a}`:`[${e}]`),a&&o?`${a}
|
|
68
|
+
${o}`:a||o}N(Nn,`stringifyTable`);function Pn(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(U(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Nn(0,e,``,t,n);return r[r.length-1]===`
|
|
69
|
+
`?r:r+`
|
|
70
|
+
`}N(Pn,`stringify`);var Fn={parse:Tn,stringify:Pn,TomlDate:un,TomlError:V},In={toml:{parse:N(e=>ee(e),`parse`),stringify:N(e=>Fn.stringify(e),`stringify`)},json:{parse:N(e=>JSON.parse(e),`parse`),stringify:N(e=>JSON.stringify(e,null,` `),`stringify`)}};function W(e,t){return In[e].parse(t)}N(W,`parseFile`);function Ln(e,t){return In[e].stringify(t)}N(Ln,`stringifyFile`);var Rn=`config`;function zn(e){if(e===void 0||e===`default`){let e=g();return e===`production`?`default`:e}return Qt(e),e}N(zn,`resolveAuthProfileBaseName`);function Bn(e,t,n=`toml`){return M.join(e,Rn,`${zn(t)}.${n}`)}N(Bn,`getAuthConfigFilePath`);var Vn=class{constructor(e,t,n=`toml`){this.configPath=e,this.profile=t,this.format=n}static{N(this,`FileCredentialStore`)}kind=`file`;filePath(){return Bn(this.configPath,this.profile,this.format)}read(){let e=this.filePath();if(O(e))return W(this.format,s(e))}write(e){let t=this.filePath();k(M.dirname(t),{recursive:!0}),j(t,Ln(this.format,e),{encoding:`utf-8`,mode:384}),he(t,384)}clear(){let e=this.filePath(),t=O(e);return t&&A(e),t}path(){return this.filePath()}describe(){return this.filePath()}},Hn=32,Un=12,Wn=16,Gn=`AES-256-GCM`,Kn=`aes-256-gcm`;function qn(){return new Uint8Array(Ee(Hn))}N(qn,`generateKey`);function Jn(e,t){if(t.length!==Hn)throw Error(`AES-256-GCM requires a ${Hn}-byte key (got ${t.length} bytes).`);let n=Ee(Un),r=Ce(Kn,t,n),i=Buffer.concat([r.update(e,`utf-8`),r.final()]),a=r.getAuthTag();return{v:1,alg:Gn,iv:n.toString(`base64`),tag:a.toString(`base64`),ciphertext:i.toString(`base64`)}}N(Jn,`encryptString`);function Yn(e,t){if(t.length!==Hn)throw Error(`AES-256-GCM requires a ${Hn}-byte key (got ${t.length} bytes).`);if(e.v!==1)throw Error(`Unsupported encrypted envelope version: ${e.v}.`);let n=Buffer.from(e.iv,`base64`),r=Buffer.from(e.tag,`base64`),i=Buffer.from(e.ciphertext,`base64`);if(n.length!==Un)throw Error(`Expected ${Un}-byte IV in envelope (got ${n.length} bytes).`);if(r.length!==Wn)throw Error(`Expected ${Wn}-byte auth tag in envelope (got ${r.length} bytes).`);let a=we(Kn,t,n);return a.setAuthTag(r),Buffer.concat([a.update(i),a.final()]).toString(`utf-8`)}N(Yn,`decryptString`);function Xn(e){if(typeof e!=`object`||!e)return;let t=e;if(!(t.v!==1||t.alg!==Gn||typeof t.iv!=`string`||typeof t.tag!=`string`||typeof t.ciphertext!=`string`))return t}N(Xn,`parseEncryptedEnvelope`);function G(e,t){return M.join(e,`config`,`${zn(t)}.enc`)}N(G,`getEncryptedAuthConfigFilePath`);var Zn=class{constructor(e,t,n,r,i=`toml`){this.configPath=e,this.keyProvider=t,this.onPlaintextMigration=n,this.profile=r,this.format=i}static{N(this,`EncryptedFileCredentialStore`)}kind=`encrypted-file`;plaintextPath(){return Bn(this.configPath,this.profile,this.format)}read(){let e=G(this.configPath,this.profile);if(O(e))return this.readEncryptedFile(e);let t=this.plaintextPath();if(O(t))return this.migrateFromPlaintext(t,e)}write(e){let t=this.ensureKey(),n=Jn(Ln(this.format,e),t),r=G(this.configPath,this.profile);k(M.dirname(r),{recursive:!0}),j(r,JSON.stringify(n,null,` `),{encoding:`utf-8`,mode:384}),he(r,384);let i=this.plaintextPath();O(i)&&A(i)}clear(){let e=G(this.configPath,this.profile),t=this.plaintextPath(),n=!1;O(e)&&(A(e),n=!0),O(t)&&(A(t),n=!0);try{this.keyProvider.deleteKey()}catch{}return n}path(){return G(this.configPath,this.profile)}describe(){return`Encrypted file (${G(this.configPath,this.profile)}) with key in ${this.keyProvider.describe()}`}readEncryptedFile(e){let t=this.keyProvider.getKey();if(t===void 0)return;let n=s(e),r;try{r=Xn(JSON.parse(n))}catch{return}if(r===void 0)return;let i;try{i=Yn(r,t)}catch{return}try{return W(this.format,i)}catch{return}}migrateFromPlaintext(e,t){let n=s(e),r;try{r=W(this.format,n)}catch{return}return this.write(r),this.onPlaintextMigration?.({plaintextPath:e,encryptedPath:t,keyProviderDescription:this.keyProvider.describe()}),r}ensureKey(){let e=this.keyProvider.getKey();if(e!==void 0)return e;let t=qn();return this.keyProvider.setKey(t),t}},Qn=`1.3.0`;function $n(e){return Se(`npm`,e,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],shell:process.platform===`win32`})}N($n,`defaultNpmRunner`);var er=$n,K=new Map;function tr(e){er=e??$n,K.clear()}N(tr,`setNpmRunner`);function nr(e){return M.join(e,`native`,`keyring`)}N(nr,`getKeyringInstallDir`);function rr(e){return M.join(e,`node_modules`,`@napi-rs`,`keyring`)}N(rr,`getInstalledBindingPath`);function ir(e){let t=K.get(e);if(t!==void 0)return t;let n=rr(e);if(O(M.join(n,`index.js`)))return K.set(e,n),n;try{let t=er([`root`,`-g`]);if(t.status===0){let n=M.join(t.stdout.trim(),`@napi-rs`,`keyring`);if(O(M.join(n,`index.js`)))return K.set(e,n),n}}catch{}return K.set(e,null),null}N(ir,`findKeyringBinding`);function ar(e){let t=e;k(t,{recursive:!0});let n=M.join(t,`package.json`);O(n)||j(n,JSON.stringify({private:!0,name:`cloudflare-auth-keyring-host`},null,` `),`utf-8`);let r;try{r=er([`install`,`@napi-rs/keyring@${Qn}`,`--prefix`,t,`--no-save`,`--no-audit`,`--no-fund`,`--no-package-lock`,`--loglevel=error`])}catch(e){throw new h(`Failed to spawn \`npm\` to install the keyring backend: ${e instanceof Error?e.message:String(e)}
|
|
71
|
+
|
|
72
|
+
Install \`npm\` and retry, or install the binding globally:
|
|
73
|
+
npm install -g @napi-rs/keyring@${Qn}`,{telemetryMessage:`workers-auth keyring npm spawn failed`})}if(r.status!==0)throw new h(`Failed to install \`@napi-rs/keyring\` (npm exited ${r.status}):
|
|
74
|
+
${r.stderr?.trim()??`(no stderr)`}
|
|
75
|
+
|
|
76
|
+
Retry once the underlying issue is fixed, or install the binding globally:
|
|
77
|
+
npm install -g @napi-rs/keyring@${Qn}`,{telemetryMessage:`workers-auth keyring npm install failed`});K.delete(e)}N(ar,`installKeyringBindingSync`);var or;function sr(e){or=e}N(sr,`setKeyringEntryFactory`);var cr=me(import.meta.url);function lr(e){if(or!==void 0)return or;let t=ir(e);if(t===null)throw Error("`@napi-rs/keyring` binding not found. Call `installKeyringBindingSync()` first.");let n=cr(t);return(e,t)=>new n.Entry(e,t)}N(lr,`resolveKeyringEntryFactory`);function q(e){return zn(e)}N(q,`getKeyringAccountName`);function ur(e){let t={v:1,key:Buffer.from(e).toString(`base64`),created:new Date().toISOString()};return JSON.stringify(t)}N(ur,`encodeKeyEnvelope`);function dr(e){if(e===``)return;let t;try{t=JSON.parse(e)}catch{return}if(!(typeof t!=`object`||!t||t.v!==1||typeof t.key!=`string`))try{let e=Buffer.from(t.key,`base64`);return e.length===32?new Uint8Array(e):void 0}catch{return}}N(dr,`decodeKeyEnvelope`);function fr(e,t={}){return Se(`secret-tool`,e,{encoding:`utf-8`,input:t.input})}N(fr,`defaultRunner`);var pr=fr,mr=void 0;function hr(e){pr=e??fr,mr=void 0}N(hr,`setLinuxSecretToolRunner`);function gr(){if(mr!==void 0)return mr;let e;try{e=pr([`--version`]).status===0}catch{e=!1}return mr=e,e}N(gr,`probeSecretTool`);var _r=class{constructor(e,t){this.serviceName=e,this.profile=t}static{N(this,`LinuxSecretToolKeyProvider`)}getKey(){let e=pr([`lookup`,`service`,this.serviceName,`account`,q(this.profile)]);if(e.status!==1){if(e.status!==0)throw Error(`Failed to read key via secret-tool (exit ${e.status}): ${e.stderr?.trim()??`(no stderr)`}`);return dr(e.stdout.trim())}}setKey(e){let t=pr([`store`,`--label=Cloudflare credentials key`,`service`,this.serviceName,`account`,q(this.profile)],{input:ur(e)});if(t.status!==0)throw Error(`Failed to write key via secret-tool (exit ${t.status}): ${t.stderr?.trim()??`(no stderr)`}`)}deleteKey(){let e=pr([`clear`,`service`,this.serviceName,`account`,q(this.profile)]);if(e.status!==0)throw Error(`Failed to delete key via secret-tool (exit ${e.status}): ${e.stderr?.trim()??`(no stderr)`}`)}describe(){return`Linux secret-tool (service=${this.serviceName}, account=${q(this.profile)})`}},vr=44;function yr(e,t={}){return Se(`/usr/bin/security`,e,{encoding:`utf-8`,input:t.input})}N(yr,`defaultRunner`);var br=yr;function xr(e){br=e??yr}N(xr,`setMacSecurityCommandRunner`);var Sr=class{constructor(e,t){this.serviceName=e,this.profile=t}static{N(this,`MacSecurityKeyProvider`)}getKey(){let e=br([`find-generic-password`,`-s`,this.serviceName,`-a`,q(this.profile),`-w`]);if(e.status!==vr){if(e.status!==0)throw Error(`Failed to read key from macOS Keychain (exit ${e.status}): ${e.stderr?.trim()??`(no stderr)`}`);return dr(e.stdout.trim())}}setKey(e){let t=br([`add-generic-password`,`-s`,this.serviceName,`-a`,q(this.profile),`-w`,ur(e),`-U`]);if(t.status!==0)throw Error(`Failed to write key to macOS Keychain (exit ${t.status}): ${t.stderr?.trim()??`(no stderr)`}`)}deleteKey(){let e=br([`delete-generic-password`,`-s`,this.serviceName,`-a`,q(this.profile)]);if(!(e.status===0||e.status===vr))throw Error(`Failed to delete key from macOS Keychain (exit ${e.status}): ${e.stderr?.trim()??`(no stderr)`}`)}describe(){return`macOS Keychain (service=${this.serviceName}, account=${q(this.profile)})`}},Cr=class{constructor(e,t,n){this.serviceName=e,this.installDir=t,this.profile=n}static{N(this,`NapiKeyringKeyProvider`)}entry(){return lr(this.installDir)(this.serviceName,q(this.profile))}getKey(){let e=this.entry().getPassword();if(!(e===null||e===``))return dr(e)}setKey(e){this.entry().setPassword(ur(e))}deleteKey(){try{this.entry().deletePassword()}catch{}}describe(){return`${process.platform===`win32`?`Windows Credential Manager`:`OS keyring`} via @napi-rs/keyring (service=${this.serviceName}, account=${q(this.profile)})`}},wr;function Tr(e){wr=e}N(Tr,`setKeyProviderFactoryForTesting`);function Er(e,t,n){if(wr!==void 0)return{kind:`available`,provider:wr(e,t)};switch(process.platform){case`darwin`:return{kind:`available`,provider:new Sr(e,t)};case`linux`:return gr()?{kind:`available`,provider:new _r(e,t)}:{kind:`unsupported`};case`win32`:{let r=nr(n);return ir(r)===null?{kind:`needs-install`,install:N(()=>ar(r),`install`),afterInstall:N(()=>new Cr(e,r,t),`afterInstall`)}:{kind:`available`,provider:new Cr(e,r,t)}}default:return{kind:`unsupported`}}}N(Er,`resolveKeyProvider`);var Dr={installFailedThisSession:!1,hasWarnedAboutKeyringFallback:!1,hasWarnedAboutSecretToolMissing:!1};function Or(){return Dr}N(Or,`getResolverSessionFlags`);function kr(){Dr.installFailedThisSession=!1,Dr.hasWarnedAboutKeyringFallback=!1,Dr.hasWarnedAboutSecretToolMissing=!1}N(kr,`resetCredentialStorageState`);function Ar(e){let t={...e,loginCommand:e.loginCommand??`your CLI login`,format:e.format??`toml`};function n(e){return jr(t,e)}N(n,`getActiveStore`);function r(e){return{read:N(()=>n(e).read(),`read`),write:N(t=>n(e).write(t),`write`),clear:N(()=>n(e).clear(),`clear`),path:N(()=>n(e).path(),`path`)}}return N(r,`storageFactory`),{storageFactory:r,getActiveStore:n}}N(Ar,`createCredentialStorageContext`);function jr(e,t){let n=Ye(),r=e.getConfigPath();if(n===!1)return new Vn(r,t,e.format);let i=n===!0;if(!(n??e.isKeyringEnabled()??!1))return new Vn(r,t,e.format);let a=Er(e.serviceName,t,r);switch(a.kind){case`available`:return new Zn(r,a.provider,Mr(e),t,e.format);case`needs-install`:return Nr(a,i,e,t);case`unsupported`:return Pr(i,e,t)}}N(jr,`resolveActiveCredentialStore`);function Mr(e){return t=>{e.logger.warn(`Migrated credentials from ${t.plaintextPath} into ${t.encryptedPath} (key in ${t.keyProviderDescription}). The plaintext file has been deleted.`)}}N(Mr,`buildMigrationLogger`);function Nr(e,t,n,r){let i=Or();if(i.installFailedThisSession){if(t)throw new h(`CLOUDFLARE_AUTH_USE_KEYRING is set but the keyring backend could not be installed earlier this session.`,{telemetryMessage:`workers-auth keyring install previously failed`});return Fr(`The keyring backend could not be installed earlier this session; using the plaintext credentials file.`,n,r)}if(n.isNonInteractiveOrCI())throw new h(Lr(n.loginCommand),{telemetryMessage:`workers-auth keyring binding not installed`});try{n.logger.log(`🔐 Installing keyring backend (one-time, ~2 MB)…`),e.install()}catch(e){if(i.installFailedThisSession=!0,t)throw e instanceof h?e:new h(`Failed to install the keyring backend: ${e instanceof Error?e.message:String(e)}`,{telemetryMessage:`workers-auth keyring install threw`});return Fr(`Failed to install the keyring backend (${e instanceof Error?e.message:String(e)}); falling back to the plaintext credentials file.`,n,r)}return new Zn(n.getConfigPath(),e.afterInstall(),Mr(n),r,n.format)}N(Nr,`handleNeedsInstall`);function Pr(e,t,n){let r=process.platform,i=r===`linux`,a=i?Ir(t.loginCommand):`OS keyring storage is not supported on \`${r}\`; falling back to the plaintext credentials file.`;if(e)throw new h(i?`CLOUDFLARE_AUTH_USE_KEYRING is set but ${a}`:`CLOUDFLARE_AUTH_USE_KEYRING is set but no keyring backend is available on \`${r}\`.`,{telemetryMessage:i?`workers-auth keyring secret tool missing`:`workers-auth keyring unsupported platform`});if(i&&t.isNonInteractiveOrCI())throw new h(a,{telemetryMessage:`workers-auth keyring secret tool missing`});let o=Or();return i?(o.hasWarnedAboutSecretToolMissing||(o.hasWarnedAboutSecretToolMissing=!0,t.logger.warn(`${a}
|
|
78
|
+
|
|
79
|
+
Falling back to the plaintext credentials file for this session.`)),new Vn(t.getConfigPath(),n,t.format)):Fr(a,t,n)}N(Pr,`handleUnsupported`);function Fr(e,t,n){let r=Or();return r.hasWarnedAboutKeyringFallback||(r.hasWarnedAboutKeyringFallback=!0,t.logger.warn(e)),new Vn(t.getConfigPath(),n,t.format)}N(Fr,`fallbackToFileWithWarning`);function Ir(e){return`\`secret-tool\` is required for OS keyring storage on Linux but is not installed.
|
|
80
|
+
|
|
81
|
+
Install it via your package manager:
|
|
82
|
+
Debian/Ubuntu: sudo apt-get install libsecret-tools
|
|
83
|
+
Fedora/RHEL: sudo dnf install libsecret
|
|
84
|
+
Arch: sudo pacman -S libsecret
|
|
85
|
+
Alpine: apk add libsecret
|
|
86
|
+
|
|
87
|
+
Or disable keyring storage: \`${e} --no-use-keyring\`.`}N(Ir,`secretToolMissingMessage`);function Lr(e){return`\`@napi-rs/keyring\` is required for OS keyring storage on Windows but is not installed.
|
|
88
|
+
|
|
89
|
+
Run \`${e} --use-keyring\` interactively to install it automatically, or install it globally for CI:
|
|
90
|
+
|
|
91
|
+
npm install -g @napi-rs/keyring@${Qn}
|
|
92
|
+
|
|
93
|
+
Or disable keyring storage: \`${e} --no-use-keyring\`.`}N(Lr,`windowsBindingMissingMessage`);function Rr(e){let t=G(e.configPath,e.profile),n=O(t),r=Er(e.serviceName,e.profile,e.configPath);return r.kind===`available`?(new Zn(e.configPath,r.provider,void 0,e.profile,e.format??`toml`).clear(),{backendAvailable:!0,encryptedFileExisted:n}):(n&&A(t),{backendAvailable:!1,encryptedFileExisted:n})}N(Rr,`scrubEncryptedCredentials`);const{white:zr,gray:Br,dim:Vr,hidden:Hr,bold:Ur,cyanBright:Wr,bgCyan:Gr}=T;T.hex(`#BD5B08`);const Kr=T.hex(`#111`);T.hex(`#0E838F`);const qr=Kr.bgHex(`#0E838F`);T.hex(`#AB2526`);const Jr=Kr.bgHex(`#AB2526`);T.hex(`#218529`);const Yr=Kr.bgHex(`#218529`);T.hex(`#7F7322`);const Xr=Kr.bgHex(`#7F7322`),Zr=process.stdout;process.stderr;var Qr=e(oe(),1);const $r={diamond:`◇`,dash:`─`,radioInactive:`○`,radioActive:`●`,backActive:`◀`,backInactive:`◁`,bar:`│`,leftT:`├`,rigthT:`┤`,arrows:{left:`‹`,right:`›`},corners:{tl:`╭`,bl:`╰`,tr:`╮`,br:`╯`}};Jr(` ERROR `),Xr(` WARNING `),qr(` INFO `),Yr(` SUCCESS `),zr.bgRed(` X `),ue(Zr),Br($r.bar),Br($r.corners.bl),Br($r.leftT);function ei(){try{return!!(process.stdin.isTTY&&process.stdout.isTTY)}catch{return!1}}function J(){return!ei()||Qr.isCI}const ti=Qr.isCI;function ni(){o(n)}async function ri(e){let t=x(),n=e.map(e=>({value:e,label:e.name})),r=await new se({options:n,initialValue:n[0]?.value,render(){let e=t.bold(`Select an account`),n=this.options.map((e,n)=>{let r=n===this.cursor,i=e.value,a=t.hex(S.muted)(`${i.id.slice(0,12)}...`);return r?` ${t.hex(S.orange)(`>`)} ${t.bold(i.name)} ${a}`:` ${t.dim(i.name)} ${a}`});return`${e} ${t.dim(`(use arrow keys, enter to confirm)`)}\n${n.join(`
|
|
94
|
+
`)}`}}).prompt();return D(r)||!r?null:r}async function ii(){let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));let t=Buffer.concat(e).toString(`utf-8`);return t.endsWith(`
|
|
95
|
+
`)?t.slice(0,-1):t}async function ai(e,t,n){let r=n?.kind??`text`;if(J()){if(r===`secret`){let t=await ii();if(t.length>0)return t;throw Error(`--${e} is required. Pipe the value via stdin, pass --${e} <value>, or run interactively.`)}throw Error(`--${e} is required. Pass --${e} <value> or run interactively.`)}let i=`Enter value for --${e}`,a=t||n?.question||i;ni();let o=r===`secret`?await le({message:a,mask:`•`,validate:e=>e&&e.length>0?void 0:`Value cannot be empty`}):await ce({message:a,validate:e=>e&&e.length>0?void 0:`Value cannot be empty`});return(D(o)||typeof o!=`string`)&&process.exit(130),o}async function oi(e,t,n){if(J())throw Error(`--${e} is required (one of: ${n.join(`, `)}). Pass --${e} <value> or run interactively.`);let r=`Select value for --${e}`,i=t||r;ni();let a=await E({message:i,options:n.map(e=>({value:e,label:e}))});return(D(a)||typeof a!=`string`)&&process.exit(130),a}async function si(e={}){if(e.force===!0)return!0;let t=e.message?`${e.message} Continue?`:`This permanently deletes the resource. Continue?`;if(J()){let e=x();return process.stderr.write(`${e.hex(S.warning)(`?`)} ${t}\n ${e.dim(`(non-interactive; pass --force to confirm)`)}\n`),!1}ni();let n=await de({message:t,initialValue:!1});return D(n)&&process.exit(130),n===!0}const ci=`.cfrc`;function li(e){let t=e||process.cwd(),n=be(t);for(;t!==n;){let e=xe(t,ci);if(O(e))try{let t=ge(e,`utf-8`).replace(/^\s*\/\/.*$/gm,``);return{config:JSON.parse(t),path:e}}catch{}t=be(t)}let r=xe(t,ci);if(O(r))try{let e=ge(r,`utf-8`).replace(/^\s*\/\/.*$/gm,``);return{config:JSON.parse(e),path:r}}catch{}return null}function ui(e,t){j(xe(t||process.cwd(),ci),JSON.stringify(e,null,2)+`
|
|
96
|
+
`,{mode:384})}function di(e){let t=xe(e||process.cwd(),ci);return O(t)?(ve(t),!0):!1}async function fi(e){let t={},n=Y(`accountId`,`CLOUDFLARE_ACCOUNT_ID`);n&&(t.accountId=n);let r=Y(`zone`,`CLOUDFLARE_ZONE_ID`,e?.zone);r&&(t.zone=r);let i=Y(`complianceRegion`,`CLOUDFLARE_COMPLIANCE_REGION`);return i&&(t.complianceRegion=i),t}function Y(e,t,n){if(n)return{value:n,source:`flag`};let r=process.env[t];if(r)return{value:r,source:`env`};let i=li(),a=i?.config[e];if(a)return{value:a,source:`project`,path:i.path};let o=ae().defaults?.[e];if(o)return{value:o,source:`config`,path:w()}}function pi(){return Y(`accountId`,`CLOUDFLARE_ACCOUNT_ID`)?.value}async function mi(e){let t=Y(`accountId`,`CLOUDFLARE_ACCOUNT_ID`);if(t)return hi(t.value,Ti(t,`accountId`)),t.value;if(e){let t=await gi(e);if(t)return t}throw Error(`No account ID found.
|
|
97
|
+
|
|
98
|
+
Please provide one of the following:
|
|
99
|
+
1. CLOUDFLARE_ACCOUNT_ID environment variable
|
|
100
|
+
2. Run 'cf context set account-id <id>' to set a default
|
|
101
|
+
3. Create a .cfrc file in your project
|
|
102
|
+
|
|
103
|
+
You can find your account ID in the Cloudflare dashboard URL:
|
|
104
|
+
https://dash.cloudflare.com/<account-id>/...`)}function hi(e,t){if(!process.env.DEBUG)return;let n=e.length>12?e.slice(0,12)+`…`:e;process.stderr.write(`Using account: ${n} (${t})\n`)}async function gi(e){let t;try{t=await Oi(e)}catch{return}if(t.length===0)return;if(t.length===1&&t[0]){let n=t[0],{displayName:r}=await Ei(`accountId`,n.id,`user`,e);return hi(n.id,`auto-selected from token — ${r}`),n.id}if(J()){let e=t.map(e=>` ${e.id} ${e.name}`).join(`
|
|
105
|
+
`);throw Error(`Multiple accounts available but running non-interactively.
|
|
106
|
+
|
|
107
|
+
Available accounts:
|
|
108
|
+
${e}
|
|
109
|
+
|
|
110
|
+
Set one with CLOUDFLARE_ACCOUNT_ID or 'cf context set account-id'.`)}let n=await ri(t);n||process.exit(130);let{displayName:r}=await Ei(`accountId`,n.id,`user`,e);return hi(n.id,`selected interactively — ${r}`),n.id}async function _i(e,t,n){if(e?.zoneId)return vi(e.zoneId,t);let r=Y(`zone`,`CLOUDFLARE_ZONE_ID`,e?.zone);if(r){if(!n?.quiet&&r.source!==`flag`){let e=Ti(r);console.error(`Using zone: ${r.value} (from ${e})`)}return vi(r.value,t)}throw Error(`No zone specified.
|
|
111
|
+
|
|
112
|
+
Please provide one of the following:
|
|
113
|
+
1. Zone as a positional argument: cf dns records list <zone>
|
|
114
|
+
2. --zone flag (or -z): cf dns records list --zone example.com
|
|
115
|
+
3. CLOUDFLARE_ZONE_ID environment variable
|
|
116
|
+
4. Run 'cf context set zone <zone>' to set a default
|
|
117
|
+
5. Create a .cfrc file in your project with {"zone": "example.com"}`)}async function vi(e,t){if(pe(e)||!t)return e;let{resolveZoneId:n}=await import(`./resolve-D1mG0REg.mjs`).then(e=>e.r);return n(t,await mi(),e)}function yi(e){if(e?.scriptName)return e.scriptName;throw Error("Required Worker name missing. Please specify the Worker name with `--worker <name>`.")}const bi=[`public`,`fedramp_high`],xi={"account-id":`accountId`,zone:`zone`,"compliance-region":`complianceRegion`},Si=Object.keys(xi);function Ci(e){return bi.includes(e)}function wi(){let e=Y(`complianceRegion`,`CLOUDFLARE_COMPLIANCE_REGION`);if(!e)return`public`;if(!Ci(e.value))throw Error(`Invalid compliance region "${e.value}". Must be one of: ${bi.join(`, `)}`);return e.value}function Ti(e,t=`zone`){switch(e.source){case`flag`:return t===`zone`?`--zone flag`:`(flag)`;case`env`:return{accountId:`CLOUDFLARE_ACCOUNT_ID`,zone:`CLOUDFLARE_ZONE_ID`,complianceRegion:`CLOUDFLARE_COMPLIANCE_REGION`}[t];case`project`:return`.cfrc`;case`config`:return`~/.config/cf/config.json`}}async function Ei(e,t,n,r){let i=t,a=t;if(e===`accountId`){if(!r)throw Error(`Authentication required to validate account ID`);let{id:e,name:n}=await ki(t,r);i=e,a=n?`${e.slice(0,12)}... (${n})`:e}else if(e===`zone`){if(!r)throw Error(`Authentication required to validate zone`);let e=await Ai(t,r);i=t,a=e.name}else e===`complianceRegion`&&(i=t,a=t);if(n===`project`){let t=li()?.config||{};t[e]=i,ui(t)}else{let t=ae();t.defaults||={},t.defaults[e]=i,C(t)}return{resolvedValue:i,displayName:a}}function Di(e,t){if(t===`project`)if(e===`all`)di();else{let t=li();t&&(delete t.config[e],Object.keys(t.config).length===0?di(be(t.path)):ui(t.config,be(t.path)))}else{let t=ae();t.defaults&&(e===`all`?delete t.defaults:(delete t.defaults[e],Object.keys(t.defaults).length===0&&delete t.defaults),C(t))}}async function Oi(e){return(await e.accounts.list({})).result}async function ki(e,t){let n=await Oi(t),r=n.find(t=>t.id===e);if(r)return{id:r.id,name:r.name};let i=n.find(t=>t.name.toLowerCase()===e.toLowerCase());if(i)return{id:i.id,name:i.name};if(pe(e))return{id:e};throw Error(`Account not found: "${e}"
|
|
118
|
+
|
|
119
|
+
Available accounts:
|
|
120
|
+
${n.map(e=>` ${e.id.slice(0,12)}... ${e.name}`).join(`
|
|
121
|
+
`)}`)}async function Ai(e,t){let n=(await t.zones.list({})).result,r=n.find(t=>t.id===e);if(r)return{id:r.id,name:r.name};let i=n.find(t=>t.name.toLowerCase()===e.toLowerCase());if(i)return{id:i.id,name:i.name};throw fe(e)?Error(`Zone not found: "${e}"
|
|
122
|
+
|
|
123
|
+
This zone either doesn't exist or you don't have access to it.
|
|
124
|
+
Run 'cf zones list' to see available zones.`):Error(`Invalid zone: "${e}"
|
|
125
|
+
|
|
126
|
+
Please provide a zone ID or domain name.
|
|
127
|
+
Run 'cf zones list' to see available zones.`)}function ji(){return xe(process.cwd(),ci)}function Mi(e){function t(){return M.resolve(e(),`preferences.json`)}N(t,`getUserPreferencesPath`);function n(){try{let e=ge(t(),`utf8`),n=JSON.parse(e);return typeof n==`object`&&n?n:{}}catch{return{}}}N(n,`readUserPreferences`);function r(e){let r={...n(),...e},i=t();k(M.dirname(i),{recursive:!0}),j(i,JSON.stringify(r,null,` `),{encoding:`utf-8`})}return N(r,`updateUserPreferences`),{readUserPreferences:n,updateUserPreferences:r}}N(Mi,`createPreferences`);var Ni=6e4,Pi=525600,Fi=43200,Ii=1440,Li=Symbol.for(`constructDateFrom`);function Ri(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&Li in e?e[Li](t):e instanceof Date?new e.constructor(t):new Date(t)}N(Ri,`constructFrom`);function zi(e,t){return Ri(t||e,e)}N(zi,`toDate`);var Bi={};function Vi(){return Bi}N(Vi,`getDefaultOptions`);function Hi(e){let t=zi(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}N(Hi,`getTimezoneOffsetInMilliseconds`);function Ui(e,...t){let n=Ri.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}N(Ui,`normalizeDates`);function Wi(e,t){let n=zi(e)-+zi(t);return n<0?-1:n>0?1:n}N(Wi,`compareAsc`);function Gi(e){return Ri(e,Date.now())}N(Gi,`constructNow`);function Ki(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}N(Ki,`getRoundingMethod`);var qi={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},Ji=N((e,t,n)=>{let r,i=qi[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r},`formatDistance`);function Yi(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}N(Yi,`buildFormatLongFn`);var Xi={date:Yi({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:Yi({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:Yi({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},Zi={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},Qi=N((e,t,n,r)=>Zi[e],`formatRelative`);function X(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}N(X,`buildLocalizeFn`);var $i={ordinalNumber:N((e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},`ordinalNumber`),era:X({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:X({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:N(e=>e-1,`argumentCallback`)}),month:X({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:X({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:X({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function Z(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?ta(s,e=>e.test(o)):ea(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}N(Z,`buildMatchFn`);function ea(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}N(ea,`findKey`);function ta(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}N(ta,`findIndex`);function na(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}N(na,`buildMatchPatternFn`);var ra={code:`en-US`,formatDistance:Ji,formatLong:Xi,formatRelative:Qi,localize:$i,match:{ordinalNumber:na({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:N(e=>parseInt(e,10),`valueCallback`)}),era:Z({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:Z({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:N(e=>e+1,`valueCallback`)}),month:Z({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:Z({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:Z({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function ia(e,t,n){let r=Vi(),i=n?.locale??r.locale??ra,a=Wi(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),[s,c]=Ui(n?.in,...a>0?[t,e]:[e,t]),l=Ki(n?.roundingMethod??`round`),u=c.getTime()-s.getTime(),d=u/Ni,f=(u-(Hi(c)-Hi(s)))/Ni,p=n?.unit,m;if(m=p||(d<1?`second`:d<60?`minute`:d<Ii?`hour`:f<Fi?`day`:f<Pi?`month`:`year`),m===`second`){let e=l(u/1e3);return i.formatDistance(`xSeconds`,e,o)}else if(m===`minute`){let e=l(d);return i.formatDistance(`xMinutes`,e,o)}else if(m===`hour`){let e=l(d/60);return i.formatDistance(`xHours`,e,o)}else if(m===`day`){let e=l(f/Ii);return i.formatDistance(`xDays`,e,o)}else if(m===`month`){let e=l(f/Fi);return e===12&&p!==`month`?i.formatDistance(`xYears`,1,o):i.formatDistance(`xMonths`,e,o)}else{let e=l(f/Pi);return i.formatDistance(`xYears`,e,o)}}N(ia,`formatDistanceStrict`);function aa(e,t){return ia(e,Gi(e),t)}N(aa,`formatDistanceToNowStrict`);function oa(e,t){return{read:N(()=>{let n=t();if(!O(n))return;let r=s(n);try{return W(e,r)}catch{return}},`read`),write(n){let r=t();k(M.dirname(r),{recursive:!0}),j(r,Ln(e,n),{encoding:`utf-8`,mode:384}),he(r,384)},clear(){let e=t(),n=O(e);return A(e,{force:!0}),n},path:t}}N(oa,`createFileStorage`);function sa(e){let{logger:t,prompt:n}=e;return N(async function(e,r){if(f())return t.log(r),!0;let i=await n(e);return typeof i==`string`&&i.trim().toLowerCase()===`yes`},`ensureTemporaryTermsAccepted`)}N(sa,`createTemporaryTermsPrompt`);var ca=[9106,1e4];function la(e){return e?.code}N(la,`getErrorCode`);function ua(e){let t=la(e);return t!==void 0&&ca.includes(t)}N(ua,`isMembershipsInaccessible`);function da(e){return{"no-credentials-non-interactive":`Could not authenticate because no credentials were found and the environment is non-interactive. Set a CLOUDFLARE_API_TOKEN environment variable or run \`${e}\` in an interactive terminal first.`,"no-credentials-login-failed":`No credentials were found and the login attempt was unsuccessful. Run \`${e}\` to try again.`,"token-expired-non-interactive":`Your auth token has expired and could not be refreshed, and the environment is non-interactive. Run \`${e}\` in an interactive terminal or set a CLOUDFLARE_API_TOKEN.`,"token-expired-login-failed":`Your auth token has expired and could not be refreshed, and the login attempt was unsuccessful. Run \`${e}\` to try again.`}}N(da,`notLoggedInErrorBodies`);function fa(e,t,n){let r=new Date(t.claim.expiresAt);e.log(xt`
|
|
128
|
+
Temporary account ready:
|
|
129
|
+
Account: ${t.account.name} (${n?`reused`:`created`})
|
|
130
|
+
Claim within: ${aa(r)}
|
|
131
|
+
Claim URL: ${t.claim.url}
|
|
132
|
+
`)}N(fa,`logTemporaryPreviewAccount`);function pa(e,t){let{logger:n}=t,r=e.cliName,i=da(e.commands.login),a=`
|
|
133
|
+
Run \`${e.commands.whoami}\` to check your current authentication status.`,o=Mi(e.getConfigPath),s=te(n,e.cacheNamespace?{namespace:e.cacheNamespace}:void 0),l=Ar({serviceName:e.keyringServiceName,getConfigPath:e.getConfigPath,isKeyringEnabled:N(()=>o.readUserPreferences().keyring_enabled===!0,`isKeyringEnabled`),logger:n,isNonInteractiveOrCI:f,loginCommand:e.commands.login,format:e.fileFormat}),d=e.allowGlobalAuthKey??!0,m=Yt({logger:n,isNonInteractiveOrCI:f,openInBrowser:N(e=>p(e,n),`openInBrowser`),hasEnvCredentials:N(()=>ze({allowGlobalAuthKey:d})!==void 0,`hasEnvCredentials`),purgeOnLoginOrLogout:s.purgeConfigCaches,clientId:e.clientId,consent:e.consent,redirectUri:e.redirectUri,storageFactory:l.storageFactory,allowGlobalAuthKey:d,temporary:{storage:oa(e.fileFormat,e.getTemporaryAccountConfigPath),prompt:sa({logger:n,prompt:t.prompt})}});function ee(e){m.setProfile(e)}N(ee,`setProfile`);function g(){return m.getActiveProfile()}N(g,`getActiveProfile`);function _(){return l.getActiveStore(m.getActiveProfile())}N(_,`getCredentialStore`);function v(e){m.setTemporaryAllowed(e)}N(v,`setTemporaryAllowed`);function y(){return m.getAPIToken()}N(y,`getAPIToken`);function b(){return m.requireApiToken()}N(b,`requireApiToken`);function x(t,n){return{complianceConfig:t,scopes:n?.scopes??e.getDefaultScopeKeys(),browser:n?.browser??!0,callbackHost:n?.callbackHost,callbackPort:n?.callbackPort,profile:n?.profile}}N(x,`withDefaultScopes`);async function S(e,t){return m.login(x(e,t))}N(S,`login`);async function C(e){return m.logout(e)}N(C,`logout`);async function w(e,t){return m.getActiveTemporaryAccount()?{loggedIn:!0}:m.loginOrRefreshIfRequired(x(e,t))}N(w,`loginOrRefreshIfRequired`);async function ae(){return m.getOAuthTokenFromLocalState()}N(ae,`getOAuthTokenFromLocalState`);function oe(){return m.getScopes()}N(oe,`getScopes`);function se(){return l.storageFactory(g()).read()}N(se,`readAuthCredentials`);function T(e){l.storageFactory(g()).write(e)}N(T,`writeAuthCredentials`);function E(){let t=m.getActiveProfile();return t===`default`?`${e.accountCachePrefix}.json`:`${e.accountCachePrefix}-${t}.json`}N(E,`getAccountCacheFileName`);function D(e){s.saveToConfigCache(E(),{account:e})}N(D,`saveAccountToCache`);function ce(){return s.getConfigCache(E()).account}N(ce,`getAccountFromCache`);async function le(e,r){let o=await w(e);if(!o.loggedIn)throw new h(`Not logged in. ${i[o.reason]}${a}`,{telemetryMessage:`cfetch auth login required`});let s=b(),l=[],d=!0,f=1,p;for(;d;){p=new je(p),p.set(`page`,String(f));let{response:i,status:a}=await re(e,r,{},t.userAgent,n,p,void 0,s);i.success?(l.push(...i.result),c(i.result_info)?f+=1:d=!1):u(r,i,a)}return l}N(le,`fetchAccountsPaged`);async function ue(t,n={}){let{throwOnEmpty:r=!0}=n,[i,a]=await Promise.allSettled([le(t,`/accounts`),le(t,`/memberships`)]);if(i.status===`rejected`)throw i.reason;if(a.status===`rejected`)if(ua(a.reason)){if(i.status===`fulfilled`&&i.value.length>0)return i.value;throw la(a.reason)===9106?new h(`Failed to automatically retrieve account IDs for the logged in user.
|
|
134
|
+
You may have incorrect permissions on your API token, or an environment variable such as CLOUDFLARE_API_TOKEN, CLOUDFLARE_API_KEY, or CLOUDFLARE_EMAIL may be set to an invalid value.
|
|
135
|
+
Check your environment and unset or correct any Cloudflare credential variables, or run \`${e.commands.login}\` to re-authenticate.
|
|
136
|
+
You can also skip this account check by adding an \`account_id\` in your ${e.getConfigFileLabel()} file, or by setting the value of CLOUDFLARE_ACCOUNT_ID`,{telemetryMessage:`user account fetch permission denied`}):new h(`Failed to automatically retrieve account IDs for the logged in user.
|
|
137
|
+
You may have incorrect permissions on your API token, or your authentication may have expired. Try running \`${e.commands.login}\` to re-authenticate. You can also skip this account check by adding an \`account_id\` in your ${e.getConfigFileLabel()} file, or by setting the value of CLOUDFLARE_ACCOUNT_ID`,{telemetryMessage:`user account fetch permission denied`})}else throw a.reason;let o=new Set(a.value.map(e=>e.account.id)),s=i.value.filter(e=>o.has(e.id));if(s.length===0&&r)throw new h(`Failed to automatically retrieve account IDs for the logged in user.
|
|
138
|
+
In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or as \`account_id\` in your ${e.getConfigFileLabel()} file.
|
|
139
|
+
Alternatively, try running \`${e.commands.login}\` to re-authenticate.`,{telemetryMessage:`user account fetch empty`});return s}N(ue,`fetchAllAccounts`);function de(e){let t=m.getActiveTemporaryAccount();return t?t.account.id:e.account_id?e.account_id:Ge()||ce()?.id}N(de,`getActiveAccountId`);async function fe(n){let r=de(n);if(r)return r;let i=await ue(n);if(i.length===1)return D({id:i[0].id,name:i[0].name}),i[0].id;try{let e=await t.select(`Select an account`,{choices:i.map(e=>({title:e.name,value:e.id}))}),n=i.find(t=>t.id===e);if(!n)throw Error(`Selected account not found in accounts list`);return D({id:n.id,name:n.name}),e}catch(n){if(t.isNoDefaultValueProvidedError(n)){let t=ne();throw new h(`More than one account available but unable to select one in non-interactive mode.
|
|
140
|
+
Please set the appropriate \`account_id\` in your ${e.getConfigFileLabel()} file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
|
|
141
|
+
Available accounts are (\`<name>\`: \`<account_id>\`):
|
|
142
|
+
${i.map(e=>` \`${t?`(redacted)`:e.name}\`: \`${e.id}\``).join(`
|
|
143
|
+
`)}`,{telemetryMessage:`user account selection unavailable`})}throw n}}N(fe,`getOrSelectAccountId`);async function pe(e){if(m.isTemporaryAllowed()){if(ie(e)!==`public`)throw new h(`Temporary accounts aren't available when the compliance region is not set to public.`,{telemetryMessage:`user temporary account unavailable in compliance region`});if(y())throw new h("You're already authenticated with Cloudflare, so `--temporary` can't be used. Temporary preview accounts are only for unauthenticated use. Either remove `--temporary` to use your existing account, or log out (and unset CLOUDFLARE_API_TOKEN) first.",{telemetryMessage:`user temporary account already authenticated`});let{account:t,cached:r}=await m.activateTemporaryAccount();return fa(n,t,r),t.account.id}let t=await w(e);if(!t.loggedIn)throw t.reason===`no-credentials-non-interactive`||t.reason===`token-expired-non-interactive`?new h(`In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for ${r} to work. Please go to https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.`,{telemetryMessage:`user auth missing api token non interactive`}):new h(`Did not login, quitting...`,{telemetryMessage:`user login cancelled`});let i=await fe(e);if(!i)throw new h(`No account id found, quitting...`,{telemetryMessage:`user auth missing account id`});return i}return N(pe,`requireAuth`),{setProfile:ee,getActiveProfile:g,getCredentialStore:_,setTemporaryAllowed:v,getAPIToken:y,requireApiToken:b,login:S,logout:C,loginOrRefreshIfRequired:w,getOAuthTokenFromLocalState:ae,getScopes:oe,readAuthCredentials:se,writeAuthCredentials:T,getActiveAccountId:de,getOrSelectAccountId:fe,getAccountFromCache:ce,fetchAllAccounts:ue,requireAuth:pe}}N(pa,`createCloudflareAuth`);var ma=`profiles/directory-bindings.json`,ha=`.enc`;function ga(e){let{logger:t,getConfigPath:n,keyringServiceName:r,format:i}=e,a=`.${i}`;function o(e){return Bn(n(),e,i)}N(o,`plaintextPath`);function s(e){return G(n(),e)}N(s,`encryptedPath`);function c(){return M.dirname(o(`default`))}N(c,`getProfileConfigDirectory`);let l={exists(e){return O(o(e))||O(s(e))},list(){let e=c();if(!O(e))return[];let t=new Set;for(let n of _e(e))n.endsWith(a)?t.add(n.slice(0,-a.length)):n.endsWith(ha)&&t.add(n.slice(0,-ha.length));return[...t]},delete(e){let{backendAvailable:a,encryptedFileExisted:s}=Rr({serviceName:r,configPath:n(),profile:e,format:i});oa(i,()=>o(e)).clear(),s&&!a&&t.warn(`Removed the credential files for profile "${e}", but the keyring backend was not reachable on this host so its keyring entry could not be cleared. Clear it manually if it persists.`)}};function u(){return M.join(n(),ma)}return N(u,`getDirectoryBindingsPath`),Zt({configs:l,bindings:{read(){try{let e=ge(u(),`utf-8`);return JSON.parse(e)}catch{return{}}},write(e){let t=u();k(M.dirname(t),{recursive:!0}),j(t,JSON.stringify(e,null,` `),`utf-8`)}}})}N(ga,`createCloudflareProfileStore`);function _a(e){let{loginCommand:t,createProfileCommand:n,keyringServiceName:r,getConfigPath:i,format:a,preferences:o}=e,{readUserPreferences:s,updateUserPreferences:c}=o;function l(e){return e??`default`}N(l,`describeProfile`);function u(e){let t=[];O(G(i()))&&t.push(void 0);let n=ga({logger:e,getConfigPath:i,keyringServiceName:r,format:a});for(let e of n.configs.list()){try{Qt(e)}catch{continue}O(G(i(),e))&&t.push(e)}return t}N(u,`listEncryptedProfiles`);function d(e){let o=u(e);if(o.length===0)return;let s=[],c=[];for(let t of o)try{let{backendAvailable:e}=Rr({serviceName:r,configPath:i(),profile:t,format:a});s.push(l(t)),e||c.push(l(t))}catch(n){e.warn(`Failed to remove encrypted credentials for profile "${l(t)}": ${n instanceof Error?n.message:String(n)}. You may need to clear them manually.`)}if(s.length>0){let r=n?`Re-authenticate with \`${t}\` (default profile) or \`${n} <name>\` (named profiles).`:`Re-authenticate with \`${t}\`.`;e.log(`Removed encrypted credentials for ${s.map(e=>`"${e}"`).join(`, `)}. ${r}`)}c.length>0&&e.warn(`The keyring backend was not reachable on this host, so the keyring entry for ${c.map(e=>`"${e}"`).join(`, `)} could not be cleared. Clear it manually if it persists.`)}N(d,`scrubAllEncryptedProfiles`);function f(e,t){let{logger:n,getCredentialStore:r}=t,i=s().keyring_enabled===!0,a=Ye();if(a!==void 0&&a!==e&&n.warn(`CLOUDFLARE_AUTH_USE_KEYRING=${a} overrides ${e?`enabling`:`disabling`} keyring storage for this command.`),!e&&a!==!0&&d(n),c({keyring_enabled:e}),e&&a!==!1)try{r().kind!==`encrypted-file`&&(c({keyring_enabled:i}),n.warn(`Keyring storage isn't available on this host (see warning above), so it was not enabled. Try again once the keyring backend is reachable.`))}catch(e){throw c({keyring_enabled:i}),e}return{enabled:s().keyring_enabled===!0}}return N(f,`setKeyringPreference`),{setKeyringPreference:f}}N(_a,`createKeyringPreference`);function va(e){let{getConfigPath:t,format:n}=e;function r(e){return Bn(t(),e,n)}N(r,`getAuthConfigFilePath`);function i(e){return G(t(),e)}N(i,`getEncryptedAuthConfigFilePath`);function a(e){return oa(n,()=>r(e))}N(a,`defaultAuthConfigStorage`);function o(e,t){a(t).write(e)}N(o,`writeAuthConfigFile`);function s(e){return a(e).read()}return N(s,`readAuthConfigFile`),{getAuthConfigFilePath:r,getEncryptedAuthConfigFilePath:i,defaultAuthConfigStorage:a,readAuthConfigFile:s,writeAuthConfigFile:o}}N(va,`createAuthConfigFileHelpers`);var ya=`cloudflare`,ba=`cf`,xa=`http://localhost:8877/oauth/callback`,Sa={granted:{url:`https://welcome.developers.workers.dev/cf-oauth-consent-granted`},denied:{url:`https://welcome.developers.workers.dev/cf-oauth-consent-denied`,error:"Error: Consent denied. You must grant consent to cf in order to login.\nIf you don't want to do this consider passing an API token via the `CLOUDFLARE_API_TOKEN` environment variable"}},Ca=m({variableName:`CLOUDFLARE_CLIENT_ID`,defaultValue:N(()=>`cbca97e7-c331-4cdd-8fd8-e25a451b98bf`,`defaultValue`)});function Q(){return _({appName:`cloudflare`,leadingDot:!1,useLegacyHomeDir:!1})}N(Q,`getCfConfigPath`);var wa=`openid.offline.user:read.account:read.access:read.access:write.agw:read.agw:run.agw:write.ai:read.ai:write.ai-search:read.ai-search:run.ai-search:write.aiaudit:read.aiaudit:write.aig:read.aig:write.auditlogs:read.browser:read.browser:write.cfone:read.cfone:write.cloudchamber:write.connectivity:admin.connectivity:bind.connectivity:read.constellation:write.containers:write.d1:write.dex:read.dex:write.dns_analytics:read.dns_records:edit.dns_records:read.dns_settings:read.firstpartytags:write.images:read.images:write.lb:edit.lb:read.logpush:read.logpush:write.mcp_portals:read.mcp_portals:write.notebook-examples:read.notification:read.notification:write.pages:read.pages:write.pipelines:read.pipelines:setup.pipelines:write.query_cache:write.queues:write.r2_catalog:write.radar:read.rag:read.rag:write.registrar:read.registrar:write.secrets_store:read.secrets_store:write.sso-connector:read.sso-connector:write.ssl_certs:write.teams:pii.teams:read.teams:secure_location.teams:write.url_scanner:read.url_scanner:write.vectorize:write.workers:read.workers:write.workers_builds:read.workers_builds:write.workers_deployments:read.workers_kv:write.workers_observability:read.workers_observability:write.workers_observability_telemetry:write.workers_routes:write.workers_scripts:write.workers_tail:read.zone:read`.split(`.`),Ta=[...wa];function Ea(e){Ta=e}N(Ea,`setLoginScopeKeys`);var Da=new Set(wa);function Oa(e){return e.every(e=>Da.has(e))}N(Oa,`validateScopeKeys`);function ka(){let e=g();return e===`production`?`cloudflare-temporary-account.json`:`cloudflare-temporary-account.${e}.json`}N(ka,`getTemporaryAccountConfigFile`);function Aa(){return M.join(Q(),ka())}N(Aa,`getCfTemporaryAccountConfigPath`);function ja(e){return oa(`json`,e)}N(ja,`createJsonFileStorage`);var{getAuthConfigFilePath:Ma,getEncryptedAuthConfigFilePath:Na,defaultAuthConfigStorage:Pa,readAuthConfigFile:Fa,writeAuthConfigFile:Ia}=va({getConfigPath:Q,format:`json`}),La={cliName:ba,commands:{login:`cf auth login`,whoami:`cf auth whoami`},keyringServiceName:ya,clientId:Ca,consent:Sa,redirectUri:xa,allowGlobalAuthKey:!1,getConfigPath:Q,getTemporaryAccountConfigPath:Aa,fileFormat:`json`,accountCachePrefix:`cloudflare-account`,cacheNamespace:`cloudflare`,getConfigFileLabel:N(()=>`cf config`,`getConfigFileLabel`),getDefaultScopeKeys:N(()=>Ta,`getDefaultScopeKeys`)},Ra=Mi(Q),{readUserPreferences:za,updateUserPreferences:Ba}=Ra;function Va(e){return pa(La,e)}N(Va,`createCfAuth`);function Ha(e){return ga({logger:e.logger,getConfigPath:Q,keyringServiceName:ya,format:`json`})}N(Ha,`createCfProfileStore`);var Ua=_a({loginCommand:La.commands.login,createProfileCommand:La.commands.createProfile,keyringServiceName:ya,getConfigPath:Q,format:`json`,preferences:Ra});function Wa(e,t){return Ua.setKeyringPreference(e,t)}N(Wa,`setKeyringPreference`);const Ga={debug:(...e)=>{process.env.DEBUG&&console.error(...e)},info:(...e)=>console.error(...e),log:(...e)=>console.error(...e),warn:(...e)=>console.error(...e),error:(...e)=>console.error(...e)};var Ka=class extends Error{};async function qa(e){if(J())throw new Ka;o(n);let t=await ce({message:e});return(D(t)||typeof t!=`string`)&&process.exit(130),t}async function Ja(e,t){if(J())throw new Ka;o(n);let r=await E({message:e,options:t.choices.map(({title:e,value:t})=>({label:e,value:t}))});return(D(r)||typeof r!=`string`)&&process.exit(130),r}const $=Va({logger:Ga,userAgent:i,prompt:qa,select:Ja,isNoDefaultValueProvidedError:e=>e instanceof Ka});function Ya(e){if(e?.scopes&&!Oa(e.scopes))throw Error(`One or more of the requested scopes are not valid cf OAuth scopes.`);return $.login({compliance_region:wi()},{browser:e?.browser??!0,...e?.scopes&&{scopes:e.scopes}})}function Xa(){return $.logout()}function Za(){return $.getOAuthTokenFromLocalState()}function Qa(){return $.readAuthCredentials()?.oauth_token!==void 0}function $a(){return $.readAuthCredentials()}function eo(){return $.getCredentialStore().path()}function to(e){try{let t=Me(`ps -p ${e} -o pid=,ppid=,command=`,{encoding:`utf8`,timeout:5e3}).trim();if(!t)return null;let[n,r,...i]=t.split(/\s+/),a=n?parseInt(n,10):NaN,o=r?parseInt(r,10):NaN;return isNaN(a)||isNaN(o)?null:{pid:a,ppid:o,command:i.join(` `)||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function no(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=to(r);if(!e||e.ppid===0||e.ppid===1)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function ro(e){try{let t=Me(`wmic process where (ProcessId=${e}) get ProcessId,ParentProcessId,CommandLine /format:csv`,{encoding:`utf8`,timeout:1e4});if(!t)return null;let n=t.split(`
|
|
144
|
+
`).filter(e=>e.trim()&&!e.startsWith(`Node`)).pop()?.split(`,`);if(!n||n.length<4)return null;let[r,i,a,o]=n,s=o?parseInt(o.trim(),10):NaN,c=a?parseInt(a.trim(),10):NaN;return isNaN(s)||isNaN(c)?null:{pid:s,ppid:c,command:i?.trim()||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function io(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=ro(r);if(!e||e.ppid===0||e.ppid===4)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function ao(e=process.pid){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`PID must be a positive integer`);return Ne.platform()===`win32`?io(e):no(e)}const oo=[{id:`opencode`,name:`OpenCode`,type:`agent`,envVars:[{any:[`OPENCODE`,`OPENCODE_BIN_PATH`,`OPENCODE_SERVER`,`OPENCODE_APP_INFO`,`OPENCODE_MODES`]}]},{id:`jules`,name:`Jules`,type:`agent`,envVars:[{all:[[`HOME`,`/home/jules`],[`USER`,`swebot`]]}]},{id:`claude-code`,name:`Claude Code`,type:`agent`,envVars:[`CLAUDECODE`]},{id:`cursor-agent`,name:`Cursor Agent`,type:`agent`,envVars:[{all:[`CURSOR_TRACE_ID`,[`PAGER`,`head -n 10000 | cat`]]}]},{id:`cursor`,name:`Cursor`,type:`interactive`,envVars:[`CURSOR_TRACE_ID`]},{id:`gemini-agent`,name:`Gemini Agent`,type:`agent`,processChecks:[`gemini`]},{id:`codex`,name:`OpenAI Codex`,type:`agent`,processChecks:[`codex`]},{id:`replit`,name:`Replit`,type:`agent`,envVars:[`REPL_ID`]},{id:`aider`,name:`Aider`,type:`agent`,envVars:[`AIDER_API_KEY`],processChecks:[`aider`]},{id:`bolt-agent`,name:`Bolt.new Agent`,type:`agent`,envVars:[{all:[[`SHELL`,`/bin/jsh`],`npm_config_yes`]}]},{id:`bolt`,name:`Bolt.new`,type:`interactive`,envVars:[{all:[[`SHELL`,`/bin/jsh`]],none:[`npm_config_yes`]}]},{id:`zed-agent`,name:`Zed Agent`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`zed`],[`PAGER`,`cat`]]}]},{id:`zed`,name:`Zed`,type:`interactive`,envVars:[{all:[[`TERM_PROGRAM`,`zed`]],none:[[`PAGER`,`cat`]]}]},{id:`replit-assistant`,name:`Replit Assistant`,type:`agent`,envVars:[{all:[`REPL_ID`,[`REPLIT_MODE`,`assistant`]]}]},{id:`replit`,name:`Replit`,type:`interactive`,envVars:[{all:[`REPL_ID`],none:[[`REPLIT_MODE`,`assistant`]]}]},{id:`windsurf`,name:`Windsurf`,type:`agent`,envVars:[`CODEIUM_EDITOR_APP_ROOT`]},{id:`crush`,name:`Crush`,type:`agent`,processChecks:[`crush`]},{id:`vscode-copilot-agent`,name:`GitHub Copilot in VS Code`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`vscode`],[`GIT_PAGER`,`cat`]]}]},{id:`warp`,name:`Warp Terminal`,type:`hybrid`,envVars:[{all:[[`TERM_PROGRAM`,`WarpTerminal`]]}]},{id:`octofriend`,name:`Octofriend`,type:`agent`,processChecks:[`octofriend`]}];function so(e,t=process.env){let[n,r]=typeof e==`string`?[e,void 0]:e,i=t[n];return!!(i&&(!r||i===r))}function co(e,t){try{let n=t??ao();for(let t of n)if(t.command?.includes(e))return!0}catch{}return!1}function lo(e,t=process.env){if(typeof e==`string`||Array.isArray(e))return so(e,t);let{any:n,all:r,none:i}=e,a=!n?.length||n.some(e=>so(e,t)),o=!r?.length||r.every(e=>so(e,t)),s=!i?.length||!i.some(e=>so(e,t));return a&&o&&s}function uo(e){return e.customDetectors?.some(e=>{try{return e()}catch{return!1}})??!1}function fo(e){return{isAgentic:!0,id:e.id,name:e.name,type:e.type}}function po(e=process.env,t){for(let t of oo)if(t.envVars?.some(t=>lo(t,e)))return fo(t);let n=t,r=()=>{if(n===void 0)try{n=ao()}catch{n=[]}return n};for(let e of oo)if(e.processChecks?.some(e=>co(e,r())))return fo(e);for(let e of oo)if(uo(e))return fo(e);return{isAgentic:!1,id:null,name:null,type:null}}function mo(){return ti?`ci`:ei()?`interactive`:`non-interactive`}function ho(){let e=po(),t=e.isAgentic&&e.id!==null?{"X-CF-CLI-Agent":e.id}:{};return{"User-Agent":i,"X-CF-CLI-Mode":mo(),...t}}const go=3e4,_o=r.Default;function vo(e){return e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||e instanceof ReadableStream||e instanceof URLSearchParams}function yo(e){return Object.keys(e).some(e=>e.toLowerCase()===`content-type`)}async function bo(e){let t=e.headers.get(`content-type`)??``;try{return t.includes(`application/json`)?await e.json():await e.text()}catch{return null}}function xo(e,t,n){if(!(n==null||n===``)){if(Array.isArray(n)){for(let r of n)xo(e,t,r);return}e.append(t,String(n))}}function So(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))xo(t,n,r);return t.toString()}function Co(e,t,n){let r=new URL(t.endsWith(`/`)?t:`${t}/`),i=new URL(e.startsWith(`/`)?e.slice(1):e,r);if(i.origin!==r.origin)throw Error(`Refusing to send an authenticated request to ${i.origin} (expected ${r.origin})`);let a=So(n??{});return a&&(i.search=a),i.toString()}const wo=new WeakMap;async function To(e,t,n,r={}){let i=Co(n,wo.get(e)??_o,r.query),o={...r.headers},s;r.body!==void 0&&(vo(r.body)||typeof r.body==`string`&&yo(o)?s=r.body:(o[`Content-Type`]??=`application/json`,s=JSON.stringify(r.body)));let c;try{c=await e.fetch(i,{method:t,headers:o,body:s,signal:r.signal},{timeoutInSeconds:r.timeout?r.timeout/1e3:void 0,abortSignal:r.signal})}catch(e){throw r.signal?.aborted?Error(`Request aborted`):e instanceof Error&&e.name===`AbortError`?Error(`Request timed out after ${r.timeout??go}ms`):e instanceof Error?Error(`Request failed: ${e.message}`):e}if(!c.ok)throw new a({statusCode:c.status,body:await bo(c),rawResponse:{status:c.status,statusText:c.statusText,url:c.url||i,headers:c.headers,redirected:c.redirected,type:c.type}});if(c.status===204)return null;let l=await c.text();if(l===``)return null;if(!(c.headers.get(`content-type`)??``).includes(`application/json`))return l;let u=JSON.parse(l);if(u.success===!1)throw new a({message:`API error: ${u.errors?.map(e=>e.message).filter(Boolean).join(`, `)||`unknown error`}`,statusCode:c.status,body:u});return`result`in u?u.result:u}function Eo(e){let n=e.baseURL??_o,r=new t({baseUrl:n,auth:async()=>({headers:{Authorization:`Bearer ${e.apiToken}`}}),headers:e.defaultHeaders,timeoutInSeconds:(e.timeout??go)/1e3,maxRetries:0,fetch:e.fetch??globalThis.fetch});return wo.set(r,n),r}async function Do(){let e=ze({allowGlobalAuthKey:!1});if(e&&`apiToken`in e)return e.apiToken;let t=await Za();if(t)return t;throw Error(`No authentication token found.
|
|
145
|
+
|
|
146
|
+
Please set one of the following:
|
|
147
|
+
1. Set the CLOUDFLARE_API_TOKEN environment variable
|
|
148
|
+
2. Run 'cf auth login' to authenticate via OAuth
|
|
149
|
+
|
|
150
|
+
For API tokens, visit: https://dash.cloudflare.com/profile/api-tokens`)}async function Oo(e){let t=v({compliance_region:wi()});if(e.local){if(!e.localEndpoint)throw Error(`--local requires --local-endpoint <url>; this should have been caught by the global middleware.`);let{createLocalFetch:n}=await import(`./local-D8bhHUMK.mjs`).then(e=>e.r);return Eo({apiToken:`cf-local-mode-no-auth`,baseURL:t,defaultHeaders:ho(),fetch:n({endpoint:e.localEndpoint})})}return Eo({apiToken:await Do(),baseURL:t,defaultHeaders:ho()})}export{pi as C,ai as D,oi as E,J as O,_i as S,si as T,mi as _,ho as a,ji as b,Qa as c,$a as d,Si as f,li as g,Di as h,To as i,Ya as l,bi as m,Oo as n,eo as o,xi as p,Do as r,Za as s,Eo as t,Xa as u,wi as v,Ei as w,yi as x,fi as y};
|