cf 1.0.0-rc.2 → 1.0.0-rc.4
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/README.md +11 -0
- package/dist/_meta/commands.json +3335 -2206
- package/dist/_meta/hand-written-commands.json +106 -0
- package/dist/_meta/schemas.json +2351 -1454
- package/dist/{abuse-reports-7pRdd95h.mjs → abuse-reports-CmCGvR9N.mjs} +1 -1
- package/dist/{access-CON978TG.mjs → access-DKY7-mel.mjs} +1 -1
- package/dist/{accounts-DfTIQ1ol.mjs → accounts-sljLsnZt.mjs} +1 -1
- package/dist/{acm-DUOtXoq1.mjs → acm-BVicUMW4.mjs} +1 -1
- package/dist/{addressing-BGI1lmHJ.mjs → addressing-B_0yLBBj.mjs} +13 -13
- package/dist/{agent-memory-B7_ERHJA.mjs → agent-memory-D3LHr1Jb.mjs} +1 -1
- package/dist/{ai-CEUT9znF.mjs → ai-D1UNFv3e.mjs} +1 -1
- package/dist/{ai-audit-BhbsdF3R.mjs → ai-audit-DGLS1RJP.mjs} +1 -1
- package/dist/{ai-gateway-BMJ_sOoU.mjs → ai-gateway-ijht01vB.mjs} +45 -35
- package/dist/{ai-search-jYmV4tZM.mjs → ai-search-XudmIVw2.mjs} +1 -1
- package/dist/{ai-security-X7rya3Nc.mjs → ai-security-Coc4EXYV.mjs} +1 -1
- package/dist/{alerting-DrfOZuwU.mjs → alerting-_d2RkAgt.mjs} +1 -1
- package/dist/{analytics-CzMjVnxF.mjs → analytics-CSHwiNxB.mjs} +1 -1
- package/dist/{analytics-engine-DqNMYgeV.mjs → analytics-engine-BBGjNxal.mjs} +1 -1
- package/dist/{api-security-D3WIvBHW.mjs → api-security-Dd3nqQqz.mjs} +3 -3
- package/dist/{argo-D77o9nA0.mjs → argo-DZ7FcQDp.mjs} +1 -1
- package/dist/{artifacts-JhJU8lVg.mjs → artifacts-TAWj18ud.mjs} +1 -1
- package/dist/{audit-logs-BWNa7T1S.mjs → audit-logs-CnC2ipYN.mjs} +1 -1
- package/dist/auth-BOAIQNrB.mjs +2 -0
- package/dist/auth-DwPkWHHB.mjs +3 -0
- package/dist/auth-Fl7walZt.mjs +2 -0
- package/dist/auth-token-vS_OH8l7.mjs +8 -0
- package/dist/authentication-error-CFW0YLMA-CyvbCVD8.mjs +131 -0
- package/dist/autoconfig-B4vwjOUq.mjs +647 -0
- package/dist/{basin-catalog-BLGqOmj3.mjs → basin-catalog-BbduQMcn.mjs} +1 -1
- package/dist/{billing-MKjaJ5OH.mjs → billing-BLtPPd6a.mjs} +2 -2
- package/dist/{blocks-BhHWbQEb.mjs → blocks-CBp_warE.mjs} +1 -1
- package/dist/{body-parser-HN91kAf0.mjs → body-parser-DftnWjJP.mjs} +1 -1
- package/dist/{body-unions-QFGGUlIr.mjs → body-unions-DX9G5Vny.mjs} +1 -1
- package/dist/{bot-management-C6XG6ndL.mjs → bot-management-N1l1Cpn6.mjs} +1 -1
- package/dist/{botnet-feed-BKous_vP.mjs → botnet-feed-yZc2Ig_L.mjs} +1 -1
- package/dist/{brand-protection-D4hFdjyk.mjs → brand-protection-1SFr6bGh.mjs} +1 -1
- package/dist/{browser-run-BHLEEC5E.mjs → browser-run-Da8rp_rp.mjs} +4 -2
- package/dist/build-4tmWVjpg.mjs +2 -0
- package/dist/{build-CMyWk3oc.mjs → build-CQpuIBTK.mjs} +1 -1
- package/dist/{builds-Knlir3zp.mjs → builds-BD5sLopX.mjs} +1 -1
- package/dist/{cache-27OeN2zW.mjs → cache-DSUtHc4S.mjs} +18 -18
- package/dist/cf-zVgRO5PY.mjs +17 -0
- package/dist/{cli-BGJM9SBt.mjs → cli-Hrw5Pbhp.mjs} +1 -1
- package/dist/{client-side-security-DhFutOIw.mjs → client-side-security-Ge3I3rgO.mjs} +1 -1
- package/dist/{cloud-connector-DUR52h7h.mjs → cloud-connector-Ddb8vvtz.mjs} +1 -1
- package/dist/{cloudflared-CSDMIBKX.mjs → cloudflared-DJhAGc-2.mjs} +1 -1
- package/dist/{cloudforce-one-C0SzLz65.mjs → cloudforce-one-l3SgKPdg.mjs} +22 -24
- package/dist/{command-DMb8_5QR.mjs → command-08pqSG_2.mjs} +1 -1
- package/dist/{command-BzExw-4e.mjs → command-5kBKsg5P.mjs} +1 -1
- package/dist/command-B8OAAYUZ.mjs +2 -0
- package/dist/{command-CkBbgXY8.mjs → command-BSqxEqc7.mjs} +1 -1
- package/dist/{command-Drp8GAuW.mjs → command-B_7Pm7dq.mjs} +1 -1
- package/dist/{command-C6ddiqb8.mjs → command-C9XTqxMi.mjs} +1 -1
- package/dist/{command-CxhOAu2x.mjs → command-CkNsLK8g.mjs} +1 -1
- package/dist/{command-Co0d2ime.mjs → command-D4i6V7wE.mjs} +1 -1
- package/dist/{command-Bt_yk3sP.mjs → command-DSW0KMQZ.mjs} +1 -1
- package/dist/{command-Bufh8wFd.mjs → command-DZoJ3vMV.mjs} +1 -1
- package/dist/{command-B5v4F93a.mjs → command-Das6RBQL.mjs} +1 -1
- package/dist/{command-B8KcAAzJ.mjs → command-HlItYmgS.mjs} +1 -1
- package/dist/{command-CLeeImJr.mjs → command-KOIS6pIJ.mjs} +1 -1
- package/dist/{command-BENj0-eD.mjs → command-Kph6cPx4.mjs} +1 -1
- package/dist/{command-DfmJhh-K.mjs → command-kkAVVWsY.mjs} +1 -1
- package/dist/{completions-Chw9TYCy.mjs → completions-CmqLeFUH.mjs} +1 -1
- package/dist/config-WFtvFMMN-DO1DX3tx.mjs +300 -0
- package/dist/{connector-interrupts-DljkLm8i.mjs → connector-interrupts-DfREV4XN.mjs} +1 -1
- package/dist/{connector-telemetry-events-fZ_Uqwfd.mjs → connector-telemetry-events-SCU5vCYP.mjs} +1 -1
- package/dist/{connector-telemetry-snapshots-Bv5aAa_3.mjs → connector-telemetry-snapshots-DJZvVI4-.mjs} +1 -1
- package/dist/{connectors-BJQW9yKU.mjs → connectors-DqcM39im.mjs} +1 -1
- package/dist/{containers-D_QkjuSF.mjs → containers-C8nAjirq.mjs} +15 -15
- package/dist/{content-scan-mmmapOqc.mjs → content-scan-BbpsNNth.mjs} +1 -1
- package/dist/{context-ChcbaAGw.mjs → context-DZ_o-H15.mjs} +1 -1
- package/dist/{cps-CKOptk6d.mjs → cps-BCeCBhxr.mjs} +1 -1
- package/dist/create-worker-upload-form-DhzLEfNO-BCarSV0E.mjs +2 -0
- package/dist/{csam-scanner-Cgj2eo9n.mjs → csam-scanner-DPVIZWsj.mjs} +1 -1
- package/dist/{custom-csrs-BhpfDaqQ.mjs → custom-csrs-vqlDIOtD.mjs} +1 -1
- package/dist/{custom-hostnames-DW8Rpdm5.mjs → custom-hostnames-BdeiP25g.mjs} +1 -1
- package/dist/{custom-nameservers-Djpe8V3o.mjs → custom-nameservers-CsLh_cDC.mjs} +1 -1
- package/dist/{custom-pages-Chhva9aF.mjs → custom-pages-CMMLfTjo.mjs} +1 -1
- package/dist/{d1-BssqKsHt.mjs → d1-BlaNa5Fu.mjs} +1 -1
- package/dist/{delegate-CwB0ZkLX.mjs → delegate-Bzvi_ugB.mjs} +1 -1
- package/dist/delegate.mjs +1 -1
- package/dist/{deploy-CYdpmaPG.mjs → deploy-DlxJvz9y.mjs} +1 -1
- package/dist/deploy-context-DeHkCJT9.mjs +122 -0
- package/dist/{deploy-input-pcciD1Bc.mjs → deploy-input-Db7ggScI.mjs} +1 -1
- package/dist/dev-YNjyJj7T.mjs +4 -0
- package/dist/{diagnostics-Cm8Og_bM.mjs → diagnostics-tD8QINvM.mjs} +1 -1
- package/dist/{disk-cache-Csyrc7L_.mjs → disk-cache-CBpH8Qwx.mjs} +1 -1
- package/dist/dist-CoYrirmB.mjs +70 -0
- package/dist/{dls-CNMSLaWR.mjs → dls-SwQx0kK4.mjs} +1 -1
- package/dist/{dns-Cwdq9kAp.mjs → dns-C1MlG2d7.mjs} +15 -17
- package/dist/{dns-firewall-s33oZN9_.mjs → dns-firewall-Ci_CGN3o.mjs} +8 -8
- package/dist/{docs-BX7oBoFp.mjs → docs-D-jNhiZc.mjs} +1 -1
- package/dist/dot-prop-XnlHjVnE-Bi3oBTbt.mjs +2 -0
- package/dist/dotenv-Bs0zODmf.mjs +4 -0
- package/dist/{durable-objects-CZcj1eaJ.mjs → durable-objects-CHD_yg4p.mjs} +3 -3
- package/dist/{email-auth-CiOaqD27.mjs → email-auth-BjLElRZ4.mjs} +1 -1
- package/dist/{email-routing-0dzp8ahc.mjs → email-routing-Dyccezo3.mjs} +1 -1
- package/dist/{email-security-CPhkouDM.mjs → email-security-BX8uZu_6.mjs} +1 -1
- package/dist/{email-sending-DkwjDkpK.mjs → email-sending-BunoST49.mjs} +1 -1
- package/dist/error-sanitization-CoqDzMhY.mjs +2 -0
- package/dist/error-sanitization-DSyaOCwI.mjs +2 -0
- package/dist/{errors-BAF6Z21q.mjs → errors-kqU4AkAP.mjs} +1 -1
- package/dist/feedback-dOtkyoJ_.mjs +4 -0
- package/dist/{field-extractors-rpFJB4FT.mjs → field-extractors-CwSm76XL.mjs} +1 -1
- package/dist/{firewall-GB6SpbJU.mjs → firewall-BxoJLuuD.mjs} +1 -1
- package/dist/{flagship-B0sIdg7R.mjs → flagship-BNmFgpmb.mjs} +1 -1
- package/dist/{fraud-Ca1zvG-F.mjs → fraud-87jF9d-q.mjs} +1 -1
- package/dist/{google-tag-gateway-CC4xqAxo.mjs → google-tag-gateway-XYH8azp2.mjs} +1 -1
- package/dist/{gt-BV-jij5q.mjs → gt-CfD9QGOr.mjs} +1 -1
- package/dist/{healthchecks-Cnl6Pv23.mjs → healthchecks-CJB0k-uq.mjs} +1 -1
- package/dist/{hyperdrive-CK-zHef4.mjs → hyperdrive-OnaEun3F.mjs} +1 -1
- package/dist/{iam-D4GpREnO.mjs → iam-BxnesgCU.mjs} +1 -1
- package/dist/{images-CQdKkefj.mjs → images-CVSOsmBO.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{init-Cj8qCJj7.mjs → init-DWKDBlDR.mjs} +2 -2
- package/dist/{intel-Di4M_luj.mjs → intel-Bmc8fQP2.mjs} +5 -5
- package/dist/{interactive-FI8YIUbv.mjs → interactive-Bg9WyJ5G.mjs} +19 -19
- package/dist/{ips-BsSF2_y1.mjs → ips-D516R1W7.mjs} +1 -1
- package/dist/{k2-D3q3rmmF.mjs → k2-Cb9GSgVl.mjs} +1 -1
- package/dist/{kv-T85sRcDz.mjs → kv-DHte77e-.mjs} +1 -1
- package/dist/{lazy-command-B3N4aXWS.mjs → lazy-command-CXkIdRTR.mjs} +1 -1
- package/dist/{leaked-credential-checks--ulkoKo8.mjs → leaked-credential-checks-inTD7r5G.mjs} +1 -1
- package/dist/list-B8-Zc_GC.mjs +2 -0
- package/dist/list-DFJK-wNX.mjs +2 -0
- package/dist/{load-balancers-DcLotLBB.mjs → load-balancers-mzoAnWty.mjs} +1 -1
- package/dist/login-Pl57NFXW.mjs +5 -0
- package/dist/login-SNm0pWc2.mjs +2 -0
- package/dist/{logpush-DAewBJFe.mjs → logpush-BWUzMBKP.mjs} +1 -1
- package/dist/{logs-DIRHM-E9.mjs → logs-d7eJikoq.mjs} +1 -1
- package/dist/{magic-network-monitoring-XtKqbZsz.mjs → magic-network-monitoring-DNLnbVaL.mjs} +1 -1
- package/dist/{magic-transit-DEt-PMS_.mjs → magic-transit-Bpsnro56.mjs} +1 -1
- package/dist/{managed-defense-CGITrGgV.mjs → managed-defense-BznDhiE9.mjs} +1 -1
- package/dist/{managed-transforms-C27VjoWR.mjs → managed-transforms-js7R6wmk.mjs} +1 -1
- package/dist/{mcp-DMWcXkfV.mjs → mcp-COUHiudY.mjs} +2 -2
- package/dist/{mesh-CfZcm-Rl.mjs → mesh-D8RRgdmC.mjs} +1 -1
- package/dist/{migrate-D-xf74Yn.mjs → migrate-BGnkrxAz.mjs} +1 -1
- package/dist/{monetization-B5ksXOGO.mjs → monetization-BUJ-giat.mjs} +1 -1
- package/dist/{network-BON9bFrK.mjs → network-Dj-KssOA.mjs} +4 -4
- package/dist/{network-interconnects-BWMs0LvT.mjs → network-interconnects-DVYyr9sl.mjs} +1 -1
- package/dist/npm-launcher-Cx4wMwLb.mjs +2 -0
- package/dist/{o11y-CyZO37dy.mjs → o11y-qSJAU2CT.mjs} +37 -41
- package/dist/{oauth-CXm7-A7X.mjs → oauth-CbYuhP6T.mjs} +2 -2
- package/dist/oauth-UT4w2Aob.mjs +2 -0
- package/dist/{observability-DYy09kYo.mjs → observability-CiofkZ4g.mjs} +2 -2
- package/dist/{ohttp-gateway-Cqh36jz6.mjs → ohttp-gateway-BtStCXOO.mjs} +1 -1
- package/dist/open-BPppUKSJ-CtZ6XNLR.mjs +3 -0
- package/dist/{organizations-CiMeaQl0.mjs → organizations-CZk1_ZUR.mjs} +2 -2
- package/dist/package-Cj8_ZOGE.mjs +2 -0
- package/dist/{page-rules-DFNj-ZUk.mjs → page-rules-XpZlvctb.mjs} +1 -1
- package/dist/{pages-SSooyF53.mjs → pages-zvRglCt-.mjs} +2 -2
- package/dist/{pay-per-crawl-CC-mvH0h.mjs → pay-per-crawl-D4pSHKeH.mjs} +1 -1
- package/dist/pay-per-use-Cju3Z-WS.mjs +40 -0
- package/dist/{pipelines-DGEpLhjs.mjs → pipelines-CRurvded.mjs} +2 -2
- package/dist/{precursor-CDnv_b0d.mjs → precursor-A0aksdf3.mjs} +1 -1
- package/dist/previews-CnzsaM5g.mjs +6 -0
- package/dist/{progress-LGZ6-91a.mjs → progress-CKu4TPPI.mjs} +1 -1
- package/dist/{prompt-BSLPgIUg.mjs → prompt-B4fCnTfF.mjs} +1 -1
- package/dist/{queues-DLGsVwH2.mjs → queues-BQ8FIzCN.mjs} +3 -3
- package/dist/{r2-D94n2j1x.mjs → r2-C-nSv0u1.mjs} +2 -2
- package/dist/{radar-FHMHBDvg.mjs → radar-Dvr11Hs3.mjs} +3 -3
- package/dist/raw-fetch-DPl7eKQx.mjs +2 -0
- package/dist/{realtime-D4ImR9js.mjs → realtime-DL1yDaq3.mjs} +38 -38
- package/dist/{registrar-BhCVJBi8.mjs → registrar-1rRsFWBj.mjs} +1 -1
- package/dist/{registrar-sandbox-7S73fEBK.mjs → registrar-sandbox-Wc4FZXoi.mjs} +1 -1
- package/dist/{reporting-D-QpeRFo.mjs → reporting-CqbwVIFn.mjs} +1 -1
- package/dist/{request-headers-Inpc06QI.mjs → request-headers-DN5TYtJe.mjs} +1 -1
- package/dist/{request-tracers--W_ox55F.mjs → request-tracers-Ct1HPRhB.mjs} +1 -1
- package/dist/{resource-sharing-DX-ySgCn.mjs → resource-sharing-nZw5IudN.mjs} +5 -5
- package/dist/rolldown-runtime-BMUeFane-B0Knkemy.mjs +2 -0
- package/dist/{rules--3pEhUqP.mjs → rules-DqwqSdDr.mjs} +1 -1
- package/dist/{rulesets-UXNMbf21.mjs → rulesets-BIA4y4rX.mjs} +11 -11
- package/dist/{rum-BI5bcaxj.mjs → rum-DlYhE-0Z.mjs} +1 -1
- package/dist/run-BQIkT0nW.mjs +2 -0
- package/dist/run-DURbDvRl.mjs +2 -0
- package/dist/{schema-cache-CoAkY3EL.mjs → schema-cache-DHECPju4.mjs} +1 -1
- package/dist/{schema-flags-YgeJ6Bey.mjs → schema-flags-CDUlHuF1.mjs} +1 -1
- package/dist/{scim-CUDTL74k.mjs → scim-Zy_BbCe1.mjs} +1 -1
- package/dist/{secrets-store-cpAAAdOD.mjs → secrets-store-Cuor7149.mjs} +1 -1
- package/dist/{security-insights-DQDGeoGK.mjs → security-insights-n5gnhY18.mjs} +1 -1
- package/dist/{security-txt-DMqNwxtT.mjs → security-txt-BTGNvOWU.mjs} +1 -1
- package/dist/session-B3YezqpH.mjs +2 -0
- package/dist/shared-BgqBDSHb.mjs +2 -0
- package/dist/{smart-shield-Tjh_-EWc.mjs → smart-shield-BJFwWXaZ.mjs} +1 -1
- package/dist/{snippets-DL_OB7QE.mjs → snippets-DQPTiHJ9.mjs} +1 -1
- package/dist/{spawn-Dcit1ZgW.mjs → spawn-BVgaOYTB.mjs} +4 -4
- package/dist/{spectrum-BDbdvXiL.mjs → spectrum-DG0Ka-G8.mjs} +1 -1
- package/dist/{speed-PzlKqOxf.mjs → speed-DHrWN6K6.mjs} +1 -1
- package/dist/{sql-DqBcAQOi.mjs → sql-BAEWd7eq.mjs} +1 -1
- package/dist/{src-DY1gO4Hq.mjs → src-DOV4VsOr.mjs} +5 -5
- package/dist/{ssl-DmOr9F4p.mjs → ssl-Dr06JRYb.mjs} +2 -2
- package/dist/startup-profile-Cbj0m__A.mjs +2 -0
- package/dist/startup-profile-Dv_n6cTV.mjs +27 -0
- package/dist/state-CLwk9bEA.mjs +2 -0
- package/dist/{state-jXwCUs1C.mjs → state-qrqAdKcE.mjs} +1 -1
- package/dist/static-assets-tRMJaLSL.mjs +268 -0
- package/dist/{stream-BgqXnjWX.mjs → stream-CmyyjtsY.mjs} +4 -4
- package/dist/{tags-CkXGEaVr.mjs → tags-DdbMVXA8.mjs} +1 -1
- package/dist/{telemetry-CtWrahO4.mjs → telemetry-Ci5p3FRX.mjs} +1 -1
- package/dist/telemetry-D33WsYG8.mjs +2 -0
- package/dist/{tenant-custom-nameservers-CbQRqKgy.mjs → tenant-custom-nameservers-sk7Kfwk2.mjs} +1 -1
- package/dist/{tenants-fugWMuoJ.mjs → tenants-azRL8FKq.mjs} +1 -1
- package/dist/{tunnels-C6xf10z5.mjs → tunnels-DKbyBPhs.mjs} +23 -13
- package/dist/{turnstile-BRICGTnt.mjs → turnstile-CN510piW.mjs} +4 -5
- package/dist/ui-C1lhJqmW.mjs +2 -0
- package/dist/undici-C4huyh7H.mjs +262 -0
- package/dist/update-B1OMH2nT.mjs +4 -0
- package/dist/update-check-CxCLa8dK.mjs +2 -0
- package/dist/{update-check-Cza2MgCa.mjs → update-check-DN0X3jDo.mjs} +1 -1
- package/dist/update-check-worker.mjs +1 -1
- package/dist/{url-normalization-CosYnVMB.mjs → url-normalization-s_wLdVpJ.mjs} +1 -1
- package/dist/{url-scanner-BVH_6AJG.mjs → url-scanner-CkV5i3Ic.mjs} +1 -1
- package/dist/{user-Bu7ff3bx.mjs → user-DRu0_DK4.mjs} +30 -30
- package/dist/valid-DVkqhQD-.mjs +2 -0
- package/dist/vectorize-CXHGgH4C.mjs +30 -0
- package/dist/version-DhMG6xmF.mjs +2 -0
- package/dist/{waiting-rooms-CXY1SQVQ.mjs → waiting-rooms-Ci8YC7hc.mjs} +3 -3
- package/dist/{web-assets-OGdIcJ6Q.mjs → web-assets-BS4ML2Qn.mjs} +1 -1
- package/dist/web3-B6hUD3S1.mjs +26 -0
- package/dist/{whoami-sg_pvN-b.mjs → whoami-Cav17gsZ.mjs} +3 -3
- package/dist/whoami-dpqnuJsW.mjs +2 -0
- package/dist/workers-DQBT82CP.mjs +41 -0
- package/dist/{workers-for-platforms-DQyH5xmF.mjs → workers-for-platforms-CfZufMBX.mjs} +1 -1
- package/dist/{workers-vpc-Dv_4bVyj.mjs → workers-vpc-Bui53Ho6.mjs} +1 -1
- package/dist/{workflows-Bm0mxDoC.mjs → workflows-BH-cBkn4.mjs} +1 -1
- package/dist/wrangler-migration-Erxfi8YK.mjs +614 -0
- package/dist/{zaraz-Nw7gzQK9.mjs → zaraz-BKd97Jys.mjs} +1 -1
- package/dist/{zero-trust-iL97isOb.mjs → zero-trust-DH_Qw3uK.mjs} +14 -14
- package/dist/{zones-BNtHBhcK.mjs → zones-C49-hK3s.mjs} +2 -2
- package/package.json +15 -14
- package/dist/auth-Bir2IDwr.mjs +0 -2
- package/dist/auth-C2vTENwf.mjs +0 -2
- package/dist/auth-MdFy7pyc.mjs +0 -3
- package/dist/auth-token-e3ippjSj.mjs +0 -8
- package/dist/autoconfig-DdFyUPGn.mjs +0 -812
- package/dist/build-ep4sfzzA.mjs +0 -2
- package/dist/cf-TB3QCSDh.mjs +0 -18
- package/dist/chunk-AAQI36FL-e6E5HW1g.mjs +0 -319
- package/dist/chunk-DSGVRFIS-5bsdVCqZ.mjs +0 -2
- package/dist/chunk-JP6R7L72-C0kFUelb.mjs +0 -2
- package/dist/chunk-SQ32YSCG-CQ3eXDT8.mjs +0 -363
- package/dist/chunk-U6NEESU5-DqqRCaWH.mjs +0 -2
- package/dist/chunk-WMOON6TZ-C0dmPHpM.mjs +0 -2
- package/dist/command-DkM3rDla.mjs +0 -2
- package/dist/deploy-context-DmYBYd8Q.mjs +0 -55
- package/dist/dev-DgerLZtO.mjs +0 -4
- package/dist/dist-aDyCGA5i.mjs +0 -465
- package/dist/dot-prop-IITUZ2XW-C4pkmT-K.mjs +0 -2
- package/dist/dotenv-DKRemNCH.mjs +0 -4
- package/dist/error-sanitization-Bve6lZ3A.mjs +0 -2
- package/dist/error-sanitization-CZolnIrD.mjs +0 -2
- package/dist/login-B8_ufSFI.mjs +0 -2
- package/dist/login-DGY-anz-.mjs +0 -5
- package/dist/oauth-Do7K1Ycd.mjs +0 -2
- package/dist/open-PCXX3ZDZ-5J5IU2MX-DFe2CQkm.mjs +0 -4
- package/dist/open-PCXX3ZDZ-BD2iNJqn.mjs +0 -4
- package/dist/package-DLWHXbG1.mjs +0 -2
- package/dist/pay-per-use-9W39KK5F.mjs +0 -34
- package/dist/previews-CjBD7r9s.mjs +0 -6
- package/dist/raw-fetch-Cy2YR7bJ.mjs +0 -2
- package/dist/run-Bq0XGAg9.mjs +0 -2
- package/dist/run-CWmtD2lJ.mjs +0 -2
- package/dist/session-BfWuE2ax.mjs +0 -2
- package/dist/shared-BhmS_OQE.mjs +0 -2
- package/dist/startup-profile-C0UCllfs.mjs +0 -27
- package/dist/startup-profile-DT8dG8q7.mjs +0 -2
- package/dist/state-CQZhgMaN.mjs +0 -2
- package/dist/static-assets-n9iBqrrt.mjs +0 -386
- package/dist/telemetry-CvCFWLQU.mjs +0 -2
- package/dist/ui-C6DiSszw.mjs +0 -2
- package/dist/update-check-CO84YQp5.mjs +0 -2
- package/dist/vectorize-CIdh1Bb7.mjs +0 -30
- package/dist/version-DNYoInKC.mjs +0 -2
- package/dist/web3-BkwNeLQR.mjs +0 -26
- package/dist/whoami-DmQbL0w1.mjs +0 -2
- package/dist/workers-CCxmTaS8.mjs +0 -39
- package/dist/wrangler-migration-iPVbGt2G.mjs +0 -959
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{i as e,n as t}from"./auth-
|
|
2
|
+
import{i as e,n as t}from"./auth-Fl7walZt.mjs";import{t as n}from"./path-DRw6Y-nd.mjs";import{c as r,i,n as a,o,r as s,t as c}from"./body-parser-DftnWjJP.mjs";import{t as l}from"./dry-run-B4_5Qb0J.mjs";import{a as u,t as d}from"./context-DZ_o-H15.mjs";import{n as f,t as p}from"./input-validation-D7z60HJH.mjs";import{t as m}from"./local-CLMvfqkt.mjs";import{t as h}from"./output-DcDP8hsi.mjs";import{t as g}from"./run-DURbDvRl.mjs";import{t as _}from"./progress-CKu4TPPI.mjs";import"./telemetry-D33WsYG8.mjs";import"./api-5qkbb5HW.mjs";import{a as v,i as y,n as b}from"./prompt-B4fCnTfF.mjs";import{n as x,t as ee}from"./raw-fetch-DPl7eKQx.mjs";function te(e){return e.usage(`$0 ai-search chat-completions <instance-id>
|
|
3
3
|
|
|
4
4
|
Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses.`).positional(`instance-id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Namespace to use for this operation.`,default:`default`}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).coerce(`ai-search-options-cache-cache-threshold`,e=>f(e,`ai-search-options-cache-cache-threshold`,`text`)).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-custom-metadata`,{type:`string`,description:`Metadata added to AI Gateway logs for requests this operation triggers. Accepts up to 2 string, number, or boolean entries. Reserved keys: 'ai-search', 'task', 'origin', and any key beginning with 'cf.'. Provide as a JSON object or @path/to/file.json. Shape: {"<key>": (string | number | boolean)}.`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`Minimum reranker relevance score a chunk must reach to be returned. When omitted, falls back to the instance-level score_threshold, then to 0.4.`}).option(`ai-search-options-reranking-model`,{type:`string`,description:`The ai_search_options.reranking.model field`}).option(`ai-search-options-retrieval-boost-by`,{type:`string`,description:`Metadata fields to boost search results by. Overrides the instance-level boost_by config. Direction defaults to 'asc' for numeric/datetime fields, 'exists' for text/boolean fields. Fields must match 'timestamp' or a defined custom_metadata field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"field": string, "direction"?: "asc" | "desc" | "exists" | ...more}]. ? marks optional keys.`}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`}).option(`ai-search-options-retrieval-filters`,{type:`string`,description:`The ai_search_options.retrieval.filters field. Provide as a JSON object or @path/to/file.json. Shape: {"<key>": unknown}.`}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).coerce(`ai-search-options-retrieval-fusion-method`,e=>f(e,`ai-search-options-retrieval-fusion-method`,`text`)).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents become candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term and ranks results according to BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).coerce(`ai-search-options-retrieval-keyword-match-mode`,e=>f(e,`ai-search-options-retrieval-keyword-match-mode`,`text`)).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`Minimum similarity score a chunk must reach to be returned. When omitted, falls back to the instance-level score_threshold, then to 0.4.`}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`Maximum number of results to return. When omitted, falls back to the instance-level max_num_results, then to 10.`}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).coerce(`ai-search-options-retrieval-retrieval-type`,e=>f(e,`ai-search-options-retrieval-retrieval-type`,`text`)).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`}).option(`messages`,{type:`string`,description:`The messages field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"content": (string | [{...}] | null), "role": "system" | "developer" | "user" | ...more, "<key>": unknown}].`}).option(`model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`stream`,{type:`boolean`,description:`The stream field`}).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 ne={command:`chat-completions <instance-id>`,describe:`Chat Completions`,builder:te,handler:async n=>g({command:`ai-search chat-completions`,classification:{safeFlags:[`ai-search-options-cache-cache-threshold`,`ai-search-options-cache-enabled`,`ai-search-options-query-rewrite-enabled`,`ai-search-options-reranking-enabled`,`ai-search-options-retrieval-fusion-method`,`ai-search-options-retrieval-keyword-match-mode`,`ai-search-options-retrieval-retrieval-type`,`ai-search-options-retrieval-return-on-failure`,`stream`,`dry-run`]}},n,async()=>{let a=async()=>{if(n.messages===void 0)throw Error(`--messages is required (or pass --body with this field set).`)};if(n.dryRun){n.body===void 0&&await a();let e=await u();l({command:`cf ai-search chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e??`<account-id>`}/ai-search/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/instances/${n[`instance-id`]==null?`<instance-id>`:encodeURIComponent(String(n[`instance-id`]))}/chat/completions`,pathParams:{namespace:String(n.namespace??``),"instance-id":String(n[`instance-id`]??``)},bodyKind:`json`,body:n.body===void 0?c({ai_search_options:{cache:{cache_threshold:n[`ai-search-options-cache-cache-threshold`],enabled:n[`ai-search-options-cache-enabled`]},custom_metadata:i(n[`ai-search-options-custom-metadata`],`ai-search-options-custom-metadata`),query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],model:f(n[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:f(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`],model:f(n[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{boost_by:o(n[`ai-search-options-retrieval-boost-by`],`ai-search-options-retrieval-boost-by`),context_expansion:n[`ai-search-options-retrieval-context-expansion`],filters:i(n[`ai-search-options-retrieval-filters`],`ai-search-options-retrieval-filters`),fusion_method:n[`ai-search-options-retrieval-fusion-method`],keyword_match_mode:n[`ai-search-options-retrieval-keyword-match-mode`],match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:n[`ai-search-options-retrieval-retrieval-type`],return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},messages:o(n.messages,`messages`),model:f(n.model,`model`,`text`),stream:n.stream},[[`ai_search_options`,`custom_metadata`],[`ai_search_options`,`retrieval`,`filters`]]):s(n.body)});return}let p=n.body===void 0?void 0:s(n.body),g=await t(n),v=n.local?m:await d();if(n.accountId=v,n.body!==void 0){let t=p,r=await _(`Creating`,async()=>e(g,`POST`,`/accounts/${v}/ai-search/namespaces/${encodeURIComponent(String(n.namespace))}/instances/${encodeURIComponent(String(n[`instance-id`]))}/chat/completions`,{body:t}));h(r,{successLabel:`Created`});return}await a();let y={};n[`ai-search-options-cache-cache-threshold`]!==void 0&&r(y,[`ai_search_options`,`cache`,`cache_threshold`],n[`ai-search-options-cache-cache-threshold`]),n[`ai-search-options-cache-enabled`]!==void 0&&r(y,[`ai_search_options`,`cache`,`enabled`],n[`ai-search-options-cache-enabled`]),n[`ai-search-options-custom-metadata`]!==void 0&&r(y,[`ai_search_options`,`custom_metadata`],i(n[`ai-search-options-custom-metadata`],`ai-search-options-custom-metadata`)),n[`ai-search-options-query-rewrite-enabled`]!==void 0&&r(y,[`ai_search_options`,`query_rewrite`,`enabled`],n[`ai-search-options-query-rewrite-enabled`]),n[`ai-search-options-query-rewrite-model`]!==void 0&&r(y,[`ai_search_options`,`query_rewrite`,`model`],f(n[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`)),n[`ai-search-options-query-rewrite-rewrite-prompt`]!==void 0&&r(y,[`ai_search_options`,`query_rewrite`,`rewrite_prompt`],f(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)),n[`ai-search-options-reranking-enabled`]!==void 0&&r(y,[`ai_search_options`,`reranking`,`enabled`],n[`ai-search-options-reranking-enabled`]),n[`ai-search-options-reranking-match-threshold`]!==void 0&&r(y,[`ai_search_options`,`reranking`,`match_threshold`],n[`ai-search-options-reranking-match-threshold`]),n[`ai-search-options-reranking-model`]!==void 0&&r(y,[`ai_search_options`,`reranking`,`model`],f(n[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)),n[`ai-search-options-retrieval-boost-by`]!==void 0&&r(y,[`ai_search_options`,`retrieval`,`boost_by`],o(n[`ai-search-options-retrieval-boost-by`],`ai-search-options-retrieval-boost-by`)),n[`ai-search-options-retrieval-context-expansion`]!==void 0&&r(y,[`ai_search_options`,`retrieval`,`context_expansion`],n[`ai-search-options-retrieval-context-expansion`]),n[`ai-search-options-retrieval-filters`]!==void 0&&r(y,[`ai_search_options`,`retrieval`,`filters`],i(n[`ai-search-options-retrieval-filters`],`ai-search-options-retrieval-filters`)),n[`ai-search-options-retrieval-fusion-method`]!==void 0&&r(y,[`ai_search_options`,`retrieval`,`fusion_method`],n[`ai-search-options-retrieval-fusion-method`]),n[`ai-search-options-retrieval-keyword-match-mode`]!==void 0&&r(y,[`ai_search_options`,`retrieval`,`keyword_match_mode`],n[`ai-search-options-retrieval-keyword-match-mode`]),n[`ai-search-options-retrieval-match-threshold`]!==void 0&&r(y,[`ai_search_options`,`retrieval`,`match_threshold`],n[`ai-search-options-retrieval-match-threshold`]),n[`ai-search-options-retrieval-max-num-results`]!==void 0&&r(y,[`ai_search_options`,`retrieval`,`max_num_results`],n[`ai-search-options-retrieval-max-num-results`]),n[`ai-search-options-retrieval-retrieval-type`]!==void 0&&r(y,[`ai_search_options`,`retrieval`,`retrieval_type`],n[`ai-search-options-retrieval-retrieval-type`]),n[`ai-search-options-retrieval-return-on-failure`]!==void 0&&r(y,[`ai_search_options`,`retrieval`,`return_on_failure`],n[`ai-search-options-retrieval-return-on-failure`]),n.messages!==void 0&&r(y,[`messages`],o(n.messages,`messages`)),n.model!==void 0&&r(y,[`model`],f(n.model,`model`,`text`)),n.stream!==void 0&&r(y,[`stream`],n.stream);let b=await _(`Creating`,async()=>e(g,`POST`,`/accounts/${v}/ai-search/namespaces/${encodeURIComponent(String(n.namespace))}/instances/${encodeURIComponent(String(n[`instance-id`]))}/chat/completions`,{body:y}));h(b,{successLabel:`Created`})})};var S={method:`POST`,path:e=>n`/accounts/${e.account_id}/ai-search/namespaces/${e.namespace}/instances`,body:`json`,errors:{400:`BadRequestError`,403:`ForbiddenError`,409:`ConflictError`,503:`ServiceUnavailableError`}};function re(e){return e.usage(`$0 ai-search create <id>
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-
|
|
2
|
+
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-Fl7walZt.mjs";import{i as n}from"./context-DZ_o-H15.mjs";import{t as r}from"./dry-run-B4_5Qb0J.mjs";import{t as i}from"./output-DcDP8hsi.mjs";import{t as a}from"./progress-CKu4TPPI.mjs";import{t as o}from"./run-DURbDvRl.mjs";import"./telemetry-D33WsYG8.mjs";import{o as s,r as c,t as l}from"./body-parser-DftnWjJP.mjs";import{n as u}from"./prompt-B4fCnTfF.mjs";var d={method:`GET`,path:t=>e`/zones/${t.zone_id}/ai-security/custom-topics`};function f(e){return e.usage(`$0 ai-security custom-topics get
|
|
3
3
|
|
|
4
4
|
Get the custom topic categories defined for the zone. While AI Security for Apps is enabled, it scores every incoming prompt against these topics and writes the scores to the \`cf.llm.prompt.custom_topic_categories\` field, keyed by topic label. Topics can be configured while the detection is disabled, but no prompt is scored until you enable it.`).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const p={command:`get`,describe:`Get the AI Security for Apps custom topics of a zone.`,builder:f,handler:async e=>o({command:`ai-security custom-topics get`,classification:{safeFlags:[`dry-run`]}},e,async()=>{if(e.dryRun){r({command:`cf ai-security custom-topics get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/ai-security/custom-topics`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let o=await t(e),s=await n({zone:e.zone},o,{quiet:e.quiet});e.zoneId=s;let c=await a(`Loading`,async()=>o.send(d,{zone_id:s}));i(c,{successLabel:`Loaded`})})};var m={method:`PUT`,path:t=>e`/zones/${t.zone_id}/ai-security/custom-topics`,body:`json`};function h(e){return e.usage("$0 ai-security custom-topics update\n\nUpdate the custom topic list of the zone, overwriting it entirely with the topics in the request, so include every topic you want to keep. Changes can take up to a minute to propagate. Each entry has a `label`, used to reference the topic in rule expressions and analytics, and a `topic` description, which the classifier scores prompts against while AI Security for Apps is enabled. The following rules apply: - A zone can hold at most 20 topics. - `label` must be 2–20 characters, using only lowercase letters (a–z), digits (0–9), and hyphens. - `topic` must be 2–50 UTF-8 bytes. Text in any language is supported, including spaces, numbers, punctuation, and symbols. Tabs, line breaks, invalid text, and invisible formatting characters are not allowed. - Labels must be unique within the zone, and so must topic descriptions.").option(`topics`,{type:`string`,description:`Custom topic categories for AI Security for Apps content detection. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"label": string, "topic": string}].`}).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 g={command:`update`,describe:`Update the AI Security for Apps custom topics of a zone.`,builder:h,handler:async e=>o({command:`ai-security custom-topics update`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},e,async()=>{if(e.dryRun){r({command:`cf ai-security custom-topics update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/ai-security/custom-topics`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?l({topics:s(e.topics,`topics`)}):c(e.body)});return}let o=e.body===void 0?void 0:c(e.body),d=await t(e),f=await n({zone:e.zone},d,{quiet:e.quiet});if(e.zoneId=f,!await u({force:!!e.force,message:`This operation overwrites the AI Security for Apps custom topics for a zone.`}))return;if(e.body!==void 0){let e=o,t=await a(`Updating`,async()=>d.send(m,{body:e,zone_id:f}));i(t,{successLabel:`Updated`});return}let p=l({topics:s(e.topics,`topics`)}),h=await a(`Updating`,async()=>d.send(m,{body:p,zone_id:f}));i(h,{successLabel:`Updated`})})},_={command:`custom-topics`,describe:`Organization-specific topic categories used by AI Security for Apps content detection`,builder:e=>e.command(p).command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};var v={method:`GET`,path:t=>e`/zones/${t.zone_id}/ai-security/settings`};function y(e){return e.usage(`$0 ai-security get
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-
|
|
2
|
+
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-Fl7walZt.mjs";import{t as n}from"./dry-run-B4_5Qb0J.mjs";import{a as r,t as i}from"./context-DZ_o-H15.mjs";import{t as a}from"./local-CLMvfqkt.mjs";import{t as o}from"./output-DcDP8hsi.mjs";import{t as s}from"./progress-CKu4TPPI.mjs";import{t as c}from"./run-DURbDvRl.mjs";import"./telemetry-D33WsYG8.mjs";import{a as l,i as u,n as d}from"./prompt-B4fCnTfF.mjs";import{o as f,r as p,t as m}from"./body-parser-DftnWjJP.mjs";import{n as h}from"./input-validation-D7z60HJH.mjs";import{n as g,t as _}from"./raw-fetch-DPl7eKQx.mjs";var v={method:`GET`,path:t=>e`/accounts/${t.account_id}/alerting/v3/available_alerts`};function y(e){return e.usage(`$0 alerting available-alerts list
|
|
3
3
|
|
|
4
4
|
Gets a list of all alert types for which an account is eligible.`).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`list`,describe:`Get Alert Types`,builder:y,handler:async e=>c({command:`alerting available-alerts list`,classification:{safeFlags:[`dry-run`]}},e,async()=>{if(e.dryRun){let e=await r();n({command:`cf alerting available-alerts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e??`<account-id>`}/alerting/v3/available_alerts`,pathParams:{},bodyKind:`none`});return}let c=await t(e),l=e.local?a:await i();e.accountId=l;let u=await s(`Loading`,async()=>c.send(v,{account_id:l}));o(u,{successLabel:`Loaded`})})},x={command:`available-alerts`,describe:`Operations for available-alerts`,builder:e=>e.command(b).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};var ee={method:`GET`,path:t=>e`/accounts/${t.account_id}/alerting/v3/destinations/eligible`};function te(e){return e.usage(`$0 alerting destinations eligible get
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-
|
|
2
|
+
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-Fl7walZt.mjs";import{t as n}from"./dry-run-B4_5Qb0J.mjs";import{a as r,i,t as a}from"./context-DZ_o-H15.mjs";import{t as o}from"./output-DcDP8hsi.mjs";import{t as s}from"./progress-CKu4TPPI.mjs";import"./telemetry-D33WsYG8.mjs";import{t as c}from"./run-DURbDvRl.mjs";import{o as l,r as u,t as d}from"./body-parser-DftnWjJP.mjs";import{n as f}from"./input-validation-D7z60HJH.mjs";import{t as p}from"./local-CLMvfqkt.mjs";import{a as m}from"./prompt-B4fCnTfF.mjs";var h={method:`GET`,path:t=>e`/zones/${t.zone_id}/analytics/latency/colos`};function g(e){return e.usage(`$0 analytics latency colos get
|
|
3
3
|
|
|
4
4
|
Retrieves Argo Smart Routing analytics broken down by geographic points of presence (PoPs). Shows latency improvements and routing efficiency per location.`).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get`,describe:`Argo Analytics for a zone at different PoPs`,builder:g,handler:async e=>c({command:`analytics latency colos get`,classification:{safeFlags:[`dry-run`]}},e,async()=>{if(e.dryRun){n({command:`cf analytics latency colos get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/analytics/latency/colos`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await t(e),a=await i({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a;let c=await s(`Loading`,async()=>r.send(h,{zone_id:a}));o(c,{successLabel:`Loaded`})})},v={command:`colos`,describe:`Operations for latency.colos`,builder:e=>e.command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};var y={method:`GET`,path:t=>e`/zones/${t.zone_id}/analytics/latency`,query:[`bins`]};function b(e){return e.usage(`$0 analytics latency get
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{i as e,n as t}from"./auth-
|
|
2
|
+
import{i as e,n as t}from"./auth-Fl7walZt.mjs";import{t as n}from"./dry-run-B4_5Qb0J.mjs";import{a as r,t as i}from"./context-DZ_o-H15.mjs";import{n as a,t as o}from"./input-validation-D7z60HJH.mjs";import{t as s}from"./local-CLMvfqkt.mjs";import{t as c}from"./output-DcDP8hsi.mjs";import{t as l}from"./run-DURbDvRl.mjs";import{t as u}from"./progress-CKu4TPPI.mjs";import"./telemetry-D33WsYG8.mjs";function d(e){return e.usage(`$0 analytics-engine sql query
|
|
3
3
|
|
|
4
4
|
Executes a SQL query against Workers Analytics Engine data. Pass the SQL query in the request body as plain text. The response uses newline-delimited JSON (NDJSON) by default, or a single JSON object when the query includes a FORMAT JSON clause. Prefer this method for longer queries that may exceed URL length limits.`).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Plain-text request body (without JSON quotes)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`})}const f={command:`query`,describe:`Execute an Analytics Engine SQL query via request body`,builder:d,handler:async d=>l({command:`analytics-engine sql query`,classification:{safeFlags:[`dry-run`]}},d,async()=>{if(d.body===void 0&&d.file===void 0)throw Error(`--body or --file is required for this command. Pass --body '<value>' or --file path/to/file.`);if(d.dryRun){let e=await r();n({command:`cf analytics-engine sql query`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e??`<account-id>`}/analytics_engine/sql`,pathParams:{},bodyKind:`octet-stream`,body:d.file===void 0?d.body:{file:d.file}});return}let l=d.file===void 0?a(d.body,`body`,`binary`):void 0,f=await t(d),p=d.local?s:await i();if(d.accountId=p,d.file!==void 0){let t=o(d.file),n=await u(`Loading`,async()=>e(f,`POST`,`/accounts/${p}/analytics_engine/sql`,{body:t,headers:{"Content-Type":`text/plain`}}));c(n,{successLabel:`Loaded`})}else if(d.body!==void 0){let t=l,n=await u(`Loading`,async()=>e(f,`POST`,`/accounts/${p}/analytics_engine/sql`,{body:t,headers:{"Content-Type":`text/plain`}}));c(n,{successLabel:`Loaded`})}})},p={command:`sql`,describe:`Operations for sql`,builder:e=>e.command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},m={command:`analytics-engine`,describe:`analytics-engine`,builder:e=>e.command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{m as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{i as t,n}from"./auth-
|
|
2
|
+
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{i as t,n}from"./auth-Fl7walZt.mjs";import{o as r,r as i,t as a}from"./body-parser-DftnWjJP.mjs";import{a as o,i as s,t as c}from"./context-DZ_o-H15.mjs";import{t as l}from"./dry-run-B4_5Qb0J.mjs";import{n as u}from"./input-validation-D7z60HJH.mjs";import{t as d}from"./output-DcDP8hsi.mjs";import{t as f}from"./run-DURbDvRl.mjs";import{t as p}from"./progress-CKu4TPPI.mjs";import{a as m,i as h,n as g}from"./prompt-B4fCnTfF.mjs";import"./telemetry-D33WsYG8.mjs";import{t as _}from"./local-CLMvfqkt.mjs";var v={method:`POST`,path:t=>e`/zones/${t.zone_id}/schema_validation/schemas`,body:`json`,constants:{kind:`openapi_v3`}};function ee(e){return e.usage(`$0 api-security schema-validation schemas create
|
|
3
3
|
|
|
4
4
|
Uploads an OpenAPI schema that defines expected request formats for API operations.`).option(`kind`,{type:`string`,description:`The kind of the schema`,choices:[`openapi_v3`]}).coerce(`kind`,e=>u(e,`kind`,`text`)).option(`name`,{type:`string`,description:`A human-readable name for the schema`}).option(`source`,{type:`string`,description:`The raw schema, e.g., the OpenAPI schema, either as JSON or YAML`}).option(`validation-enabled`,{type:`boolean`,description:`An indicator if this schema is enabled`}).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 y={command:`create`,describe:`Upload a schema`,builder:ee,handler:async e=>f({command:`api-security schema-validation schemas create`,classification:{safeFlags:[`kind`,`validation-enabled`,`dry-run`]}},e,async()=>{let t=async()=>{if(e.kind===void 0&&(e.kind=await h(`kind`,`The kind of the schema`,[`openapi_v3`])),e.name===void 0&&(e.name=await m(`name`,`A human-readable name for the schema`)),e.source===void 0&&(e.source=await m(`source`,`The raw schema, e.g., the OpenAPI schema, either as JSON or YAML`)),e[`validation-enabled`]===void 0)throw Error(`--validation-enabled is required (or pass --body with this field set).`)};if(e.dryRun){e.body===void 0&&await t(),l({command:`cf api-security schema-validation schemas create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/schema_validation/schemas`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?a({kind:e.kind,name:u(e.name,`name`,`text`),source:u(e.source,`source`,`text`),validation_enabled:e[`validation-enabled`]}):i(e.body)});return}let r=e.body===void 0?void 0:i(e.body),o=await n(e),c=await s({zone:e.zone},o,{quiet:e.quiet});if(e.zoneId=c,e.body!==void 0){let e=r,t=await p(`Creating`,async()=>o.send(v,{body:e,zone_id:c}));d(t,{successLabel:`Created`});return}await t();let f=a({kind:e.kind,name:u(e.name,`name`,`text`),source:u(e.source,`source`,`text`),validation_enabled:e[`validation-enabled`]}),g=await p(`Creating`,async()=>o.send(v,{body:f,zone_id:c}));d(g,{successLabel:`Created`})})};var te={method:`DELETE`,path:t=>e`/zones/${t.zone_id}/schema_validation/schemas/${t.schema_id}`};function ne(e){return e.usage(`$0 api-security schema-validation schemas delete <schema-id>
|
|
5
5
|
|
|
@@ -76,14 +76,14 @@ Updates and reorders multiple token validation rules in one request, then return
|
|
|
76
76
|
Creates a token validation rule for the zone.`).option(`action`,{type:`string`,description:"Action to take on requests that match operations included in `selector` and fail `expression`.",choices:[`log`,`block`]}).coerce(`action`,e=>u(e,`action`,`text`)).option(`description`,{type:`string`,description:"A human-readable description that gives more details than `title`."}).option(`enabled`,{type:`boolean`,description:`Toggle rule on or off.`}).option(`expression`,{type:`string`,description:`Rule expression. Requests that fail to match this expression will be subject to \`action\`.
|
|
77
77
|
|
|
78
78
|
For details on expressions, see the [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
|
|
79
|
-
`}).option(`selector-exclude`,{type:`string`,description:'Ignore operations that were otherwise included by `include`. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"operation_ids"?: [string]}]. ? marks optional keys.'}).option(`selector-include`,{type:`string`,description:`Select all matching operations. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"host"?: [string]}]. ? marks optional keys.`}).option(`title`,{type:`string`,description:`A human-readable name for the rule.`}).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 dt={command:`create`,describe:`Create a token validation rule`,builder:ut,handler:async e=>f({command:`api-security token-validation rules create`,classification:{safeFlags:[`action`,`enabled`,`dry-run`]}},e,async()=>{let t=async()=>{if(e.action===void 0&&(e.action=await h(`action`,"Action to take on requests that match operations included in `selector` and fail `expression`.",[`log`,`block`])),e.description===void 0&&(e.description=await m(`description`,"A human-readable description that gives more details than `title`.")),e.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);e.expression===void 0&&(e.expression=await m(`expression`,"Rule expression. Requests that fail to match this expression will be subject to `action`. For details on expressions, see the [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/). ")),e.title===void 0&&(e.title=await m(`title`,`A human-readable name for the rule.`))};if(e.dryRun){e.body===void 0&&await t(),l({command:`cf api-security token-validation rules create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/token_validation/rules`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?a({action:e.action,description:u(e.description,`description`,`text`),enabled:e.enabled,expression:u(e.expression,`expression`,`text`),selector:{exclude:r(e[`selector-exclude`],`selector-exclude
|
|
79
|
+
`}).option(`selector-exclude`,{type:`string`,description:'Ignore operations that were otherwise included by `include`. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"operation_ids"?: [string]}]. ? marks optional keys.'}).option(`selector-include`,{type:`string`,description:`Select all matching operations. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"host"?: [string]}]. ? marks optional keys.`}).option(`title`,{type:`string`,description:`A human-readable name for the rule.`}).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 dt={command:`create`,describe:`Create a token validation rule`,builder:ut,handler:async e=>f({command:`api-security token-validation rules create`,classification:{safeFlags:[`action`,`enabled`,`dry-run`]}},e,async()=>{let t=async()=>{if(e.action===void 0&&(e.action=await h(`action`,"Action to take on requests that match operations included in `selector` and fail `expression`.",[`log`,`block`])),e.description===void 0&&(e.description=await m(`description`,"A human-readable description that gives more details than `title`.")),e.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);e.expression===void 0&&(e.expression=await m(`expression`,"Rule expression. Requests that fail to match this expression will be subject to `action`. For details on expressions, see the [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/). ")),e.title===void 0&&(e.title=await m(`title`,`A human-readable name for the rule.`))};if(e.dryRun){e.body===void 0&&await t(),l({command:`cf api-security token-validation rules create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/token_validation/rules`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?a({action:e.action,description:u(e.description,`description`,`text`),enabled:e.enabled,expression:u(e.expression,`expression`,`text`),selector:{exclude:r(e[`selector-exclude`],`selector-exclude`,!0),include:r(e[`selector-include`],`selector-include`,!0)},title:u(e.title,`title`,`text`)}):i(e.body)});return}let o=e.body===void 0?void 0:i(e.body),c=await n(e),f=await s({zone:e.zone},c,{quiet:e.quiet});if(e.zoneId=f,e.body!==void 0){let e=o,t=await p(`Creating`,async()=>c.send(V,{body:e,zone_id:f}));d(t,{successLabel:`Created`});return}await t();let g=a({action:e.action,description:u(e.description,`description`,`text`),enabled:e.enabled,expression:u(e.expression,`expression`,`text`),selector:{exclude:r(e[`selector-exclude`],`selector-exclude`,!0),include:r(e[`selector-include`],`selector-include`,!0)},title:u(e.title,`title`,`text`)}),_=await p(`Creating`,async()=>c.send(V,{body:g,zone_id:f}));d(_,{successLabel:`Created`})})};var ft={method:`DELETE`,path:t=>e`/zones/${t.zone_id}/token_validation/rules/${t.rule_id}`};function pt(e){return e.usage(`$0 api-security token-validation rules delete <rule-id>
|
|
80
80
|
|
|
81
81
|
Deletes a token validation rule from the zone.`).positional(`rule-id`,{type:`string`,description:`Token Validation Rule ID`,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 mt={command:`delete <rule-id>`,describe:`Delete a token validation rule`,builder:pt,handler:async e=>f({command:`api-security token-validation rules delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},e,async()=>{if(e.dryRun){l({command:`cf api-security token-validation rules delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/token_validation/rules/${e[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(e[`rule-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"rule-id":String(e[`rule-id`]??``)},bodyKind:`none`});return}let t=await n(e),r=await s({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,!await g({force:!!e.force,message:`This operation deletes the token validation rule from the zone.`}))return;let i=await p(`Deleting`,async()=>t.send(ft,{zone_id:r,rule_id:e[`rule-id`]}));d(i,{successLabel:`Deleted`})})};var H={method:`PATCH`,path:t=>e`/zones/${t.zone_id}/token_validation/rules/${t.rule_id}`,body:`json`};function ht(e){return e.usage(`$0 api-security token-validation rules edit <rule-id>
|
|
82
82
|
|
|
83
83
|
Updates only the supplied fields on a token validation rule.`).positional(`rule-id`,{type:`string`,description:`Token Validation Rule ID`,demandOption:!0}).option(`action`,{type:`string`,description:"Action to take on requests that match operations included in `selector` and fail `expression`.",choices:[`log`,`block`]}).coerce(`action`,e=>u(e,`action`,`text`)).option(`description`,{type:`string`,description:"A human-readable description that gives more details than `title`."}).option(`enabled`,{type:`boolean`,description:`Toggle rule on or off.`}).option(`expression`,{type:`string`,description:`Rule expression. Requests that fail to match this expression will be subject to \`action\`.
|
|
84
84
|
|
|
85
85
|
For details on expressions, see the [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
|
|
86
|
-
`}).option(`selector-exclude`,{type:`string`,description:'Ignore operations that were otherwise included by `include`. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"operation_ids"?: [string]}]. ? marks optional keys.'}).option(`selector-include`,{type:`string`,description:`Select all matching operations. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"host"?: [string]}]. ? marks optional keys.`}).option(`title`,{type:`string`,description:`A human-readable name for the rule.`}).option(`position-index`,{type:`number`,description:`Move rule to this position`}).option(`position-before`,{type:`string`,description:`Move rule to before rule with this ID.`}).option(`position-after`,{type:`string`,description:`Move rule to after rule with this ID.`}).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)`}).conflicts(`position-index`,[`position-before`,`position-after`]).conflicts(`position-before`,[`position-index`,`position-after`]).conflicts(`position-after`,[`position-index`,`position-before`])}const gt={command:`edit <rule-id>`,describe:`Edit a token validation rule`,builder:ht,handler:async e=>f({command:`api-security token-validation rules edit`,classification:{safeFlags:[`action`,`enabled`,`dry-run`]}},e,async()=>{if(e.dryRun){l({command:`cf api-security token-validation rules edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/token_validation/rules/${e[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(e[`rule-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"rule-id":String(e[`rule-id`]??``)},bodyKind:`json`,body:e.body===void 0?a({action:e.action,description:u(e.description,`description`,`text`),enabled:e.enabled,expression:u(e.expression,`expression`,`text`),selector:{exclude:r(e[`selector-exclude`],`selector-exclude
|
|
86
|
+
`}).option(`selector-exclude`,{type:`string`,description:'Ignore operations that were otherwise included by `include`. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"operation_ids"?: [string]}]. ? marks optional keys.'}).option(`selector-include`,{type:`string`,description:`Select all matching operations. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"host"?: [string]}]. ? marks optional keys.`}).option(`title`,{type:`string`,description:`A human-readable name for the rule.`}).option(`position-index`,{type:`number`,description:`Move rule to this position`}).option(`position-before`,{type:`string`,description:`Move rule to before rule with this ID.`}).option(`position-after`,{type:`string`,description:`Move rule to after rule with this ID.`}).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)`}).conflicts(`position-index`,[`position-before`,`position-after`]).conflicts(`position-before`,[`position-index`,`position-after`]).conflicts(`position-after`,[`position-index`,`position-before`])}const gt={command:`edit <rule-id>`,describe:`Edit a token validation rule`,builder:ht,handler:async e=>f({command:`api-security token-validation rules edit`,classification:{safeFlags:[`action`,`enabled`,`dry-run`]}},e,async()=>{if(e.dryRun){l({command:`cf api-security token-validation rules edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/token_validation/rules/${e[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(e[`rule-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"rule-id":String(e[`rule-id`]??``)},bodyKind:`json`,body:e.body===void 0?a({action:e.action,description:u(e.description,`description`,`text`),enabled:e.enabled,expression:u(e.expression,`expression`,`text`),selector:{exclude:r(e[`selector-exclude`],`selector-exclude`,!0),include:r(e[`selector-include`],`selector-include`,!0)},title:u(e.title,`title`,`text`),position:{index:e[`position-index`],before:u(e[`position-before`],`position-before`,`text`),after:u(e[`position-after`],`position-after`,`text`)}}):i(e.body)});return}let t=e.body===void 0?void 0:i(e.body),o=await n(e),c=await s({zone:e.zone},o,{quiet:e.quiet});if(e.zoneId=c,e.body!==void 0){let n=t,r=await p(`Updating`,async()=>o.send(H,{body:n,zone_id:c,rule_id:e[`rule-id`]}));d(r,{successLabel:`Updated`});return}let f=a({action:e.action,description:u(e.description,`description`,`text`),enabled:e.enabled,expression:u(e.expression,`expression`,`text`),selector:{exclude:r(e[`selector-exclude`],`selector-exclude`,!0),include:r(e[`selector-include`],`selector-include`,!0)},title:u(e.title,`title`,`text`),position:{index:e[`position-index`],before:u(e[`position-before`],`position-before`,`text`),after:u(e[`position-after`],`position-after`,`text`)}}),m=await p(`Updating`,async()=>o.send(H,{body:f,zone_id:c,rule_id:e[`rule-id`]}));d(m,{successLabel:`Updated`})})};var _t={method:`GET`,path:t=>e`/zones/${t.zone_id}/token_validation/rules/${t.rule_id}`};function vt(e){return e.usage(`$0 api-security token-validation rules get <rule-id>
|
|
87
87
|
|
|
88
88
|
Returns a token validation rule by ID.`).positional(`rule-id`,{type:`string`,description:`Token Validation Rule ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const yt={command:`get <rule-id>`,describe:`Get a token validation rule`,builder:vt,handler:async e=>f({command:`api-security token-validation rules get`,classification:{safeFlags:[`dry-run`]}},e,async()=>{if(e.dryRun){l({command:`cf api-security token-validation rules get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/token_validation/rules/${e[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(e[`rule-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"rule-id":String(e[`rule-id`]??``)},bodyKind:`none`});return}let t=await n(e),r=await s({zone:e.zone},t,{quiet:e.quiet});e.zoneId=r;let i=await p(`Loading`,async()=>t.send(_t,{zone_id:r,rule_id:e[`rule-id`]}));d(i,{successLabel:`Loaded`})})};var bt={method:`GET`,path:t=>e`/zones/${t.zone_id}/token_validation/rules`,query:[`per_page`,`page`,`token_configuration`,`action`,`enabled`,`id`,`rule_id`,`host`,`hostname`]};function xt(e){return e.usage(`$0 api-security token-validation rules list
|
|
89
89
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-
|
|
2
|
+
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-Fl7walZt.mjs";import{t as n}from"./dry-run-B4_5Qb0J.mjs";import{a as r,i,t as a}from"./context-DZ_o-H15.mjs";import{t as o}from"./local-CLMvfqkt.mjs";import{t as s}from"./output-DcDP8hsi.mjs";import{t as c}from"./progress-CKu4TPPI.mjs";import{t as l}from"./run-DURbDvRl.mjs";import"./telemetry-D33WsYG8.mjs";import{r as u,t as d}from"./body-parser-DftnWjJP.mjs";import{n as f}from"./input-validation-D7z60HJH.mjs";import{i as p}from"./prompt-B4fCnTfF.mjs";var m={method:`GET`,path:t=>e`/accounts/${t.account_id}/argo/count_zones_enabled`};function h(e){return e.usage(`$0 argo smart-routing count-zones-enabled-for-account
|
|
3
3
|
|
|
4
4
|
Returns the number of zones that have Argo Smart Routing enabled for the specified account.`).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`count-zones-enabled-for-account`,describe:`Get count of zones with Argo Smart Routing enabled for account`,builder:h,handler:async e=>l({command:`argo smart-routing count-zones-enabled-for-account`,classification:{safeFlags:[`dry-run`]}},e,async()=>{if(e.dryRun){let e=await r();n({command:`cf argo smart-routing count-zones-enabled-for-account`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e??`<account-id>`}/argo/count_zones_enabled`,pathParams:{},bodyKind:`none`});return}let i=await t(e),l=e.local?o:await a();e.accountId=l;let u=await c(`Loading`,async()=>i.send(m,{account_id:l}));s(u,{successLabel:`Loaded`})})};var _={method:`GET`,path:()=>`/user/argo/count_zones_enabled`};function v(e){return e.usage(`$0 argo smart-routing count-zones-enabled-for-user
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-
|
|
2
|
+
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-Fl7walZt.mjs";import{r as n,t as r}from"./body-parser-DftnWjJP.mjs";import{a as i,t as a}from"./context-DZ_o-H15.mjs";import{t as o}from"./dry-run-B4_5Qb0J.mjs";import{n as s}from"./input-validation-D7z60HJH.mjs";import{t as c}from"./local-CLMvfqkt.mjs";import{t as l}from"./run-DURbDvRl.mjs";import{t as u}from"./output-DcDP8hsi.mjs";import{t as d}from"./progress-CKu4TPPI.mjs";import{a as f,n as p}from"./prompt-B4fCnTfF.mjs";import"./telemetry-D33WsYG8.mjs";import{n as m,t as h}from"./raw-fetch-DPl7eKQx.mjs";var g={method:`POST`,path:t=>e`/accounts/${t.account_id}/artifacts/namespaces`,body:`json`,errors:{400:`BadRequestError`,401:`UnauthorizedError`,403:`ForbiddenError`,409:`ConflictError`,500:`InternalServerError`}};function _(e){return e.usage(`$0 artifacts namespaces create
|
|
3
3
|
|
|
4
4
|
Creates an empty Artifacts namespace for an account.`).option(`jurisdiction`,{type:`string`,description:`The jurisdiction field`,choices:[`unrestricted`,`us`,`eu`,`fedramp`],default:`unrestricted`}).coerce(`jurisdiction`,e=>s(e,`jurisdiction`,`text`)).option(`namespace`,{type:`string`,description:`The namespace field`}).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:`create`,describe:`Create a namespace`,builder:_,handler:async e=>l({command:`artifacts namespaces create`,classification:{safeFlags:[`jurisdiction`,`dry-run`]}},e,async()=>{let l=async()=>{e.namespace===void 0&&(e.namespace=await f(`namespace`,`The namespace field`))};if(e.dryRun){e.body===void 0&&await l();let t=await i();o({command:`cf artifacts namespaces create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/artifacts/namespaces`,pathParams:{},bodyKind:`json`,body:e.body===void 0?r({jurisdiction:e.jurisdiction,namespace:s(e.namespace,`namespace`,`text`)}):n(e.body)});return}let p=e.body===void 0?void 0:n(e.body),m=await t(e),h=e.local?c:await a();if(e.accountId=h,e.body!==void 0){let e=p,t=await d(`Creating`,async()=>m.send(g,{body:e,account_id:h}));u(t,{successLabel:`Created`});return}await l();let _=r({jurisdiction:e.jurisdiction,namespace:s(e.namespace,`namespace`,`text`)}),v=await d(`Creating`,async()=>m.send(g,{body:_,account_id:h}));u(v,{successLabel:`Created`})})};var y={method:`DELETE`,path:t=>e`/accounts/${t.account_id}/artifacts/namespaces/${t.namespace}`,response:!1,errors:{400:`BadRequestError`,401:`UnauthorizedError`,403:`ForbiddenError`,404:`NotFoundError`,409:`ConflictError`,500:`InternalServerError`}};function b(e){return e.usage(`$0 artifacts namespaces delete <namespace>
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-
|
|
2
|
+
import"./api-5qkbb5HW.mjs";import{t as e}from"./path-DRw6Y-nd.mjs";import{n as t}from"./auth-Fl7walZt.mjs";import{t as n}from"./dry-run-B4_5Qb0J.mjs";import{a as r,t as i}from"./context-DZ_o-H15.mjs";import{t as a}from"./local-CLMvfqkt.mjs";import{t as o}from"./output-DcDP8hsi.mjs";import{t as s}from"./progress-CKu4TPPI.mjs";import{t as c}from"./run-DURbDvRl.mjs";import"./telemetry-D33WsYG8.mjs";var l={method:`GET`,path:t=>e`/accounts/${t.account_id}/audit_logs`,query:[`id`,`export`,`action.type`,`actor.ip`,`actor.email`,`since`,`before`,`zone.name`,`direction`,`per_page`,`page`,`hide_user_logs`]};function u(e){return e.usage(`$0 audit-logs list
|
|
3
3
|
|
|
4
4
|
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.`).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:`Since`}).option(`before`,{type:`string`,description:`Before`}).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 d={command:`list`,describe:`Get account audit logs`,builder:u,handler:async e=>c({command:`audit-logs list`,classification:{safeFlags:[`export`,`direction`,`hide-user-logs`,`dry-run`]}},e,async()=>{let c={id:e.id,export:e.export,"action.type":e[`action-type`],"actor.ip":e[`actor-ip`],"actor.email":e[`actor-email`],since:e.since,before:e.before,"zone.name":e[`zone-name`],direction:e.direction,per_page:e[`per-page`],page:e.page,hide_user_logs:e[`hide-user-logs`]};if(e.dryRun){let e=await r();n({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 u=await t(e),d=e.local?a:await i();e.accountId=d;let f=await s(`Loading`,async()=>u.send(l,{account_id:d,...c}));o(f,{successLabel:`Loaded`})})},f={command:`audit-logs`,describe:`audit-logs`,builder:e=>e.command(d).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{f as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{r as e}from"./theme-BGHWSKCw.mjs";import"./telemetry-D33WsYG8.mjs";import{a as t,c as n,i as r,n as i,o as a,r as o,s,t as c}from"./login-Pl57NFXW.mjs";import{f as l,i as u,p as d}from"./oauth-CbYuhP6T.mjs";import"./ui-C1lhJqmW.mjs";import{n as f}from"./run-DURbDvRl.mjs";import{t as p}from"./log-LXeTb6Zo.mjs";import{c as m}from"./authentication-error-CFW0YLMA-CyvbCVD8.mjs";import{n as h}from"./schema-cache-DHECPju4.mjs";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./whoami-Cav17gsZ.mjs";const C={command:`logout`,describe:`Log out and remove stored credentials`,handler:async t=>{r(t,`logout`,"Run `cf auth delete <name>` to remove a named profile.");let n=u();n!=="default"&&p.warn(`This directory has profile "${n}" active. ${e.code(`cf auth logout`)} removes the default profile's token, not "${n}". To delete "${n}", run:`,`cf auth delete ${n}`),await l(`default`)}};function w(e){let t=u();return t==="default"?e?`cf auth login --force`:`cf auth login`:`cf auth create ${t}`}function T(t){let n=t?.statusCode;return n===401||n===403?`your login was rejected; run ${e.code(w(!0))} to log in again`:h(t)}const E={command:`scopes [product]`,describe:`Show the OAuth scopes granted to the current login, by product`,builder:e=>e.positional(`product`,{type:`string`,description:`Show the granted permissions in product areas matching this name, such as dns or developer`}).option(`all`,{type:`boolean`,description:`Show every granted permission, grouped by product`,default:!1}).option(`filter`,{type:`string`,description:`Show the granted permissions whose scope contains this term`}),handler:async t=>{if(t[`temporary-account`]||t[`event-code`]!==void 0)throw Error(`--temporary-account and --event-code are not supported by cf auth scopes.`);if(m({allowGlobalAuthKey:!1})!==void 0){p.warn(`${e.code(`CLOUDFLARE_API_TOKEN`)} is set, so its own permissions apply rather than OAuth scopes.`);return}let n=d();if(n?.oauth_token===void 0){p.info(`Not logged in. Run ${e.code(w(!1))} to log in.`);return}let{scopes:r}=n;if(!r){p.info(`This login didn't record its scopes. Run ${e.code(w(!0))} to log in again.`);return}if(!g(r)){p.info(`No product scopes granted. Run ${e.code(w(!0))} to log in with the default scopes.`);return}let i;try{i=await x(async()=>{let{createCommandClient:e}=await import(`./auth-BOAIQNrB.mjs`);return e(t)})}catch(e){p.warn(`Couldn't load Cloudflare's scope catalogue (${T(e)}), so scopes are listed without product groups.`),console.log(r.join(`
|
|
3
|
+
`));return}if(t.product===void 0&&!t.all&&t.filter===void 0){console.log(_(r,i)),p.info(`Run ${e.code(`cf auth scopes <product>`)} to see a product's permissions, or ${e.code(`cf auth scopes --all`)} for every granted product.`);return}let{product:a}=t;a!==void 0&&!v(i).some(e=>y(e,a))?p.info(`No product area matches "${a}". Run ${e.code(`cf auth scopes --filter ${a}`)} to search scope names instead.`):console.log(b(r,i,{product:t.product,filter:t.filter})||e.muted(`No granted scopes match.`))}},D={command:`auth`,describe:`Manage authentication and profiles`,builder:e=>e.command(f(c,{command:`auth login`,classification:i})).command(O(C,`auth logout`)).command(O(S,`auth whoami`,[`json`])).command(O(E,`auth scopes`,[`all`])).command(O(t,`auth create`,[`browser`,`device`])).command(O(s,`auth delete`)).command(O(o,`auth activate`)).command(O(a,`auth deactivate`)).command(O(n,`auth list`)).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function O(e,t,n=[],r){return f(e,{command:t,classification:{safeFlags:n,shortFlagAliases:r}})}export{D as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{D as e}from"./undici-C4huyh7H.mjs";import{L as t}from"./dist-CoYrirmB.mjs";import{t as n}from"./auth-token-vS_OH8l7.mjs";import{a as r,n as i}from"./context-DZ_o-H15.mjs";import{u as a}from"./oauth-CbYuhP6T.mjs";import{n as o}from"./request-headers-DN5TYtJe.mjs";import{i as s,r as c,t as l}from"./api-5qkbb5HW.mjs";const u=6e4;function d(e){return(n,r)=>{if(!process.env.CLOUDFLARE_API_HEADERS)return e(n,r);let i={...r,duplex:`half`},a=new Request(n,i);return t(a.headers),e(a)}}function f(e){return e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||e instanceof ReadableStream}var p={method:`GET`,path:()=>`/accounts`,query:[`name`,`page`,`per_page`,`direction`]},m={method:`GET`,path:()=>`/memberships`,query:[`account.name`,`page`,`per_page`,`order`,`direction`,`name`,`status`]};function h(e){return e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||e instanceof ReadableStream||e instanceof URLSearchParams}function g(e){return Object.keys(e).some(e=>e.toLowerCase()===`content-type`)}async function _(e){let t=e.headers.get(`content-type`)??``;try{return t.includes(`application/json`)?await e.json():await e.text()}catch{return null}}function v(e,t,n){if(n!=null&&n!==``){if(Array.isArray(n))for(let r of n)v(e,t,r);else e.append(t,String(n))}}function y(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))v(t,n,r);return t.toString()}function b(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=y(n??{});return a&&(i.search=a),i.toString()}const x=/* @__PURE__ */ new WeakMap,S=/* @__PURE__ */ new WeakMap;async function C(e,t,n,r={}){let i=e.baseUrl,a=b(n,i,r.query),o={...r.headers},l;r.body!==void 0&&(h(r.body)||typeof r.body==`string`&&g(o)?l=r.body:(o[`Content-Type`]??=`application/json`,l=JSON.stringify(r.body)));let u=r.timeout===void 0&&f(l)?S.get(e):void 0,d=r.timeout??x.get(e)??6e4,p;try{p=await(u??e).fetch(a,{method:t,headers:o,body:l,signal:r.signal},{timeoutInSeconds:r.timeout===void 0?void 0:r.timeout/1e3,abortSignal:r.signal})}catch(e){throw r.signal?.aborted?Error(`Request aborted`):e===`timeout`||e instanceof Error&&e.name===`AbortError`?Error(u?`Request timed out`:`Request timed out after ${d}ms`):e instanceof Error?Error(`Request failed: ${e.message}`):e}if(!p.ok)throw new s({statusCode:p.status,body:await _(p),rawResponse:{status:p.status,statusText:p.statusText,url:p.url||a,headers:p.headers,redirected:p.redirected,type:p.type}});if(p.status===204)return null;let m=p.headers.get(`content-type`)??``;if(!m.includes(`application/json`)&&r.preserveNonJsonBytes)return Buffer.from(await p.arrayBuffer());let v=await p.text();if(v===``)return null;if(!m.includes(`application/json`))return v;let y=JSON.parse(v);if(y.success===!1){let e=y.errors?.map(e=>e.message).filter(Boolean).join(`, `)||`unknown error`;throw new s({message:`API error: ${e}`,statusCode:p.status,body:y})}return`result`in y?c(y.result,y.result_info):y}function w(e){let t={baseUrl:e.baseURL??`https://api.cloudflare.com/client/v4`,auth:async()=>({headers:{Authorization:`Bearer ${typeof e.apiToken==`function`?await e.apiToken():e.apiToken}`}}),headers:e.defaultHeaders,timeoutInSeconds:(e.timeout??6e4)/1e3,maxRetries:0,fetch:e.customApiHeaders===!1?e.fetch??globalThis.fetch:d(e.fetch??globalThis.fetch)},n=new l(t);return x.set(n,e.timeout??6e4),e.timeout===void 0&&S.set(n,new l({...t,timeoutInSeconds:void 0})),n}async function T(t){if(a())return;let s=await r();if(s)return s;try{let r=await n(),a=e({compliance_region:await i()}),s=t-Date.now();if(s<=0)return;let c=w({apiToken:r,baseURL:a,defaultHeaders:o()}),l={timeoutInSeconds:s/1e3,maxRetries:0},[u,d]=await Promise.allSettled([c.send(p,{per_page:50},l),c.send(m,{per_page:50},l)]);if(u.status===`rejected`)return;let f=u.value;if((f.result_info?.total_count??f.result.length)>f.result.length)return;let h=f.result;if(d.status===`fulfilled`){let e=d.value.result??[];if((d.value.result_info?.total_count??e.length)>e.length)return;let t=new Set(e.map(e=>e.account?.id).filter(e=>e!==void 0));h=h.filter(e=>t.has(e.id))}return h.length===1?h[0]?.id:void 0}catch{return}}async function E(t){if(t.dryRun&&a())throw Error(`This command's dry run cannot be used with --temporary-account. Remove --dry-run to run the command for real.`);let r=e({compliance_region:await i()});if(t.local){let{createLocalFetch:e}=await import(`./local-HUPujWMR.mjs`);return w({apiToken:`cf-local-mode-no-auth`,customApiHeaders:!1,baseURL:r,defaultHeaders:o(),fetch:e({persistTo:t.persistTo,apiBaseUrl:r})})}return await n(),w({apiToken:n,baseURL:r,defaultHeaders:o()})}export{T as a,f as c,C as i,d as l,E as n,m as o,y as r,p as s,w as t,u};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{c as e}from"./authentication-error-CFW0YLMA-CyvbCVD8.mjs";import{t}from"./errors-kqU4AkAP.mjs";import{c as n,i as r,l as i,m as a,s as o,u as s}from"./oauth-CbYuhP6T.mjs";async function c(c){if(s())return(await a(c)).apiToken;let l=e({allowGlobalAuthKey:!1});if(l&&`apiToken`in l)return l.apiToken;let u=await n();if(u)return u;if(i())throw Error(`Could not refresh your stored OAuth token. Check your connection and retry, or run 'cf auth login' to authenticate again.`);let d=r();if(d!=="default"){let e=o();if(!e.configs.exists(d)){let n=e.configs.list(),r=n.length>0?` (available: ${n.join(`, `)})`:``;throw new t(`Auth profile "${d}" not found${r}. Run 'cf auth create ${d}' to authenticate it.`)}}throw new t(`No authentication token found.
|
|
3
|
+
|
|
4
|
+
Please set one of the following:
|
|
5
|
+
1. Set the CLOUDFLARE_API_TOKEN environment variable
|
|
6
|
+
2. Run 'cf auth login' to authenticate via OAuth
|
|
7
|
+
|
|
8
|
+
For API tokens, visit: https://dash.cloudflare.com/profile/api-tokens`)}export{c as t};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{C as e,S as t,v as n,y as r}from"./config-WFtvFMMN-DO1DX3tx.mjs";import{C as i,L as a}from"./dist-CoYrirmB.mjs";import{B as o,C as s,D as c,H as l,O as u,k as d,t as f}from"./undici-C4huyh7H.mjs";import{createRequire as p}from"node:module";import{chmodSync as m,existsSync as h,mkdirSync as g,rmSync as _,writeFileSync as v}from"node:fs";import y from"node:path";import ee from"node:url";import b from"node:assert";import te from"node:http";import{TextEncoder as ne}from"node:util";import{createCipheriv as re,createDecipheriv as ie,createHash as x,randomBytes as ae,webcrypto as S}from"node:crypto";import{spawn as oe,spawnSync as C}from"node:child_process";var se=Object.defineProperty,ce=(e,t)=>se(e,`name`,{value:t,configurable:!0}),w=f();let le=!1;function T(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?(!le&&n&&(le=!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`}.\nThis is no longer supported in the current version of Wrangler.
|
|
4
|
+
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\` environment variable.`)),{deprecatedApiToken:c}):{}}const ue=l({variableName:`CLOUDFLARE_API_TOKEN`,deprecatedName:`CF_API_TOKEN`}),de=l({variableName:`CLOUDFLARE_API_KEY`,deprecatedName:`CF_API_KEY`}),fe=l({variableName:`CLOUDFLARE_EMAIL`,deprecatedName:`CF_EMAIL`});function pe(e){if(e?.allowGlobalAuthKey??!0){let e=de(),t=fe();if(e&&t)return{authKey:e,authEmail:t}}let t=ue();if(t)return{apiToken:t}}function me(e){let t=pe(e);if(t)return t;let n=T({storage:e.storage,warningLogger:e.warningLogger});if(n.deprecatedApiToken)return{apiToken:n.deprecatedApiToken};if(n.accessToken?.value)return{apiToken:n.accessToken.value}}function he(t){let n=me(t);if(!n)throw new e(`No API token found.`,{telemetryMessage:`user auth missing api token`});return n}const ge=/^[A-Za-z0-9_-]+$/;function _e(t,n){if(!ge.test(t))throw new e(`Invalid account ID "${t}" ${n}. Account IDs may only contain alphanumeric characters, hyphens, and underscores.`,{telemetryMessage:`user account id invalid characters`});return t}const ve=l({variableName:`CLOUDFLARE_AUTH_PROFILE`}),E=l({variableName:`WRANGLER_AUTH_DOMAIN`,defaultValue:()=>u()===`staging`?`dash.staging.cloudflare.com`:`dash.cloudflare.com`}),ye=l({variableName:`WRANGLER_AUTH_URL`,defaultValue:()=>`https://${E()}/oauth2/auth`}),D=l({variableName:`WRANGLER_TOKEN_URL`,defaultValue:()=>`https://${E()}/oauth2/token`}),be=l({variableName:`WRANGLER_REVOKE_URL`,defaultValue:()=>`https://${E()}/oauth2/revoke`}),xe=l({variableName:`CLOUDFLARE_ACCOUNT_ID`,deprecatedName:`CF_ACCOUNT_ID`});function Se(){let e=xe();if(e)return _e(e,"set in the `CLOUDFLARE_ACCOUNT_ID` environment variable")}function Ce(){return`https://${E()}/oauth2/device/auth`}const we=l({variableName:`CLOUDFLARE_ACCESS_CLIENT_ID`}),Te=l({variableName:`CLOUDFLARE_ACCESS_CLIENT_SECRET`}),Ee=l({variableName:`WRANGLER_CF_AUTHORIZATION_TOKEN`}),De=o({variableName:`CLOUDFLARE_AUTH_USE_KEYRING`}),Oe={},O=/* @__PURE__ */ new Map;function ke(e,t){let n=new URL(`https://${e}`);return t&&n.searchParams.set(`cf_workers_preview_token`,t),n.toString()}async function Ae(e,t,n){t.debug(`Checking if domain has Access enabled:`,e);let r=JSON.stringify([e,!!n]);if(O.has(r))return t.debug(`Using cached Access switch for:`,e,O.get(r)),O.get(r)??!1;t.debug(`Access switch not cached for:`,e);try{let i=new AbortController,a=setTimeout(()=>{i.abort()},1e3),o=await(0,w.fetch)(ke(e,n),{redirect:`manual`,signal:i.signal});clearTimeout(a);let s=!!(o.status===302&&o.headers.get(`location`)?.includes(`cloudflareaccess.com`));return(s||!n)&&(t.debug(`Caching access switch for:`,e),O.set(r,s)),s}catch{return t.debug(`Access probe failed for:`,e),!1}}async function je(t,n){let r=n.logger,a=we(),o=Te();if(a&&o)return r.debug(`Using Access Service Token headers for domain:`,t),{"CF-Access-Client-Id":a,"CF-Access-Client-Secret":o};if((a!==void 0||o!==void 0)&&r.warn(`Both CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET must be set to use Access Service Token authentication. Only ${a===void 0?`CLOUDFLARE_ACCESS_CLIENT_SECRET`:`CLOUDFLARE_ACCESS_CLIENT_ID`} was found.`),!await Ae(t,r,n.previewToken))return{};if(r.debug(`Getting Access headers for domain:`,t),Oe[t])return r.debug(`Using cached Access headers for domain:`,t),Oe[t];if((n.isNonInteractiveOrCI??i)())throw new e(`The domain "${t}" is behind Cloudflare Access, but no Access Service Token credentials were found and the current environment is non-interactive.\nSet the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET environment variables to authenticate with an Access Service Token.\nSee https://developers.cloudflare.com/cloudflare-one/access-controls/service-credentials/service-tokens/`,{telemetryMessage:`user access missing service token non interactive`});r.debug(`Spawning cloudflared to get Access token for domain:`);let s=await Me(ke(t,n.previewToken),n.signal);if(s.error)throw new e(`To use ${n.cliDisplayName} 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 c=s.stdout;r.debug(`cloudflared output:`,c);let l=c.match(/fetched your token:\n\n(.*)/m);if(l&&l.length>=2){let e={Cookie:`CF_Authorization=${l[1]}`};return Oe[t]=e,r.debug(`Caching Access headers for domain:`,t),e}throw Error(`Failed to authenticate with Cloudflare Access`)}function Me(e,t){return new Promise((n,r)=>{let i=oe(`cloudflared`,[`access`,`login`,e],{signal:t}),a=[];i.stdout.on(`data`,e=>a.push(e)),i.stderr.resume();let o=()=>i.kill();process.once(`exit`,o),i.on(`error`,e=>{process.removeListener(`exit`,o),t?.aborted?r(e):n({error:e,stdout:``})}),i.on(`close`,()=>{process.removeListener(`exit`,o),t?.aborted?r(t.reason??/* @__PURE__ */ Error(`The operation was aborted`)):n({stdout:Buffer.concat(a).toString()})})})}async function Ne(e){let t=Ee();return t===void 0?je(E(),e):(e.logger.debug(`Using WRANGLER_CF_AUTHORIZATION_TOKEN from environment`),{Cookie:`CF_Authorization=${t}`})}function k(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(`
|
|
5
|
+
[ ]{`+Math.min.apply(Math,r)+`}`,`g`);n=n.map(function(e){return e.replace(i,`
|
|
6
|
+
`)})}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(`
|
|
7
|
+
`)&&(o=String(e).split(`
|
|
8
|
+
`).map(function(e,t){return t===0?e:``+i+e}).join(`
|
|
9
|
+
`)),a+=o+n[t+1]}),a}var A=class extends e{code;description;uri;toString(){return`ErrorOAuth2`}},Pe=class extends A{toString(){return`ErrorUnknown`}},Fe=class extends A{toString(){return`ErrorAuthServerUnreachable`}},Ie=class extends A{toString(){return`ErrorNoAuthCode`}},Le=class extends A{toString(){return`ErrorInvalidReturnedStateParam`}},Re=class extends A{toString(){return`ErrorInvalidJson`}},ze=class extends A{toString(){return`ErrorInvalidScope`}},Be=class extends A{toString(){return`ErrorInvalidRequest`}},Ve=class extends A{toString(){return`ErrorInvalidToken`}},j=class extends A{toString(){return`ErrorAuthenticationGrant`}},He=class extends j{toString(){return`ErrorUnauthorizedClient`}},Ue=class extends j{toString(){return`ErrorAccessDenied`}},We=class extends j{toString(){return`ErrorUnsupportedResponseType`}},Ge=class extends j{toString(){return`ErrorServerError`}},Ke=class extends j{toString(){return`ErrorTemporarilyUnavailable`}},qe=class extends A{toString(){return`ErrorAccessTokenResponse`}},Je=class extends qe{toString(){return`ErrorInvalidClient`}},Ye=class extends qe{toString(){return`ErrorInvalidGrant`}},Xe=class extends qe{toString(){return`ErrorUnsupportedGrantType`}};function Ze(e,t,n){let r=`OAuth error: ${M(e)}`;return t&&(r+=`\n ${M(t)}`),n&&(r+=`\n See: ${M(n)}`),r}function M(e){return e.replace(/[\u0000-\u001f\u007f-\u009f]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function N(e,t,n){let r=Ze(e,t,n),i;switch(e){case`invalid_request`:i=new Be(r,{telemetryMessage:`user oauth invalid request`});break;case`invalid_grant`:i=new Ye(r,{telemetryMessage:`user oauth invalid grant`});break;case`unauthorized_client`:i=new He(r,{telemetryMessage:`user oauth unauthorized client`});break;case`access_denied`:i=new Ue(r,{telemetryMessage:`user oauth access denied`});break;case`unsupported_response_type`:i=new We(r,{telemetryMessage:`user oauth unsupported response type`});break;case`invalid_scope`:i=new ze(r,{telemetryMessage:`user oauth invalid scope`});break;case`server_error`:i=new Ge(r,{telemetryMessage:`user oauth server error`});break;case`temporarily_unavailable`:i=new Ke(r,{telemetryMessage:`user oauth temporarily unavailable`});break;case`invalid_client`:i=new Je(r,{telemetryMessage:`user oauth invalid client`});break;case`unsupported_grant_type`:i=new Xe(r,{telemetryMessage:`user oauth unsupported grant type`});break;case`invalid_json`:i=new Re(r,{telemetryMessage:`user oauth invalid json`});break;case`invalid_token`:i=new Ve(r,{telemetryMessage:`user oauth invalid token`});break;default:i=new Pe(r,{telemetryMessage:`user oauth unknown error`})}return i.code=e,i.description=t,i.uri=n,i}const Qe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~`;function $e(e){let t=btoa(e);return t=t.replace(/\+/g,`-`),t=t.replace(/\//g,`_`),t=t.replace(/=/g,``),t}async function et(){let e=/* @__PURE__ */ new Uint32Array(96);S.getRandomValues(e);let t=$e(Array.from(e).map(e=>Qe[e%66]).join(``)),n=await S.subtle.digest(`SHA-256`,new ne().encode(t)),r=new Uint8Array(n),i=``,a=r.byteLength;for(let e=0;e<a;e++)i+=String.fromCharCode(r[e]);return{codeChallenge:$e(i),codeVerifier:t}}const tt=3e4;function nt(e,t,n){let r=e.state;if(!t.stateQueryParam||r!==t.stateQueryParam)throw n.warn(`Received query string parameter doesn't match the one sent! Possible malicious activity somewhere.`),new Le(``,{telemetryMessage:`user oauth invalid returned state`});if(e.error)throw N(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 i=e.code;return i?(b(!Array.isArray(i)),t.authorizationCode=i,t.hasAuthCodeBeenExchangedForAccessToken=!1,!0):!1}async function rt(e,t,n,r,i){let{codeChallenge:a,codeVerifier:o}=await et(),s=i.generateRandomState(32);return Object.assign(r,{codeChallenge:a,codeVerifier:o,stateQueryParam:s}),i.generateAuthUrl({authUrl:ye(),clientId:t,scopes:e,stateQueryParam:s,codeChallenge:a,redirectUri:n})}async function it(e,t,n,r,i){r||e.warn(`No refresh token is present.`);let a=await ot(new URLSearchParams({grant_type:`refresh_token`,refresh_token:r?.value??``,client_id:n}),e,t,i);if(a.status>=400){let t;try{t=await P(a,e)}catch(t){e.error(t)}throw t===void 0?new Pe(`Failed to parse Error from exchangeRefreshTokenForAccessToken`,{telemetryMessage:`user oauth refresh token exchange parse error`}):typeof t==`string`?Error(t):t}try{let t=await P(a,e);if(`error`in t)throw t.error;let{access_token:n,expires_in:i,refresh_token:o,scope:s}=t;return{token:{value:n,expiry:new Date(Date.now()+i*1e3).toISOString()},scopes:s?s.split(` `):[],refreshToken:o?{value:o}:r}}catch(e){throw typeof e==`string`?N(e):e}}async function at(e,t,n,r,i,a){let{authorizationCode:o,codeVerifier:s=``}=e;s?o||t.warn(`No authorization grant code is being passed.`):t.warn(`No code verifier is being sent.`);let c=await ot(new URLSearchParams({grant_type:`authorization_code`,code:o??``,redirect_uri:i,client_id:r,code_verifier:s}),t,n,a);if(!c.ok){let{error:e}=await P(c,t);throw e===`invalid_grant`&&t.log(`Expired! Auth code or refresh token needs to be renewed.`),N(e)}let l=await P(c,t);if(`error`in l)throw N(l.error);let{access_token:u,expires_in:d,refresh_token:f,scope:p}=l;return e.hasAuthCodeBeenExchangedForAccessToken=!0,{token:{value:u,expiry:new Date(Date.now()+d*1e3).toISOString()},scopes:p?p.split(` `):[],refreshToken:f?{value:f}:void 0}}async function ot(e,t,n,r){let i={"Content-Type":`application/x-www-form-urlencoded`};if(t.debug(`fetching auth token`,`grant_type=${e.get(`grant_type`)??`<unknown>`}`),await Ae(E(),t)){t.debug(`Using Cloudflare Access to get an access token for the auth request`);let e=await Ne({logger:t,isNonInteractiveOrCI:n,cliDisplayName:r});Object.assign(i,e)}t.debug(`Fetching auth token from`,D());try{let n=await(0,w.fetch)(D(),{method:`POST`,body:e.toString(),headers:i,signal:AbortSignal.timeout(tt)});return n.ok||t.debug(`Failed to fetch auth token:`,n.status,n.statusText),n}catch(e){t.debug(`Failed to fetch auth token:`,e);let n=e?.cause,r=e?.name===`TimeoutError`?` (timed out after ${tt/1e3} seconds)`:typeof n?.code==`string`?` (${n.code})`:``;throw new Fe(`Could not reach the Cloudflare auth server at ${D()}${r}.`,{cause:e,telemetryMessage:`user oauth token endpoint unreachable`})}}async function P(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
|
|
10
|
+
|
|
11
|
+
`,n),Error(`Invalid JSON in response: status: ${e.status} ${e.statusText}`,{cause:r})}}function st(e,t){let n=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),r=t.code?`<p>Code: <code>${n(t.code)}</code></p>`:``,i=t.description?`<p class="detail">${n(t.description)}</p>`:``,a=n(e);return k`
|
|
12
|
+
<!doctype html>
|
|
13
|
+
<html lang="en">
|
|
14
|
+
<head>
|
|
15
|
+
<meta charset="utf-8" />
|
|
16
|
+
<title>${a} login failed</title>
|
|
17
|
+
<style>
|
|
18
|
+
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; }
|
|
19
|
+
h1 { color: #c12d3f; }
|
|
20
|
+
code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
|
|
21
|
+
p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
|
|
22
|
+
</style>
|
|
23
|
+
</head>
|
|
24
|
+
<body>
|
|
25
|
+
<h1>${a} login failed</h1>
|
|
26
|
+
<p>The Cloudflare OAuth provider returned an error.</p>
|
|
27
|
+
${r}
|
|
28
|
+
${i}
|
|
29
|
+
<p>You can close this tab and return to your terminal for more details.</p>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
|
32
|
+
`}async function ct(t,n,r,i){let a=await rt(t.scopes,t.clientId,t.redirectUri,n,i),o=new URL(t.redirectUri).pathname,s,c,l=new Promise((t,n)=>{c=setTimeout(()=>{s.close(),clearTimeout(c),n(new e(`Timed out waiting for authorization code, please try again.`,{telemetryMessage:`user oauth authorization timeout`}))},12e4)}),u=new Promise((i,a)=>{s=te.createServer(async(l,u)=>{function d(e,t){clearTimeout(c),u.writableEnded||u.end(),s.close(n=>{t||n?a(t||n):(b(e),i(e))})}function f(e){u.writeHead(400,{"Content-Type":`text/html; charset=utf-8`}),u.end(st(r.cliDisplayName,e))}b(l.url,`This request doesn't have a URL`);let{pathname:p,query:m}=ee.parse(l.url,!0);if(l.method!==`GET`)return u.end(`OK`);switch(p){case o:{let i=!1;try{i=nt(m,n,r.logger)}catch(n){if(n instanceof Le){f({description:`This callback does not match the pending login. Return to the authorization page to continue.`});return}if(n instanceof Ue){u.writeHead(307,{Location:t.denied.url}),u.end(()=>{d(null,new e(t.denied.error,{telemetryMessage:`user oauth consent denied`}))});return}let r=n;f({code:r.code,description:r.description??r.message}),d(null,r);return}if(!i){let e=`The Cloudflare OAuth provider did not return an authorisation code.`;f({description:e}),d(null,new Ie(e,{telemetryMessage:`user oauth missing auth code`}));return}try{let e=await at(n,r.logger,r.isNonInteractiveOrCI,t.clientId,t.redirectUri,r.cliDisplayName);u.writeHead(307,{Location:t.granted.url}),u.end(()=>{d(e)})}catch(e){let t=e,n=t instanceof A;f({code:n?t.code:void 0,description:(n?t.description:void 0)??t.message??`Failed to exchange the authorisation code for an access token.`}),d(null,t)}return}}});let l=new URL(t.redirectUri),u=Number(l.port||(l.protocol===`https:`?443:80));(l.hostname!==t.callbackHost||u!==t.callbackPort)&&(r.logger.log(`Temporary login server listening on ${t.callbackHost}:${t.callbackPort}`),r.logger.log(`Note that the OAuth login page will always redirect to \`${t.redirectUri}\`.\nIf 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.`)),s.once(`error`,n=>{clearTimeout(c),n.code===`EADDRINUSE`?a(new e(`The OAuth callback server could not bind to ${t.callbackHost}:${t.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`})):a(n)}),s.listen(t.callbackPort,t.callbackHost)});return t.browser?(r.logger.log(`Opening a link in your default browser: ${a}`),await r.openInBrowser(a)):r.logger.log(`Visit this link to authenticate: ${a}`),Promise.race([l,u])}const lt=({verificationUri:e,userCode:t})=>{let n=new URL(e);return n.searchParams.set(`user_code`,t),n.toString()};function ut(e){try{return new URL(e)}catch{return}}function dt(t,n){let r=ut(t),i=ut(`https://${n.authDomain}`);if(r===void 0||i===void 0||r.protocol!==`https:`||r.username!==``||r.password!==``||r.host!==i.host)throw new e(`The authorization server returned an untrusted \`${n.field}\`: ${t}\nExpected an \`https\` URL on \`${n.authDomain}\`. Refusing to display or open it.`,{telemetryMessage:`user device-flow untrusted verification url`})}function F(e,t){if(typeof e!=`object`||!e)return;let n=e[t];return typeof n==`string`&&n!==``?n:void 0}function ft(e,t){if(typeof e!=`object`||!e)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)&&n>0?n:void 0}function pt(e,t){let n=`HTTP ${e.status} ${e.statusText}`.trim(),r=F(t,`error_description`);return r?`${n}: ${r}`:n}function mt(e){return e>=500||e===429}function ht(e){let t=F(e,`device_code`),n=F(e,`user_code`),r=F(e,`verification_uri`),i=ft(e,`expires_in`);if(t&&n&&r&&i!==void 0)return{device_code:t,user_code:n,verification_uri:r,verification_uri_complete:F(e,`verification_uri_complete`),expires_in:i,interval:ft(e,`interval`)}}async function gt(e,t){let n=await e.text();try{return JSON.parse(n)}catch(r){throw n.match(/<!DOCTYPE html>/)&&(t.debug(`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.debug(`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
|
|
33
|
+
|
|
34
|
+
`,n),Error(`Invalid JSON in response: status: ${e.status} ${e.statusText}`,{cause:r})}}async function _t(e,t,n){let r={"Content-Type":`application/x-www-form-urlencoded`};return await Ae(E(),e)&&(e.debug(`Using Cloudflare Access to get an access token for the device authorization request`),Object.assign(r,await Ne({logger:e,isNonInteractiveOrCI:t,cliDisplayName:n}))),r}async function vt(t,n,r,i,a){let o=new URLSearchParams({client_id:n,scope:[...t,`offline_access`].join(` `)}),s=await _t(r,i,a),c=Ce();r.debug(`Fetching device authorization from`,c);let l=await(0,w.fetch)(c,{method:`POST`,body:o.toString(),headers:s});if(!l.ok){let e=await gt(l,r).catch(()=>void 0);throw N(e&&typeof e==`object`&&`error`in e?String(e.error):`HTTP ${l.status} ${l.statusText}`)}let u=await gt(l,r),d=ht(u);if(d===void 0)throw r.debug(`Unusable device authorization response body:`,u),new e(`The device authorization endpoint returned a response that could not be interpreted (${pt(l,u)}).\nEnable debug logging to see the full response.`,{telemetryMessage:`user device-flow unusable device authorization response`});return d}async function yt(e,t,n,r,i){let a=await ot(new URLSearchParams({grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:e,client_id:t}),n,r,i),o=await gt(a,n),s=F(o,`error`);if(s!==void 0)return{kind:`oauth-error`,error:s};let c=F(o,`access_token`),l=ft(o,`expires_in`);return!a.ok||c===void 0||l===void 0?(n.debug(`Unusable token response body:`,o),{kind:`unexpected`,detail:pt(a,o),retryable:!a.ok&&mt(a.status)}):{kind:`token`,grant:{access_token:c,expires_in:l,refresh_token:F(o,`refresh_token`),scope:F(o,`scope`)}}}function bt(e){return new Promise(t=>setTimeout(t,e*1e3))}async function xt(t,n){let{logger:r,openInBrowser:i,isNonInteractiveOrCI:a}=n,o=await vt(t.scopes,t.clientId,r,a,n.cliDisplayName),s=E();dt(o.verification_uri,{field:`verification_uri`,authDomain:s}),o.verification_uri_complete!==void 0&&dt(o.verification_uri_complete,{field:`verification_uri_complete`,authDomain:s});let c=o.verification_uri_complete??lt({verificationUri:o.verification_uri,userCode:o.user_code}),l=Math.min(o.expires_in,300);r.log(k`
|
|
35
|
+
To authorize ${n.cliDisplayName}, please visit:
|
|
36
|
+
|
|
37
|
+
${o.verification_uri}
|
|
38
|
+
|
|
39
|
+
and enter the code:
|
|
40
|
+
|
|
41
|
+
${o.user_code}
|
|
42
|
+
|
|
43
|
+
You have ${St(l)} to approve this request.
|
|
44
|
+
`),t.browser&&(r.log(`\nOpening a link in your default browser: ${c}`),await i(c));let u=Date.now()+l*1e3,d=Math.max(o.interval??1,1),f=!0,p;for(;Date.now()<u;){f||await bt(d),f=!1;let i;try{i=await yt(o.device_code,t.clientId,r,a,n.cliDisplayName)}catch(e){r.debug(`Ignoring transient error while polling for token:`,e),p=e instanceof Error?e.message:String(e);continue}if(i.kind===`unexpected`){if(!i.retryable)throw new e(`The token endpoint returned a response that could not be interpreted (${i.detail}).\nEnable debug logging to see the full response.`,{telemetryMessage:`user device-flow unusable token response`});r.debug(`Ignoring transient response while polling for token:`,i.detail),p=i.detail;continue}if(p=void 0,i.kind===`oauth-error`)switch(i.error){case`authorization_pending`:continue;case`slow_down`:d+=5;continue;case`access_denied`:throw new e(`Consent denied. You must grant consent to ${n.cliDisplayName} in order to login.\nIf you don't want to do this consider passing an API token via the \`CLOUDFLARE_API_TOKEN\` environment variable.`,{telemetryMessage:`user device-flow consent denied`});case`expired_token`:throw new e(`Device code expired before the request was approved. Please run \`${n.deviceLoginCommand}\` again to obtain a new code.`,{telemetryMessage:`user device-flow code expired`});default:throw N(i.error)}let{grant:s}=i;return{token:{value:s.access_token,expiry:new Date(Date.now()+s.expires_in*1e3).toISOString()},scopes:s.scope?s.scope.split(` `):[],refreshToken:s.refresh_token?{value:s.refresh_token}:void 0}}throw p===void 0?new e(`Device authorization timed out after ${St(l)}. Please run \`${n.deviceLoginCommand}\` again to obtain a new code.`,{telemetryMessage:`user device-flow authorization timeout`}):new e(`Gave up waiting for device authorization: the token endpoint kept returning responses that could not be interpreted (last: ${p}).\nEnable debug logging to see the full response, then run \`${n.deviceLoginCommand}\` to try again.`,{telemetryMessage:`user device-flow poll failed`})}function St(e){if(e<60)return`${e} seconds`;let t=Math.floor(e/60),n=t===1?`minute`:`minutes`,r=e%60;return r===0?`${t} ${n}`:r==59?`${t+1} ${n}`:`${t} ${n} and ${r} ${r===1?`second`:`seconds`}`}const Ct=({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`;function wt(e){let t=new Uint32Array(e);return S.getRandomValues(t),Array.from(t).map(e=>Qe[e%66]).join(``)}function Tt(e,t,n){let r=Array(t+1),i=x(`sha256`).update(e).digest();r[0]=i;for(let e=0;e<t;e++){for(let e=0;e<n;e++)i=x(`sha256`).update(i).digest();r[e+1]=i}return r}function Et(e){return Buffer.concat(e).toString(`base64`)}function Dt(e){let t=Tt(Buffer.from(e.seed,`base64url`),e.k,e.g);return{challengeToken:e.challengeToken,solution:{checkpoints:Et(t)}}}const I={termsOfService:`https://www.cloudflare.com/terms/`,privacyPolicy:`https://www.cloudflare.com/privacypolicy/`},Ot=`You must accept Cloudflare's Terms of Service (${I.termsOfService}) and Privacy Policy (${I.privacyPolicy}) in order to continue. By typing "yes", you agree to these terms. Type "yes" to continue.`,kt=`Continuing means you accept Cloudflare's Terms of Service (${I.termsOfService}) and Privacy Policy (${I.privacyPolicy}).`,At=/* @__PURE__ */ new Map([[1035,{message:`The event code is malformed. Check it and try again.`,telemetryMessage:`deploy temporary event code invalid`}],[1036,{message:`The event code was not found. Check it and try again.`,telemetryMessage:`deploy temporary event not found`}],[1037,{message:`This event has not started yet.`,telemetryMessage:`deploy temporary event not started`}],[1038,{message:`This event has ended.`,telemetryMessage:`deploy temporary event expired`}],[1039,{message:`This event is disabled. Contact the event organizer.`,telemetryMessage:`deploy temporary event disabled`}],[1040,{message:`This event has no temporary accounts remaining.`,telemetryMessage:`deploy temporary event exhausted`}],[1041,{message:`The event account could not be prepared. Try again later or contact the event organizer.`,telemetryMessage:`deploy temporary event provisioning unavailable`,fatal:!0}]]);function jt(e){if(typeof e!=`object`||!e||!(`errors`in e))return;let{errors:t}=e;if(!Array.isArray(t)||t.length===0)return;let[n]=t;if(typeof n==`object`&&n&&`code`in n)return typeof n.code==`number`?n.code:void 0}async function Mt(n){let r;try{r=await n.json()}catch{return}let i=jt(r);if(i===void 0)return;let a=At.get(i);if(!a)return;let o={telemetryMessage:a.telemetryMessage};return a.fatal?new t(a.message,o):new e(a.message,o)}function Nt(){return`${c(s)}/provisioning/previews`}function Pt(){return`${Nt()}/challenge`}function Ft(e){let t=Date.parse(e);return!Number.isNaN(t)&&t>Date.now()}function It(e){let t=e.read();if(t&&t.account?.id&&t.account?.apiToken&&t.account?.name&&t.claim?.url&&Ft(t.account?.expiresAt??``)&&Ft(t.claim?.expiresAt??``))return t}async function Lt(e,n){let r=new w.Headers({"Content-Type":`application/json`});a(r);let i=await(0,w.fetch)(Pt(),{method:`POST`,headers:r,body:`{}`});if(!i.ok)throw new t(`Failed to request a proof-of-work challenge (${i.status} ${i.statusText}).`,{telemetryMessage:`deploy temporary account challenge failed`});let o;try{o=await i.json()}catch{throw new t(`Failed to request a proof-of-work challenge. Received an invalid response (${i.status} ${i.statusText}).`,{telemetryMessage:`deploy temporary account challenge invalid response`})}let{challengeToken:s,seed:c,k:l,g:u}=o.result??{};if(s===void 0||c===void 0||l===void 0||u===void 0)throw new t(`Failed to request a proof-of-work challenge because the response was missing required fields.`,{telemetryMessage:`deploy temporary account challenge incomplete`});if(!Number.isInteger(l)||!Number.isInteger(u)||l<=0||u<=0||l*u>64e6||Buffer.from(c,`base64url`).length!==32)throw new t(`The proof-of-work challenge is not supported by this version of ${n}.`,{telemetryMessage:`deploy temporary account challenge difficulty unsupported`});return e.log(`Solving proof-of-work challenge…`),Dt({challengeToken:s,seed:c,k:l,g:u})}async function Rt(e,n,r=`Wrangler`){let i=await Lt(e,r),o=new w.Headers({"Content-Type":`application/json`});a(o);let s=await(0,w.fetch)(Nt(),{method:`POST`,headers:o,body:JSON.stringify({termsOfService:I.termsOfService,privacyPolicy:I.privacyPolicy,acceptTermsOfService:`yes`,challengeToken:i.challengeToken,solution:i.solution,...n?.eventCode?{eventCode:n.eventCode}:{}})});if(!s.ok){if(n?.eventCode){let e=await Mt(s);if(e)throw e}throw new t(`Failed to create a temporary preview account (${s.status} ${s.statusText}).`,{telemetryMessage:`deploy temporary account create failed`})}let c;try{c=await s.json()}catch{throw new t(`Failed to create a temporary preview account. Received an invalid response (${s.status} ${s.statusText}).`,{telemetryMessage:`deploy temporary account invalid response`})}let l=c.result,u=l?.account?.id,d=l?.account?.name,f=l?.account?.apiToken,p=l?.account?.expiresAt,m=l?.claim?.url,h=l?.claim?.expiresAt,g=l?.eventCodeAccepted;if(u===void 0||d===void 0||f===void 0||p===void 0||m===void 0||h===void 0)throw new t(`Failed to create a temporary preview account because the response was missing required fields.`,{telemetryMessage:`deploy temporary account response incomplete`});if(n?.eventCode&&g!==!0)throw new t(`Failed to create a temporary preview account because the response did not acknowledge the event code.`,{telemetryMessage:`deploy temporary event acknowledgement missing`});return{account:{id:u,name:d,apiToken:f,expiresAt:p},claim:{url:m,expiresAt:h}}}async function zt(t){let n=It(t.storage);if(n){if(t.request?.eventCode)throw new e(`A temporary account is already cached. Rerun without --event-code to reuse it, or run \`${t.logoutCommand??`wrangler logout`}\` and retry to create an account for this event.`,{telemetryMessage:`deploy temporary event cache conflict`});return{account:n,cached:!0}}if(!await t.prompt(Ot,kt))throw new e(`You must accept Cloudflare's Terms of Service (${I.termsOfService}) and Privacy Policy (${I.privacyPolicy}) to use ${t.temporaryAccountFlag??`--temporary-account`}.`,{telemetryMessage:`user temporary terms not accepted`});let r=await Rt(t.temporaryAccountLogger,t.request,t.cliDisplayName);return t.storage.write(r),{account:r,cached:!1}}function Bt(t){let n={},r={generateAuthUrl:t.generateAuthUrl??Ct,generateRandomState:t.generateRandomState??wt},i=`default`;function a(e){return t.storageFactory(e??i)}let o=()=>typeof t.clientId==`function`?t.clientId():t.clientId,s=t.consent,c,l,u=new URL(t.redirectUri),f=u.hostname,p=Number(u.port);async function m(i){if(t.hasEnvCredentials())return t.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 c=d(i.complianceConfig);if(c===`fedramp_high`){let t=i.complianceConfig?.compliance_region?"`compliance_region` configuration property":"`CLOUDFLARE_API_ENVIRONMENT` environment variable";throw new e(k`
|
|
45
|
+
OAuth login is not supported in the \`${c}\` compliance region.
|
|
46
|
+
Please use a Cloudflare API token (\`CLOUDFLARE_API_TOKEN\` environment variable) or remove the ${t}.
|
|
47
|
+
`,{telemetryMessage:`user login unsupported compliance region`})}let l;return i.device?(t.logger.log(`Attempting to login via OAuth Device Authorization Grant...`),l=await xt({browser:i.browser??!0,scopes:i.scopes,clientId:o()},t)):(t.logger.log(`Attempting to login via OAuth...`),l=await ct({browser:i.browser??!0,scopes:i.scopes,clientId:o(),redirectUri:t.redirectUri,denied:s.denied,granted:s.granted,callbackHost:i.callbackHost??f,callbackPort:i.callbackPort??p},n,t,r)),a(i.profile).write({oauth_token:l.token?.value??``,expiration_time:l.token?.expiry,refresh_token:l.refreshToken?.value,scopes:l.scopes}),t.logger.log(`Successfully logged in.`),x(),t.purgeOnLoginOrLogout?.(),!0}function h(e){if(t.hasEnvCredentials())return!1;let{accessToken:n}=T({warningLogger:t.logger,storage:a(e)});return!!(n&&/* @__PURE__ */ new Date>=new Date(n.expiry))}async function g(e){let n=a(e);try{let e=T({warningLogger:t.logger,storage:n});if(e.accessToken&&/* @__PURE__ */ new Date<new Date(e.accessToken.expiry))return`refreshed`;let{token:{value:r,expiry:i}={value:``,expiry:``},refreshToken:{value:a}={},scopes:s}=await it(t.logger,t.isNonInteractiveOrCI,o(),e.refreshToken,t.cliDisplayName);return n.write({oauth_token:r,expiration_time:i,refresh_token:a,scopes:s}),`refreshed`}catch(e){return t.logger.debug(`Token refresh failed: ${e instanceof Error?e.message:String(e)}`),e instanceof Fe||e instanceof Error&&e.name===`TimeoutError`?`unreachable`:`rejected`}}async function _(e){if(t.hasEnvCredentials())return{loggedIn:!0};let n=T({warningLogger:t.logger,storage:a(e.profile)});if(!n.accessToken&&!n.deprecatedApiToken)return t.isNonInteractiveOrCI()?{loggedIn:!1,reason:`no-credentials-non-interactive`}:await m(e)?{loggedIn:!0}:{loggedIn:!1,reason:`no-credentials-login-failed`};if(h(e.profile)){let n=await g(e.profile);return n===`refreshed`?{loggedIn:!0}:n===`unreachable`?{loggedIn:!1,reason:`token-refresh-unreachable`}:t.isNonInteractiveOrCI()?{loggedIn:!1,reason:`token-expired-non-interactive`}:await m(e)?{loggedIn:!0}:{loggedIn:!1,reason:`token-expired-login-failed`}}return{loggedIn:!0}}async function v(e){let n=x();if(t.hasEnvCredentials()){t.logger.log(`You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log out.`);return}let r=T({warningLogger:t.logger,storage:a(e)}).refreshToken;if(!r){t.logger.log(n?`Cleared temporary preview account.`:`Not logged in, exiting...`);return}let i=`client_id=${encodeURIComponent(o())}&token_type_hint=refresh_token&token=${encodeURIComponent(r.value||``)}`;await(await(0,w.fetch)(be(),{method:`POST`,body:i,headers:{"Content-Type":`application/x-www-form-urlencoded`}})).text(),a(e).clear(),t.logger.log(`Successfully logged out.`),t.purgeOnLoginOrLogout?.()}async function y(){let e=T({warningLogger:t.logger,storage:a()});if(e.accessToken){if(e.accessToken&&/* @__PURE__ */ new Date>=new Date(e.accessToken.expiry)){if(await g()!==`refreshed`)return;e=T({warningLogger:t.logger,storage:a()})}return e.accessToken?.value}}function ee(){return l?{apiToken:l.account.apiToken}:me({storage:a(),warningLogger:t.logger,allowGlobalAuthKey:t.allowGlobalAuthKey})}function b(){return l?{apiToken:l.account.apiToken}:he({storage:a(),warningLogger:t.logger,allowGlobalAuthKey:t.allowGlobalAuthKey})}function te(e,n){c=e&&t.temporary!==void 0?n??{}:void 0,l=void 0}function ne(){return c!==void 0}function re(){return l}async function ie(){if(!t.temporary)throw new e(`Temporary preview accounts are not supported by ${t.cliDisplayName}.`,{telemetryMessage:`user temporary account unsupported`});let n=await zt({...t.temporary,...c?{request:c}:{}});return l=n.account,n}function x(){return l=void 0,t.temporary?.storage.clear()??!1}function ae(e){i=e}function S(){return i}function oe(){return T({warningLogger:t.logger,storage:a()}).scopes}return{setProfile:ae,getActiveProfile:S,login:m,logout:v,loginOrRefreshIfRequired:_,getOAuthTokenFromLocalState:y,getAPIToken:ee,requireApiToken:b,getScopes:oe,setTemporaryAllowed:te,isTemporaryAllowed:ne,getActiveTemporaryAccount:re,activateTemporaryAccount:ie}}const Vt=[`default`,`staging`];function Ht(t){let n={read(){return t.bindings.read()},write(e){t.bindings.write(e)},activate(e,n){let r=y.resolve(n),i=t.bindings.read();i[r]=e,t.bindings.write(i)},deactivate(n){let r=y.resolve(n),i=t.bindings.read(),a=i[r];if(a===void 0){let t=z(r,i);throw t?new e(`No profile is directly bound to "${R(r)}". The active profile "${t.profile}" is bound at "${R(t.dir)}". Run the deactivate command from that directory instead.`,{telemetryMessage:`auth deactivate wrong directory`}):new e(`No profile is bound to "${R(r)}". Nothing to deactivate.`,{telemetryMessage:`auth deactivate no binding`})}delete i[r],t.bindings.write(i);let o=z(r,i);return o?{removedProfile:a,newResolution:{profile:o.profile,source:`inherited from ${o.dir}`}}:t.configs.exists(`default`)?{removedProfile:a,newResolution:{profile:`default`,source:`default profile`}}:{removedProfile:a,newResolution:{profile:void 0,source:`no profile`}}},getProfileForDirectory(e){return z(e,t.bindings.read())?.profile},getBindingsForProfile(e){return Object.entries(t.bindings.read()).filter(([,t])=>t===e).map(([e])=>e)},removeAllBindingsForProfile(e){let n=t.bindings.read(),r=[];for(let[t,i]of Object.entries(n))i===e&&(r.push(t),delete n[t]);return r.length>0&&t.bindings.write(n),r}};return{configs:t.configs,bindings:n,resolve(e){let t=e.profile||ve();return t?t==="default"?`default`:(L(t),t):n.getProfileForDirectory(e.cwd)||`default`}}}function L(t){if(Vt.includes(t.toLowerCase()))throw new e(`"${t}" is a reserved profile name. Use the login and logout commands to manage the default profile, which applies as a global fallback.`,{telemetryMessage:`auth profile reserved name`});if(!/^[a-zA-Z0-9_-]+$/.test(t))throw new e(`Invalid profile name "${t}". Profile names may only contain alphanumeric characters, hyphens, and underscores.`,{telemetryMessage:`auth profile invalid name`})}function R(e){return y.relative(process.cwd(),e)||`.`}function z(e,t){let n=y.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]===y.sep)return{profile:t,dir:e}}
|
|
48
|
+
/*!
|
|
49
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
50
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
51
|
+
*
|
|
52
|
+
* Redistribution and use in source and binary forms, with or without
|
|
53
|
+
* modification, are permitted provided that the following conditions are met:
|
|
54
|
+
*
|
|
55
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
56
|
+
* list of conditions and the following disclaimer.
|
|
57
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
58
|
+
* this list of conditions and the following disclaimer in the
|
|
59
|
+
* documentation and/or other materials provided with the distribution.
|
|
60
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
61
|
+
* may be used to endorse or promote products derived from this software without
|
|
62
|
+
* specific prior written permission.
|
|
63
|
+
*
|
|
64
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
65
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
66
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
67
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
68
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
69
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
70
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
71
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
72
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
73
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
74
|
+
*/
|
|
75
|
+
let Ut=/^[a-z0-9-_]+$/i,Wt=!!``.isWellFormed;function B(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(typeof e.getUTCDate==`function`&&e instanceof Date)return`date`;if(globalThis.Temporal){if(e.until){if(e instanceof Temporal.ZonedDateTime)return`temporal/tz+uc`;if(e instanceof Temporal.PlainDateTime||e instanceof Temporal.PlainDate)return`temporal/uc`;if(e instanceof Temporal.PlainTime||e instanceof Temporal.Instant)return`temporal`;if(e instanceof Temporal.PlainYearMonth)return`temporal/x`}else if(e.toPlainDate&&e instanceof Temporal.PlainMonthDay||e.negated&&e instanceof Temporal.Duration)return`temporal/x`}}return t}function Gt(e){for(let t=0;t<e.length;t++)if(B(e[t])!==`object`)return!1;return e.length!=0}function Kt(e){return JSON.stringify(e).replaceAll(``,`\\u007f`)}function qt(e){return Kt(Wt?e.toWellFormed():e)}function Jt(e){if(Ut.test(e))return e;if(Wt&&!e.isWellFormed())throw RangeError(`key contains illegal lone surrogates`);return Kt(e)}function V(e,t,n,r,i){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);switch(t){case`number`:if(isNaN(e))return`nan`;if(e===1/0)return`inf`;if(e===-1/0)return`-inf`;if(Number.isInteger(e)&&(r||!Number.isSafeInteger(e)))return e.toFixed(1);case`bigint`:case`boolean`:case`temporal`:return e.toString();case`string`:return qt(e);case`date`:if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString();case`object`:return Yt(e,n,r,i);case`array`:return Xt(e,n,r,i);case`temporal/tz+uc`:if(i){let t=e.timeZoneId,n=t.charCodeAt(0);if(n!==43&&n!==45&&(n!==85&&n!==71&&n!==90&&n!==69||t!==`UTC`&&t!==`UCT`&&t!==`Universal`&&t!==`Zulu`&&!t.startsWith(`GMT`)&&t!==`Greenwich`&&!t.startsWith(`Etc/`)))throw TypeError(`Temporal objects with an IANA timezone are not allowed in Temporal strict mode`)}case`temporal/uc`:if(i&&e.calendarId!==`iso8601`)throw TypeError(`Temporal objects with a non-default calendar are not allowed in Temporal strict mode`);return e.toString({calendarName:`never`,timeZoneName:`never`});case`temporal/x`:throw TypeError(`Unsupported `+e[Symbol.toStringTag])}}function Yt(e,t,n,r){let i=Object.keys(e);if(i.length===0)return`{}`;let a=`{ `;for(let o=0;o<i.length;o++){let s=i[o];o&&(a+=`, `),a+=Jt(s)+` = `+V(e[s],B(e[s]),t-1,n,r)}return a+` }`}function Xt(e,t,n,r){if(e.length===0)return`[]`;let i=`[ `;for(let a=0;a<e.length;a++){if(a&&(i+=`, `),e[a]===null||e[a]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);i+=V(e[a],B(e[a]),t-1,n,r)}return i+` ]`}function Zt(e,t,n,r,i){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``;for(let o=0;o<e.length;o++)a+=`${a&&`
|
|
76
|
+
`}[[${t}]]\n`,a+=H(0,e[o],t,n,r,i);return a}function H(e,t,n,r,i,a){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let o=``,s=``,c=Object.keys(t);for(let e=0;e<c.length;e++){let l=c[e];if(t[l]!==null&&t[l]!==void 0){let e=B(t[l]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let c=Jt(l);if(e===`array`&&Gt(t[l]))s+=(s&&`
|
|
77
|
+
`)+Zt(t[l],n?`${n}.${c}`:c,r-1,i,a);else if(e===`object`){let e=n?`${n}.${c}`:c;s+=(s&&`
|
|
78
|
+
`)+H(e,t[l],e,r-1,i,a)}else o+=c,o+=` = `,o+=V(t[l],e,r,i,a),o+=`
|
|
79
|
+
`}}return e&&(o||!s)&&(o=o?`[${e}]\n${o}`:`[${e}]`),o&&s?`${o}\n${s}`:o||s}function Qt(e,{maxDepth:t=1e3,numbersAsFloat:n=!1,strictTemporal:r=!1}={}){if(B(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let i=H(0,e,``,t,n,r);return i[i.length-1]===`
|
|
80
|
+
`?i:i+`
|
|
81
|
+
`}
|
|
82
|
+
/*!
|
|
83
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
84
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
85
|
+
*
|
|
86
|
+
* Redistribution and use in source and binary forms, with or without
|
|
87
|
+
* modification, are permitted provided that the following conditions are met:
|
|
88
|
+
*
|
|
89
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
90
|
+
* list of conditions and the following disclaimer.
|
|
91
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
92
|
+
* this list of conditions and the following disclaimer in the
|
|
93
|
+
* documentation and/or other materials provided with the distribution.
|
|
94
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
95
|
+
* may be used to endorse or promote products derived from this software without
|
|
96
|
+
* specific prior written permission.
|
|
97
|
+
*
|
|
98
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
99
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
100
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
101
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
102
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
103
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
104
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
105
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
106
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
107
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
108
|
+
*/
|
|
109
|
+
const $t={toml:{parse:e=>n(e),stringify:e=>Qt(e)},json:{parse:e=>JSON.parse(e),stringify:e=>JSON.stringify(e,null,` `)}};function U(e,t){return $t[e].parse(t)}function W(e,t){return $t[e].stringify(t)}function G(e){if(e===void 0||e==="default"){let e=u();return e===`production`?`default`:e}return L(e),e}function K(e,t,n=`toml`){return y.join(e,`config`,`${G(t)}.${n}`)}var q=class{configPath;profile;format;kind=`file`;constructor(e,t,n=`toml`){this.configPath=e,this.profile=t,this.format=n}filePath(){return K(this.configPath,this.profile,this.format)}read(){let e=this.filePath();if(h(e))return U(this.format,r(e))}write(e){let t=this.filePath();g(y.dirname(t),{recursive:!0}),v(t,W(this.format,e),{encoding:`utf-8`,mode:384}),m(t,384)}clear(){let e=this.filePath(),t=h(e);return t&&_(e),t}path(){return this.filePath()}describe(){return this.filePath()}};const en=`AES-256-GCM`,tn=`aes-256-gcm`;function nn(){return new Uint8Array(ae(32))}function rn(e,t){if(t.length!==32)throw Error(`AES-256-GCM requires a 32-byte key (got ${t.length} bytes).`);let n=ae(12),r=re(tn,t,n),i=Buffer.concat([r.update(e,`utf-8`),r.final()]),a=r.getAuthTag();return{v:1,alg:en,iv:n.toString(`base64`),tag:a.toString(`base64`),ciphertext:i.toString(`base64`)}}function an(e,t){if(t.length!==32)throw Error(`AES-256-GCM requires a 32-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!==12)throw Error(`Expected 12-byte IV in envelope (got ${n.length} bytes).`);if(r.length!==16)throw Error(`Expected 16-byte auth tag in envelope (got ${r.length} bytes).`);let a=ie(tn,t,n);return a.setAuthTag(r),Buffer.concat([a.update(i),a.final()]).toString(`utf-8`)}function on(e){if(typeof e!=`object`||!e)return;let t=e;if(t.v===1&&t.alg===en&&typeof t.iv==`string`&&typeof t.tag==`string`&&typeof t.ciphertext==`string`)return t}function J(e,t){return y.join(e,`config`,`${G(t)}.enc`)}var sn=class{configPath;keyProvider;onPlaintextMigration;profile;format;kind=`encrypted-file`;constructor(e,t,n,r,i=`toml`){this.configPath=e,this.keyProvider=t,this.onPlaintextMigration=n,this.profile=r,this.format=i}plaintextPath(){return K(this.configPath,this.profile,this.format)}read(){let e=J(this.configPath,this.profile);if(h(e))return this.readEncryptedFile(e);let t=this.plaintextPath();if(h(t))return this.migrateFromPlaintext(t,e)}write(e){let t=this.ensureKey(),n=rn(W(this.format,e),t),r=J(this.configPath,this.profile);g(y.dirname(r),{recursive:!0}),v(r,JSON.stringify(n,null,` `),{encoding:`utf-8`,mode:384}),m(r,384);let i=this.plaintextPath();h(i)&&_(i)}clear(){let e=J(this.configPath,this.profile),t=this.plaintextPath(),n=!1;h(e)&&(_(e),n=!0),h(t)&&(_(t),n=!0);try{this.keyProvider.deleteKey()}catch{}return n}path(){return J(this.configPath,this.profile)}describe(){return`Encrypted file (${J(this.configPath,this.profile)}) with key in ${this.keyProvider.describe()}`}readEncryptedFile(e){let t=this.keyProvider.getKey();if(t===void 0)return;let n=r(e),i;try{i=on(JSON.parse(n))}catch{return}if(i===void 0)return;let a;try{a=an(i,t)}catch{return}try{return U(this.format,a)}catch{return}}migrateFromPlaintext(e,t){let n=r(e),i;try{i=U(this.format,n)}catch{return}return this.write(i),this.onPlaintextMigration?.({plaintextPath:e,encryptedPath:t,keyProviderDescription:this.keyProvider.describe()}),i}ensureKey(){let e=this.keyProvider.getKey();if(e!==void 0)return e;let t=nn();return this.keyProvider.setKey(t),t}};const Y=`1.3.0`;function cn(e){let t={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`]};if(process.platform===`win32`){let n={...process.env},r=[`npm`,...e.map((e,t)=>{let r=`WORKERS_AUTH_NPM_ARG_${t}`;return n[r]=e,`"%${r}%"`})].join(` `);return C(r,{...t,env:n,shell:!0})}return C(`npm`,e,t)}let ln=cn;const X=/* @__PURE__ */ new Map;function un(e){return y.join(e,`native`,`keyring`)}function dn(e){return y.join(e,`node_modules`,`@napi-rs`,`keyring`)}function fn(e){try{return p(e)(e),!0}catch{return!1}}function pn(e){let t=X.get(e);if(t!==void 0)return t;let n=dn(e);if(h(y.join(n,`index.js`))&&fn(n))return X.set(e,n),n;try{let t=ln([`root`,`-g`]);if(t.status===0){let n=y.join(t.stdout.trim(),`@napi-rs`,`keyring`);if(h(y.join(n,`index.js`))&&fn(n))return X.set(e,n),n}}catch{}return X.set(e,null),null}function mn(t){let n=t;g(n,{recursive:!0});let r=y.join(n,`package.json`);h(r)||v(r,JSON.stringify({private:!0,name:`cloudflare-auth-keyring-host`},null,` `),`utf-8`);let i;try{i=ln([`install`,`@napi-rs/keyring@${Y}`,`--prefix`,n,`--no-save`,`--no-audit`,`--no-fund`,`--no-package-lock`,`--loglevel=error`])}catch(t){throw new e(`Failed to spawn \`npm\` to install the keyring backend: ${t instanceof Error?t.message:String(t)}\n\nInstall \`npm\` and retry, or install the binding globally:\n npm install -g @napi-rs/keyring@${Y}`,{telemetryMessage:`workers-auth keyring npm spawn failed`})}if(i.status!==0)throw new e(`Failed to install \`@napi-rs/keyring\` (npm exited ${i.status}):\n${i.stderr?.trim()??`(no stderr)`}\n\nRetry once the underlying issue is fixed, or install the binding globally:\n npm install -g @napi-rs/keyring@${Y}`,{telemetryMessage:`workers-auth keyring npm install failed`});if(X.delete(t),pn(t)===null)throw new e(`\`npm\` reported success but the \`@napi-rs/keyring\` native binding still cannot be loaded.
|
|
110
|
+
|
|
111
|
+
Its platform-specific binary ships as a separate optional package, so a download that was skipped or interrupted leaves the binding unusable.
|
|
112
|
+
|
|
113
|
+
Retry once the underlying issue is fixed, or install the binding globally:
|
|
114
|
+
npm install -g @napi-rs/keyring@${Y}`,{telemetryMessage:`workers-auth keyring install incomplete`})}function hn(t){let n=pn(t);if(n===null)throw new e(`The \`@napi-rs/keyring\` native binding is not available.
|
|
115
|
+
|
|
116
|
+
Retry the command, or install the binding globally:
|
|
117
|
+
npm install -g @napi-rs/keyring@${Y}`,{telemetryMessage:`workers-auth keyring binding not loadable`});let r=p(n)(n);return(e,t)=>new r.Entry(e,t)}function Z(e){return G(e)}function gn(e){let t={v:1,key:Buffer.from(e).toString(`base64`),created:(/* @__PURE__ */ new Date()).toISOString()};return JSON.stringify(t)}function Q(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}}function _n(e,t={}){return C(`secret-tool`,e,{encoding:`utf-8`,input:t.input})}ce(_n,`defaultRunner`);let $=_n,vn;function yn(){if(vn!==void 0)return vn;let e;try{e=$([`--version`]).error===void 0}catch{e=!1}return vn=e,e}var bn=class{serviceName;profile;constructor(e,t){this.serviceName=e,this.profile=t}getKey(){let e=$([`lookup`,`service`,this.serviceName,`account`,Z(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 Q(e.stdout.trim())}}setKey(e){let t=$([`store`,`--label=Cloudflare credentials key`,`service`,this.serviceName,`account`,Z(this.profile)],{input:gn(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=$([`clear`,`service`,this.serviceName,`account`,Z(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=${Z(this.profile)})`}};function xn(e,t={}){return C(`/usr/bin/security`,e,{encoding:`utf-8`,input:t.input})}let Sn=xn;var Cn=class{serviceName;profile;constructor(e,t){this.serviceName=e,this.profile=t}getKey(){let e=Sn([`find-generic-password`,`-s`,this.serviceName,`-a`,Z(this.profile),`-w`]);if(e.status!==44){if(e.status!==0)throw Error(`Failed to read key from macOS Keychain (exit ${e.status}): ${e.stderr?.trim()??`(no stderr)`}`);return Q(e.stdout.trim())}}setKey(e){let t=Sn([`add-generic-password`,`-s`,this.serviceName,`-a`,Z(this.profile),`-w`,gn(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=Sn([`delete-generic-password`,`-s`,this.serviceName,`-a`,Z(this.profile)]);if(e.status!==0&&e.status!==44)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=${Z(this.profile)})`}},wn=class{serviceName;installDir;profile;constructor(e,t,n){this.serviceName=e,this.installDir=t,this.profile=n}entry(){return hn(this.installDir)(this.serviceName,Z(this.profile))}getKey(){let e=this.entry().getPassword();if(e!==null&&e!==``)return Q(e)}setKey(e){this.entry().setPassword(gn(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=${Z(this.profile)})`}};function Tn(e,t,n){switch(process.platform){case`darwin`:return{kind:`available`,provider:new Cn(e,t)};case`linux`:return yn()?{kind:`available`,provider:new bn(e,t)}:{kind:`unsupported`};case`win32`:{let r=un(n);return pn(r)===null?{kind:`needs-install`,install:()=>mn(r),afterInstall:()=>new wn(e,r,t)}:{kind:`available`,provider:new wn(e,r,t)}}default:return{kind:`unsupported`}}}const En={installFailedThisSession:!1,hasWarnedAboutKeyringFallback:!1,hasWarnedAboutSecretToolMissing:!1};function Dn(){return En}function On(e){let t={...e,loginCommand:e.loginCommand??`your CLI login`,format:e.format??`toml`};function n(e){return kn(t,e)}function r(e){return{read:()=>n(e).read(),write:t=>n(e).write(t),clear:()=>n(e).clear(),path:()=>n(e).path()}}return{storageFactory:r,getActiveStore:n}}function kn(e,t){let n=De(),r=e.getConfigPath();if(n===!1)return new q(r,t,e.format);let i=n===!0;if(!(n??e.isKeyringEnabled()??!1))return new q(r,t,e.format);let a=Tn(e.serviceName,t,r);switch(a.kind){case`available`:return new sn(r,a.provider,An(e),t,e.format);case`needs-install`:return jn(a,i,e,t);case`unsupported`:return Mn(i,e,t)}}function An(e){return t=>{e.logger.warn(`Migrated credentials from ${t.plaintextPath} into ${t.encryptedPath} (key in ${t.keyProviderDescription}). The plaintext file has been deleted.`)}}function jn(t,n,r,i){let a=Dn();if(a.installFailedThisSession){if(n)throw new e(`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 Nn(`The keyring backend could not be installed earlier this session; using the plaintext credentials file.`,r,i)}if(r.isNonInteractiveOrCI())throw new e(Fn(r.loginCommand),{telemetryMessage:`workers-auth keyring binding not installed`});try{r.logger.log(`🔐 Installing keyring backend (one-time, ~2 MB)…`),t.install()}catch(t){if(a.installFailedThisSession=!0,n)throw t instanceof e?t:new e(`Failed to install the keyring backend: ${t instanceof Error?t.message:String(t)}`,{telemetryMessage:`workers-auth keyring install threw`});return Nn(`Failed to install the keyring backend (${t instanceof Error?t.message:String(t)}); falling back to the plaintext credentials file.`,r,i)}return new sn(r.getConfigPath(),t.afterInstall(),An(r),i,r.format)}function Mn(t,n,r){let i=process.platform,a=i===`linux`,o=a?Pn(n.loginCommand):`OS keyring storage is not supported on \`${i}\`; falling back to the plaintext credentials file.`;if(t)throw new e(a?`CLOUDFLARE_AUTH_USE_KEYRING is set but ${o}`:`CLOUDFLARE_AUTH_USE_KEYRING is set but no keyring backend is available on \`${i}\`.`,{telemetryMessage:a?`workers-auth keyring secret tool missing`:`workers-auth keyring unsupported platform`});if(a&&n.isNonInteractiveOrCI())throw new e(o,{telemetryMessage:`workers-auth keyring secret tool missing`});let s=Dn();return a?(s.hasWarnedAboutSecretToolMissing||(s.hasWarnedAboutSecretToolMissing=!0,n.logger.warn(`${o}\n\nFalling back to the plaintext credentials file for this session.`)),new q(n.getConfigPath(),r,n.format)):Nn(o,n,r)}function Nn(e,t,n){let r=Dn();return r.hasWarnedAboutKeyringFallback||(r.hasWarnedAboutKeyringFallback=!0,t.logger.warn(e)),new q(t.getConfigPath(),n,t.format)}function Pn(e){return`\`secret-tool\` is required for OS keyring storage on Linux but is not installed.
|
|
118
|
+
|
|
119
|
+
Install it via your package manager:
|
|
120
|
+
Debian/Ubuntu: sudo apt-get install libsecret-tools
|
|
121
|
+
Fedora/RHEL: sudo dnf install libsecret
|
|
122
|
+
Arch: sudo pacman -S libsecret
|
|
123
|
+
Alpine: apk add libsecret
|
|
124
|
+
|
|
125
|
+
Or disable keyring storage: \`${e} --no-use-keyring\`.`}function Fn(e){return`\`@napi-rs/keyring\` is required for OS keyring storage on Windows but is not installed.
|
|
126
|
+
|
|
127
|
+
Run \`${e} --use-keyring\` interactively to install it automatically, or install it globally for CI:
|
|
128
|
+
|
|
129
|
+
npm install -g @napi-rs/keyring@${Y}
|
|
130
|
+
|
|
131
|
+
Or disable keyring storage: \`${e} --no-use-keyring\`.`}function In(e){let t=J(e.configPath,e.profile),n=h(t),r=Tn(e.serviceName,e.profile,e.configPath);return r.kind===`available`?(new sn(e.configPath,r.provider,void 0,e.profile,e.format??`toml`).clear(),{backendAvailable:!0,encryptedFileExisted:n}):(n&&_(t),{backendAvailable:!1,encryptedFileExisted:n})}var Ln=class extends e{reason;constructor(e,t,n){super(e,{telemetryMessage:n}),this.reason=t}};export{W as _,k as a,ce as b,pe as c,ve as d,De as f,In as g,Tn as h,Ht as i,ue as l,U as m,On as n,nn as o,J as p,Bt as r,K as s,Ln as t,Se as u,_e as v,L as y};
|