cf 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_meta/agent-context.json +63 -62
- package/dist/_meta/commands.json +12365 -9690
- package/dist/_meta/schemas.json +19206 -15404
- package/dist/abuse-reports-dMIfUJ8v.mjs +8 -0
- package/dist/accounts-Kx1epdA1.mjs +22 -0
- package/dist/acm-Utu252kC.mjs +3 -0
- package/dist/addressing-CBq7Z7Vq.mjs +12 -0
- package/dist/{agent-context-D26woB9J.mjs → agent-context-BGTU299M.mjs} +1 -1
- package/dist/ai-DOOKLPkG.mjs +2 -0
- package/dist/ai-gateway-Cj1T3avF.mjs +8 -0
- package/dist/ai-search-CQF_Sn7d.mjs +7 -0
- package/dist/ai_gateway-C3fH22C0.mjs +4 -0
- package/dist/alerting-CqmEIaKn.mjs +6 -0
- package/dist/analytics-Dv-X8x7D.mjs +20 -0
- package/dist/analytics_engine-DdXVR8z2.mjs +2 -0
- package/dist/api-gateway-CNv0IHTU.mjs +33 -0
- package/dist/argo-CX_A4kcn.mjs +2 -0
- package/dist/audit-logs-BfBf3oo-.mjs +2 -0
- package/dist/auth-SyWhMmPu.mjs +6 -0
- package/dist/auth-ffdf9yR0.mjs +135 -0
- package/dist/autorag-BuGhGTeZ.mjs +2 -0
- package/dist/billing-PoG81XaQ.mjs +2 -0
- package/dist/body-parser-DKa8Ipg1.mjs +2 -0
- package/dist/bot-management-CFvtVx62.mjs +5 -0
- package/dist/botnet-feed-B-M4Yu0W.mjs +3 -0
- package/dist/brand-protection-D05Eg-_6.mjs +3 -0
- package/dist/browser-rendering-xu8F_Rrv.mjs +4 -0
- package/dist/{build-5jmmOZhm.mjs → build-DYkGW4dh.mjs} +1 -1
- package/dist/cache-DsoW6Xwv.mjs +5 -0
- package/dist/calls-CZbO7TyR.mjs +4 -0
- package/dist/certificate-authorities-D2yr7_3t.mjs +2 -0
- package/dist/cli-types-CRIDdDw3.mjs +2 -0
- package/dist/client-certificates-MJcDsTId.mjs +3 -0
- package/dist/cloud-connector-DWOrN2eM.mjs +2 -0
- package/dist/cloudforce-one-2Bhz8YdW.mjs +21 -0
- package/dist/{completions-BKrxcfhN.mjs → completions-BwRpZQVn.mjs} +1 -1
- package/dist/connectivity-BX8C7tvK.mjs +3 -0
- package/dist/content-scanning-r6uzMO1r.mjs +4 -0
- package/dist/context-DGlHRGWM.mjs +2 -0
- package/dist/custom-certificates-aAiEguR7.mjs +5 -0
- package/dist/custom-hostnames-AG5yBHIi.mjs +5 -0
- package/dist/custom-nameservers-D1DtlRue.mjs +3 -0
- package/dist/custom-pages-DQCi2plU.mjs +4 -0
- package/dist/d1-DbnYhw45.mjs +4 -0
- package/dist/data-security-D_EtYBfo.mjs +6 -0
- package/dist/dcv-delegation-CHspSzTI.mjs +2 -0
- package/dist/{deploy-DbkiIzUr.mjs → deploy-CQial3kN.mjs} +1 -1
- package/dist/{dev-C6iSuQZm.mjs → dev-B38LfCTl.mjs} +1 -1
- package/dist/diagnostics-BJQGjVJn.mjs +3 -0
- package/dist/dispatch-namespaces-DmHvoBOg.mjs +7 -0
- package/dist/{dist-CnSubA1Z.mjs → dist-AIcZFk0U.mjs} +7 -7
- package/dist/dns-VMhQSr5n.mjs +29 -0
- package/dist/dns-firewall-B4DVXFBQ.mjs +57 -0
- package/dist/durable-objects-CTboySEo.mjs +2 -0
- package/dist/email-routing-tIR2SFu-.mjs +10 -0
- package/dist/email-security-Ca1id3rZ.mjs +8 -0
- package/dist/email-sending-DwWKc5jC.mjs +3 -0
- package/dist/filters-A4dg_a68.mjs +4 -0
- package/dist/firewall-DWPQgYd9.mjs +11 -0
- package/dist/fraud-BMkSsJGU.mjs +20 -0
- package/dist/google-tag-gateway-BGD49nRC.mjs +2 -0
- package/dist/healthchecks-CtIfrFql.mjs +4 -0
- package/dist/hostnames-BiomxukN.mjs +3 -0
- package/dist/hyperdrive-Da104VaQ.mjs +18 -0
- package/dist/iam-BIGKo0WW.mjs +6 -0
- package/dist/images-BO8FbDAa.mjs +5 -0
- package/dist/index.mjs +1 -1
- package/dist/intel-CY6_79v8.mjs +3 -0
- package/dist/{ips-B8fwxKZD.mjs → ips-K4bzaGqd.mjs} +1 -1
- package/dist/keyless-certificates-CZC-L8gM.mjs +3 -0
- package/dist/kv-8o27w_pY.mjs +5 -0
- package/dist/leaked-credential-checks-qLzRyu85.mjs +3 -0
- package/dist/load-balancers-DtG8nj25.mjs +6 -0
- package/dist/logpush-4L0njy1d.mjs +4 -0
- package/dist/logs-B_Yp95hv.mjs +3 -0
- package/dist/magic-cloud-networking-CSOM3EM-.mjs +5 -0
- package/dist/magic-network-monitoring-BnwvM4-I.mjs +4 -0
- package/dist/magic-transit-CXDyvhxq.mjs +90 -0
- package/dist/managed-transforms-D15yVbZx.mjs +3 -0
- package/dist/mtls-certificates-D8k0AXWK.mjs +3 -0
- package/dist/network-interconnects-rrr7red3.mjs +36 -0
- package/dist/observability-DWvpqnQJ.mjs +4 -0
- package/dist/organizations-T77D50Sq.mjs +41 -0
- package/dist/origin-ca-certificates-DXIvD8H5.mjs +3 -0
- package/dist/origin-post-quantum-encryption-C8oOczyV.mjs +2 -0
- package/dist/origin-tls-client-auth-CaVW1Ztp.mjs +4 -0
- package/dist/output-BJFNwj7b.mjs +2 -0
- package/dist/page-rules-CjZPTMQX.mjs +18 -0
- package/dist/page-shield-D5RRNJCY.mjs +37 -0
- package/dist/pages-CWJtJnL0.mjs +11 -0
- package/dist/pipelines-B0L_7j9e.mjs +6 -0
- package/dist/{progress-CjcQ6ato.mjs → progress-CrCGTq7N.mjs} +1 -1
- package/dist/queues-CN6DPhRR.mjs +6 -0
- package/dist/r2-DQIcyRtA.mjs +21 -0
- package/dist/r2-data-catalog-Bbo93TJx.mjs +14 -0
- package/dist/radar-Bxb0WX8V.mjs +2 -0
- package/dist/rate-limits-DcrQV6Ar.mjs +5 -0
- package/dist/raw-fetch-Dlccg0Tr.mjs +2 -0
- package/dist/realtime-kit-CaquuVOE.mjs +18 -0
- package/dist/registrar-Ko-xZemf.mjs +46 -0
- package/dist/request-tracers-DOW_reTJ.mjs +2 -0
- package/dist/{resolve-BuJRWSk0.mjs → resolve-4-OSeHlK.mjs} +1 -1
- package/dist/resource-sharing-D7TX0JV0.mjs +5 -0
- package/dist/resource-tagging-C3qtLzCz.mjs +16 -0
- package/dist/rules-BXRADHL5.mjs +4 -0
- package/dist/rulesets-CBgpeSvJ.mjs +8 -0
- package/dist/rum-BjPptTUP.mjs +4 -0
- package/dist/{schema-CHBfkARI.mjs → schema-D16TgWBg.mjs} +1 -1
- package/dist/schema-validation-Dgv_opM3.mjs +24 -0
- package/dist/scim-DdSEr4kZ.mjs +3 -0
- package/dist/secrets-store-7BfyvJLb.mjs +25 -0
- package/dist/security-center-DAy6AKtT.mjs +2 -0
- package/dist/security-txt-xAMb7K6Y.mjs +3 -0
- package/dist/session-COHHdS7A.mjs +5 -0
- package/dist/{shared-DEzmTsEC.mjs → shared-AGtpXwwL.mjs} +1 -1
- package/dist/smart-shield-TeWZFnH2.mjs +3 -0
- package/dist/snippets-CCSsCXVs.mjs +4 -0
- package/dist/{spawn-13QQ0IwO.mjs → spawn-DcppKGI5.mjs} +1 -1
- package/dist/spectrum-CTTZID8u.mjs +63 -0
- package/dist/speed-CuzTE0AL.mjs +4 -0
- package/dist/{src-B9cKsgsg.mjs → src-BW6vfAwE.mjs} +10 -10
- package/dist/ssl-BWA2LdwC.mjs +15 -0
- package/dist/stream-GFsIZ-pP.mjs +14 -0
- package/dist/tenants-Bd7NGQ_m.mjs +2 -0
- package/dist/token-validation-DAgtFOvs.mjs +10 -0
- package/dist/{tools-B7QiNu-d.mjs → tools-DXQmfFuE.mjs} +1 -1
- package/dist/turnstile-cfdaO4ca.mjs +23 -0
- package/dist/{ui-BXjU1dX1.mjs → ui-D4KtlMh9.mjs} +1 -1
- package/dist/url-normalization-B5RN4nLD.mjs +3 -0
- package/dist/url-scanner-BrZ1L9OC.mjs +2 -0
- package/dist/user-CAo-yCJA.mjs +10 -0
- package/dist/vectorize-C7_oQlaI.mjs +4 -0
- package/dist/{versions-DzyrlUAi.mjs → versions-CUwWJWmy.mjs} +1 -1
- package/dist/waiting-rooms-Dln5ICg5.mjs +11 -0
- package/dist/web3-HQJRm38W.mjs +4 -0
- package/dist/workers-Dg7ddG2Q.mjs +18 -0
- package/dist/workers-builds-AVfx8IyL.mjs +7 -0
- package/dist/workflows-VquuSh2J.mjs +4 -0
- package/dist/zaraz-xYSWIV4P.mjs +2 -0
- package/dist/zero-trust-CP96wnSh.mjs +118 -0
- package/dist/zones-BSgmZ9WC.mjs +21 -0
- package/package.json +4 -3
- package/dist/abuse-reports-KtfZhi6j.mjs +0 -8
- package/dist/accounts-BopMfODC.mjs +0 -21
- package/dist/acm-BT4vlnEJ.mjs +0 -3
- package/dist/addressing-B3uFxHst.mjs +0 -13
- package/dist/ai-DWHqwMap.mjs +0 -2
- package/dist/ai-gateway-CbKEO-3o.mjs +0 -8
- package/dist/ai-search-VnOQ5n--.mjs +0 -7
- package/dist/alerting-BmmgIlIO.mjs +0 -6
- package/dist/analytics-isY03taL.mjs +0 -20
- package/dist/api-gateway-DXurEbA-.mjs +0 -33
- package/dist/argo-B02BL_hp.mjs +0 -2
- package/dist/audit-logs-DcgR9xUc.mjs +0 -2
- package/dist/auth-CQcAgnOy.mjs +0 -135
- package/dist/auth-DenWm_X0.mjs +0 -6
- package/dist/autorag-CmrwnGVj.mjs +0 -2
- package/dist/billing-CaW1ZAB1.mjs +0 -2
- package/dist/body-parser-Br-BoYk-.mjs +0 -2
- package/dist/bot-management-CeBsFx68.mjs +0 -5
- package/dist/botnet-feed-B396vQeQ.mjs +0 -3
- package/dist/brand-protection-D4V1v5Kl.mjs +0 -3
- package/dist/browser-rendering-GF7rNtKI.mjs +0 -4
- package/dist/builds-C_ySULja.mjs +0 -2
- package/dist/cache-DmXizSMi.mjs +0 -5
- package/dist/calls-x4KQpTB4.mjs +0 -4
- package/dist/certificate-authorities-hC0SG-Ga.mjs +0 -2
- package/dist/client-certificates-BGVsDyeJ.mjs +0 -3
- package/dist/cloud-connector-BClQpEzI.mjs +0 -2
- package/dist/cloudforce-one-BfhFrO6M.mjs +0 -21
- package/dist/connectivity-G0NP6LtW.mjs +0 -3
- package/dist/content-scanning-DEtPJ7aF.mjs +0 -4
- package/dist/context-CC0Rhkhy.mjs +0 -2
- package/dist/custom-certificates-rJXFpUWu.mjs +0 -5
- package/dist/custom-hostnames-Be5mgLeF.mjs +0 -5
- package/dist/custom-nameservers-CoFdy6hD.mjs +0 -3
- package/dist/custom-pages-D-oErw57.mjs +0 -4
- package/dist/d1-C95ckPKI.mjs +0 -3
- package/dist/dcv-delegation-CWSkbGuc.mjs +0 -2
- package/dist/diagnostics-DEEhPnXj.mjs +0 -3
- package/dist/dispatch-namespaces-BzXeV7PH.mjs +0 -7
- package/dist/dns-firewall-BQXD_NxG.mjs +0 -57
- package/dist/dns-qW-3TZOT.mjs +0 -29
- package/dist/durable-objects-CgWFYEJJ.mjs +0 -2
- package/dist/email-routing-tdNJaCpJ.mjs +0 -10
- package/dist/email-security-DTVHNr2h.mjs +0 -60
- package/dist/email-sending-DsFTvE31.mjs +0 -3
- package/dist/filters-DO1Is_tI.mjs +0 -4
- package/dist/firewall-DbUhVTCg.mjs +0 -11
- package/dist/fraud-Bzr4njYb.mjs +0 -8
- package/dist/google-tag-gateway-BQxkA90M.mjs +0 -2
- package/dist/healthchecks-BBAs-lS_.mjs +0 -4
- package/dist/hostnames-Dz9PEUKS.mjs +0 -3
- package/dist/hyperdrive-B1iUJddG.mjs +0 -18
- package/dist/iam-CJM8gHpG.mjs +0 -6
- package/dist/images-DEoBmtFS.mjs +0 -5
- package/dist/intel-BM6xkZ0C.mjs +0 -3
- package/dist/keyless-certificates-DffYnd4b.mjs +0 -3
- package/dist/kv-BTceLtWZ.mjs +0 -5
- package/dist/leaked-credential-checks-CALfvoCo.mjs +0 -3
- package/dist/load-balancers-C1Ho1gCF.mjs +0 -6
- package/dist/logpush-CSYhgevA.mjs +0 -4
- package/dist/logs-DlIwmMpt.mjs +0 -3
- package/dist/magic-cloud-networking-Czu0pZ0a.mjs +0 -5
- package/dist/magic-network-monitoring-d7GJE5Yt.mjs +0 -4
- package/dist/magic-transit-qQmA-981.mjs +0 -89
- package/dist/managed-transforms-Dd6AnbWE.mjs +0 -3
- package/dist/mtls-certificates-C0rlCRGs.mjs +0 -3
- package/dist/network-interconnects-CxG2deY0.mjs +0 -36
- package/dist/organizations-DyEAiGiR.mjs +0 -41
- package/dist/origin-ca-certificates-S8RcoMF6.mjs +0 -3
- package/dist/origin-post-quantum-encryption-B8ZcpLu5.mjs +0 -2
- package/dist/origin-tls-client-auth-BlxMmQrE.mjs +0 -5
- package/dist/output-D7_yAFVR.mjs +0 -2
- package/dist/page-rules-DP-w6TAm.mjs +0 -18
- package/dist/page-shield-Bf7kFp8c.mjs +0 -37
- package/dist/pages-D0Y_XRqW.mjs +0 -10
- package/dist/pipelines-C-SPESAk.mjs +0 -6
- package/dist/queues-wv6CZsi8.mjs +0 -6
- package/dist/r2-DuXjp9n5.mjs +0 -21
- package/dist/r2-data-catalog-DQCMrmNO.mjs +0 -14
- package/dist/radar-BW_ZHP8X.mjs +0 -2
- package/dist/rate-limits-DLTkIvwr.mjs +0 -5
- package/dist/raw-fetch-hRv-6P3D.mjs +0 -2
- package/dist/realtime-kit-Ch7Vg3vj.mjs +0 -6
- package/dist/registrar-DIIv6fWd.mjs +0 -46
- package/dist/request-tracers-DMej0Drs.mjs +0 -2
- package/dist/resource-sharing-CYJ7cMWq.mjs +0 -5
- package/dist/resource-tagging-Dnz65MgH.mjs +0 -16
- package/dist/rules-DLJpOYbC.mjs +0 -4
- package/dist/rulesets-D9nqEJT5.mjs +0 -8
- package/dist/rum-DBVmdPkp.mjs +0 -4
- package/dist/schema-validation-MCd3xdtX.mjs +0 -4
- package/dist/scim-DZA3VXog.mjs +0 -3
- package/dist/scm-CilfPOue.mjs +0 -2
- package/dist/secrets-store-BrvcZSOM.mjs +0 -21
- package/dist/security-center-BU6f3Cm1.mjs +0 -2
- package/dist/security-txt-BPIbP3dG.mjs +0 -3
- package/dist/session-H7IV2BrM.mjs +0 -2
- package/dist/smart-shield-e8XFBkiF.mjs +0 -3
- package/dist/snippets-B4M3MMb8.mjs +0 -4
- package/dist/spectrum-B0adfSRI.mjs +0 -59
- package/dist/speed-BVcUtkAz.mjs +0 -4
- package/dist/ssl-BAa91gsc.mjs +0 -15
- package/dist/stream-D53sxKb3.mjs +0 -14
- package/dist/tenants-bH5pt3dJ.mjs +0 -2
- package/dist/token-validation-M61Vx_Tw.mjs +0 -4
- package/dist/turnstile-wAU0Gc2Z.mjs +0 -23
- package/dist/url-normalization-DZrWDgB5.mjs +0 -3
- package/dist/url-scanner-Zo49edNp.mjs +0 -2
- package/dist/user-DbXlVReB.mjs +0 -10
- package/dist/vectorize-CUnTM0DT.mjs +0 -4
- package/dist/vuln-scanner-Br_2lQp1.mjs +0 -2
- package/dist/waiting-rooms-BZW0X69-.mjs +0 -11
- package/dist/web3-DueyOQtx.mjs +0 -4
- package/dist/workers-builds-BM_aoeUR.mjs +0 -7
- package/dist/workers-nV_vBCfV.mjs +0 -16
- package/dist/workflows-CQITmo-s.mjs +0 -4
- package/dist/zaraz-DIbpF5Op.mjs +0 -2
- package/dist/zero-trust-CKp8j512.mjs +0 -119
- package/dist/zones-BZ5tZDbH.mjs +0 -28
- /package/dist/{metadata-DGdCpUxn.mjs → metadata-5VwHPW6C.mjs} +0 -0
package/dist/auth-CQcAgnOy.mjs
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{o as e}from"./chunk-DH-VkVmc.mjs";import{i as t,r as n,t as r}from"./session-H7IV2BrM.mjs";import{A as i,G as a,H as o,L as s,N as c,b as l,f as u,g as d,h as f,m as p,q as m,t as ee}from"./dist-DNBSHor6.mjs";import{n as h,t as g}from"./theme-BklJDrb2.mjs";import{a as te,i as _,n as ne,r as re}from"./config-DYzlVxcB.mjs";import{c as ie,f as ae,h as v,i as oe,m as y,o as se,r as ce,s as le,t as ue}from"./dist-CnSubA1Z.mjs";import{n as de,t as fe}from"./resolve-BuJRWSk0.mjs";import{createRequire as pe}from"node:module";import{chmodSync as me,existsSync as b,mkdirSync as he,readFileSync as ge,rmSync as x,unlinkSync as _e,writeFileSync as S}from"node:fs";import ve from"node:assert";import{platform as ye}from"node:os";import C,{dirname as w,join as T}from"node:path";import{exec as be,spawnSync as xe}from"node:child_process";import{createCipheriv as Se,createDecipheriv as Ce,createHash as we,randomBytes as Te,webcrypto as Ee}from"node:crypto";import De from"node:http";import{TextEncoder as Oe}from"node:util";import ke from"node:url";import"node:process";import{execSync as Ae}from"child_process";import je from"os";var Me=Object.defineProperty,E=(e,t)=>Me(e,`name`,{value:t,configurable:!0}),D=i(),Ne=!1;function O(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?(!Ne&&n&&(Ne=!0,n.warn(`It looks like you have used Wrangler v1's \`config\` command to login with an API token
|
|
3
|
-
from ${t===void 0?r.path():`in-memory config`}.
|
|
4
|
-
This is no longer supported in the current version of Wrangler.
|
|
5
|
-
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\` environment variable.`)),{deprecatedApiToken:c}):{}}E(O,`readStoredAuthState`);var Pe=l({variableName:`CLOUDFLARE_API_TOKEN`,deprecatedName:`CF_API_TOKEN`}),Fe=l({variableName:`CLOUDFLARE_API_KEY`,deprecatedName:`CF_API_KEY`}),Ie=l({variableName:`CLOUDFLARE_EMAIL`,deprecatedName:`CF_EMAIL`});function Le(e){if(e?.allowGlobalAuthKey??!0){let e=Fe(),t=Ie();if(e&&t)return{authKey:e,authEmail:t}}let t=Pe();if(t)return{apiToken:t}}E(Le,`getAuthFromEnv`);function Re(e){let t=Le(e);if(t)return t;let n=O({storage:e.storage,warningLogger:e.warningLogger});if(n.deprecatedApiToken)return{apiToken:n.deprecatedApiToken};if(n.accessToken?.value)return{apiToken:n.accessToken.value}}E(Re,`getAPIToken`);function ze(e){let t=Re(e);if(!t)throw new s(`No API token found.`,{telemetryMessage:`user auth missing api token`});return t}E(ze,`requireApiToken`);var k=l({variableName:`WRANGLER_AUTH_DOMAIN`,defaultValue:E(()=>f()===`staging`?`dash.staging.cloudflare.com`:`dash.cloudflare.com`,`defaultValue`)}),Be=l({variableName:`WRANGLER_AUTH_URL`,defaultValue:E(()=>`https://${k()}/oauth2/auth`,`defaultValue`)}),Ve=l({variableName:`WRANGLER_TOKEN_URL`,defaultValue:E(()=>`https://${k()}/oauth2/token`,`defaultValue`)}),He=l({variableName:`WRANGLER_REVOKE_URL`,defaultValue:E(()=>`https://${k()}/oauth2/revoke`,`defaultValue`)}),Ue=l({variableName:`CLOUDFLARE_ACCESS_CLIENT_ID`}),We=l({variableName:`CLOUDFLARE_ACCESS_CLIENT_SECRET`}),Ge=l({variableName:`WRANGLER_CF_AUTHORIZATION_TOKEN`}),Ke=u({variableName:`CLOUDFLARE_AUTH_USE_KEYRING`}),A={},j=new Map;function qe(){for(let e of Object.keys(A))delete A[e];j.clear()}E(qe,`clearAccessCaches`);async function Je(e,t){if(t.debug(`Checking if domain has Access enabled:`,e),j.has(e))return t.debug(`Using cached Access switch for:`,e,j.get(e)),j.get(e)??!1;t.debug(`Access switch not cached for:`,e);try{let n=new AbortController,r=setTimeout(()=>{n.abort()},1e3),i=await(0,D.fetch)(`https://${e}`,{redirect:`manual`,signal:n.signal});clearTimeout(r);let a=!!(i.status===302&&i.headers.get(`location`)?.includes(`cloudflareaccess.com`));return t.debug(`Caching access switch for:`,e),j.set(e,a),a}catch{return j.set(e,!1),!1}}E(Je,`domainUsesAccess`);async function Ye(e,t){let n=t.logger,r=t.isNonInteractiveOrCI,i=Ue(),a=We();if(i&&a){n.debug(`Using Access Service Token headers for domain:`,e);let t={"CF-Access-Client-Id":i,"CF-Access-Client-Secret":a};return A[e]=t,t}if((i!==void 0||a!==void 0)&&n.warn(`Both CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET must be set to use Access Service Token authentication. Only ${i===void 0?`CLOUDFLARE_ACCESS_CLIENT_SECRET`:`CLOUDFLARE_ACCESS_CLIENT_ID`} was found.`),!await Je(e,n))return{};if(n.debug(`Getting Access headers for domain:`,e),A[e])return n.debug(`Using cached Access headers for domain:`,e),A[e];if(r())throw new s(`The domain "${e}" is behind Cloudflare Access, but no Access Service Token credentials were found and the current environment is non-interactive.
|
|
6
|
-
Set the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET environment variables to authenticate with an Access Service Token.
|
|
7
|
-
See https://developers.cloudflare.com/cloudflare-one/access-controls/service-credentials/service-tokens/`,{telemetryMessage:`user access missing service token non interactive`});n.debug(`Spawning cloudflared to get Access token for domain:`);let o=xe(`cloudflared`,[`access`,`login`,e]);if(o.error)throw new s("To use Wrangler with Cloudflare Access, please install `cloudflared` from https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation",{telemetryMessage:`user access missing cloudflared`});let c=o.stdout.toString();n.debug(`cloudflared output:`,c);let l=c.match(/fetched your token:\n\n(.*)/m);if(l&&l.length>=2){let t={Cookie:`CF_Authorization=${l[1]}`};return A[e]=t,n.debug(`Caching Access headers for domain:`,e),t}throw Error(`Failed to authenticate with Cloudflare Access`)}E(Ye,`getAccessHeaders`);async function Xe(e){let t=Ge();return t===void 0?Ye(k(),e):(e.logger.debug(`Using WRANGLER_CF_AUTHORIZATION_TOKEN from environment`),{Cookie:`CF_Authorization=${t}`})}E(Xe,`getCloudflareAccessHeaders`);function Ze(e){var t=[...arguments].slice(1),n=Array.from(typeof e==`string`?[e]:e);n[n.length-1]=n[n.length-1].replace(/\r?\n([\t ]*)$/,``);var r=n.reduce(function(e,t){var n=t.match(/\n([\t ]+|(?!\s).)/g);return n?e.concat(n.map(function(e){return e.match(/[\t ]/g)?.length??0})):e},[]);if(r.length){var i=RegExp(`
|
|
8
|
-
[ ]{`+Math.min.apply(Math,r)+`}`,`g`);n=n.map(function(e){return e.replace(i,`
|
|
9
|
-
`)})}n[0]=n[0].replace(/^\r?\n/,``);var a=n[0];return t.forEach(function(e,t){var r=a.match(/(?:^|\n)( *)$/),i=r?r[1]:``,o=e;typeof e==`string`&&e.includes(`
|
|
10
|
-
`)&&(o=String(e).split(`
|
|
11
|
-
`).map(function(e,t){return t===0?e:``+i+e}).join(`
|
|
12
|
-
`)),a+=o+n[t+1]}),a}E(Ze,`dedent`);var Qe=Ze,M=class extends s{static{E(this,`ErrorOAuth2`)}code;description;uri;toString(){return`ErrorOAuth2`}},$e=class extends M{static{E(this,`ErrorUnknown`)}toString(){return`ErrorUnknown`}},et=class extends M{static{E(this,`ErrorNoAuthCode`)}toString(){return`ErrorNoAuthCode`}},tt=class extends M{static{E(this,`ErrorInvalidReturnedStateParam`)}toString(){return`ErrorInvalidReturnedStateParam`}},nt=class extends M{static{E(this,`ErrorInvalidJson`)}toString(){return`ErrorInvalidJson`}},rt=class extends M{static{E(this,`ErrorInvalidScope`)}toString(){return`ErrorInvalidScope`}},it=class extends M{static{E(this,`ErrorInvalidRequest`)}toString(){return`ErrorInvalidRequest`}},at=class extends M{static{E(this,`ErrorInvalidToken`)}toString(){return`ErrorInvalidToken`}},N=class extends M{static{E(this,`ErrorAuthenticationGrant`)}toString(){return`ErrorAuthenticationGrant`}},ot=class extends N{static{E(this,`ErrorUnauthorizedClient`)}toString(){return`ErrorUnauthorizedClient`}},st=class extends N{static{E(this,`ErrorAccessDenied`)}toString(){return`ErrorAccessDenied`}},ct=class extends N{static{E(this,`ErrorUnsupportedResponseType`)}toString(){return`ErrorUnsupportedResponseType`}},lt=class extends N{static{E(this,`ErrorServerError`)}toString(){return`ErrorServerError`}},ut=class extends N{static{E(this,`ErrorTemporarilyUnavailable`)}toString(){return`ErrorTemporarilyUnavailable`}},dt=class extends M{static{E(this,`ErrorAccessTokenResponse`)}toString(){return`ErrorAccessTokenResponse`}},ft=class extends dt{static{E(this,`ErrorInvalidClient`)}toString(){return`ErrorInvalidClient`}},pt=class extends dt{static{E(this,`ErrorInvalidGrant`)}toString(){return`ErrorInvalidGrant`}},mt=class extends dt{static{E(this,`ErrorUnsupportedGrantType`)}toString(){return`ErrorUnsupportedGrantType`}};function ht(e,t,n){let r=`OAuth error: ${e}`;return t&&(r+=`
|
|
13
|
-
${t}`),n&&(r+=`
|
|
14
|
-
See: ${n}`),r}E(ht,`formatOAuthErrorMessage`);function P(e,t,n){let r=ht(e,t,n),i;switch(e){case`invalid_request`:i=new it(r,{telemetryMessage:`user oauth invalid request`});break;case`invalid_grant`:i=new pt(r,{telemetryMessage:`user oauth invalid grant`});break;case`unauthorized_client`:i=new ot(r,{telemetryMessage:`user oauth unauthorized client`});break;case`access_denied`:i=new st(r,{telemetryMessage:`user oauth access denied`});break;case`unsupported_response_type`:i=new ct(r,{telemetryMessage:`user oauth unsupported response type`});break;case`invalid_scope`:i=new rt(r,{telemetryMessage:`user oauth invalid scope`});break;case`server_error`:i=new lt(r,{telemetryMessage:`user oauth server error`});break;case`temporarily_unavailable`:i=new ut(r,{telemetryMessage:`user oauth temporarily unavailable`});break;case`invalid_client`:i=new ft(r,{telemetryMessage:`user oauth invalid client`});break;case`unsupported_grant_type`:i=new mt(r,{telemetryMessage:`user oauth unsupported grant type`});break;case`invalid_json`:i=new nt(r,{telemetryMessage:`user oauth invalid json`});break;case`invalid_token`:i=new at(r,{telemetryMessage:`user oauth invalid token`});break;default:i=new $e(r,{telemetryMessage:`user oauth unknown error`});break}return i.code=e,i.description=t,i.uri=n,i}E(P,`toErrorClass`);var gt=96,_t=32,F=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~`;function vt(e){let t=btoa(e);return t=t.replace(/\+/g,`-`),t=t.replace(/\//g,`_`),t=t.replace(/=/g,``),t}E(vt,`base64urlEncode`);async function yt(){let e=new Uint32Array(gt);Ee.getRandomValues(e);let t=vt(Array.from(e).map(e=>F[e%F.length]).join(``)),n=await Ee.subtle.digest(`SHA-256`,new Oe().encode(t)),r=new Uint8Array(n),i=``,a=r.byteLength;for(let e=0;e<a;e++)i+=String.fromCharCode(r[e]);return{codeChallenge:vt(i),codeVerifier:t}}E(yt,`generatePKCECodes`);function bt(e,t,n){if(e.error)throw P(Array.isArray(e.error)?e.error[0]:e.error,Array.isArray(e.error_description)?e.error_description[0]:e.error_description,Array.isArray(e.error_uri)?e.error_uri[0]:e.error_uri);let r=e.code;if(!r)return!1;if(e.state!==t.stateQueryParam)throw n.warn(`Received query string parameter doesn't match the one sent! Possible malicious activity somewhere.`),new tt(``,{telemetryMessage:`user oauth invalid returned state`});return ve(!Array.isArray(r)),t.authorizationCode=r,t.hasAuthCodeBeenExchangedForAccessToken=!1,!0}E(bt,`isReturningFromAuthServer`);async function xt(e,t,n,r,i){let{codeChallenge:a,codeVerifier:o}=await yt(),s=i.generateRandomState(_t);return Object.assign(r,{codeChallenge:a,codeVerifier:o,stateQueryParam:s}),i.generateAuthUrl({authUrl:Be(),clientId:t,scopes:e,stateQueryParam:s,codeChallenge:a,redirectUri:n})}E(xt,`getAuthURL`);async function St(e,t,n,r){let i=O({warningLogger:e,storage:r}).refreshToken;i||e.warn(`No refresh token is present.`);let a=await wt(new URLSearchParams({grant_type:`refresh_token`,refresh_token:i?.value??``,client_id:n}),e,t);if(a.status>=400){let t;try{t=await I(a,e)}catch(t){e.error(t)}throw t===void 0?new $e(`Failed to parse Error from exchangeRefreshTokenForAccessToken`,{telemetryMessage:`user oauth refresh token exchange parse error`}):typeof t==`string`?Error(t):t}else try{let t=await I(a,e);if(`error`in t)throw t.error;let{access_token:n,expires_in:r,refresh_token:o,scope:s}=t;return{token:{value:n,expiry:new Date(Date.now()+r*1e3).toISOString()},scopes:s?s.split(` `):[],refreshToken:o?{value:o}:i}}catch(e){throw typeof e==`string`?P(e):e}}E(St,`exchangeRefreshTokenForAccessToken`);async function Ct(e,t,n,r,i){let{authorizationCode:a,codeVerifier:o=``}=e;o?a||t.warn(`No authorization grant code is being passed.`):t.warn(`No code verifier is being sent.`);let s=await wt(new URLSearchParams({grant_type:`authorization_code`,code:a??``,redirect_uri:i,client_id:r,code_verifier:o}),t,n);if(!s.ok){let{error:e}=await I(s,t);throw e===`invalid_grant`&&t.log(`Expired! Auth code or refresh token needs to be renewed.`),P(e)}let c=await I(s,t);if(`error`in c)throw P(c.error);let{access_token:l,expires_in:u,refresh_token:d,scope:f}=c;return e.hasAuthCodeBeenExchangedForAccessToken=!0,{token:{value:l,expiry:new Date(Date.now()+u*1e3).toISOString()},scopes:f?f.split(` `):[],refreshToken:d?{value:d}:void 0}}E(Ct,`exchangeAuthCodeForAccessToken`);async function wt(e,t,n){let r={"Content-Type":`application/x-www-form-urlencoded`};if(t.debug(`fetching auth token`,`grant_type=${e.get(`grant_type`)??`<unknown>`}`),await Je(k(),t)){t.debug(`Using Cloudflare Access to get an access token for the auth request`);let e=await Xe({logger:t,isNonInteractiveOrCI:n});Object.assign(r,e)}t.debug(`Fetching auth token from`,Ve());try{let n=await(0,D.fetch)(Ve(),{method:`POST`,body:e.toString(),headers:r});return n.ok||t.debug(`Failed to fetch auth token:`,n.status,n.statusText),n}catch(e){throw t.debug(`Failed to fetch auth token:`,e),e}}E(wt,`fetchAuthToken`);async function I(e,t){let n=await e.text();try{return JSON.parse(n)}catch(r){throw n.match(/<!DOCTYPE html>/)&&(t.error(`The body of the response was HTML rather than JSON. Check the debug logs to see the full body of the response.`),n.match(/challenge-platform/)&&t.error(`It looks like you might have hit a bot challenge page. This may be transient but if not, please contact Cloudflare to find out what can be done. When you contact Cloudflare, please provide your Ray ID: ${e.headers.get(`cf-ray`)}`)),t.debug(`Full body of response
|
|
15
|
-
|
|
16
|
-
`,n),Error(`Invalid JSON in response: status: ${e.status} ${e.statusText}`,{cause:r})}}E(I,`getJSONFromResponse`);async function Tt(e,t,n,r){let i=await xt(e.scopes,e.clientId,e.redirectUri,t,r),a=new URL(e.redirectUri).pathname,o,c,l=new Promise((e,t)=>{c=setTimeout(()=>{o.close(),clearTimeout(c),t(new s(`Timed out waiting for authorization code, please try again.`,{telemetryMessage:`user oauth authorization timeout`}))},12e4)}),u=new Promise((r,i)=>{o=De.createServer(async(l,u)=>{function d(e,t){clearTimeout(c),u.writableEnded||u.end(),o.close(n=>{t||n?i(t||n):(ve(e),r(e))})}E(d,`finish`);function f(e){let t=E(e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),`escape`),n=`<!doctype html>
|
|
17
|
-
<html lang="en">
|
|
18
|
-
<head>
|
|
19
|
-
<meta charset="utf-8" />
|
|
20
|
-
<title>Wrangler login failed</title>
|
|
21
|
-
<style>
|
|
22
|
-
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; max-width: 720px; margin: 4rem auto; padding: 0 1rem; color: #1f2933; line-height: 1.5; }
|
|
23
|
-
h1 { color: #c12d3f; }
|
|
24
|
-
code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
|
|
25
|
-
p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
|
|
26
|
-
</style>
|
|
27
|
-
</head>
|
|
28
|
-
<body>
|
|
29
|
-
<h1>Wrangler login failed</h1>
|
|
30
|
-
<p>The Cloudflare OAuth provider returned an error.</p>
|
|
31
|
-
${e.code?`<p>Code: <code>${t(e.code)}</code></p>`:``}
|
|
32
|
-
${e.description?`<p class="detail">${t(e.description)}</p>`:``}
|
|
33
|
-
<p>You can close this tab and return to your terminal for more details.</p>
|
|
34
|
-
</body>
|
|
35
|
-
</html>`;u.writeHead(400,{"Content-Type":`text/html; charset=utf-8`}),u.end(n)}E(f,`renderErrorPage`),ve(l.url,`This request doesn't have a URL`);let{pathname:p,query:m}=ke.parse(l.url,!0);if(l.method!==`GET`)return u.end(`OK`);switch(p){case a:{let r=!1;try{r=bt(m,t,n.logger)}catch(t){if(t instanceof st){u.writeHead(307,{Location:e.denied.url}),u.end(()=>{d(null,new s(e.denied.error,{telemetryMessage:`user oauth consent denied`}))});return}let n=t;f({code:n.code,description:n.description??n.message}),d(null,n);return}if(!r){let e=`The Cloudflare OAuth provider did not return an authorisation code.`;f({description:e}),d(null,new et(e,{telemetryMessage:`user oauth missing auth code`}));return}try{let r=await Ct(t,n.logger,n.isNonInteractiveOrCI,e.clientId,e.redirectUri);u.writeHead(307,{Location:e.granted.url}),u.end(()=>{d(r)})}catch(e){let t=e,n=t instanceof M;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(e.redirectUri),u=Number(l.port||(l.protocol===`https:`?443:80));(l.hostname!==e.callbackHost||u!==e.callbackPort)&&(n.logger.log(`Temporary login server listening on ${e.callbackHost}:${e.callbackPort}`),n.logger.log(`Note that the OAuth login page will always redirect to \`${e.redirectUri}\`.
|
|
36
|
-
If you have changed the callback host or port because you are running in a container, then ensure that you have port forwarding set up correctly.`)),o.once(`error`,t=>{clearTimeout(c),t.code===`EADDRINUSE`?i(new s(`The OAuth callback server could not bind to ${e.callbackHost}:${e.callbackPort} because the port is already in use. Stop the process using that port or pass a different \`--callback-port\`.`,{telemetryMessage:`user oauth callback port in use`})):i(t)}),o.listen(e.callbackPort,e.callbackHost)});return e.browser?(n.logger.log(`Opening a link in your default browser: ${i}`),await n.openInBrowser(i)):n.logger.log(`Visit this link to authenticate: ${i}`),Promise.race([l,u])}E(Tt,`getOauthToken`);var Et=E(({authUrl:e,clientId:t,scopes:n,stateQueryParam:r,codeChallenge:i,redirectUri:a})=>e+`?response_type=code&client_id=${encodeURIComponent(t)}&redirect_uri=${encodeURIComponent(a)}&scope=${encodeURIComponent([...n,`offline_access`].join(` `))}&state=${r}&code_challenge=${encodeURIComponent(i)}&code_challenge_method=S256`,`generateAuthUrl`);function Dt(e){let t=new Uint32Array(e);return Ee.getRandomValues(t),Array.from(t).map(e=>F[e%F.length]).join(``)}E(Dt,`generateRandomState`);var Ot=64e6;function kt(e,t,n){let r=Array(t+1),i=we(`sha256`).update(e).digest();r[0]=i;for(let e=0;e<t;e++){for(let e=0;e<n;e++)i=we(`sha256`).update(i).digest();r[e+1]=i}return r}E(kt,`solvePow`);function At(e){return Buffer.concat(e).toString(`base64`)}E(At,`encodeCheckpoints`);function jt(e){let t=kt(Buffer.from(e.seed,`base64url`),e.k,e.g);return{challengeToken:e.challengeToken,solution:{checkpoints:At(t)}}}E(jt,`solveChallenge`);var L={termsOfService:`https://www.cloudflare.com/terms/`,privacyPolicy:`https://www.cloudflare.com/privacypolicy/`},Mt=`You must accept Cloudflare's Terms of Service (${L.termsOfService}) and Privacy Policy (${L.privacyPolicy}) in order to continue. By typing "yes", you agree to these terms. Type "yes" to continue.`,Nt=`Continuing means you accept Cloudflare's Terms of Service (${L.termsOfService}) and Privacy Policy (${L.privacyPolicy}).`,Pt=`You must accept Cloudflare's Terms of Service (${L.termsOfService}) and Privacy Policy (${L.privacyPolicy}) to use --temporary.`;function Ft(){return`${p(ee)}/provisioning/previews`}E(Ft,`getTemporaryPreviewUrl`);function It(){return`${Ft()}/challenge`}E(It,`getTemporaryPreviewChallengeUrl`);function Lt(e){let t=Date.parse(e);return!Number.isNaN(t)&&t>Date.now()}E(Lt,`isFutureTimestamp`);function Rt(e){let t=e.read();if(t&&!(!t.account?.id||!t.account?.apiToken||!t.account?.name||!t.claim?.url||!Lt(t.account?.expiresAt??``)||!Lt(t.claim?.expiresAt??``)))return t}E(Rt,`getCachedTemporaryPreviewAccount`);async function zt(e){let t=await(0,D.fetch)(It(),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok)throw new c(`Failed to request a proof-of-work challenge (${t.status} ${t.statusText}).`,{telemetryMessage:`deploy temporary account challenge failed`});let n;try{n=await t.json()}catch{throw new c(`Failed to request a proof-of-work challenge. Received an invalid response (${t.status} ${t.statusText}).`,{telemetryMessage:`deploy temporary account challenge invalid response`})}let{challengeToken:r,seed:i,k:a,g:o}=n.result??{};if(r===void 0||i===void 0||a===void 0||o===void 0)throw new c(`Failed to request a proof-of-work challenge because the response was missing required fields.`,{telemetryMessage:`deploy temporary account challenge incomplete`});if(!Number.isInteger(a)||!Number.isInteger(o)||a<=0||o<=0||a*o>Ot||Buffer.from(i,`base64url`).length!==32)throw new c(`The proof-of-work challenge is not supported by this version of Wrangler.`,{telemetryMessage:`deploy temporary account challenge difficulty unsupported`});return e.log(`Solving proof-of-work challenge…`),jt({challengeToken:r,seed:i,k:a,g:o})}E(zt,`requestPowSolution`);async function Bt(e){let t=await zt(e),n=await(0,D.fetch)(Ft(),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({termsOfService:L.termsOfService,privacyPolicy:L.privacyPolicy,acceptTermsOfService:`yes`,challengeToken:t.challengeToken,solution:t.solution})});if(!n.ok)throw new c(`Failed to create a temporary preview account (${n.status} ${n.statusText}).`,{telemetryMessage:`deploy temporary account create failed`});let r;try{r=await n.json()}catch{throw new c(`Failed to create a temporary preview account. Received an invalid response (${n.status} ${n.statusText}).`,{telemetryMessage:`deploy temporary account invalid response`})}let i=r.result,a=i?.account?.id,o=i?.account?.name,s=i?.account?.apiToken,l=i?.account?.expiresAt,u=i?.claim?.url,d=i?.claim?.expiresAt;if(a===void 0||o===void 0||s===void 0||l===void 0||u===void 0||d===void 0)throw new c(`Failed to create a temporary preview account because the response was missing required fields.`,{telemetryMessage:`deploy temporary account response incomplete`});return{account:{id:a,name:o,apiToken:s,expiresAt:l},claim:{url:u,expiresAt:d}}}E(Bt,`createTemporaryPreviewAccount`);async function Vt(e){let t=Rt(e.storage);if(t)return{account:t,cached:!0};if(!await e.prompt(Mt,Nt))throw new s(Pt,{telemetryMessage:`user temporary terms not accepted`});let n=await Bt(e.logger);return e.storage.write(n),{account:n,cached:!1}}E(Vt,`getOrCreateTemporaryPreviewAccount`);function Ht(e){let t={},n={generateAuthUrl:e.generateAuthUrl??Et,generateRandomState:e.generateRandomState??Dt},r=`default`;function i(t){return e.storageFactory(t??r)}E(i,`getStorage`);let a=E(()=>typeof e.clientId==`function`?e.clientId():e.clientId,`getClientId`),o=e.consent,c=!1,l,u=new URL(e.redirectUri),f=u.hostname,p=Number(u.port);async function m(r){if(e.hasEnvCredentials())return e.logger.error(`You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log in via OAuth.`),!1;let c=d(r.complianceConfig);if(c===`fedramp_high`)throw new s(Qe`
|
|
37
|
-
OAuth login is not supported in the \`${c}\` compliance region.
|
|
38
|
-
Please use a Cloudflare API token (\`CLOUDFLARE_API_TOKEN\` environment variable) or remove the ${r.complianceConfig?.compliance_region?"`compliance_region` configuration property":"`CLOUDFLARE_API_ENVIRONMENT` environment variable"}.
|
|
39
|
-
`,{telemetryMessage:`user login unsupported compliance region`});e.logger.log(`Attempting to login via OAuth...`);let l=await Tt({browser:r.browser??!0,scopes:r.scopes,clientId:a(),redirectUri:e.redirectUri,denied:o.denied,granted:o.granted,callbackHost:r.callbackHost??f,callbackPort:r.callbackPort??p},t,e,n);return i(r.profile).write({oauth_token:l.token?.value??``,expiration_time:l.token?.expiry,refresh_token:l.refreshToken?.value,scopes:l.scopes}),e.logger.log(`Successfully logged in.`),y(),e.purgeOnLoginOrLogout?.(),!0}E(m,`login`);function ee(t){if(e.hasEnvCredentials())return!1;let{accessToken:n}=O({warningLogger:e.logger,storage:i(t)});return!!(n&&new Date>=new Date(n.expiry))}E(ee,`isRefreshNeeded`);async function h(t){let n=i(t);try{let{token:{value:t,expiry:r}={value:``,expiry:``},refreshToken:{value:i}={},scopes:o}=await St(e.logger,e.isNonInteractiveOrCI,a(),n);return n.write({oauth_token:t,expiration_time:r,refresh_token:i,scopes:o}),!0}catch(t){return e.logger.debug(`Token refresh failed: ${t instanceof Error?t.message:String(t)}`),!1}}E(h,`refreshToken`);async function g(t){if(e.hasEnvCredentials())return{loggedIn:!0};let n=O({warningLogger:e.logger,storage:i(t.profile)});return!n.accessToken&&!n.deprecatedApiToken?e.isNonInteractiveOrCI()?{loggedIn:!1,reason:`no-credentials-non-interactive`}:await m(t)?{loggedIn:!0}:{loggedIn:!1,reason:`no-credentials-login-failed`}:ee(t.profile)?await h(t.profile)?{loggedIn:!0}:e.isNonInteractiveOrCI()?{loggedIn:!1,reason:`token-expired-non-interactive`}:await m(t)?{loggedIn:!0}:{loggedIn:!1,reason:`token-expired-login-failed`}:{loggedIn:!0}}E(g,`loginOrRefreshIfRequired`);async function te(t){let n=y();if(e.hasEnvCredentials()){e.logger.log(`You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log out.`);return}let r=O({warningLogger:e.logger,storage:i(t)}).refreshToken;if(!r){e.logger.log(n?`Cleared temporary preview account.`:`Not logged in, exiting...`);return}let o=`client_id=${encodeURIComponent(a())}&token_type_hint=refresh_token&token=${encodeURIComponent(r.value||``)}`;await(await(0,D.fetch)(He(),{method:`POST`,body:o,headers:{"Content-Type":`application/x-www-form-urlencoded`}})).text(),i(t).clear(),e.logger.log(`Successfully logged out.`),e.purgeOnLoginOrLogout?.()}E(te,`logout`);async function _(){let t=O({warningLogger:e.logger,storage:i()});if(t.accessToken){if(t.accessToken&&new Date>=new Date(t.accessToken.expiry)){if(!await h())return;t=O({warningLogger:e.logger,storage:i()})}return t.accessToken?.value}}E(_,`getOAuthTokenFromLocalState`);function ne(){return l?{apiToken:l.account.apiToken}:Re({storage:i(),warningLogger:e.logger,allowGlobalAuthKey:e.allowGlobalAuthKey})}E(ne,`getAPITokenInternal`);function re(){return l?{apiToken:l.account.apiToken}:ze({storage:i(),warningLogger:e.logger,allowGlobalAuthKey:e.allowGlobalAuthKey})}E(re,`requireApiTokenInternal`);function ie(t){c=t&&e.temporary!==void 0,l=void 0}E(ie,`setTemporaryAllowed`);function ae(){return c}E(ae,`isTemporaryAllowed`);function v(){return l}E(v,`getActiveTemporaryAccount`);async function oe(){if(!e.temporary)throw new s(`Temporary preview accounts are not supported by this CLI.`,{telemetryMessage:`user temporary account unsupported`});let t=await Vt({...e.temporary,logger:e.logger});return l=t.account,t}E(oe,`activateTemporaryAccount`);function y(){return l=void 0,e.temporary?.storage.clear()??!1}E(y,`clearTemporaryAccount`);function se(e){r=e}E(se,`setProfile`);function ce(){return r}E(ce,`getActiveProfile`);function le(){return O({warningLogger:e.logger,storage:i()}).scopes}return E(le,`getScopes`),{setProfile:se,getActiveProfile:ce,login:m,logout:te,loginOrRefreshIfRequired:g,getOAuthTokenFromLocalState:_,getAPIToken:ne,requireApiToken:re,getScopes:le,setTemporaryAllowed:ie,isTemporaryAllowed:ae,getActiveTemporaryAccount:v,activateTemporaryAccount:oe}}E(Ht,`createOAuthFlow`);var Ut=[`default`,`staging`];function Wt(e){let t={read(){return e.bindings.read()},write(t){e.bindings.write(t)},activate(t,n){let r=C.resolve(n),i=e.bindings.read();i[r]=t,e.bindings.write(i)},deactivate(t){let n=C.resolve(t),r=e.bindings.read(),i=r[n];if(i===void 0){let e=qt(n,r);throw e?new s(`No profile is directly bound to "${Kt(n)}". The active profile "${e.profile}" is bound at "${Kt(e.dir)}". Run \`wrangler auth deactivate\` from that directory instead.`,{telemetryMessage:`auth deactivate wrong directory`}):new s(`No profile is bound to "${Kt(n)}". Nothing to deactivate.`,{telemetryMessage:`auth deactivate no binding`})}delete r[n],e.bindings.write(r);let a=qt(n,r);return a?{removedProfile:i,newResolution:{profile:a.profile,source:`inherited from ${a.dir}`}}:e.configs.exists(`default`)?{removedProfile:i,newResolution:{profile:`default`,source:`default profile`}}:{removedProfile:i,newResolution:{profile:void 0,source:`no profile`}}},getProfileForDirectory(t){return qt(t,e.bindings.read())?.profile},getBindingsForProfile(t){return Object.entries(e.bindings.read()).filter(([,e])=>e===t).map(([e])=>e)},removeAllBindingsForProfile(t){let n=e.bindings.read(),r=[];for(let[e,i]of Object.entries(n))i===t&&(r.push(e),delete n[e]);return r.length>0&&e.bindings.write(n),r}};return{configs:e.configs,bindings:t,resolve(e){return e.profile?e.profile===`default`?`default`:(Gt(e.profile),e.profile):t.getProfileForDirectory(e.cwd)||`default`}}}E(Wt,`createProfileStore`);function Gt(e){if(Ut.includes(e.toLowerCase()))throw new s(`"${e}" is a reserved profile name. Use \`wrangler login\` and \`wrangler logout\` to manage the default profile, which applies as a global fallback.`,{telemetryMessage:`auth profile reserved name`});if(!/^[a-zA-Z0-9_-]+$/.test(e))throw new s(`Invalid profile name "${e}". Profile names may only contain alphanumeric characters, hyphens, and underscores.`,{telemetryMessage:`auth profile invalid name`})}E(Gt,`validateProfileName`);function Kt(e){return C.relative(process.cwd(),e)||`.`}E(Kt,`formatDirectoryForUserError`);function qt(e,t){let n=C.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]===C.sep)return{profile:t,dir:e}}E(qt,`getProfileForDirectoryFromBindings`);function Jt(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}E(Jt,`getLineColFromPtr`);function Yt(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
|
|
40
|
-
`,e===t&&(i+=` `.repeat(a+n+2),i+=`^
|
|
41
|
-
`))}return i}E(Yt,`makeCodeBlock`);var R=class extends Error{static{E(this,`TomlError`)}line;column;codeblock;constructor(e,t){let[n,r]=Jt(t.toml,t.ptr),i=Yt(t.toml,n,r);super(`Invalid TOML document: ${e}
|
|
42
|
-
|
|
43
|
-
${i}`,t),this.line=n,this.column=r,this.codeblock=i}};function Xt(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}E(Xt,`isEscaped`);function z(e,t=0,n=e.length){let r=e.indexOf(`
|
|
44
|
-
`,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}E(z,`indexOfNewline`);function B(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
|
|
45
|
-
`)return n;if(r===`\r`&&e[n+1]===`
|
|
46
|
-
`)return n+1;if(r<` `&&r!==` `||r===``)throw new R(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}E(B,`skipComment`);function V(e,t,n,r){let i;for(;(i=e[t])===` `||i===` `||!n&&(i===`
|
|
47
|
-
`||i===`\r`&&e[t+1]===`
|
|
48
|
-
`);)t++;return r||i!==`#`?t:V(e,B(e,t),n)}E(V,`skipVoid`);function Zt(e,t,n,r,i=!1){if(!r)return t=z(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=z(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
|
|
49
|
-
`||t===`\r`&&e[a+1]===`
|
|
50
|
-
`))return a}throw new R(`cannot find end of structure`,{toml:e,ptr:t})}E(Zt,`skipUntil`);function Qt(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do t=e.indexOf(r,++t);while(t>-1&&n!==`'`&&Xt(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}E(Qt,`getStringEnd`);var $t=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i,en=class e extends Date{static{E(this,`TomlDate`)}#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match($t);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}},tn=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,nn=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,rn=/^[+-]?0[0-9_]/,an=/^[0-9a-f]{4,8}$/i,on={b:`\b`,t:` `,n:`
|
|
51
|
-
`,f:`\f`,r:`\r`,'"':`"`,"\\":`\\`};function sn(e,t=0,n=e.length){let r=e[t]===`'`,i=e[t++]===e[t]&&e[t]===e[t+1];i&&(n-=2,e[t+=2]===`\r`&&t++,e[t]===`
|
|
52
|
-
`&&t++);let a=0,o,s=``,c=t;for(;t<n-1;){let n=e[t++];if(n===`
|
|
53
|
-
`||n===`\r`&&e[t]===`
|
|
54
|
-
`){if(!i)throw new R(`newlines are not allowed in strings`,{toml:e,ptr:t-1})}else if(n<` `&&n!==` `||n===``)throw new R(`control characters are not allowed in strings`,{toml:e,ptr:t-1});if(o){if(o=!1,n===`u`||n===`U`){let r=e.slice(t,t+=n===`u`?4:8);if(!an.test(r))throw new R(`invalid unicode escape`,{toml:e,ptr:a});try{s+=String.fromCodePoint(parseInt(r,16))}catch{throw new R(`invalid unicode escape`,{toml:e,ptr:a})}}else if(i&&(n===`
|
|
55
|
-
`||n===` `||n===` `||n===`\r`)){if(t=V(e,t-1,!0),e[t]!==`
|
|
56
|
-
`&&e[t]!==`\r`)throw new R(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:a});t=V(e,t)}else if(n in on)s+=on[n];else throw new R(`unrecognized escape sequence`,{toml:e,ptr:a});c=t}else !r&&n===`\\`&&(a=t-1,o=!0,s+=e.slice(c,a))}return s+e.slice(c,n-1)}E(sn,`parseString`);function cn(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=tn.test(e);if(i||nn.test(e)){if(rn.test(e))throw new R(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new R(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new R(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new en(e);if(!a.isValid())throw new R(`invalid value`,{toml:t,ptr:n});return a}E(cn,`parseValue`);function ln(e,t,n,r){let i=e.slice(t,n),a=i.indexOf(`#`);a>-1&&(B(e,a),i=i.slice(0,a));let o=i.trimEnd();if(!r){let n=i.indexOf(`
|
|
57
|
-
`,o.length);if(n>-1)throw new R(`newlines are not allowed in inline tables`,{toml:e,ptr:t+n})}return[o,a]}E(ln,`sliceAndTrimEndOf`);function un(e,t,n,r,i){if(r===0)throw new R(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?pn(e,t,r,i):fn(e,t,r,i),c=n?Zt(e,s,`,`,n):s;if(s-c&&n===`}`){let t=z(e,s,c);if(t>-1)throw new R(`newlines are not allowed in inline tables`,{toml:e,ptr:t})}return[o,c]}let o;if(a===`"`||a===`'`){o=Qt(e,t);let r=sn(e,t,o);if(n){if(o=V(e,o,n!==`]`),e[o]&&e[o]!==`,`&&e[o]!==n&&e[o]!==`
|
|
58
|
-
`&&e[o]!==`\r`)throw new R(`unexpected character encountered`,{toml:e,ptr:o});o+=+(e[o]===`,`)}return[r,o]}o=Zt(e,t,`,`,n);let s=ln(e,t,o-+(e[o-1]===`,`),n===`]`);if(!s[0])throw new R(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=V(e,t+s[1]),o+=+(e[o]===`,`)),[cn(s[0],e,t,i),o]}E(un,`extractValue`);var dn=/^[a-zA-Z0-9-_]+[ \t]*$/;function H(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new R(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `)if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new R(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let s=Qt(e,t);if(s<0)throw new R(`unfinished string encountered`,{toml:e,ptr:t});r=e.indexOf(`.`,s);let c=e.slice(s,r<0||r>a?a:r),l=z(c);if(l>-1)throw new R(`newlines are not allowed in keys`,{toml:e,ptr:t+r+l});if(c.trimStart())throw new R(`found extra tokens after the string part`,{toml:e,ptr:s});if(a<s&&(a=e.indexOf(n,s),a<0))throw new R(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(sn(e,t,s))}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!dn.test(n))throw new R(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}while(r+1&&r<a);return[i,V(e,a+1,!0,!0)]}E(H,`parseKey`);function fn(e,t,n,r){let i={},a=new Set,o,s=0;for(t++;(o=e[t++])!==`}`&&o;){let c={toml:e,ptr:t-1};if(o===`
|
|
59
|
-
`)throw new R(`newlines are not allowed in inline tables`,c);if(o===`#`)throw new R(`inline tables cannot contain comments`,c);if(o===`,`)throw new R(`expected key-value, found comma`,c);if(o!==` `&&o!==` `){let o,c=i,l=!1,[u,d]=H(e,t-1);for(let n=0;n<u.length;n++){if(n&&(c=l?c[o]:c[o]={}),o=u[n],(l=Object.hasOwn(c,o))&&(typeof c[o]!=`object`||a.has(c[o])))throw new R(`trying to redefine an already defined value`,{toml:e,ptr:t});!l&&o===`__proto__`&&Object.defineProperty(c,o,{enumerable:!0,configurable:!0,writable:!0})}if(l)throw new R(`trying to redefine an already defined value`,{toml:e,ptr:t});let[f,p]=un(e,d,`}`,n-1,r);a.add(f),c[o]=f,t=p,s=e[t-1]===`,`?t-1:0}}if(s)throw new R(`trailing commas are not allowed in inline tables`,{toml:e,ptr:s});if(!o)throw new R(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}E(fn,`parseInlineTable`);function pn(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new R(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=B(e,t);else if(a!==` `&&a!==` `&&a!==`
|
|
60
|
-
`&&a!==`\r`){let a=un(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new R(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}E(pn,`parseArray`);function mn(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}E(mn,`peekTable`);function hn(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=V(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=H(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new R(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=mn(n[0],r,i,t?2:1);if(!c)throw new R(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=H(e,s),i=mn(r[0],a,o,0);if(!i)throw new R(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=un(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=V(e,s,!0),e[s]&&e[s]!==`
|
|
61
|
-
`&&e[s]!==`\r`)throw new R(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=V(e,s)}return r}E(hn,`parse`);var gn=/^[a-z0-9-_]+$/i;function U(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}E(U,`extendedTypeOf`);function _n(e){for(let t=0;t<e.length;t++)if(U(e[t])!==`object`)return!1;return e.length!=0}E(_n,`isArrayOfTables`);function W(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}E(W,`formatString`);function vn(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:r&&Number.isInteger(e)?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return W(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return yn(e,n,r);if(t===`array`)return bn(e,n,r)}E(vn,`stringifyValue`);function yn(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=gn.test(o)?o:W(o),i+=` = `,i+=vn(e[o],U(e[o]),t-1,n)}return i+` }`}E(yn,`stringifyInlineTable`);function bn(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=vn(e[i],U(e[i]),t-1,n)}return r+` ]`}E(bn,`stringifyArray`);function xn(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
|
|
62
|
-
`}[[${t}]]
|
|
63
|
-
`,i+=Sn(0,e[a],t,n,r);return i}E(xn,`stringifyArrayTable`);function Sn(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=U(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=gn.test(c)?c:W(c);if(e===`array`&&_n(t[c]))o+=(o&&`
|
|
64
|
-
`)+xn(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
|
|
65
|
-
`)+Sn(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=vn(t[c],e,r,i),a+=`
|
|
66
|
-
`}}return e&&(a||!o)&&(a=a?`[${e}]
|
|
67
|
-
${a}`:`[${e}]`),a&&o?`${a}
|
|
68
|
-
${o}`:a||o}E(Sn,`stringifyTable`);function Cn(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(U(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Sn(0,e,``,t,n);return r[r.length-1]===`
|
|
69
|
-
`?r:r+`
|
|
70
|
-
`}E(Cn,`stringify`);var wn={parse:hn,stringify:Cn,TomlDate:en,TomlError:R},Tn=`config`;function En(e){if(e===void 0||e===`default`){let e=f();return e===`production`?`default`:e}return Gt(e),e}E(En,`resolveAuthProfileBaseName`);function G(e,t){return C.join(e,Tn,`${En(t)}.toml`)}E(G,`getAuthConfigFilePath`);var Dn=class{constructor(e,t){this.configPath=e,this.profile=t}static{E(this,`FileCredentialStore`)}kind=`file`;read(){let e=G(this.configPath,this.profile);if(b(e))return a(m(e))}write(e){let t=G(this.configPath,this.profile);he(C.dirname(t),{recursive:!0}),S(t,wn.stringify(e),{encoding:`utf-8`,mode:384}),me(t,384)}clear(){let e=G(this.configPath,this.profile),t=b(e);return t&&x(e),t}path(){return G(this.configPath,this.profile)}describe(){return G(this.configPath,this.profile)}},K=32,On=12,kn=16,An=`AES-256-GCM`,jn=`aes-256-gcm`;function Mn(){return new Uint8Array(Te(K))}E(Mn,`generateKey`);function Nn(e,t){if(t.length!==K)throw Error(`AES-256-GCM requires a ${K}-byte key (got ${t.length} bytes).`);let n=Te(On),r=Se(jn,t,n),i=Buffer.concat([r.update(e,`utf-8`),r.final()]),a=r.getAuthTag();return{v:1,alg:An,iv:n.toString(`base64`),tag:a.toString(`base64`),ciphertext:i.toString(`base64`)}}E(Nn,`encryptString`);function Pn(e,t){if(t.length!==K)throw Error(`AES-256-GCM requires a ${K}-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!==On)throw Error(`Expected ${On}-byte IV in envelope (got ${n.length} bytes).`);if(r.length!==kn)throw Error(`Expected ${kn}-byte auth tag in envelope (got ${r.length} bytes).`);let a=Ce(jn,t,n);return a.setAuthTag(r),Buffer.concat([a.update(i),a.final()]).toString(`utf-8`)}E(Pn,`decryptString`);function Fn(e){if(typeof e!=`object`||!e)return;let t=e;if(!(t.v!==1||t.alg!==An||typeof t.iv!=`string`||typeof t.tag!=`string`||typeof t.ciphertext!=`string`))return t}E(Fn,`parseEncryptedEnvelope`);function q(e,t){return C.join(e,`config`,`${En(t)}.enc`)}E(q,`getEncryptedAuthConfigFilePath`);var In=class{constructor(e,t,n,r){this.configPath=e,this.keyProvider=t,this.onPlaintextMigration=n,this.profile=r}static{E(this,`EncryptedFileCredentialStore`)}kind=`encrypted-file`;read(){let e=q(this.configPath,this.profile);if(b(e))return this.readEncryptedFile(e);let t=G(this.configPath,this.profile);if(b(t))return this.migrateFromPlaintext(t,e)}write(e){let t=this.ensureKey(),n=Nn(wn.stringify(e),t),r=q(this.configPath,this.profile);he(C.dirname(r),{recursive:!0}),S(r,JSON.stringify(n,null,` `),{encoding:`utf-8`,mode:384}),me(r,384);let i=G(this.configPath,this.profile);b(i)&&x(i)}clear(){let e=q(this.configPath,this.profile),t=G(this.configPath,this.profile),n=!1;b(e)&&(x(e),n=!0),b(t)&&(x(t),n=!0);try{this.keyProvider.deleteKey()}catch{}return n}path(){return q(this.configPath,this.profile)}describe(){return`Encrypted file (${q(this.configPath,this.profile)}) with key in ${this.keyProvider.describe()}`}readEncryptedFile(e){let t=this.keyProvider.getKey();if(t===void 0)return;let n=m(e),r;try{r=Fn(JSON.parse(n))}catch{return}if(r===void 0)return;let i;try{i=Pn(r,t)}catch{return}try{return wn.parse(i)}catch{return}}migrateFromPlaintext(e,t){let n=m(e),r;try{r=wn.parse(n)}catch{return}return this.write(r),this.onPlaintextMigration?.({plaintextPath:e,encryptedPath:t,keyProviderDescription:this.keyProvider.describe()}),r}ensureKey(){let e=this.keyProvider.getKey();if(e!==void 0)return e;let t=Mn();return this.keyProvider.setKey(t),t}},Ln=`1.3.0`;function Rn(e){return xe(`npm`,e,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],shell:process.platform===`win32`})}E(Rn,`defaultNpmRunner`);var zn=Rn,J=new Map;function Bn(e){zn=e??Rn,J.clear()}E(Bn,`setNpmRunner`);function Vn(e){return C.join(e,`native`,`keyring`)}E(Vn,`getKeyringInstallDir`);function Hn(e){return C.join(e,`node_modules`,`@napi-rs`,`keyring`)}E(Hn,`getInstalledBindingPath`);function Un(e){let t=J.get(e);if(t!==void 0)return t;let n=Hn(e);if(b(C.join(n,`index.js`)))return J.set(e,n),n;try{let t=zn([`root`,`-g`]);if(t.status===0){let n=C.join(t.stdout.trim(),`@napi-rs`,`keyring`);if(b(C.join(n,`index.js`)))return J.set(e,n),n}}catch{}return J.set(e,null),null}E(Un,`findKeyringBinding`);function Wn(e){let t=e;he(t,{recursive:!0});let n=C.join(t,`package.json`);b(n)||S(n,JSON.stringify({private:!0,name:`cloudflare-auth-keyring-host`},null,` `),`utf-8`);let r;try{r=zn([`install`,`@napi-rs/keyring@${Ln}`,`--prefix`,t,`--no-save`,`--no-audit`,`--no-fund`,`--no-package-lock`,`--loglevel=error`])}catch(e){throw new s(`Failed to spawn \`npm\` to install the keyring backend: ${e instanceof Error?e.message:String(e)}
|
|
71
|
-
|
|
72
|
-
Install \`npm\` and retry, or install the binding globally:
|
|
73
|
-
npm install -g @napi-rs/keyring@${Ln}`,{telemetryMessage:`workers-auth keyring npm spawn failed`})}if(r.status!==0)throw new s(`Failed to install \`@napi-rs/keyring\` (npm exited ${r.status}):
|
|
74
|
-
${r.stderr?.trim()??`(no stderr)`}
|
|
75
|
-
|
|
76
|
-
Retry once the underlying issue is fixed, or install the binding globally:
|
|
77
|
-
npm install -g @napi-rs/keyring@${Ln}`,{telemetryMessage:`workers-auth keyring npm install failed`});J.delete(e)}E(Wn,`installKeyringBindingSync`);var Gn;function Kn(e){Gn=e}E(Kn,`setKeyringEntryFactory`);var qn=pe(import.meta.url);function Jn(e){if(Gn!==void 0)return Gn;let t=Un(e);if(t===null)throw Error("`@napi-rs/keyring` binding not found. Call `installKeyringBindingSync()` first.");let n=qn(t);return(e,t)=>new n.Entry(e,t)}E(Jn,`resolveKeyringEntryFactory`);function Y(e){return En(e)}E(Y,`getKeyringAccountName`);function Yn(e){let t={v:1,key:Buffer.from(e).toString(`base64`),created:new Date().toISOString()};return JSON.stringify(t)}E(Yn,`encodeKeyEnvelope`);function Xn(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}}E(Xn,`decodeKeyEnvelope`);function Zn(e,t={}){return xe(`secret-tool`,e,{encoding:`utf-8`,input:t.input})}E(Zn,`defaultRunner`);var X=Zn,Qn=void 0;function $n(e){X=e??Zn,Qn=void 0}E($n,`setLinuxSecretToolRunner`);function er(){if(Qn!==void 0)return Qn;let e;try{e=X([`--version`]).status===0}catch{e=!1}return Qn=e,e}E(er,`probeSecretTool`);var tr=class{constructor(e,t){this.serviceName=e,this.profile=t}static{E(this,`LinuxSecretToolKeyProvider`)}getKey(){let e=X([`lookup`,`service`,this.serviceName,`account`,Y(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 Xn(e.stdout.trim())}}setKey(e){let t=X([`store`,`--label=Cloudflare credentials key`,`service`,this.serviceName,`account`,Y(this.profile)],{input:Yn(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=X([`clear`,`service`,this.serviceName,`account`,Y(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=${Y(this.profile)})`}},nr=44;function rr(e,t={}){return xe(`/usr/bin/security`,e,{encoding:`utf-8`,input:t.input})}E(rr,`defaultRunner`);var ir=rr;function ar(e){ir=e??rr}E(ar,`setMacSecurityCommandRunner`);var or=class{constructor(e,t){this.serviceName=e,this.profile=t}static{E(this,`MacSecurityKeyProvider`)}getKey(){let e=ir([`find-generic-password`,`-s`,this.serviceName,`-a`,Y(this.profile),`-w`]);if(e.status!==nr){if(e.status!==0)throw Error(`Failed to read key from macOS Keychain (exit ${e.status}): ${e.stderr?.trim()??`(no stderr)`}`);return Xn(e.stdout.trim())}}setKey(e){let t=ir([`add-generic-password`,`-s`,this.serviceName,`-a`,Y(this.profile),`-w`,Yn(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=ir([`delete-generic-password`,`-s`,this.serviceName,`-a`,Y(this.profile)]);if(!(e.status===0||e.status===nr))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=${Y(this.profile)})`}},sr=class{constructor(e,t,n){this.serviceName=e,this.installDir=t,this.profile=n}static{E(this,`NapiKeyringKeyProvider`)}entry(){return Jn(this.installDir)(this.serviceName,Y(this.profile))}getKey(){let e=this.entry().getPassword();if(!(e===null||e===``))return Xn(e)}setKey(e){this.entry().setPassword(Yn(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=${Y(this.profile)})`}},cr;function lr(e){cr=e}E(lr,`setKeyProviderFactoryForTesting`);function ur(e,t,n){if(cr!==void 0)return{kind:`available`,provider:cr(e,t)};switch(process.platform){case`darwin`:return{kind:`available`,provider:new or(e,t)};case`linux`:return er()?{kind:`available`,provider:new tr(e,t)}:{kind:`unsupported`};case`win32`:{let r=Vn(n);return Un(r)===null?{kind:`needs-install`,install:E(()=>Wn(r),`install`),afterInstall:E(()=>new sr(e,r,t),`afterInstall`)}:{kind:`available`,provider:new sr(e,r,t)}}default:return{kind:`unsupported`}}}E(ur,`resolveKeyProvider`);var dr={installFailedThisSession:!1,hasWarnedAboutKeyringFallback:!1,hasWarnedAboutSecretToolMissing:!1};function fr(){return dr}E(fr,`getResolverSessionFlags`);function pr(){dr.installFailedThisSession=!1,dr.hasWarnedAboutKeyringFallback=!1,dr.hasWarnedAboutSecretToolMissing=!1}E(pr,`resetCredentialStorageState`);function mr(e){let t={...e,cliName:e.cliName??`your CLI`};function n(e){return hr(t,e)}E(n,`getActiveStore`);function r(e){return{read:E(()=>n(e).read(),`read`),write:E(t=>n(e).write(t),`write`),clear:E(()=>n(e).clear(),`clear`),path:E(()=>n(e).path(),`path`)}}return E(r,`storageFactory`),{storageFactory:r,getActiveStore:n}}E(mr,`createCredentialStorageContext`);function hr(e,t){let n=Ke(),r=e.getConfigPath();if(n===!1)return new Dn(r,t);let i=n===!0;if(!(n??e.isKeyringEnabled()??!1))return new Dn(r,t);let a=ur(e.serviceName,t,r);switch(a.kind){case`available`:return new In(r,a.provider,gr(e),t);case`needs-install`:return _r(a,i,e,t);case`unsupported`:return vr(i,e,t)}}E(hr,`resolveActiveCredentialStore`);function gr(e){return t=>{e.logger.warn(`Migrated credentials from ${t.plaintextPath} into ${t.encryptedPath} (key in ${t.keyProviderDescription}). The plaintext file has been deleted.`)}}E(gr,`buildMigrationLogger`);function _r(e,t,n,r){let i=fr();if(i.installFailedThisSession){if(t)throw new s(`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 yr(`The keyring backend could not be installed earlier this session; using the plaintext credentials file.`,n,r)}if(n.isNonInteractiveOrCI())throw new s(xr(n.cliName),{telemetryMessage:`workers-auth keyring binding not installed`});try{n.logger.log(`🔐 Installing keyring backend (one-time, ~2 MB)…`),e.install()}catch(e){if(i.installFailedThisSession=!0,t)throw e instanceof s?e:new s(`Failed to install the keyring backend: ${e instanceof Error?e.message:String(e)}`,{telemetryMessage:`workers-auth keyring install threw`});return yr(`Failed to install the keyring backend (${e instanceof Error?e.message:String(e)}); falling back to the plaintext credentials file.`,n,r)}return new In(n.getConfigPath(),e.afterInstall(),gr(n),r)}E(_r,`handleNeedsInstall`);function vr(e,t,n){let r=process.platform,i=r===`linux`,a=i?br(t.cliName):`OS keyring storage is not supported on \`${r}\`; falling back to the plaintext credentials file.`;if(e)throw new s(i?`CLOUDFLARE_AUTH_USE_KEYRING is set but ${a}`:`CLOUDFLARE_AUTH_USE_KEYRING is set but no keyring backend is available on \`${r}\`.`,{telemetryMessage:i?`workers-auth keyring secret tool missing`:`workers-auth keyring unsupported platform`});if(i&&t.isNonInteractiveOrCI())throw new s(a,{telemetryMessage:`workers-auth keyring secret tool missing`});let o=fr();return i?(o.hasWarnedAboutSecretToolMissing||(o.hasWarnedAboutSecretToolMissing=!0,t.logger.warn(`${a}
|
|
78
|
-
|
|
79
|
-
Falling back to the plaintext credentials file for this session.`)),new Dn(t.getConfigPath(),n)):yr(a,t,n)}E(vr,`handleUnsupported`);function yr(e,t,n){let r=fr();return r.hasWarnedAboutKeyringFallback||(r.hasWarnedAboutKeyringFallback=!0,t.logger.warn(e)),new Dn(t.getConfigPath(),n)}E(yr,`fallbackToFileWithWarning`);function br(e){return`\`secret-tool\` is required for OS keyring storage on Linux but is not installed.
|
|
80
|
-
|
|
81
|
-
Install it via your package manager:
|
|
82
|
-
Debian/Ubuntu: sudo apt-get install libsecret-tools
|
|
83
|
-
Fedora/RHEL: sudo dnf install libsecret
|
|
84
|
-
Arch: sudo pacman -S libsecret
|
|
85
|
-
Alpine: apk add libsecret
|
|
86
|
-
|
|
87
|
-
Or disable keyring storage: \`${e} login --no-use-keyring\`.`}E(br,`secretToolMissingMessage`);function xr(e){return`\`@napi-rs/keyring\` is required for OS keyring storage on Windows but is not installed.
|
|
88
|
-
|
|
89
|
-
Run \`${e} login --use-keyring\` interactively to install it automatically, or install it globally for CI:
|
|
90
|
-
|
|
91
|
-
npm install -g @napi-rs/keyring@${Ln}
|
|
92
|
-
|
|
93
|
-
Or disable keyring storage: \`${e} login --no-use-keyring\`.`}E(xr,`windowsBindingMissingMessage`);function Sr(e){let t=q(e.configPath,e.profile),n=b(t),r=ur(e.serviceName,e.profile,e.configPath);return r.kind===`available`?(new In(e.configPath,r.provider,void 0,e.profile).clear(),{backendAvailable:!0,encryptedFileExisted:n}):(n&&x(t),{backendAvailable:!1,encryptedFileExisted:n})}E(Sr,`scrubEncryptedCredentials`);const{white:Cr,gray:wr,dim:Tr,hidden:Er,bold:Dr,cyanBright:Or,bgCyan:kr}=v;v.hex(`#BD5B08`);const Ar=v.hex(`#111`);v.hex(`#0E838F`);const jr=Ar.bgHex(`#0E838F`);v.hex(`#AB2526`);const Mr=Ar.bgHex(`#AB2526`);v.hex(`#218529`);const Nr=Ar.bgHex(`#218529`);v.hex(`#7F7322`);const Pr=Ar.bgHex(`#7F7322`),Fr=process.stdout;process.stderr;var Ir=e(ie(),1);const Lr={diamond:`◇`,dash:`─`,radioInactive:`○`,radioActive:`●`,backActive:`◀`,backInactive:`◁`,bar:`│`,leftT:`├`,rigthT:`┤`,arrows:{left:`‹`,right:`›`},corners:{tl:`╭`,bl:`╰`,tr:`╮`,br:`╯`}};Mr(` ERROR `),Pr(` WARNING `),jr(` INFO `),Nr(` SUCCESS `),Cr.bgRed(` X `),le(Fr),wr(Lr.bar),wr(Lr.corners.bl),wr(Lr.leftT);function Rr(){try{return!!(process.stdin.isTTY&&process.stdout.isTTY)}catch{return!1}}function Z(){return!Rr()||Ir.isCI}const zr=Ir.isCI;function Br(){r(n)}async function Vr(e){let t=h(),n=e.map(e=>({value:e,label:e.name})),r=await new ae({options:n,initialValue:n[0]?.value,render(){let e=t.bold(`Select an account`),n=this.options.map((e,n)=>{let r=n===this.cursor,i=e.value,a=t.hex(g.muted)(`${i.id.slice(0,12)}...`);return r?` ${t.hex(g.orange)(`>`)} ${t.bold(i.name)} ${a}`:` ${t.dim(i.name)} ${a}`});return`${e} ${t.dim(`(use arrow keys, enter to confirm)`)}\n${n.join(`
|
|
94
|
-
`)}`}}).prompt();return y(r)||!r?null:r}async function Hr(){let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));let t=Buffer.concat(e).toString(`utf-8`);return t.endsWith(`
|
|
95
|
-
`)?t.slice(0,-1):t}async function Ur(e,t,n){let r=n?.kind??`text`;if(Z()){if(r===`secret`){let t=await Hr();if(t.length>0)return t;throw Error(`--${e} is required. Pipe the value via stdin, pass --${e} <value>, or run interactively.`)}throw Error(`--${e} is required. Pass --${e} <value> or run interactively.`)}let i=`Enter value for --${e}`,a=t||n?.question||i;Br();let o=r===`secret`?await ce({message:a,mask:`•`,validate:e=>e&&e.length>0?void 0:`Value cannot be empty`}):await se({message:a,validate:e=>e&&e.length>0?void 0:`Value cannot be empty`});return(y(o)||typeof o!=`string`)&&process.exit(130),o}async function Wr(e,t,n){if(Z())throw Error(`--${e} is required (one of: ${n.join(`, `)}). Pass --${e} <value> or run interactively.`);let r=`Select value for --${e}`,i=t||r;Br();let a=await oe({message:i,options:n.map(e=>({value:e,label:e}))});return(y(a)||typeof a!=`string`)&&process.exit(130),a}async function Gr(e={}){if(e.force===!0)return!0;let t=e.message?`${e.message} Continue?`:`This permanently deletes the resource. Continue?`;if(Z()){let e=h();return process.stderr.write(`${e.hex(g.warning)(`?`)} ${t}\n ${e.dim(`(non-interactive; pass --force to confirm)`)}\n`),!1}Br();let n=await ue({message:t,initialValue:!1});return y(n)&&process.exit(130),n===!0}const Q=`.cfrc`;function Kr(e){let t=e||process.cwd(),n=w(t);for(;t!==n;){let e=T(t,Q);if(b(e))try{let t=ge(e,`utf-8`).replace(/^\s*\/\/.*$/gm,``);return{config:JSON.parse(t),path:e}}catch{}t=w(t)}let r=T(t,Q);if(b(r))try{let e=ge(r,`utf-8`).replace(/^\s*\/\/.*$/gm,``);return{config:JSON.parse(e),path:r}}catch{}return null}function qr(e,t){S(T(t||process.cwd(),Q),JSON.stringify(e,null,2)+`
|
|
96
|
-
`,{mode:384})}function Jr(e){let t=T(e||process.cwd(),Q);return b(t)?(_e(t),!0):!1}async function Yr(e){let t={},n=$(`accountId`,`CLOUDFLARE_ACCOUNT_ID`);n&&(t.accountId=n);let r=$(`zone`,`CLOUDFLARE_ZONE_ID`,e?.zone);r&&(t.zone=r);let i=$(`complianceRegion`,`CLOUDFLARE_COMPLIANCE_REGION`);return i&&(t.complianceRegion=i),t}function $(e,t,n){if(n)return{value:n,source:`flag`};let r=process.env[t];if(r)return{value:r,source:`env`};let i=Kr(),a=i?.config[e];if(a)return{value:a,source:`project`,path:i.path};let o=_().defaults?.[e];if(o)return{value:o,source:`config`,path:re()}}function Xr(){return $(`accountId`,`CLOUDFLARE_ACCOUNT_ID`)?.value}async function Zr(e){let t=$(`accountId`,`CLOUDFLARE_ACCOUNT_ID`);if(t)return Qr(t.value,ci(t,`accountId`)),t.value;if(e){let t=await $r(e);if(t)return t}throw Error(`No account ID found.
|
|
97
|
-
|
|
98
|
-
Please provide one of the following:
|
|
99
|
-
1. CLOUDFLARE_ACCOUNT_ID environment variable
|
|
100
|
-
2. Run 'cf context set account-id <id>' to set a default
|
|
101
|
-
3. Create a .cfrc file in your project
|
|
102
|
-
|
|
103
|
-
You can find your account ID in the Cloudflare dashboard URL:
|
|
104
|
-
https://dash.cloudflare.com/<account-id>/...`)}function Qr(e,t){if(!process.env.DEBUG)return;let n=e.length>12?e.slice(0,12)+`…`:e;process.stderr.write(`Using account: ${n} (${t})\n`)}async function $r(e){let t;try{t=await di(e)}catch{return}if(t.length===0)return;if(t.length===1&&t[0]){let n=t[0],{displayName:r}=await li(`accountId`,n.id,`user`,e);return Qr(n.id,`auto-selected from token — ${r}`),n.id}if(Z()){let e=t.map(e=>` ${e.id} ${e.name}`).join(`
|
|
105
|
-
`);throw Error(`Multiple accounts available but running non-interactively.
|
|
106
|
-
|
|
107
|
-
Available accounts:
|
|
108
|
-
${e}
|
|
109
|
-
|
|
110
|
-
Set one with CLOUDFLARE_ACCOUNT_ID or 'cf context set account-id'.`)}let n=await Vr(t);n||process.exit(130);let{displayName:r}=await li(`accountId`,n.id,`user`,e);return Qr(n.id,`selected interactively — ${r}`),n.id}async function ei(e,t,n){if(e?.zoneId)return ti(e.zoneId,t);let r=$(`zone`,`CLOUDFLARE_ZONE_ID`,e?.zone);if(r){if(!n?.quiet&&r.source!==`flag`){let e=ci(r);console.error(`Using zone: ${r.value} (from ${e})`)}return ti(r.value,t)}throw Error(`No zone specified.
|
|
111
|
-
|
|
112
|
-
Please provide one of the following:
|
|
113
|
-
1. Zone as a positional argument: cf dns records list <zone>
|
|
114
|
-
2. --zone flag (or -z): cf dns records list --zone example.com
|
|
115
|
-
3. CLOUDFLARE_ZONE_ID environment variable
|
|
116
|
-
4. Run 'cf context set zone <zone>' to set a default
|
|
117
|
-
5. Create a .cfrc file in your project with {"zone": "example.com"}`)}async function ti(e,t){if(fe(e)||!t)return e;let{resolveZoneId:n}=await import(`./resolve-BuJRWSk0.mjs`).then(e=>e.r);return n(t,await Zr(),e)}function ni(e){if(e?.scriptName)return e.scriptName;throw Error("Required Worker name missing. Please specify the Worker name with `--worker <name>`.")}const ri=[`public`,`fedramp_high`],ii={"account-id":`accountId`,zone:`zone`,"compliance-region":`complianceRegion`},ai=Object.keys(ii);function oi(e){return ri.includes(e)}function si(){let e=$(`complianceRegion`,`CLOUDFLARE_COMPLIANCE_REGION`);if(!e)return`public`;if(!oi(e.value))throw Error(`Invalid compliance region "${e.value}". Must be one of: ${ri.join(`, `)}`);return e.value}function ci(e,t=`zone`){switch(e.source){case`flag`:return t===`zone`?`--zone flag`:`(flag)`;case`env`:return{accountId:`CLOUDFLARE_ACCOUNT_ID`,zone:`CLOUDFLARE_ZONE_ID`,complianceRegion:`CLOUDFLARE_COMPLIANCE_REGION`}[t];case`project`:return`.cfrc`;case`config`:return`~/.config/cf/config.json`}}async function li(e,t,n,r){let i=t,a=t;if(e===`accountId`){if(!r)throw Error(`Authentication required to validate account ID`);let{id:e,name:n}=await fi(t,r);i=e,a=n?`${e.slice(0,12)}... (${n})`:e}else if(e===`zone`){if(!r)throw Error(`Authentication required to validate zone`);let e=await pi(t,r);i=t,a=e.name}else e===`complianceRegion`&&(i=t,a=t);if(n===`project`){let t=Kr()?.config||{};t[e]=i,qr(t)}else{let t=_();t.defaults||={},t.defaults[e]=i,te(t)}return{resolvedValue:i,displayName:a}}function ui(e,t){if(t===`project`)if(e===`all`)Jr();else{let t=Kr();t&&(delete t.config[e],Object.keys(t.config).length===0?Jr(w(t.path)):qr(t.config,w(t.path)))}else{let t=_();t.defaults&&(e===`all`?delete t.defaults:(delete t.defaults[e],Object.keys(t.defaults).length===0&&delete t.defaults),te(t))}}async function di(e){return await e.get(`/accounts`)}async function fi(e,t){let n=await di(t),r=n.find(t=>t.id===e);if(r)return{id:r.id,name:r.name};let i=n.find(t=>t.name.toLowerCase()===e.toLowerCase());if(i)return{id:i.id,name:i.name};if(fe(e))return{id:e};throw Error(`Account not found: "${e}"
|
|
118
|
-
|
|
119
|
-
Available accounts:
|
|
120
|
-
${n.map(e=>` ${e.id.slice(0,12)}... ${e.name}`).join(`
|
|
121
|
-
`)}`)}async function pi(e,t){let n=await t.zones.list(),r=n.find(t=>t.id===e);if(r)return{id:r.id,name:r.name};let i=n.find(t=>t.name.toLowerCase()===e.toLowerCase());if(i)return{id:i.id,name:i.name};throw de(e)?Error(`Zone not found: "${e}"
|
|
122
|
-
|
|
123
|
-
This zone either doesn't exist or you don't have access to it.
|
|
124
|
-
Run 'cf zones list' to see available zones.`):Error(`Invalid zone: "${e}"
|
|
125
|
-
|
|
126
|
-
Please provide a zone ID or domain name.
|
|
127
|
-
Run 'cf zones list' to see available zones.`)}function mi(){return T(process.cwd(),Q)}const hi=`openid.offline.user:read.account:read.access:read.access:write.agw:read.agw:run.agw:write.ai:read.ai:write.ai-search:read.ai-search:run.ai-search:write.aiaudit:read.aiaudit:write.aig:read.aig:write.auditlogs:read.browser:read.browser:write.cfone:read.cfone:write.cloudchamber:write.connectivity:admin.connectivity:bind.connectivity:read.constellation:write.containers:write.d1:write.dex:read.dex:write.dns_analytics:read.dns_records:edit.dns_records:read.dns_settings:read.firstpartytags:write.images:read.images:write.lb:edit.lb:read.logpush:read.logpush:write.mcp_portals:read.mcp_portals:write.notebook-examples:read.notification:read.notification:write.pages:read.pages:write.pipelines:read.pipelines:setup.pipelines:write.query_cache:write.queues:write.r2_catalog:write.radar:read.rag:read.rag:write.registrar:read.registrar:write.secrets_store:read.secrets_store:write.sso-connector:read.sso-connector:write.ssl_certs:write.teams:pii.teams:read.teams:secure_location.teams:write.url_scanner:read.url_scanner:write.vectorize:write.workers:read.workers:write.workers_builds:read.workers_builds:write.workers_deployments:read.workers_kv:write.workers_observability:read.workers_observability:write.workers_observability_telemetry:write.workers_routes:write.workers_scripts:write.workers_tail:read.zone:read`.split(`.`);function gi(){return T(ne(),`auth.jsonc`)}function _i(){return{read(){let e=gi(),t;try{t=ge(e,`utf-8`)}catch(e){if(e.code===`ENOENT`)return;throw e}try{return o(t,e)}catch{return}},write(e){let t=gi();he(w(t),{recursive:!0,mode:448}),S(t,JSON.stringify(e,null,2)+`
|
|
128
|
-
`,{encoding:`utf-8`,mode:384}),me(t,384)},clear(){let e=gi(),t=b(e);return x(e,{force:!0}),t},path(){return gi()}}}const vi=8877,yi=`localhost`,bi=`http://${yi}:${vi}/oauth/callback`,xi={granted:{url:`https://welcome.developers.workers.dev/cf-oauth-consent-granted`},denied:{url:`https://welcome.developers.workers.dev/cf-oauth-consent-denied`,error:"Error: Consent denied. You must grant consent to cf in order to login.\nIf you don't want to do this consider passing an API token via the `CLOUDFLARE_API_TOKEN` environment variable"}},Si=_i();function Ci(){return Le({allowGlobalAuthKey:!1})!==void 0}const wi={debug:(...e)=>{process.env.DEBUG&&console.error(...e)},info:(...e)=>console.error(...e),log:(...e)=>console.error(...e),warn:(...e)=>console.error(...e),error:(...e)=>console.error(...e)};function Ti(e){return new Promise((t,n)=>{let r=ye(),i;switch(r){case`darwin`:i=`open "${e}"`;break;case`win32`:i=`start "" "${e}"`;break;default:i=`xdg-open "${e}"`}be(i,e=>{e?n(Error(`Failed to open browser: ${e.message}`)):t()})})}const Ei=Ht({logger:wi,isNonInteractiveOrCI:Z,openInBrowser:Ti,hasEnvCredentials:Ci,clientId:`cbca97e7-c331-4cdd-8fd8-e25a451b98bf`,consent:xi,redirectUri:bi,storageFactory:()=>Si,allowGlobalAuthKey:!1,temporary:void 0});function Di(e){return Ei.login({complianceConfig:ee,scopes:[...hi],browser:e?.browser??!0,callbackHost:yi,callbackPort:vi})}function Oi(){return Ei.logout()}function ki(){return Ei.getOAuthTokenFromLocalState()}function Ai(){return O({storage:Si}).accessToken!==void 0}function ji(){return O({storage:Si})}function Mi(){return Si.path()}function Ni(e){try{let t=Ae(`ps -p ${e} -o pid=,ppid=,command=`,{encoding:`utf8`,timeout:5e3}).trim();if(!t)return null;let[n,r,...i]=t.split(/\s+/),a=n?parseInt(n,10):NaN,o=r?parseInt(r,10):NaN;return isNaN(a)||isNaN(o)?null:{pid:a,ppid:o,command:i.join(` `)||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function Pi(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=Ni(r);if(!e||e.ppid===0||e.ppid===1)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function Fi(e){try{let t=Ae(`wmic process where (ProcessId=${e}) get ProcessId,ParentProcessId,CommandLine /format:csv`,{encoding:`utf8`,timeout:1e4});if(!t)return null;let n=t.split(`
|
|
129
|
-
`).filter(e=>e.trim()&&!e.startsWith(`Node`)).pop()?.split(`,`);if(!n||n.length<4)return null;let[r,i,a,o]=n,s=o?parseInt(o.trim(),10):NaN,c=a?parseInt(a.trim(),10):NaN;return isNaN(s)||isNaN(c)?null:{pid:s,ppid:c,command:i?.trim()||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function Ii(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=Fi(r);if(!e||e.ppid===0||e.ppid===4)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function Li(e=process.pid){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`PID must be a positive integer`);return je.platform()===`win32`?Ii(e):Pi(e)}const Ri=[{id:`opencode`,name:`OpenCode`,type:`agent`,envVars:[{any:[`OPENCODE`,`OPENCODE_BIN_PATH`,`OPENCODE_SERVER`,`OPENCODE_APP_INFO`,`OPENCODE_MODES`]}]},{id:`jules`,name:`Jules`,type:`agent`,envVars:[{all:[[`HOME`,`/home/jules`],[`USER`,`swebot`]]}]},{id:`claude-code`,name:`Claude Code`,type:`agent`,envVars:[`CLAUDECODE`]},{id:`cursor-agent`,name:`Cursor Agent`,type:`agent`,envVars:[{all:[`CURSOR_TRACE_ID`,[`PAGER`,`head -n 10000 | cat`]]}]},{id:`cursor`,name:`Cursor`,type:`interactive`,envVars:[`CURSOR_TRACE_ID`]},{id:`gemini-agent`,name:`Gemini Agent`,type:`agent`,processChecks:[`gemini`]},{id:`codex`,name:`OpenAI Codex`,type:`agent`,processChecks:[`codex`]},{id:`replit`,name:`Replit`,type:`agent`,envVars:[`REPL_ID`]},{id:`aider`,name:`Aider`,type:`agent`,envVars:[`AIDER_API_KEY`],processChecks:[`aider`]},{id:`bolt-agent`,name:`Bolt.new Agent`,type:`agent`,envVars:[{all:[[`SHELL`,`/bin/jsh`],`npm_config_yes`]}]},{id:`bolt`,name:`Bolt.new`,type:`interactive`,envVars:[{all:[[`SHELL`,`/bin/jsh`]],none:[`npm_config_yes`]}]},{id:`zed-agent`,name:`Zed Agent`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`zed`],[`PAGER`,`cat`]]}]},{id:`zed`,name:`Zed`,type:`interactive`,envVars:[{all:[[`TERM_PROGRAM`,`zed`]],none:[[`PAGER`,`cat`]]}]},{id:`replit-assistant`,name:`Replit Assistant`,type:`agent`,envVars:[{all:[`REPL_ID`,[`REPLIT_MODE`,`assistant`]]}]},{id:`replit`,name:`Replit`,type:`interactive`,envVars:[{all:[`REPL_ID`],none:[[`REPLIT_MODE`,`assistant`]]}]},{id:`windsurf`,name:`Windsurf`,type:`agent`,envVars:[`CODEIUM_EDITOR_APP_ROOT`]},{id:`crush`,name:`Crush`,type:`agent`,processChecks:[`crush`]},{id:`vscode-copilot-agent`,name:`GitHub Copilot in VS Code`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`vscode`],[`GIT_PAGER`,`cat`]]}]},{id:`warp`,name:`Warp Terminal`,type:`hybrid`,envVars:[{all:[[`TERM_PROGRAM`,`WarpTerminal`]]}]},{id:`octofriend`,name:`Octofriend`,type:`agent`,processChecks:[`octofriend`]}];function zi(e,t=process.env){let[n,r]=typeof e==`string`?[e,void 0]:e,i=t[n];return!!(i&&(!r||i===r))}function Bi(e,t){try{let n=t??Li();for(let t of n)if(t.command?.includes(e))return!0}catch{}return!1}function Vi(e,t=process.env){if(typeof e==`string`||Array.isArray(e))return zi(e,t);let{any:n,all:r,none:i}=e,a=!n?.length||n.some(e=>zi(e,t)),o=!r?.length||r.every(e=>zi(e,t)),s=!i?.length||!i.some(e=>zi(e,t));return a&&o&&s}function Hi(e){return e.customDetectors?.some(e=>{try{return e()}catch{return!1}})??!1}function Ui(e){return{isAgentic:!0,id:e.id,name:e.name,type:e.type}}function Wi(e=process.env,t){for(let t of Ri)if(t.envVars?.some(t=>Vi(t,e)))return Ui(t);let n=t,r=()=>{if(n===void 0)try{n=Li()}catch{n=[]}return n};for(let e of Ri)if(e.processChecks?.some(e=>Bi(e,r())))return Ui(e);for(let e of Ri)if(Hi(e))return Ui(e);return{isAgentic:!1,id:null,name:null,type:null}}function Gi(){return zr?`ci`:Rr()?`interactive`:`non-interactive`}function Ki(){let e=Wi(),t=e.isAgentic&&e.id!==null?{"X-CF-CLI-Agent":e.id}:{};return{"User-Agent":`cf/${n}`,"X-CF-CLI-Mode":Gi(),...t}}async function qi(){let e=Le({allowGlobalAuthKey:!1});if(e&&`apiToken`in e)return e.apiToken;let t=await ki();if(t)return t;throw Error(`No authentication token found.
|
|
130
|
-
|
|
131
|
-
Please set one of the following:
|
|
132
|
-
1. Set the CLOUDFLARE_API_TOKEN environment variable
|
|
133
|
-
2. Run 'cf auth login' to authenticate via OAuth
|
|
134
|
-
|
|
135
|
-
For API tokens, visit: https://dash.cloudflare.com/profile/api-tokens`)}async function Ji(e){let n=p({compliance_region:si()});if(e.local){if(!e.localEndpoint)throw Error(`--local requires --local-endpoint <url>; this should have been caught by the global middleware.`);let{createLocalFetch:r}=await import(`./local-VJaJ3BZ1.mjs`).then(e=>e.r);return new t({apiToken:`cf-local-mode-no-auth`,baseURL:n,defaultHeaders:Ki(),fetch:r({endpoint:e.localEndpoint})})}return new t({apiToken:await qi(),baseURL:n,defaultHeaders:Ki()})}export{Gr as C,Z as E,li as S,Ur as T,Yr as _,ki as a,ei as b,Di as c,ii as d,ri as f,si as g,Zr as h,Mi as i,Oi as l,Kr as m,qi as n,Ai as o,ui as p,Ki as r,ji as s,Ji as t,ai as u,mi as v,Wr as w,Xr as x,ni as y};
|
package/dist/auth-DenWm_X0.mjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{i as e}from"./session-H7IV2BrM.mjs";import{a as t}from"./theme-BklJDrb2.mjs";import{i as n,n as r,r as i,t as a}from"./ui-BXjU1dX1.mjs";import{a as o,c as s,i as c,l,n as u,o as d,s as f}from"./auth-CQcAgnOy.mjs";import{t as p}from"./output-D7_yAFVR.mjs";const m={command:`login`,describe:`Authenticate with Cloudflare`,builder:e=>e.option(`force`,{type:`boolean`,alias:`f`,description:`Force re-authentication even if already logged in`,default:!1}),handler:async e=>{if(!e.force&&d()){if(await o()){let e=f();console.log(r(`You are already logged in.`)),console.log(`${t.info(`Config file:`)} ${t.muted(c())}`),e.accessToken&&console.log(`${t.info(`Token expires:`)} ${new Date(e.accessToken.expiry).toLocaleString()}`),console.log(a(`Run ${t.code(`cf auth login --force`)} to re-authenticate, or ${t.code(`cf auth logout`)} to log out.`));return}console.log(n(`Existing tokens are invalid or expired. Starting fresh login...
|
|
3
|
-
`))}else e.force&&d()&&console.log(r(`Re-authenticating...
|
|
4
|
-
`));if(console.log(r(`Starting OAuth login flow...
|
|
5
|
-
`)),!await s()){console.log(n(`CLOUDFLARE_API_TOKEN is set and takes precedence. Unset it to log in via OAuth.`));return}let l=f();console.log(`
|
|
6
|
-
`+i(`Successfully authenticated!`)),console.log(`${t.info(`Config file:`)} ${t.muted(c())}`),l.scopes&&console.log(`${t.info(`Scopes:`)} ${l.scopes.join(`, `)}`),l.accessToken&&console.log(`${t.info(`Token expires:`)} ${new Date(l.accessToken.expiry).toLocaleString()}`)}},h={command:`logout`,describe:`Log out and remove stored credentials`,handler:async()=>{let e=d(),o=!!process.env.CLOUDFLARE_API_TOKEN;if(!e){o?(console.log(r(`No cf OAuth credentials found, but CLOUDFLARE_API_TOKEN environment variable is set.`)),console.log(r(`Unset it with: unset CLOUDFLARE_API_TOKEN`))):(console.log(r(`You are not currently logged in.`)),console.log(a(`Run ${t.code(`cf auth login`)} to authenticate.`)));return}console.log(r(`Logging out...`)),await l(),console.log(i(`Successfully logged out.`)),console.log(`${t.info(`Removed:`)} OAuth tokens from ${t.muted(c())}`),o&&(console.log(``),console.log(n(`CLOUDFLARE_API_TOKEN environment variable is still set.`)),console.log(r(`You will remain authenticated via the env var. Unset it with: unset CLOUDFLARE_API_TOKEN`)))}},g={command:`whoami`,describe:`Show current user and authentication status`,builder:e=>e,handler:async t=>{let n=process.env.CLOUDFLARE_API_TOKEN,r=f(),i;i=n?`CLOUDFLARE_API_TOKEN environment variable`:r.accessToken?`OAuth token from ${c()}`:`none`;let a;try{a=await u()}catch{p({authenticated:!1,error:`Not logged in`});return}let o=new e({apiToken:a}),s=!1,l;try{let e=await o.get(`/user`);s=!0,l=e.email}catch(e){s=!1,process.env.DEBUG&&console.error(`Token verification error:`,e)}let d={authenticated:!0,authSource:i,tokenValid:s,...l&&{email:l}};r.accessToken&&(d.scopes=r.scopes,d.expiresAt=r.accessToken.expiry),p(d)}},_={command:`auth`,describe:`Authentication commands (login, logout, whoami)`,builder:e=>e.command(m).command(h).command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{_ as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{T as e,h as t,t as n,x as r}from"./auth-CQcAgnOy.mjs";import{n as i,t as a}from"./body-parser-Br-BoYk-.mjs";import{t as o}from"./output-D7_yAFVR.mjs";import{n as s,t as c}from"./progress-CjcQ6ato.mjs";import{n as l}from"./input-validation-zEO81MWN.mjs";import{t as u}from"./local-VJaJ3BZ1.mjs";function d(e){return e.positional(`id`,{type:`string`,description:`rag id`,demandOption:!0}).option(`max-num-results`,{type:`number`,description:`The max_num_results field`,default:10}).option(`query`,{type:`string`,description:`The query field`}).option(`ranking-options-ranker`,{type:`string`,description:`The ranking_options.ranker field`}).option(`ranking-options-score-threshold`,{type:`number`,description:`The ranking_options.score_threshold field`,default:.4}).option(`reranking-enabled`,{type:`boolean`,description:`The reranking.enabled field`,default:!1}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`,default:!1}).option(`stream`,{type:`boolean`,description:`The stream field`,default:!1}).option(`system-prompt`,{type:`string`,description:`The system_prompt 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 f={command:`ai-search <id>`,describe:`AI Search`,builder:d,handler:async d=>{if(d.dryRun){s({command:`cf autorag ai-search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/autorag/rags/${d.id==null?`<id>`:encodeURIComponent(String(d.id))}/ai-search`,pathParams:{id:String(d.id??``)},bodyKind:`json`,body:{"max-num-results":d[`max-num-results`],query:d.query,"ranking-options-ranker":d[`ranking-options-ranker`],"ranking-options-score-threshold":d[`ranking-options-score-threshold`],"reranking-enabled":d[`reranking-enabled`],"rewrite-query":d[`rewrite-query`],stream:d.stream,"system-prompt":d[`system-prompt`],body:d.body}});return}let f=await n(d),p=d.local?u:await t(f);if(d.accountId=p,d.body){let e=a(d.body);o(await c(`Creating`,async()=>f.post(`/accounts/${p}/autorag/rags/${encodeURIComponent(String(d.id))}/ai-search`,{body:e})),{successLabel:`Created`});return}d.query===void 0&&(d.query=await e(`query`,`The query field`));let m={};d[`max-num-results`]!==void 0&&i(m,[`max_num_results`],d[`max-num-results`]),d.query!==void 0&&i(m,[`query`],l(d.query,`query`,`text`)),d[`ranking-options-ranker`]!==void 0&&i(m,[`ranking_options`,`ranker`],l(d[`ranking-options-ranker`],`ranking-options-ranker`,`text`)),d[`ranking-options-score-threshold`]!==void 0&&i(m,[`ranking_options`,`score_threshold`],d[`ranking-options-score-threshold`]),d[`reranking-enabled`]!==void 0&&i(m,[`reranking`,`enabled`],d[`reranking-enabled`]),d[`rewrite-query`]!==void 0&&i(m,[`rewrite_query`],d[`rewrite-query`]),d.stream!==void 0&&i(m,[`stream`],d.stream),d[`system-prompt`]!==void 0&&i(m,[`system_prompt`],l(d[`system-prompt`],`system-prompt`,`text`)),o(await c(`Creating`,async()=>f.post(`/accounts/${p}/autorag/rags/${encodeURIComponent(String(d.id))}/ai-search`,{body:Object.keys(m).length>0?m:void 0})),{successLabel:`Created`})}};function p(e){return e.positional(`id`,{type:`string`,description:`rag id`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`search`,{type:`string`,description:`Search`}).option(`status`,{type:`string`,description:`Status`,choices:[`completed`,`queued`,`running`,`error`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const m={command:`files <id>`,describe:`Files`,builder:p,handler:async e=>{let i={page:e.page,per_page:e[`per-page`],search:e.search,status:e.status};if(e.dryRun){s({command:`cf autorag files`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/autorag/rags/${e.id==null?`<id>`:encodeURIComponent(String(e.id))}/files`,pathParams:{id:String(e.id??``)},query:i,bodyKind:`none`});return}let a=await n(e),l=e.local?u:await t(a);e.accountId=l,o(await c(`Loading`,async()=>a.autorag.files(e.id,l,i)),{successLabel:`Loaded`})}};function h(e){return e.positional(`job-id`,{type:`string`,description:`Job ID`,demandOption:!0}).option(`id`,{type:`string`,description:`rag id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get <job-id>`,describe:`Get a Job Details`,builder:h,handler:async e=>{if(e.dryRun){s({command:`cf autorag jobs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/autorag/rags/${e.id==null?`<id>`:encodeURIComponent(String(e.id))}/jobs/${e[`job-id`]==null?`<job-id>`:encodeURIComponent(String(e[`job-id`]))}`,pathParams:{id:String(e.id??``),"job-id":String(e[`job-id`]??``)},bodyKind:`none`});return}let i=await n(e),a=e.local?u:await t(i);e.accountId=a,o(await c(`Loading`,async()=>i.autorag.jobs.get(e.id,e[`job-id`],a)),{successLabel:`Loaded`})}};function _(e){return e.option(`id`,{type:`string`,description:`rag id`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`list`,describe:`List Jobs`,builder:_,handler:async e=>{let i={page:e.page,per_page:e[`per-page`]};if(e.dryRun){s({command:`cf autorag jobs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/autorag/rags/${e.id==null?`<id>`:encodeURIComponent(String(e.id))}/jobs`,pathParams:{id:String(e.id??``)},query:i,bodyKind:`none`});return}let a=await n(e),l=e.local?u:await t(a);e.accountId=l,o(await c(`Loading`,async()=>a.autorag.jobs.list(e.id,l,i)),{successLabel:`Loaded`})}};function y(e){return e.positional(`job-id`,{type:`string`,description:`Job ID`,demandOption:!0}).option(`id`,{type:`string`,description:`rag id`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`logs <job-id>`,describe:`List Job Logs`,builder:y,handler:async e=>{let i={page:e.page,per_page:e[`per-page`]};if(e.dryRun){s({command:`cf autorag jobs logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/autorag/rags/${e.id==null?`<id>`:encodeURIComponent(String(e.id))}/jobs/${e[`job-id`]==null?`<job-id>`:encodeURIComponent(String(e[`job-id`]))}/logs`,pathParams:{id:String(e.id??``),"job-id":String(e[`job-id`]??``)},query:i,bodyKind:`none`});return}let a=await n(e),l=e.local?u:await t(a);e.accountId=l,o(await c(`Loading`,async()=>a.autorag.jobs.logs(e.id,e[`job-id`],l,i)),{successLabel:`Loaded`})}},x={command:`jobs`,describe:`AutoRAG job operations`,builder:e=>e.command(g).command(v).command(b).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function S(e){return e.positional(`id`,{type:`string`,description:`rag id`,demandOption:!0}).option(`max-num-results`,{type:`number`,description:`The max_num_results field`,default:10}).option(`query`,{type:`string`,description:`The query field`}).option(`ranking-options-ranker`,{type:`string`,description:`The ranking_options.ranker field`}).option(`ranking-options-score-threshold`,{type:`number`,description:`The ranking_options.score_threshold field`,default:.4}).option(`reranking-enabled`,{type:`boolean`,description:`The reranking.enabled field`,default:!1}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`,default:!1}).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 C={command:`search <id>`,describe:`Search`,builder:S,handler:async d=>{if(d.dryRun){s({command:`cf autorag search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/autorag/rags/${d.id==null?`<id>`:encodeURIComponent(String(d.id))}/search`,pathParams:{id:String(d.id??``)},bodyKind:`json`,body:{"max-num-results":d[`max-num-results`],query:d.query,"ranking-options-ranker":d[`ranking-options-ranker`],"ranking-options-score-threshold":d[`ranking-options-score-threshold`],"reranking-enabled":d[`reranking-enabled`],"rewrite-query":d[`rewrite-query`],body:d.body}});return}let f=await n(d),p=d.local?u:await t(f);if(d.accountId=p,d.body){let e=a(d.body);o(await c(`Loading`,async()=>f.post(`/accounts/${p}/autorag/rags/${encodeURIComponent(String(d.id))}/search`,{body:e})),{successLabel:`Loaded`});return}d.query===void 0&&(d.query=await e(`query`,`The query field`));let m={};d[`max-num-results`]!==void 0&&i(m,[`max_num_results`],d[`max-num-results`]),d.query!==void 0&&i(m,[`query`],l(d.query,`query`,`text`)),d[`ranking-options-ranker`]!==void 0&&i(m,[`ranking_options`,`ranker`],l(d[`ranking-options-ranker`],`ranking-options-ranker`,`text`)),d[`ranking-options-score-threshold`]!==void 0&&i(m,[`ranking_options`,`score_threshold`],d[`ranking-options-score-threshold`]),d[`reranking-enabled`]!==void 0&&i(m,[`reranking`,`enabled`],d[`reranking-enabled`]),d[`rewrite-query`]!==void 0&&i(m,[`rewrite_query`],d[`rewrite-query`]),o(await c(`Loading`,async()=>f.post(`/accounts/${p}/autorag/rags/${encodeURIComponent(String(d.id))}/search`,{body:Object.keys(m).length>0?m:void 0})),{successLabel:`Loaded`})}};function w(e){return e.positional(`id`,{type:`string`,description:`rag id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`sync <id>`,describe:`Sync`,builder:w,handler:async e=>{if(e.dryRun){s({command:`cf autorag sync`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/autorag/rags/${e.id==null?`<id>`:encodeURIComponent(String(e.id))}/sync`,pathParams:{id:String(e.id??``)},bodyKind:`none`});return}let i=await n(e),a=e.local?u:await t(i);e.accountId=a,o(await c(`Updating`,async()=>i.autorag.sync(e.id,a)),{successLabel:`Updated`})}},E={command:`autorag`,describe:`AutoRAG — AI search, file management, job tracking, and sync for retrieval-augmented generation`,builder:e=>e.command(f).command(m).command(C).command(T).command(x).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{E as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{h as e,t,x as n}from"./auth-CQcAgnOy.mjs";import{t as r}from"./output-D7_yAFVR.mjs";import{n as i,t as a}from"./progress-CjcQ6ato.mjs";import{t as o}from"./local-VJaJ3BZ1.mjs";function s(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const c={command:`get`,describe:`Gets the current billing profile for the account.`,builder:s,handler:async s=>{if(s.dryRun){i({command:`cf billing profiles get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/billing/profile`,pathParams:{},bodyKind:`none`});return}let c=await t(s),l=s.local?o:await e(c);s.accountId=l,r(await a(`Loading`,async()=>c.billing.profiles.get(l)),{successLabel:`Loaded`})}},l={command:`profiles`,describe:`Billing profile with payment method, address, and invoice preferences`,builder:e=>e.command(c).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function u(e){return e.option(`from`,{type:`string`,description:`Defines the start date for the usage query (e.g., 2025-02-01).`}).option(`to`,{type:`string`,description:`Defines the end date for the usage query (e.g., 2025-03-01).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const d={command:`paygo`,describe:`Returns billable usage data for PayGo (self-serve) accounts. When no query parameters are provided, returns usage for the current billing period. This endpoint is currently in beta and access is restricted to select accounts.`,builder:u,handler:async s=>{let c={from:s.from,to:s.to};if(s.dryRun){i({command:`cf billing usage paygo`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/billing/usage/paygo`,pathParams:{},query:c,bodyKind:`none`});return}let l=await t(s),u=s.local?o:await e(l);s.accountId=u,r(await a(`Loading`,async()=>l.billing.usage.paygo(u,c)),{successLabel:`Loaded`})}},f={command:`usage`,describe:`Metered usage data for billed services — requests, bandwidth, and feature consumption`,builder:e=>e.command(d).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},p={command:`billing`,describe:`Account billing profiles and usage data for Cloudflare subscriptions and add-on services`,builder:e=>e.command(l).command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{p as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as e}from"node:fs";import{resolve as t}from"node:path";function n(e,t,n){if(t.length===0)return;let r=e;for(let e=0;e<t.length-1;e++){let n=t[e]??``;(!r[n]||typeof r[n]!=`object`)&&(r[n]={}),r=r[n]}let i=t[t.length-1]??``;r[i]=n}function r(n){let r=n;if(n.startsWith(`@`)){let i=n.slice(1);if(i.length===0)throw Error(`--body '@' must be followed by a file path (got empty path)`);let a=t(i);try{r=e(a,`utf-8`)}catch(e){let t=e instanceof Error?e.message:`unknown read error`;throw Error(`--body: cannot read file at '${i}': ${t}`)}}try{return JSON.parse(r)}catch{throw Error(`Invalid JSON in --body. Expected valid JSON.`)}}export{n,r as t};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{T as e,b as t,t as n,w as r}from"./auth-CQcAgnOy.mjs";import{n as i,t as a}from"./body-parser-Br-BoYk-.mjs";import{t as o}from"./output-D7_yAFVR.mjs";import{n as s,t as c}from"./progress-CjcQ6ato.mjs";import{n as l}from"./input-validation-zEO81MWN.mjs";function u(e){return e.option(`description`,{type:`string`,description:`The description field`}).option(`expression`,{type:`string`,description:`Wirefilter expression describing the traffic being reported.`}).option(`first-request-seen-at`,{type:`string`,description:`The first_request_seen_at field`}).option(`last-request-seen-at`,{type:`string`,description:`The last_request_seen_at field`}).option(`requests`,{type:`number`,description:`The requests field`}).option(`subtype`,{type:`string`,description:`The subtype field`}).option(`type`,{type:`string`,description:`Type of feedback report.`,choices:[`false_positive`,`false_negative`]}).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 d={command:`create`,describe:"Submit a feedback report for the specified zone. Use `type` to indicate whether the report is a false positive (good traffic flagged as bot) or a false negative (bot traffic missed). Furthermore, you can also use `expression` as a wirefilter to identify the affected traffic sample. See more accepted API fields and expression types at https://developers.cloudflare.com/bots/concepts/feedback-loop/#api-fields and https://developers.cloudflare.com/bots/concepts/feedback-loop/#expression-fields, respectively.",builder:u,handler:async u=>{if(u.dryRun){s({command:`cf bot-management feedback create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${u.zone??u.zoneId??`<zone>`}/bot_management/feedback`,pathParams:{"zone-id":String(u.zone??u[`zone-id`]??``)},bodyKind:`json`,body:{description:u.description,expression:u.expression,"first-request-seen-at":u[`first-request-seen-at`],"last-request-seen-at":u[`last-request-seen-at`],requests:u.requests,subtype:u.subtype,type:u.type,body:u.body}});return}let d=await n(u);if(u.zoneId=await t({zone:u.zone},d,{quiet:u.quiet}),u.body){let e=a(u.body);o(await c(`Creating`,async()=>d.post(`/zones/${u.zoneId}/bot_management/feedback`,{body:e})),{successLabel:`Created`});return}if(u.description===void 0&&(u.description=await e(`description`,`The description field`)),u.expression===void 0&&(u.expression=await e(`expression`,`Wirefilter expression describing the traffic being reported.`)),u[`first-request-seen-at`]===void 0&&(u[`first-request-seen-at`]=await e(`first-request-seen-at`,`The first_request_seen_at field`)),u[`last-request-seen-at`]===void 0&&(u[`last-request-seen-at`]=await e(`last-request-seen-at`,`The last_request_seen_at field`)),u.requests===void 0)throw Error(`--requests is required (or pass --body with this field set).`);u.type===void 0&&(u.type=await r(`type`,`Type of feedback report.`,[`false_positive`,`false_negative`]));let f={};u.description!==void 0&&i(f,[`description`],l(u.description,`description`,`text`)),u.expression!==void 0&&i(f,[`expression`],l(u.expression,`expression`,`text`)),u[`first-request-seen-at`]!==void 0&&i(f,[`first_request_seen_at`],l(u[`first-request-seen-at`],`first-request-seen-at`,`text`)),u[`last-request-seen-at`]!==void 0&&i(f,[`last_request_seen_at`],l(u[`last-request-seen-at`],`last-request-seen-at`,`text`)),u.requests!==void 0&&i(f,[`requests`],u.requests),u.subtype!==void 0&&i(f,[`subtype`],l(u.subtype,`subtype`,`text`)),u.type!==void 0&&i(f,[`type`],l(u.type,`type`,`text`)),o(await c(`Creating`,async()=>d.post(`/zones/${u.zoneId}/bot_management/feedback`,{body:Object.keys(f).length>0?f:void 0})),{successLabel:`Created`})}};function f(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const p={command:`list`,describe:`Returns all feedback reports previously submitted for the specified zone. Feedback reports help improve detection by sharing samples of traffic that were misclassified as bots or humans.`,builder:f,handler:async e=>{if(e.dryRun){s({command:`cf bot-management feedback list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/bot_management/feedback`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading`,async()=>r.botManagement.feedback.list(i)),{successLabel:`Loaded`})}},m={command:`feedback`,describe:`Feedback operations`,builder:e=>e.command(d).command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function h(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get`,describe:`Retrieve a zone's Bot Management Config`,builder:h,handler:async e=>{if(e.dryRun){s({command:`cf bot-management get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/bot_management`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading`,async()=>r.botManagement.get(i)),{successLabel:`Loaded`})}};function _(e){return e.option(`ai-bots-protection`,{type:`string`,description:"Enable rule to block AI Scrapers and Crawlers. Please note the value `only_on_ad_pages` is currently not available for Enterprise customers.",choices:[`block`,`disabled`,`only_on_ad_pages`]}).option(`cf-robots-variant`,{type:`string`,description:`Specifies the Robots Access Control License variant to use.`,choices:[`off`,`policy_only`]}).option(`content-bots-protection`,{type:`string`,description:`Enable rule to block content bots. When enabled, blocks automated traffic with low bot scores, excluding safe verified bot categories. Exceptions should be managed via skip rules.`,choices:[`block`,`disabled`]}).option(`crawler-protection`,{type:`string`,description:`Enable rule to punish AI Scrapers and Crawlers via a link maze.`,choices:[`enabled`,`disabled`]}).option(`enable-js`,{type:`boolean`,description:`Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/).`}).option(`is-robots-txt-managed`,{type:`boolean`,description:`Enable cloudflare managed robots.txt. If an existing robots.txt is detected, then managed robots.txt will be prepended to the existing robots.txt.`}).option(`fight-mode`,{type:`boolean`,description:`Whether to enable Bot Fight Mode.`}).option(`stale-zone-configuration-optimize-wordpress`,{type:`boolean`,description:`Indicates that the zone's wordpress optimization for SBFM is turned on.`}).option(`stale-zone-configuration-sbfm-definitely-automated`,{type:`string`,description:`Indicates that the zone's definitely automated requests are being blocked or challenged.`}).option(`stale-zone-configuration-sbfm-likely-automated`,{type:`string`,description:`Indicates that the zone's likely automated requests are being blocked or challenged.`}).option(`stale-zone-configuration-sbfm-static-resource-protection`,{type:`string`,description:`Indicates that the zone's static resource protection is turned on.`}).option(`stale-zone-configuration-sbfm-verified-bots`,{type:`string`,description:`Indicates that the zone's verified bot requests are being blocked.`}).option(`stale-zone-configuration-suppress-session-score`,{type:`boolean`,description:`Indicates that the zone's session score tracking is disabled.`}).option(`stale-zone-configuration-fight-mode`,{type:`boolean`,description:`Indicates that the zone's Bot Fight Mode is turned on.`}).option(`optimize-wordpress`,{type:`boolean`,description:`Whether to optimize Super Bot Fight Mode protections for Wordpress.`}).option(`sbfm-definitely-automated`,{type:`string`,description:`Super Bot Fight Mode (SBFM) action to take on definitely automated requests.`,choices:[`allow`,`block`,`managed_challenge`]}).option(`sbfm-static-resource-protection`,{type:`boolean`,description:`Super Bot Fight Mode (SBFM) to enable static resource protection.
|
|
3
|
-
Enable if static resources on your application need bot protection.
|
|
4
|
-
Note: Static resource protection can also result in legitimate traffic being blocked.
|
|
5
|
-
`}).option(`sbfm-verified-bots`,{type:`string`,description:`Super Bot Fight Mode (SBFM) action to take on verified bots requests.`,choices:[`allow`,`block`]}).option(`sbfm-likely-automated`,{type:`string`,description:`Super Bot Fight Mode (SBFM) action to take on likely automated requests.`,choices:[`allow`,`block`,`managed_challenge`]}).option(`auto-update-model`,{type:`boolean`,description:`Automatically update to the newest bot detection models created by Cloudflare as they are released. [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes)`}).option(`bm-cookie-enabled`,{type:`boolean`,description:`Indicates that the bot management cookie can be placed on end user devices accessing the site. Defaults to true`}).option(`suppress-session-score`,{type:`boolean`,description:`Whether to disable tracking the highest bot score for a session in the Bot Management cookie.`}).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:`update`,describe:'Updates the Bot Management configuration for a zone. This API is used to update: - **Bot Fight Mode** - **Super Bot Fight Mode** - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more information on the different plans \\ If you recently upgraded or downgraded your plan, refer to the following examples to clean up old configurations. Copy and paste the example body to remove old zone configurations based on your current plan. #### Clean up configuration for Bot Fight Mode plan ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "suppress_session_score": false } ``` #### Clean up configuration for SBFM Pro plan ```json { "sbfm_likely_automated": "allow", "fight_mode": false } ``` #### Clean up configuration for SBFM Biz plan ```json { "fight_mode": false } ``` #### Clean up configuration for BM Enterprise Subscription plan It is strongly recommended that you ensure you have [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to protect your zone before disabling the SBFM rules. Without these protections, your zone is vulnerable to attacks. ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "fight_mode": false } ```',builder:_,handler:async e=>{if(e.dryRun){s({command:`cf bot-management update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/bot_management`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:{"ai-bots-protection":e[`ai-bots-protection`],"cf-robots-variant":e[`cf-robots-variant`],"content-bots-protection":e[`content-bots-protection`],"crawler-protection":e[`crawler-protection`],"enable-js":e[`enable-js`],"is-robots-txt-managed":e[`is-robots-txt-managed`],"fight-mode":e[`fight-mode`],"stale-zone-configuration-optimize-wordpress":e[`stale-zone-configuration-optimize-wordpress`],"stale-zone-configuration-sbfm-definitely-automated":e[`stale-zone-configuration-sbfm-definitely-automated`],"stale-zone-configuration-sbfm-likely-automated":e[`stale-zone-configuration-sbfm-likely-automated`],"stale-zone-configuration-sbfm-static-resource-protection":e[`stale-zone-configuration-sbfm-static-resource-protection`],"stale-zone-configuration-sbfm-verified-bots":e[`stale-zone-configuration-sbfm-verified-bots`],"stale-zone-configuration-suppress-session-score":e[`stale-zone-configuration-suppress-session-score`],"stale-zone-configuration-fight-mode":e[`stale-zone-configuration-fight-mode`],"optimize-wordpress":e[`optimize-wordpress`],"sbfm-definitely-automated":e[`sbfm-definitely-automated`],"sbfm-static-resource-protection":e[`sbfm-static-resource-protection`],"sbfm-verified-bots":e[`sbfm-verified-bots`],"sbfm-likely-automated":e[`sbfm-likely-automated`],"auto-update-model":e[`auto-update-model`],"bm-cookie-enabled":e[`bm-cookie-enabled`],"suppress-session-score":e[`suppress-session-score`],body:e.body}});return}let r=await n(e);if(e.zoneId=await t({zone:e.zone},r,{quiet:e.quiet}),e.body){let t=a(e.body);o(await c(`Updating`,async()=>r.put(`/zones/${e.zoneId}/bot_management`,{body:t})),{successLabel:`Updated`});return}let u={};e[`ai-bots-protection`]!==void 0&&i(u,[`ai_bots_protection`],l(e[`ai-bots-protection`],`ai-bots-protection`,`text`)),e[`cf-robots-variant`]!==void 0&&i(u,[`cf_robots_variant`],l(e[`cf-robots-variant`],`cf-robots-variant`,`text`)),e[`content-bots-protection`]!==void 0&&i(u,[`content_bots_protection`],l(e[`content-bots-protection`],`content-bots-protection`,`text`)),e[`crawler-protection`]!==void 0&&i(u,[`crawler_protection`],l(e[`crawler-protection`],`crawler-protection`,`text`)),e[`enable-js`]!==void 0&&i(u,[`enable_js`],e[`enable-js`]),e[`is-robots-txt-managed`]!==void 0&&i(u,[`is_robots_txt_managed`],e[`is-robots-txt-managed`]),e[`fight-mode`]!==void 0&&i(u,[`fight_mode`],e[`fight-mode`]),e[`stale-zone-configuration-optimize-wordpress`]!==void 0&&i(u,[`stale_zone_configuration`,`optimize_wordpress`],e[`stale-zone-configuration-optimize-wordpress`]),e[`stale-zone-configuration-sbfm-definitely-automated`]!==void 0&&i(u,[`stale_zone_configuration`,`sbfm_definitely_automated`],l(e[`stale-zone-configuration-sbfm-definitely-automated`],`stale-zone-configuration-sbfm-definitely-automated`,`text`)),e[`stale-zone-configuration-sbfm-likely-automated`]!==void 0&&i(u,[`stale_zone_configuration`,`sbfm_likely_automated`],l(e[`stale-zone-configuration-sbfm-likely-automated`],`stale-zone-configuration-sbfm-likely-automated`,`text`)),e[`stale-zone-configuration-sbfm-static-resource-protection`]!==void 0&&i(u,[`stale_zone_configuration`,`sbfm_static_resource_protection`],l(e[`stale-zone-configuration-sbfm-static-resource-protection`],`stale-zone-configuration-sbfm-static-resource-protection`,`text`)),e[`stale-zone-configuration-sbfm-verified-bots`]!==void 0&&i(u,[`stale_zone_configuration`,`sbfm_verified_bots`],l(e[`stale-zone-configuration-sbfm-verified-bots`],`stale-zone-configuration-sbfm-verified-bots`,`text`)),e[`stale-zone-configuration-suppress-session-score`]!==void 0&&i(u,[`stale_zone_configuration`,`suppress_session_score`],e[`stale-zone-configuration-suppress-session-score`]),e[`stale-zone-configuration-fight-mode`]!==void 0&&i(u,[`stale_zone_configuration`,`fight_mode`],e[`stale-zone-configuration-fight-mode`]),e[`optimize-wordpress`]!==void 0&&i(u,[`optimize_wordpress`],e[`optimize-wordpress`]),e[`sbfm-definitely-automated`]!==void 0&&i(u,[`sbfm_definitely_automated`],l(e[`sbfm-definitely-automated`],`sbfm-definitely-automated`,`text`)),e[`sbfm-static-resource-protection`]!==void 0&&i(u,[`sbfm_static_resource_protection`],e[`sbfm-static-resource-protection`]),e[`sbfm-verified-bots`]!==void 0&&i(u,[`sbfm_verified_bots`],l(e[`sbfm-verified-bots`],`sbfm-verified-bots`,`text`)),e[`sbfm-likely-automated`]!==void 0&&i(u,[`sbfm_likely_automated`],l(e[`sbfm-likely-automated`],`sbfm-likely-automated`,`text`)),e[`auto-update-model`]!==void 0&&i(u,[`auto_update_model`],e[`auto-update-model`]),e[`bm-cookie-enabled`]!==void 0&&i(u,[`bm_cookie_enabled`],e[`bm-cookie-enabled`]),e[`suppress-session-score`]!==void 0&&i(u,[`suppress_session_score`],e[`suppress-session-score`]),o(await c(`Updating`,async()=>r.put(`/zones/${e.zoneId}/bot_management`,{body:Object.keys(u).length>0?u:void 0})),{successLabel:`Updated`})}},y={command:`bot-management`,describe:`Bot detection and mitigation settings — configure bot scores, JavaScript detections, and challenge behavior`,builder:e=>e.command(g).command(v).command(m).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{C as e,h as t,t as n,x as r}from"./auth-CQcAgnOy.mjs";import{t as i}from"./output-D7_yAFVR.mjs";import{n as a,t as o}from"./progress-CjcQ6ato.mjs";import{t as s}from"./local-VJaJ3BZ1.mjs";function c(e){return e.positional(`asn-id`,{type:`string`,description:`Asn ID`,demandOption:!0}).option(`date`,{type:`string`,description:`Date`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const l={command:`day-report <asn-id>`,describe:`Gets all the data the botnet tracking database has for a given ASN registered to user account for given date. If no date is given, it will return results for the previous day.`,builder:c,handler:async e=>{let c={date:e.date};if(e.dryRun){a({command:`cf botnet-feed asn day-report`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/botnet_feed/asn/${e[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(e[`asn-id`]))}/day_report`,pathParams:{"asn-id":String(e[`asn-id`]??``)},query:c,bodyKind:`none`});return}let l=await n(e),u=e.local?s:await t(l);e.accountId=u,i(await o(`Loading`,async()=>l.botnetFeed.asn.dayReport(u,e[`asn-id`],c)),{successLabel:`Loaded`})}};function u(e){return e.positional(`asn-id`,{type:`string`,description:`Asn ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const d={command:`full-report <asn-id>`,describe:`Gets all the data the botnet threat feed tracking database has for a given ASN registered to user account.`,builder:u,handler:async e=>{if(e.dryRun){a({command:`cf botnet-feed asn full-report`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/botnet_feed/asn/${e[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(e[`asn-id`]))}/full_report`,pathParams:{"asn-id":String(e[`asn-id`]??``)},bodyKind:`none`});return}let c=await n(e),l=e.local?s:await t(c);e.accountId=l,i(await o(`Loading`,async()=>c.botnetFeed.asn.fullReport(l,e[`asn-id`])),{successLabel:`Loaded`})}},f={command:`asn`,describe:`ASN-level botnet activity data showing networks with known C2 infrastructure`,builder:e=>e.command(l).command(d).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function p(e){return e.positional(`asn-id`,{type:`string`,description:`Asn 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 m={command:`delete <asn-id>`,describe:`Delete an ASN from botnet threat feed for a given user.`,builder:p,handler:async c=>{if(c.dryRun){a({command:`cf botnet-feed configs asn delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/botnet_feed/configs/asn/${c[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(c[`asn-id`]))}`,pathParams:{"asn-id":String(c[`asn-id`]??``)},bodyKind:`none`});return}let l=await n(c),u=c.local?s:await t(l);if(c.accountId=u,!await e({force:!!c.force})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}i(await o(`Deleting`,async()=>l.botnetFeed.configs.asn.delete(u,c[`asn-id`])),{successLabel:`Deleted`})}};function h(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get`,describe:`Gets a list of all ASNs registered for a user for the DDoS Botnet Feed API.`,builder:h,handler:async e=>{if(e.dryRun){a({command:`cf botnet-feed configs asn get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/botnet_feed/configs/asn`,pathParams:{},bodyKind:`none`});return}let c=await n(e),l=e.local?s:await t(c);e.accountId=l,i(await o(`Loading`,async()=>c.botnetFeed.configs.asn.get(l)),{successLabel:`Loaded`})}},_={command:`asn`,describe:`Botnet feed subscription configuration and notification preferences`,builder:e=>e.command(m).command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},v={command:`configs`,describe:`Operations for configs`,builder:e=>e.command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},y={command:`botnet-feed`,describe:`Botnet threat intelligence feeds — IP and ASN-level data on known command-and-control infrastructure`,builder:e=>e.command(f).command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{C as e,T as t,h as n,t as r,x as i}from"./auth-CQcAgnOy.mjs";import{n as a,t as o}from"./body-parser-Br-BoYk-.mjs";import{t as s}from"./output-D7_yAFVR.mjs";import{n as c,t as l}from"./progress-CjcQ6ato.mjs";import{n as u}from"./input-validation-zEO81MWN.mjs";import{t as d}from"./local-VJaJ3BZ1.mjs";function f(e){return e.option(`show-historic`,{type:`string`,description:`Include scanned images without domain metadata (historic data). Default: false (only show images with domain)`}).option(`download`,{type:`string`,description:`If true, include base64-encoded image data in the response`}).option(`image-data`,{type:`string`,description:`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`}).option(`score-threshold`,{type:`number`,description:`Minimum similarity score threshold for matches (0-1, default: 0)`,default:0}).option(`top-k`,{type:`number`,description:`Number of closest matches to return (1-100, default: 10)`,default:10}).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 p={command:`submit`,describe:`Submit an image and find the n closest matches from the scanned images index without creating any match records. Returns similarity scores and metadata for each match.`,builder:f,handler:async e=>{let f={showHistoric:e[`show-historic`],download:e.download};if(e.dryRun){c({command:`cf brand-protection submit`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${i()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/search`,pathParams:{},query:f,bodyKind:`json`,body:{"image-data":e[`image-data`],"score-threshold":e[`score-threshold`],"top-k":e[`top-k`],body:e.body}});return}let p=await r(e),m=e.local?d:await n(p);if(e.accountId=m,e.body){let t=o(e.body),n=new URLSearchParams(Object.entries(f).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();s(await l(`Creating`,async()=>p.post(`/accounts/${m}/cloudforce-one/v2/brand-protection/logo/search${n?`?`+n:``}`,{body:t})),{successLabel:`Created`});return}e[`image-data`]===void 0&&(e[`image-data`]=await t(`image-data`,`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`));let h={};e[`image-data`]!==void 0&&a(h,[`image_data`],u(e[`image-data`],`image-data`,`text`)),e[`score-threshold`]!==void 0&&a(h,[`score_threshold`],e[`score-threshold`]),e[`top-k`]!==void 0&&a(h,[`top_k`],e[`top-k`]);let g=new URLSearchParams(Object.entries(f).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();s(await l(`Creating`,async()=>p.post(`/accounts/${m}/cloudforce-one/v2/brand-protection/logo/search${g?`?`+g:``}`,{body:Object.keys(h).length>0?h:void 0})),{successLabel:`Created`})}};function m(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const h={command:`url-info`,describe:`Get the total number of saved brand protection queries (domain + logo) for an account`,builder:m,handler:async e=>{if(e.dryRun){c({command:`cf brand-protection url-info`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${i()??`<account-id>`}/cloudforce-one/v2/brand-protection/total-queries`,pathParams:{},bodyKind:`none`});return}let t=await r(e),a=e.local?d:await n(t);e.accountId=a,s(await l(`Loading`,async()=>t.brandProtection.urlInfo(a)),{successLabel:`Loaded`})}};function g(e){return e.option(`offset`,{type:`string`,description:`Offset`}).option(`limit`,{type:`string`,description:`Limit`}).option(`query-id`,{type:`string`,description:`Query ID`,demandOption:!0}).option(`download`,{type:`string`,description:`Download`}).option(`order-by`,{type:`string`,description:`Column to sort by. Options: 'matchedAt', 'domain', 'similarityScore', or 'registrar'`,choices:[`matchedAt`,`domain`,`similarityScore`,`registrar`]}).option(`order`,{type:`string`,description:`Sort order. Options: 'asc' (ascending) or 'desc' (descending)`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get`,describe:`Get paginated list of logo matches for a specific brand protection logo query`,builder:g,handler:async e=>{let t={offset:e.offset,limit:e.limit,query_id:e[`query-id`],download:e.download,orderBy:e[`order-by`],order:e.order};if(e.dryRun){c({command:`cf brand-protection v2 logo-matches get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${i()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/matches`,pathParams:{},query:t,bodyKind:`none`});return}let a=await r(e),o=e.local?d:await n(a);e.accountId=o,s(await l(`Loading`,async()=>a.brandProtection.v2.logoMatches.get(o,t)),{successLabel:`Loaded`})}},v={command:`logo-matches`,describe:`Detected visual logo matches found on potentially infringing websites`,builder:e=>e.command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function y(e){return e.option(`image-data`,{type:`string`,description:`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`}).option(`search-lookback`,{type:`boolean`,description:`If true, search historic scanned images for matches above the similarity threshold`,default:!0}).option(`similarity-threshold`,{type:`number`,description:`Minimum similarity score (0-1) required for visual matches`}).option(`tag`,{type:`string`,description:`Unique identifier for the logo query`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const b={command:`create`,describe:`Create a new saved brand protection logo query for visual similarity matching`,builder:y,handler:async e=>{if(e.dryRun){c({command:`cf brand-protection v2 logos create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${i()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/queries`,pathParams:{},bodyKind:`json`,body:{"image-data":e[`image-data`],"search-lookback":e[`search-lookback`],"similarity-threshold":e[`similarity-threshold`],tag:e.tag,body:e.body}});return}let f=await r(e),p=e.local?d:await n(f);if(e.accountId=p,e.body){let t=o(e.body);s(await l(`Creating`,async()=>f.post(`/accounts/${p}/cloudforce-one/v2/brand-protection/logo/queries`,{body:t})),{successLabel:`Created`});return}if(e[`image-data`]===void 0&&(e[`image-data`]=await t(`image-data`,`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`)),e[`similarity-threshold`]===void 0)throw Error(`--similarity-threshold is required (or pass --body with this field set).`);e.tag===void 0&&(e.tag=await t(`tag`,`Unique identifier for the logo query`));let m={};e[`image-data`]!==void 0&&a(m,[`image_data`],u(e[`image-data`],`image-data`,`text`)),e[`search-lookback`]!==void 0&&a(m,[`search_lookback`],e[`search-lookback`]),e[`similarity-threshold`]!==void 0&&a(m,[`similarity_threshold`],e[`similarity-threshold`]),e.tag!==void 0&&a(m,[`tag`],u(e.tag,`tag`,`text`)),s(await l(`Creating`,async()=>f.post(`/accounts/${p}/cloudforce-one/v2/brand-protection/logo/queries`,{body:Object.keys(m).length>0?m:void 0})),{successLabel:`Created`})}};function x(e){return e.positional(`query-id`,{type:`string`,description:`Query 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 S={command:`delete <query-id>`,describe:`Delete a saved brand protection logo query. Returns 404 if the query ID doesn't exist.`,builder:x,handler:async t=>{if(t.dryRun){c({command:`cf brand-protection v2 logos delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${i()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/queries/${t[`query-id`]==null?`<query-id>`:encodeURIComponent(String(t[`query-id`]))}`,pathParams:{"query-id":String(t[`query-id`]??``)},bodyKind:`none`});return}let a=await r(t),o=t.local?d:await n(a);if(t.accountId=o,!await e({force:!!t.force})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}s(await l(`Deleting`,async()=>a.brandProtection.v2.logos.delete(o,t[`query-id`])),{successLabel:`Deleted`})}};function C(e){return e.option(`id`,{type:`string`,description:`Optional query ID to retrieve a specific logo query`}).option(`download`,{type:`string`,description:`If true, include base64-encoded image data in the response`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const w={command:`get`,describe:`Get all saved brand protection logo queries for an account. Optionally specify id to get a single query. Set download=true to include base64-encoded image data.`,builder:C,handler:async e=>{let t={id:e.id,download:e.download};if(e.dryRun){c({command:`cf brand-protection v2 logos get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${i()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/queries`,pathParams:{},query:t,bodyKind:`none`});return}let a=await r(e),o=e.local?d:await n(a);e.accountId=o,s(await l(`Loading`,async()=>a.brandProtection.v2.logos.get(o,t)),{successLabel:`Loaded`})}},T={command:`logos`,describe:`Brand monitoring queries that define search patterns for detecting brand abuse`,builder:e=>e.command(b).command(S).command(w).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function E(e){return e.option(`offset`,{type:`string`,description:`Offset`}).option(`limit`,{type:`string`,description:`Limit`}).option(`query-id`,{type:`string`,description:`Query ID or comma-separated list of Query IDs. When multiple IDs are provided, matches are deduplicated across queries and each match includes a match_details array with per-match query metadata and dismissed state.`,demandOption:!0}).option(`include-domain-id`,{type:`string`,description:`Include domain ID`}).option(`include-dismissed`,{type:`string`,description:`Include dismissed`}).option(`domain-search`,{type:`string`,description:`Filter matches by domain name (substring match)`}).option(`order-by`,{type:`string`,description:`Column to sort by. Options: 'domain', 'first_seen', or 'registrar'`,choices:[`domain`,`first_seen`,`registrar`]}).option(`order`,{type:`string`,description:`Sort order. Options: 'asc' (ascending) or 'desc' (descending)`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const D={command:`get`,describe:`Get paginated list of domain matches for one or more brand protection queries. When multiple query_ids are provided (comma-separated), matches are deduplicated across queries and each match includes a match_details array with per-match query metadata and individual dismissed state.`,builder:E,handler:async e=>{let t={offset:e.offset,limit:e.limit,query_id:e[`query-id`],include_domain_id:e[`include-domain-id`],include_dismissed:e[`include-dismissed`],domain_search:e[`domain-search`],orderBy:e[`order-by`],order:e.order};if(e.dryRun){c({command:`cf brand-protection v2 matches get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${i()??`<account-id>`}/cloudforce-one/v2/brand-protection/domain/matches`,pathParams:{},query:t,bodyKind:`none`});return}let a=await r(e),o=e.local?d:await n(a);e.accountId=o,s(await l(`Loading`,async()=>a.brandProtection.v2.matches.get(o,t)),{successLabel:`Loaded`})}},O={command:`matches`,describe:`Detected brand abuse matches from monitoring queries with evidence downloads`,builder:e=>e.command(D).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function k(e){return e.option(`id`,{type:`string`,description:`ID`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`get`,describe:`Get all saved brand protection queries for an account`,builder:k,handler:async e=>{let t={id:e.id};if(e.dryRun){c({command:`cf brand-protection v2 queries get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${i()??`<account-id>`}/cloudforce-one/v2/brand-protection/domain/queries`,pathParams:{},query:t,bodyKind:`none`});return}let a=await r(e),o=e.local?d:await n(a);e.accountId=o,s(await l(`Loading`,async()=>a.brandProtection.v2.queries.get(o,t)),{successLabel:`Loaded`})}},j={command:`queries`,describe:`Brand monitoring queries that define search patterns for detecting brand abuse`,builder:e=>e.command(A).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},M={command:`v2`,describe:`Operations for v2`,builder:e=>e.command(v).command(T).command(O).command(j).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},N={command:`brand-protection`,describe:`Monitor the Internet for phishing sites, lookalike domains, and unauthorized use of your brand assets`,builder:e=>e.command(p).command(h).command(M).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{N as default};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{C as e,h as t,t as n,x as r}from"./auth-CQcAgnOy.mjs";import{t as i}from"./body-parser-Br-BoYk-.mjs";import{t as a}from"./output-D7_yAFVR.mjs";import{n as o,t as s}from"./progress-CjcQ6ato.mjs";import{t as c}from"./local-VJaJ3BZ1.mjs";import{n as l,t as u}from"./raw-fetch-hRv-6P3D.mjs";function d(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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 f={command:`create`,describe:"Fetches rendered HTML content from provided URL or HTML. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.",builder:d,handler:async e=>{let l={cacheTTL:e[`cache-ttl`]};if(e.dryRun){o({command:`cf browser-rendering content create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/content`,pathParams:{},query:l,bodyKind:`json`,body:{body:e.body}});return}let u=await n(e),d=e.local?c:await t(u);if(e.accountId=d,e.body){let t=i(e.body),n=new URLSearchParams(Object.entries(l).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();a(await s(`Creating`,async()=>u.post(`/accounts/${d}/browser-rendering/content${n?`?`+n:``}`,{body:t})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>u.browserRendering.content.create(d,l)),{successLabel:`Created`})}},p={command:`content`,describe:`Render a page and return its full HTML content after JavaScript execution`,builder:e=>e.command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function m(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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 ee={command:`create`,describe:"Starts a crawl job for the provided URL and its children. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.",builder:m,handler:async e=>{let l={cacheTTL:e[`cache-ttl`]};if(e.dryRun){o({command:`cf browser-rendering crawl create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/crawl`,pathParams:{},query:l,bodyKind:`json`,body:{body:e.body}});return}let u=await n(e),d=e.local?c:await t(u);if(e.accountId=d,e.body){let t=i(e.body),n=new URLSearchParams(Object.entries(l).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();a(await s(`Creating`,async()=>u.post(`/accounts/${d}/browser-rendering/crawl${n?`?`+n:``}`,{body:t})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>u.browserRendering.crawl.create(d,l)),{successLabel:`Created`})}};function h(e){return e.positional(`job-id`,{type:`string`,description:`The ID of the crawl job to cancel.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const g={command:`delete <job-id>`,describe:`Cancels an ongoing crawl job by setting its status to cancelled and stopping all queued URLs.`,builder:h,handler:async i=>{if(i.dryRun){o({command:`cf browser-rendering crawl delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/crawl/${i[`job-id`]==null?`<job-id>`:encodeURIComponent(String(i[`job-id`]))}`,pathParams:{"job-id":String(i[`job-id`]??``)},bodyKind:`none`});return}let l=await n(i),u=i.local?c:await t(l);if(i.accountId=u,!await e({force:!!i.force})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}a(await s(`Deleting`,async()=>l.browserRendering.crawl.delete(u,i[`job-id`])),{successLabel:`Deleted`})}};function _(e){return e.positional(`job-id`,{type:`string`,description:`Crawl job ID.`,demandOption:!0}).option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`status`,{type:`string`,description:`Filter by URL status.`,choices:[`queued`,`errored`,`completed`,`disallowed`,`skipped`,`cancelled`]}).option(`cursor`,{type:`number`,description:`Cursor for pagination.`}).option(`limit`,{type:`number`,description:`Limit for pagination.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`get <job-id>`,describe:`Returns the result of a crawl job.`,builder:_,handler:async e=>{let i={cacheTTL:e[`cache-ttl`],status:e.status,cursor:e.cursor,limit:e.limit};if(e.dryRun){o({command:`cf browser-rendering crawl get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/crawl/${e[`job-id`]==null?`<job-id>`:encodeURIComponent(String(e[`job-id`]))}`,pathParams:{"job-id":String(e[`job-id`]??``)},query:i,bodyKind:`none`});return}let l=await n(e),u=e.local?c:await t(l);e.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.crawl.get(u,e[`job-id`],i)),{successLabel:`Loaded`})}},y={command:`crawl`,describe:`Crawl operations`,builder:e=>e.command(ee).command(g).command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function b(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID to connect to.`,demandOption:!0}).option(`keep-alive`,{type:`number`,description:`Keep-alive time in ms (only valid when acquiring new session).`}).option(`lab`,{type:`boolean`,description:`Use experimental browser.`}).option(`recording`,{type:`boolean`,description:`Recording`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const x={command:`connect <session-id>`,describe:`Establishes a WebSocket connection to an existing browser session.`,builder:b,handler:async e=>{let i={keep_alive:e[`keep-alive`],lab:e.lab,recording:e.recording};if(e.dryRun){o({command:`cf browser-rendering devtools browser connect`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}`,pathParams:{"session-id":String(e[`session-id`]??``)},query:i,bodyKind:`none`});return}let l=await n(e),u=e.local?c:await t(l);e.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.devtools.browser.connect(u,e[`session-id`],i)),{successLabel:`Loaded`})}};function S(e){return e.option(`keep-alive`,{type:`number`,description:`Keep-alive time in milliseconds.`}).option(`lab`,{type:`boolean`,description:`Use experimental browser.`}).option(`targets`,{type:`boolean`,description:`Include browser targets in response.`}).option(`recording`,{type:`boolean`,description:`Recording`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`create`,describe:`Acquire a new browser DevTools session`,builder:S,handler:async e=>{let i={keep_alive:e[`keep-alive`],lab:e.lab,targets:e.targets,recording:e.recording};if(e.dryRun){o({command:`cf browser-rendering devtools browser create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser`,pathParams:{},query:i,bodyKind:`none`});return}let l=await n(e),u=e.local?c:await t(l);e.accountId=u,a(await s(`Creating`,async()=>l.browserRendering.devtools.browser.create(u,i)),{successLabel:`Created`})}};function w(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID to close.`,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 T={command:`delete <session-id>`,describe:`Closes an existing browser session.`,builder:w,handler:async i=>{if(i.dryRun){o({command:`cf browser-rendering devtools browser delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${i[`session-id`]==null?`<session-id>`:encodeURIComponent(String(i[`session-id`]))}`,pathParams:{"session-id":String(i[`session-id`]??``)},bodyKind:`none`});return}let l=await n(i),u=i.local?c:await t(l);if(i.accountId=u,!await e({force:!!i.force})){process.stderr.write(`Aborted.
|
|
4
|
-
`);return}a(await s(`Deleting`,async()=>l.browserRendering.devtools.browser.delete(u,i[`session-id`])),{successLabel:`Deleted`})}};function E(e){return e.option(`keep-alive`,{type:`number`,description:`Keep-alive time in ms (only valid when acquiring new session).`}).option(`lab`,{type:`boolean`,description:`Use experimental browser.`}).option(`recording`,{type:`boolean`,description:`Recording`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const D={command:`launch`,describe:`Acquires and establishes a WebSocket connection to a browser session.`,builder:E,handler:async e=>{let i={keep_alive:e[`keep-alive`],lab:e.lab,recording:e.recording};if(e.dryRun){o({command:`cf browser-rendering devtools browser launch`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser`,pathParams:{},query:i,bodyKind:`none`});return}let l=await n(e),u=e.local?c:await t(l);e.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.devtools.browser.launch(u,i)),{successLabel:`Loaded`})}};function O(e){return e.positional(`target-id`,{type:`string`,description:`Target ID, e.g. page ID.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const k={command:`get <target-id>`,describe:`Establishes a WebSocket connection to a specific Chrome DevTools target or page.`,builder:O,handler:async e=>{if(e.dryRun){o({command:`cf browser-rendering devtools browser page get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}/page/${e[`target-id`]==null?`<target-id>`:encodeURIComponent(String(e[`target-id`]))}`,pathParams:{"session-id":String(e[`session-id`]??``),"target-id":String(e[`target-id`]??``)},bodyKind:`none`});return}let i=await n(e),l=e.local?c:await t(i);e.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.page.get(l,e[`session-id`],e[`target-id`])),{successLabel:`Loaded`})}},A={command:`page`,describe:`Chrome DevTools Protocol endpoints for browser automation and debugging`,builder:e=>e.command(k).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function j(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`protocol <session-id>`,describe:`Returns the complete Chrome DevTools Protocol schema including all domains, commands, events, and types. This schema describes the entire CDP API surface.`,builder:j,handler:async e=>{if(e.dryRun){o({command:`cf browser-rendering devtools browser protocol`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}/json/protocol`,pathParams:{"session-id":String(e[`session-id`]??``)},bodyKind:`none`});return}let i=await n(e),l=e.local?c:await t(i);e.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.protocol(l,e[`session-id`])),{successLabel:`Loaded`})}};function N(e){return e.positional(`target-id`,{type:`string`,description:`Target ID to activate.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`activate <target-id>`,describe:`Activates (brings to front) a specific browser target by its ID.`,builder:N,handler:async e=>{if(e.dryRun){o({command:`cf browser-rendering devtools browser targets activate`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}/json/activate/${e[`target-id`]==null?`<target-id>`:encodeURIComponent(String(e[`target-id`]))}`,pathParams:{"session-id":String(e[`session-id`]??``),"target-id":String(e[`target-id`]??``)},bodyKind:`none`});return}let i=await n(e),l=e.local?c:await t(i);e.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.targets.activate(e[`session-id`],l,e[`target-id`])),{successLabel:`Loaded`})}};function F(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`url`,{type:`string`,description:`Url`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const I={command:`create <session-id>`,describe:`Opens a new tab in the browser. Optionally specify a URL to navigate to.`,builder:F,handler:async e=>{let i={url:e.url};if(e.dryRun){o({command:`cf browser-rendering devtools browser targets create`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}/json/new`,pathParams:{"session-id":String(e[`session-id`]??``)},query:i,bodyKind:`none`});return}let l=await n(e),u=e.local?c:await t(l);e.accountId=u,a(await s(`Updating`,async()=>l.browserRendering.devtools.browser.targets.create(u,e[`session-id`],i)),{successLabel:`Updated`})}};function L(e){return e.positional(`target-id`,{type:`string`,description:`Target ID.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const R={command:`get <target-id>`,describe:`Returns the debuggable target with the given ID.`,builder:L,handler:async e=>{if(e.dryRun){o({command:`cf browser-rendering devtools browser targets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}/json/list/${e[`target-id`]==null?`<target-id>`:encodeURIComponent(String(e[`target-id`]))}`,pathParams:{"session-id":String(e[`session-id`]??``),"target-id":String(e[`target-id`]??``)},bodyKind:`none`});return}let i=await n(e),l=e.local?c:await t(i);e.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.targets.get(l,e[`session-id`],e[`target-id`])),{successLabel:`Loaded`})}};function z(e){return e.option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const B={command:`list`,describe:`Returns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts.`,builder:z,handler:async e=>{if(e.dryRun){o({command:`cf browser-rendering devtools browser targets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}/json/list`,pathParams:{"session-id":String(e[`session-id`]??``)},bodyKind:`none`});return}let i=await n(e),l=e.local?c:await t(i);e.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.targets.list(l,e[`session-id`])),{successLabel:`Loaded`})}},V={command:`targets`,describe:`Chrome DevTools Protocol endpoints for browser automation and debugging`,builder:e=>e.command(P).command(I).command(R).command(B).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function H(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`version <session-id>`,describe:`Get browser version metadata.`,builder:H,handler:async e=>{if(e.dryRun){o({command:`cf browser-rendering devtools browser version`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}/json/version`,pathParams:{"session-id":String(e[`session-id`]??``)},bodyKind:`none`});return}let i=await n(e),l=e.local?c:await t(i);e.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.version(l,e[`session-id`])),{successLabel:`Loaded`})}},U={command:`browser`,describe:`Chrome DevTools Protocol endpoints for browser automation and debugging`,builder:e=>e.command(x).command(C).command(T).command(D).command(M).command(te).command(A).command(V).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function W(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const G={command:`get <session-id>`,describe:`Returns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts.`,builder:W,handler:async e=>{if(e.dryRun){o({command:`cf browser-rendering devtools json get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/browser/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}/json`,pathParams:{"session-id":String(e[`session-id`]??``)},bodyKind:`none`});return}let i=await n(e),l=e.local?c:await t(i);e.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.json.get(l,e[`session-id`])),{successLabel:`Loaded`})}},K={command:`json`,describe:`Chrome DevTools Protocol endpoints for browser automation and debugging`,builder:e=>e.command(G).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function q(e){return e.positional(`session-id`,{type:`string`,description:`Session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const J={command:`get <session-id>`,describe:`Get details for a specific browser session.`,builder:q,handler:async e=>{if(e.dryRun){o({command:`cf browser-rendering devtools session get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/session/${e[`session-id`]==null?`<session-id>`:encodeURIComponent(String(e[`session-id`]))}`,pathParams:{"session-id":String(e[`session-id`]??``)},bodyKind:`none`});return}let i=await n(e),l=e.local?c:await t(i);e.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.session.get(l,e[`session-id`])),{successLabel:`Loaded`})}};function Y(e){return e.option(`limit`,{type:`number`,description:`Limit`}).option(`offset`,{type:`number`,description:`Offset`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const X={command:`list`,describe:`List active browser sessions.`,builder:Y,handler:async e=>{let i={limit:e.limit,offset:e.offset};if(e.dryRun){o({command:`cf browser-rendering devtools session list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/devtools/session`,pathParams:{},query:i,bodyKind:`none`});return}let l=await n(e),u=e.local?c:await t(l);e.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.devtools.session.list(u,i)),{successLabel:`Loaded`})}},Z={command:`session`,describe:`Chrome DevTools Protocol endpoints for browser automation and debugging`,builder:e=>e.command(J).command(X).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Q={command:`devtools`,describe:`Operations for devtools`,builder:e=>e.command(U).command(K).command(Z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ne(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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 re={command:`create`,describe:"Gets json from a webpage from a provided URL or HTML. Pass `prompt` or `schema` in the body. Control page loading with `gotoOptions` and `waitFor*` options.",builder:ne,handler:async e=>{let l={cacheTTL:e[`cache-ttl`]};if(e.dryRun){o({command:`cf browser-rendering json create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/json`,pathParams:{},query:l,bodyKind:`json`,body:{body:e.body}});return}let u=await n(e),d=e.local?c:await t(u);if(e.accountId=d,e.body){let t=i(e.body),n=new URLSearchParams(Object.entries(l).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();a(await s(`Creating`,async()=>u.post(`/accounts/${d}/browser-rendering/json${n?`?`+n:``}`,{body:t})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>u.browserRendering.json.create(d,l)),{successLabel:`Created`})}},ie={command:`json`,describe:`Extract structured JSON data from rendered pages using selectors`,builder:e=>e.command(re).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ae(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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 oe={command:`create`,describe:`Get links from a web page.`,builder:ae,handler:async e=>{let l={cacheTTL:e[`cache-ttl`]};if(e.dryRun){o({command:`cf browser-rendering links create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/links`,pathParams:{},query:l,bodyKind:`json`,body:{body:e.body}});return}let u=await n(e),d=e.local?c:await t(u);if(e.accountId=d,e.body){let t=i(e.body),n=new URLSearchParams(Object.entries(l).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();a(await s(`Creating`,async()=>u.post(`/accounts/${d}/browser-rendering/links${n?`?`+n:``}`,{body:t})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>u.browserRendering.links.create(d,l)),{successLabel:`Created`})}},se={command:`links`,describe:`Extract all links from a rendered web page`,builder:e=>e.command(oe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ce(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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 le={command:`create`,describe:"Gets markdown of a webpage from provided URL or HTML. Control page loading with `gotoOptions` and `waitFor*` options.",builder:ce,handler:async e=>{let l={cacheTTL:e[`cache-ttl`]};if(e.dryRun){o({command:`cf browser-rendering markdown create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/markdown`,pathParams:{},query:l,bodyKind:`json`,body:{body:e.body}});return}let u=await n(e),d=e.local?c:await t(u);if(e.accountId=d,e.body){let t=i(e.body),n=new URLSearchParams(Object.entries(l).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();a(await s(`Creating`,async()=>u.post(`/accounts/${d}/browser-rendering/markdown${n?`?`+n:``}`,{body:t})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>u.browserRendering.markdown.create(d,l)),{successLabel:`Created`})}},ue={command:`markdown`,describe:`Convert rendered web page content to clean Markdown format`,builder:e=>e.command(le).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function de(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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)`}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const fe={command:`create`,describe:"Fetches rendered PDF from provided URL or HTML. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.",builder:de,handler:async e=>{let a={cacheTTL:e[`cache-ttl`]};if(e.dryRun){o({command:`cf browser-rendering pdf create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/pdf`,pathParams:{},query:a,bodyKind:`json`,body:{body:e.body}});return}let d=await n(e),f=e.local?c:await t(d);if(e.accountId=f,e.body){let t=i(e.body),n=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),r=await s(`Creating`,async()=>u(`/accounts/${f}/browser-rendering/pdf${n?`?`+n:``}`,{method:`POST`,localEndpoint:e.local?e.localEndpoint:void 0,body:JSON.stringify(t),contentType:`application/json`}));l(e.text===!0?r.toString(`utf-8`):r);return}let p=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),m=await s(`Creating`,async()=>u(`/accounts/${f}/browser-rendering/pdf${p?`?`+p:``}`,{method:`POST`,localEndpoint:e.local?e.localEndpoint:void 0}));l(e.text===!0?m.toString(`utf-8`):m)}},pe={command:`pdf`,describe:`Generate PDF documents from rendered web pages`,builder:e=>e.command(fe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function $(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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 me={command:`create`,describe:`Get meta attributes like height, width, text and others of selected elements.`,builder:$,handler:async e=>{let l={cacheTTL:e[`cache-ttl`]};if(e.dryRun){o({command:`cf browser-rendering scrape create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/scrape`,pathParams:{},query:l,bodyKind:`json`,body:{body:e.body}});return}let u=await n(e),d=e.local?c:await t(u);if(e.accountId=d,e.body){let t=i(e.body),n=new URLSearchParams(Object.entries(l).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();a(await s(`Creating`,async()=>u.post(`/accounts/${d}/browser-rendering/scrape${n?`?`+n:``}`,{body:t})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>u.browserRendering.scrape.create(d,l)),{successLabel:`Created`})}},he={command:`scrape`,describe:`Scrape structured data from web pages using CSS selectors`,builder:e=>e.command(me).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ge(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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)`}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const _e={command:`create`,describe:"Takes a screenshot of a webpage from provided URL or HTML. Control page loading with `gotoOptions` and `waitFor*` options. Customize screenshots with `viewport`, `fullPage`, `clip` and others.",builder:ge,handler:async e=>{let a={cacheTTL:e[`cache-ttl`]};if(e.dryRun){o({command:`cf browser-rendering screenshot create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/screenshot`,pathParams:{},query:a,bodyKind:`json`,body:{body:e.body}});return}let d=await n(e),f=e.local?c:await t(d);if(e.accountId=f,e.body){let t=i(e.body),n=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),r=await s(`Creating`,async()=>u(`/accounts/${f}/browser-rendering/screenshot${n?`?`+n:``}`,{method:`POST`,localEndpoint:e.local?e.localEndpoint:void 0,body:JSON.stringify(t),contentType:`application/json`}));l(e.text===!0?r.toString(`utf-8`):r);return}let p=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),m=await s(`Creating`,async()=>u(`/accounts/${f}/browser-rendering/screenshot${p?`?`+p:``}`,{method:`POST`,localEndpoint:e.local?e.localEndpoint:void 0}));l(e.text===!0?m.toString(`utf-8`):m)}},ve={command:`screenshot`,describe:`Capture viewport or full-page screenshots as PNG or JPEG images`,builder:e=>e.command(_e).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ye(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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 be={command:`create`,describe:"Returns the page's HTML content and screenshot. Control page loading with `gotoOptions` and `waitFor*` options. Customize screenshots with `viewport`, `fullPage`, `clip` and others.",builder:ye,handler:async e=>{let l={cacheTTL:e[`cache-ttl`]};if(e.dryRun){o({command:`cf browser-rendering snapshot create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r()??`<account-id>`}/browser-rendering/snapshot`,pathParams:{},query:l,bodyKind:`json`,body:{body:e.body}});return}let u=await n(e),d=e.local?c:await t(u);if(e.accountId=d,e.body){let t=i(e.body),n=new URLSearchParams(Object.entries(l).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();a(await s(`Creating`,async()=>u.post(`/accounts/${d}/browser-rendering/snapshot${n?`?`+n:``}`,{body:t})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>u.browserRendering.snapshot.create(d,l)),{successLabel:`Created`})}},xe={command:`snapshot`,describe:`Capture a complete DOM snapshot including styles and resources`,builder:e=>e.command(be).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Se={command:`browser-rendering`,describe:`Headless browser API — render pages, take screenshots, generate PDFs, scrape content, and extract structured data`,builder:e=>e.command(p).command(y).command(Q).command(ie).command(se).command(ue).command(pe).command(he).command(ve).command(xe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{Se as default};
|
package/dist/builds-C_ySULja.mjs
DELETED
package/dist/cache-DmXizSMi.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{C as e,b as t,t as n,w as r}from"./auth-CQcAgnOy.mjs";import{n as i,t as a}from"./body-parser-Br-BoYk-.mjs";import{t as o}from"./output-D7_yAFVR.mjs";import{n as s,t as c}from"./progress-CjcQ6ato.mjs";import{n as l}from"./input-validation-zEO81MWN.mjs";function u(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`The request body is currently not used.`})}const d={command:`clear`,describe:`You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation.`,builder:u,handler:async e=>{if(e.dryRun){s({command:`cf cache cache-reserve clear`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/cache_reserve_clear`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:{body:e.body}});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});if(e.zoneId=i,e.body){let t=a(e.body);o(await c(`Creating`,async()=>r.post(`/zones/${e.zoneId}/cache/cache_reserve_clear`,{body:t})),{successLabel:`Created`});return}o(await c(`Creating`,async()=>r.cache.cacheReserve.clear(i)),{successLabel:`Created`})}};function f(e){return e.option(`value`,{type:`string`,description:`Value of the Cache Reserve zone setting.`,choices:[`on`,`off`]}).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 p={command:`edit`,describe:`Increase cache lifetimes by automatically storing all cacheable files into Cloudflare's persistent object storage buckets. Requires Cache Reserve subscription. Note: using Tiered Cache with Cache Reserve is highly recommended to reduce Reserve operations costs. See the [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) for more information.`,builder:f,handler:async e=>{if(e.dryRun){s({command:`cf cache cache-reserve edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/cache_reserve`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:{value:e.value,body:e.body}});return}let u=await n(e);if(e.zoneId=await t({zone:e.zone},u,{quiet:e.quiet}),e.body){let t=a(e.body);o(await c(`Updating`,async()=>u.patch(`/zones/${e.zoneId}/cache/cache_reserve`,{body:t})),{successLabel:`Updated`});return}e.value===void 0&&(e.value=await r(`value`,`Value of the Cache Reserve zone setting.`,[`on`,`off`]));let d={};e.value!==void 0&&i(d,[`value`],l(e.value,`value`,`text`)),o(await c(`Updating`,async()=>u.patch(`/zones/${e.zoneId}/cache/cache_reserve`,{body:Object.keys(d).length>0?d:void 0})),{successLabel:`Updated`})}};function m(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const h={command:`get`,describe:`Increase cache lifetimes by automatically storing all cacheable files into Cloudflare's persistent object storage buckets. Requires Cache Reserve subscription. Note: using Tiered Cache with Cache Reserve is highly recommended to reduce Reserve operations costs. See the [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) for more information.`,builder:m,handler:async e=>{if(e.dryRun){s({command:`cf cache cache-reserve get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/cache_reserve`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading`,async()=>r.cache.cacheReserve.get(i)),{successLabel:`Loaded`})}};function g(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`status`,describe:`You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation.`,builder:g,handler:async e=>{if(e.dryRun){s({command:`cf cache cache-reserve status`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/cache_reserve_clear`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading`,async()=>r.cache.cacheReserve.status(i)),{successLabel:`Loaded`})}},v={command:`cache-reserve`,describe:`Persistent storage tier that keeps cached assets even after eviction from edge caches`,builder:e=>e.command(d).command(p).command(h).command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function y(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const b={command:`purge`,describe:'### Purge All Cached Content Removes ALL files from Cloudflare\'s cache. All tiers can purge everything. ``` {"purge_everything": true} ``` ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare\'s cache by specifying URLs. All tiers can purge by URL. To purge files with custom cache keys, include the headers used to compute the cache key as in the example. If you have a device type or geo in your cache key, you will need to include the CF-Device-Type or CF-IPCountry headers. If you have lang in your cache key, you will need to include the Accept-Language header. **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for http, 443 for https), but must be included otherwise. Single file purge example with files: ``` {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} ``` Single file purge example with url and header pairs: ``` {"files": [{url: "http://www.example.com/cat_picture.jpg", headers: { "CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN" }}, {url: "http://www.example.com/dog_picture.jpg", headers: { "CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US" }}]} ``` ### Purge Cached Content by Tag, Host or Prefix Granularly removes one or more files from Cloudflare\'s cache either by specifying the host, the associated Cache-Tag, or a Prefix. Flex purge with tags: ``` {"tags": ["a-cache-tag", "another-cache-tag"]} ``` Flex purge with hosts: ``` {"hosts": ["www.example.com", "images.example.com"]} ``` Flex purge with prefixes: ``` {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} ``` ### Availability and limits please refer to [purge cache availability and limits documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/#availability-and-limits).',builder:y,handler:async r=>{if(r.dryRun){s({command:`cf cache purge`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${r.zone??r.zoneId??`<zone>`}/purge_cache`,pathParams:{"zone-id":String(r.zone??r[`zone-id`]??``)},bodyKind:`json`,body:{body:r.body}});return}let i=await n(r),l=await t({zone:r.zone},i,{quiet:r.quiet});if(r.zoneId=l,!await e({force:!!r.force,message:`This operation destroys cached content for a zone.`})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}if(r.body){let e=a(r.body);o(await c(`Deleting`,async()=>i.post(`/zones/${r.zoneId}/purge_cache`,{body:e})),{successLabel:`Deleted`});return}o(await c(`Deleting`,async()=>i.cache.purge(l)),{successLabel:`Deleted`})}};function x(e){return e.option(`value`,{type:`string`,description:`Value of the Regional Tiered Cache zone setting.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const S={command:`edit`,describe:`Instructs Cloudflare to check a regional hub data center on the way to your upper tier. This can help improve performance for smart and custom tiered cache topologies.`,builder:x,handler:async e=>{if(e.dryRun){s({command:`cf cache regional-tiered-cache edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/regional_tiered_cache`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:{value:e.value,body:e.body}});return}let u=await n(e);if(e.zoneId=await t({zone:e.zone},u,{quiet:e.quiet}),e.body){let t=a(e.body);o(await c(`Updating`,async()=>u.patch(`/zones/${e.zoneId}/cache/regional_tiered_cache`,{body:t})),{successLabel:`Updated`});return}e.value===void 0&&(e.value=await r(`value`,`Value of the Regional Tiered Cache zone setting.`,[`on`,`off`]));let d={};e.value!==void 0&&i(d,[`value`],l(e.value,`value`,`text`)),o(await c(`Updating`,async()=>u.patch(`/zones/${e.zoneId}/cache/regional_tiered_cache`,{body:Object.keys(d).length>0?d:void 0})),{successLabel:`Updated`})}};function C(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const w={command:`get`,describe:`Instructs Cloudflare to check a regional hub data center on the way to your upper tier. This can help improve performance for smart and custom tiered cache topologies.`,builder:C,handler:async e=>{if(e.dryRun){s({command:`cf cache regional-tiered-cache get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/regional_tiered_cache`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading`,async()=>r.cache.regionalTieredCache.get(i)),{successLabel:`Loaded`})}},T={command:`regional-tiered-cache`,describe:`Restrict tiered cache topology to data centers within a specific geographic region`,builder:e=>e.command(S).command(w).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function E(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const D={command:`delete`,describe:`Smart Tiered Cache dynamically selects the single closest upper tier for each of your website’s origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin.`,builder:E,handler:async r=>{if(r.dryRun){s({command:`cf cache smart-tiered-cache delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${r.zone??r.zoneId??`<zone>`}/cache/tiered_cache_smart_topology_enable`,pathParams:{"zone-id":String(r.zone??r[`zone-id`]??``)},bodyKind:`none`});return}let i=await n(r),a=await t({zone:r.zone},i,{quiet:r.quiet});if(r.zoneId=a,!await e({force:!!r.force})){process.stderr.write(`Aborted.
|
|
4
|
-
`);return}o(await c(`Deleting`,async()=>i.cache.smartTieredCache.delete(a)),{successLabel:`Deleted`})}};function O(e){return e.option(`value`,{type:`string`,description:`Enable or disable the Smart Tiered Cache.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Update enablement of Smart Tiered Cache.`})}const k={command:`edit`,describe:`Smart Tiered Cache dynamically selects the single closest upper tier for each of your website’s origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin.`,builder:O,handler:async e=>{if(e.dryRun){s({command:`cf cache smart-tiered-cache edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/tiered_cache_smart_topology_enable`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:{value:e.value,body:e.body}});return}let u=await n(e);if(e.zoneId=await t({zone:e.zone},u,{quiet:e.quiet}),e.body){let t=a(e.body);o(await c(`Updating`,async()=>u.patch(`/zones/${e.zoneId}/cache/tiered_cache_smart_topology_enable`,{body:t})),{successLabel:`Updated`});return}e.value===void 0&&(e.value=await r(`value`,`Enable or disable the Smart Tiered Cache.`,[`on`,`off`]));let d={};e.value!==void 0&&i(d,[`value`],l(e.value,`value`,`text`)),o(await c(`Updating`,async()=>u.patch(`/zones/${e.zoneId}/cache/tiered_cache_smart_topology_enable`,{body:Object.keys(d).length>0?d:void 0})),{successLabel:`Updated`})}};function A(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const j={command:`get`,describe:`Smart Tiered Cache dynamically selects the single closest upper tier for each of your website’s origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin.`,builder:A,handler:async e=>{if(e.dryRun){s({command:`cf cache smart-tiered-cache get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/tiered_cache_smart_topology_enable`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading`,async()=>r.cache.smartTieredCache.get(i)),{successLabel:`Loaded`})}},M={command:`smart-tiered-cache`,describe:`Automatically determine the best upper-tier data centers for tiered cache topology`,builder:e=>e.command(D).command(k).command(j).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function N(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const P={command:`delete`,describe:`Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers.`,builder:N,handler:async r=>{if(r.dryRun){s({command:`cf cache variants delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${r.zone??r.zoneId??`<zone>`}/cache/variants`,pathParams:{"zone-id":String(r.zone??r[`zone-id`]??``)},bodyKind:`none`});return}let i=await n(r),a=await t({zone:r.zone},i,{quiet:r.quiet});if(r.zoneId=a,!await e({force:!!r.force})){process.stderr.write(`Aborted.
|
|
5
|
-
`);return}o(await c(`Deleting`,async()=>i.cache.variants.delete(a)),{successLabel:`Deleted`})}};function F(e){return e.option(`value-avif`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for avif.`}).option(`value-bmp`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for bmp.`}).option(`value-gif`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for gif.`}).option(`value-jp2`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for jp2.`}).option(`value-jpeg`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for jpeg.`}).option(`value-jpg`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for jpg.`}).option(`value-jpg2`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for jpg2.`}).option(`value-png`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for png.`}).option(`value-tif`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for tif.`}).option(`value-tiff`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for tiff.`}).option(`value-webp`,{type:`string`,array:!0,description:`List of strings with the MIME types of all the variants that should be served for webp.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const I={command:`edit`,describe:`Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers.`,builder:F,handler:async e=>{if(e.dryRun){s({command:`cf cache variants edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/variants`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:{"value-avif":e[`value-avif`],"value-bmp":e[`value-bmp`],"value-gif":e[`value-gif`],"value-jp2":e[`value-jp2`],"value-jpeg":e[`value-jpeg`],"value-jpg":e[`value-jpg`],"value-jpg2":e[`value-jpg2`],"value-png":e[`value-png`],"value-tif":e[`value-tif`],"value-tiff":e[`value-tiff`],"value-webp":e[`value-webp`],body:e.body}});return}let r=await n(e);if(e.zoneId=await t({zone:e.zone},r,{quiet:e.quiet}),e.body){let t=a(e.body);o(await c(`Updating`,async()=>r.patch(`/zones/${e.zoneId}/cache/variants`,{body:t})),{successLabel:`Updated`});return}let l={};e[`value-avif`]!==void 0&&i(l,[`value`,`avif`],e[`value-avif`]),e[`value-bmp`]!==void 0&&i(l,[`value`,`bmp`],e[`value-bmp`]),e[`value-gif`]!==void 0&&i(l,[`value`,`gif`],e[`value-gif`]),e[`value-jp2`]!==void 0&&i(l,[`value`,`jp2`],e[`value-jp2`]),e[`value-jpeg`]!==void 0&&i(l,[`value`,`jpeg`],e[`value-jpeg`]),e[`value-jpg`]!==void 0&&i(l,[`value`,`jpg`],e[`value-jpg`]),e[`value-jpg2`]!==void 0&&i(l,[`value`,`jpg2`],e[`value-jpg2`]),e[`value-png`]!==void 0&&i(l,[`value`,`png`],e[`value-png`]),e[`value-tif`]!==void 0&&i(l,[`value`,`tif`],e[`value-tif`]),e[`value-tiff`]!==void 0&&i(l,[`value`,`tiff`],e[`value-tiff`]),e[`value-webp`]!==void 0&&i(l,[`value`,`webp`],e[`value-webp`]),o(await c(`Updating`,async()=>r.patch(`/zones/${e.zoneId}/cache/variants`,{body:Object.keys(l).length>0?l:void 0})),{successLabel:`Updated`})}};function L(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const R={command:`get`,describe:`Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers.`,builder:L,handler:async e=>{if(e.dryRun){s({command:`cf cache variants get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/cache/variants`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading`,async()=>r.cache.variants.get(i)),{successLabel:`Loaded`})}},z={command:`variants`,describe:`Serve different cached versions of an image based on the Accept header (WebP, AVIF, etc.)`,builder:e=>e.command(P).command(I).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},B={command:`cache`,describe:`Purge cached content and configure Cache Reserve, tiered caching, and variant serving`,builder:e=>e.command(b).command(v).command(T).command(M).command(z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{B as default};
|