Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.
JavaScript agent-skillsai-agentsai-seoclaudeclaude-codeclaude-code-pluginclaude-skillscodexcontent-marketingconversion-rate-optimizationcopywritingcursoremail-marketinggenerative-engine-optimizationgrowth-marketingmarketingmarketing-automationsaas-marketingseoskill-md
fix(clis): bound HTTP requests and stalled response bodies (#751)
Rudy Mizrahi Celekli95db88142839
diff --git a/tests/clis/request-deadlines.test.cjs b/tests/clis/request-deadlines.test.cjsnew file mode 100644index 0000000..181fe30--- /dev/null+++ b/tests/clis/request-deadlines.test.cjs@@ -0,0 +1,8 @@+const {test}=require('node:test');const assert=require('node:assert/strict');const {spawn}=require('node:child_process');const http=require('node:http');const path=require('node:path')+function run(tool,args,port){const cli=path.resolve(__dirname,'../../tools/clis/'+tool+'.js');const script=`const nativeFetch=global.fetch;global.fetch=(url,options)=>nativeFetch('http://127.0.0.1:${port}/'+new URL(url).pathname,options);process.argv=['node',${JSON.stringify(cli)},...${JSON.stringify(args)}];require(${JSON.stringify(cli)})`;return new Promise(resolve=>{const p=spawn(process.execPath,['-e',script],{env:{PATH:process.env.PATH,EXA_API_KEY:'fixture',RESEND_API_KEY:'fixture',HOTJAR_CLIENT_ID:'fixture',HOTJAR_CLIENT_SECRET:'fixture'}});let stdout='',stderr='';p.stdout.on('data',v=>stdout+=v);p.stderr.on('data',v=>stderr+=v);const timer=setTimeout(()=>p.kill(),2000);p.on('close',(code,signal)=>{clearTimeout(timer);resolve({code,signal,stdout,stderr})})})}+async function server(mode){const sockets=new Set();const s=http.createServer((req,res)=>{if(mode==='headers')return;if(mode==='body'){res.writeHead(200,{'Content-Type':'application/json'});res.write('{');return}res.writeHead(200,{'Content-Type':'application/json'});res.end(JSON.stringify({ok:true,access_token:'fixture'}))});s.on('connection',socket=>{sockets.add(socket);socket.on('close',()=>sockets.delete(socket))});await new Promise(resolve=>s.listen(0,'127.0.0.1',resolve));return {port:s.address().port,close:async()=>{for(const socket of sockets)socket.destroy();await new Promise(resolve=>s.close(resolve))}}}+for(const [mode,tool,command] of [['headers','exa',['search','--query','fixture']],['body','resend',['emails','list']],['headers','hotjar',['sites','list']]]) {+ test(`actual HTTP deadline handles ${tool} ${mode}`,async()=>{const s=await server(mode);try{const r=await run(tool,[...command,'--timeout-ms','100'],s.port);assert.equal(r.code,1,JSON.stringify(r));assert.equal(r.signal,null);assert.match(r.stderr,/abort|timeout/i)}finally{await s.close()}})+}+test('healthy requests and redacted dry runs retain their result',async()=>{const s=await server('healthy');try{const r=await run('exa',['search','--query','fixture','--timeout-ms','1000'],s.port);assert.equal(r.code,0,r.stderr);assert.equal(JSON.parse(r.stdout).ok,true);const dry=await run('resend',['emails','list','--dry-run'],s.port);assert.equal(dry.code,0,dry.stderr);assert.equal(JSON.parse(dry.stdout)._dry_run,true);assert.equal(dry.stdout.includes('fixture'),false)}finally{await s.close()}})+test('invalid timeout values fail before making a request',async()=>{const s=await server('healthy');try{for(const value of ['0','-1','1.5','600001','Infinity']){const r=await run('exa',['search','--query','fixture','--timeout-ms',value],s.port);assert.equal(r.code,1);assert.match(r.stderr,/timeout-ms/)}const r=await run('exa',['search','--query','fixture','--timeout-ms'],s.port);assert.equal(r.code,1)}finally{await s.close()}})diff --git a/tools/clis/README.md b/tools/clis/README.mdindex bf2f1b0..98aa412 100644--- a/tools/clis/README.md+++ b/tools/clis/README.md@@ -217,3 +217,15 @@ DOMAINS=$(rewardful affiliates list | jq -r '.data[].email')| `wistia.js` | Video | [Wistia](https://wistia.com) || `zapier.js` | Automation | [Zapier](https://zapier.com) || `zoominfo.js` | Data Enrichment | [ZoomInfo](https://zoominfo.com) |++## HTTP request deadlines++HTTP calls in the 65 CLIs changed by this fix use a 30-second per-request deadline. The newly added Truelist CLI is unchanged. Override with `--timeout-ms <1-600000>` for a slow API, for example:++```bash+node tools/clis/exa.js search --query 'Recent market research' --timeout-ms 120000+```++The deadline covers obtaining headers and consuming the response body, including OAuth requests. Each subsequent HTTP call gets its own deadline; this is not a total command deadline or a bound on external credential commands. An aborted call exits as a failure. Aborting a local request does not cancel work already accepted by a provider: check provider status before manually retrying a mutation. The CLI does not add automatic retries. Dry runs issue no HTTP request.++Implemented using [Node's AbortSignal.timeout](https://nodejs.org/api/globals.html#static-method-abortsignaltimeoutdelay), available on the supported Node 18+ runtime, preserving zero-dependency standalone scripts. Native loopback tests cover stalled headers, stalled bodies, OAuth, successful responses and malformed timeout values without live accounts.diff --git a/tools/clis/activecampaign.js b/tools/clis/activecampaign.jsindex 9da725d..f6500a6 100755--- a/tools/clis/activecampaign.js+++ b/tools/clis/activecampaign.js@@ -16,11 +16,22 @@ if ((!API_URL) && rawArgs.length > 0) {const BASE_URL = API_URL ? `${API_URL.replace(/\/$/, '')}/api/3` : ''++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Api-Token': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Api-Token': API_KEY,diff --git a/tools/clis/adobe-analytics.js b/tools/clis/adobe-analytics.jsindex 7353cf1..735c541 100755--- a/tools/clis/adobe-analytics.js+++ b/tools/clis/adobe-analytics.js@@ -12,11 +12,22 @@ if ((!ACCESS_TOKEN || !CLIENT_ID || !COMPANY_ID) && rawArgs.length > 0) {const BASE_URL = `https://analytics.adobe.io/api/${COMPANY_ID}`++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'x-api-key': '***', 'x-proxy-global-company-id': COMPANY_ID, 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${ACCESS_TOKEN}`,diff --git a/tools/clis/ahrefs.js b/tools/clis/ahrefs.jsindex 52dc503..3a08eb4 100755--- a/tools/clis/ahrefs.js+++ b/tools/clis/ahrefs.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json' } }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/airops.js b/tools/clis/airops.jsindex a7125a1..610cbad 100755--- a/tools/clis/airops.js+++ b/tools/clis/airops.js@@ -9,12 +9,21 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function api(method, path, body) {const url = `${BASE_URL}${path}`if (args['dry-run']) {return { _dry_run: true, method, url, headers: { 'Authorization': 'Bearer ***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/amplitude.js b/tools/clis/amplitude.jsindex 6845d41..e8a4785 100755--- a/tools/clis/amplitude.js+++ b/tools/clis/amplitude.js@@ -11,13 +11,24 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function ingestApi(method, path, body) {if (args['dry-run']) {const maskedBody = body ? JSON.parse(JSON.stringify(body)) : undefinedif (maskedBody && maskedBody.api_key) maskedBody.api_key = '***'return { _dry_run: true, method, url: `${INGESTION_URL}${path}`, headers: { 'Content-Type': 'application/json' }, body: maskedBody }}- const res = await fetch(`${INGESTION_URL}${path}`, {+ const res = await fetch(`${INGESTION_URL}${path}`, { signal: requestSignal(),method,headers: { 'Content-Type': 'application/json' },body: body ? JSON.stringify(body) : undefined,@@ -39,7 +50,7 @@ async function queryApi(method, path, params) {return { _dry_run: true, method, url, headers: { 'Authorization': '***', 'Content-Type': 'application/json' } }}const auth = Buffer.from(`${API_KEY}:${SECRET_KEY}`).toString('base64')- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers: {'Authorization': `Basic ${auth}`,diff --git a/tools/clis/apollo.js b/tools/clis/apollo.jsindex b234c69..30580cc 100755--- a/tools/clis/apollo.js+++ b/tools/clis/apollo.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Content-Type': 'application/json', 'x-api-key': '***' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Content-Type': 'application/json',diff --git a/tools/clis/beehiiv.js b/tools/clis/beehiiv.jsindex 45893eb..b19ef38 100755--- a/tools/clis/beehiiv.js+++ b/tools/clis/beehiiv.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/brevo.js b/tools/clis/brevo.jsindex 8522bb7..0cd5b84 100755--- a/tools/clis/brevo.js+++ b/tools/clis/brevo.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'api-key': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'api-key': API_KEY,diff --git a/tools/clis/buffer.js b/tools/clis/buffer.jsindex 24b8b16..e5a87f9 100755--- a/tools/clis/buffer.js+++ b/tools/clis/buffer.js@@ -9,6 +9,17 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const headers = {'Authorization': `Bearer ${API_KEY}`,@@ -20,7 +31,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, 'Authorization': '***' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? new URLSearchParams(body).toString() : undefined,@@ -37,7 +48,7 @@ async function apiJson(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,@@ -172,7 +183,7 @@ async function main() {result = { _dry_run: true, method: 'POST', url: `${BASE_URL}/updates/create.json`, headers: { 'Authorization': '***', 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json' }, body: formBody.toString() }break}- const res = await fetch(`${BASE_URL}/updates/create.json`, {+ const res = await fetch(`${BASE_URL}/updates/create.json`, { signal: requestSignal(),method: 'POST',headers: {'Authorization': `Bearer ${API_KEY}`,@@ -218,7 +229,7 @@ async function main() {result = { _dry_run: true, method: 'POST', url: `${BASE_URL}/profiles/${id}/updates/reorder.json`, headers: { 'Authorization': '***', 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json' }, body: formBody.toString() }break}- const res = await fetch(`${BASE_URL}/profiles/${id}/updates/reorder.json`, {+ const res = await fetch(`${BASE_URL}/profiles/${id}/updates/reorder.json`, { signal: requestSignal(),method: 'POST',headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/calendly.js b/tools/clis/calendly.jsindex 5924fd5..8a7aff5 100755--- a/tools/clis/calendly.js+++ b/tools/clis/calendly.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/clay.js b/tools/clis/clay.jsindex aade7c3..ae9289c 100755--- a/tools/clis/clay.js+++ b/tools/clis/clay.js@@ -9,6 +9,17 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': 'Bearer ***', 'Content-Type': 'application/json' }, body: body || undefined }@@ -21,7 +32,7 @@ async function api(method, path, body) {},}if (body) options.body = JSON.stringify(body)- const res = await fetch(`${BASE_URL}${path}`, options)+ const res = await fetch(`${BASE_URL}${path}`, { ...options, signal: requestSignal() })if (!res.ok) process.exitCode = 1const text = await res.text()try {diff --git a/tools/clis/clearbit.js b/tools/clis/clearbit.jsindex 48db11c..d27c7c4 100755--- a/tools/clis/clearbit.js+++ b/tools/clis/clearbit.js@@ -8,12 +8,23 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, baseUrl, path, body) {const auth = 'Basic ' + Buffer.from(`${API_KEY}:`).toString('base64')if (args['dry-run']) {return { _dry_run: true, method, url: `${baseUrl}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${baseUrl}${path}`, {+ const res = await fetch(`${baseUrl}${path}`, { signal: requestSignal(),method,headers: {'Authorization': auth,diff --git a/tools/clis/close.js b/tools/clis/close.jsindex 0989ee6..76bd21e 100755--- a/tools/clis/close.js+++ b/tools/clis/close.js@@ -9,12 +9,23 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const url = `${BASE_URL}${path}`if (args['dry-run']) {return { _dry_run: true, method, url, headers: { 'Content-Type': 'application/json', 'Authorization': 'Basic ***' }, body: body || undefined }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers: {'Content-Type': 'application/json',diff --git a/tools/clis/coupler.js b/tools/clis/coupler.jsindex 215767f..1d5f584 100755--- a/tools/clis/coupler.js+++ b/tools/clis/coupler.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': 'Bearer ***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/crossbeam.js b/tools/clis/crossbeam.jsindex d52830e..10369e1 100755--- a/tools/clis/crossbeam.js+++ b/tools/clis/crossbeam.js@@ -9,12 +9,23 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const url = `${BASE_URL}${path}`if (args['dry-run']) {return { _dry_run: true, method, url, headers: { 'Authorization': 'Bearer ***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/customer-io.js b/tools/clis/customer-io.jsindex a543bbc..920e438 100755--- a/tools/clis/customer-io.js+++ b/tools/clis/customer-io.js@@ -23,6 +23,17 @@ if ((!hasTrackAuth && !hasAppAuth) && rawArgs.length > 0) {const basicAuth = hasTrackAuth ? Buffer.from(`${SITE_ID}:${API_KEY}`).toString('base64') : null++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function trackApi(method, path, body) {if (!hasTrackAuth) {return { error: 'Track API requires CUSTOMERIO_SITE_ID and CUSTOMERIO_API_KEY environment variables' }@@ -30,7 +41,7 @@ async function trackApi(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${TRACK_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${TRACK_URL}${path}`, {+ const res = await fetch(`${TRACK_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Basic ${basicAuth}`,@@ -53,7 +64,7 @@ async function appApi(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${APP_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${APP_URL}${path}`, {+ const res = await fetch(`${APP_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${APP_KEY}`,diff --git a/tools/clis/dataforseo.js b/tools/clis/dataforseo.jsindex 3dea944..18a14e0 100755--- a/tools/clis/dataforseo.js+++ b/tools/clis/dataforseo.js@@ -12,11 +12,22 @@ if ((!LOGIN || !PASSWORD) && rawArgs.length > 0) {const AUTH = 'Basic ' + Buffer.from(`${LOGIN}:${PASSWORD}`).toString('base64')++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': AUTH,diff --git a/tools/clis/demio.js b/tools/clis/demio.jsindex aa5ada9..42fb6ff 100755--- a/tools/clis/demio.js+++ b/tools/clis/demio.js@@ -15,11 +15,22 @@ if ((!API_SECRET) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Api-Key': '***', 'Api-Secret': '***', 'Content-Type': 'application/json', Accept: 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Api-Key': API_KEY,diff --git a/tools/clis/dub.js b/tools/clis/dub.jsindex 1c2bcd2..e13bfca 100755--- a/tools/clis/dub.js+++ b/tools/clis/dub.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/exa.js b/tools/clis/exa.jsindex 7e86e6c..30300f9 100755--- a/tools/clis/exa.js+++ b/tools/clis/exa.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'x-api-key': '***', 'Content-Type': 'application/json', 'x-exa-integration': 'marketingskills' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'x-api-key': API_KEY,diff --git a/tools/clis/firecrawl.js b/tools/clis/firecrawl.jsindex 9df4569..cb5c7c4 100755--- a/tools/clis/firecrawl.js+++ b/tools/clis/firecrawl.js@@ -9,11 +9,22 @@ if (!API_KEY && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: 'Bearer ***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {Authorization: `Bearer ${API_KEY}`,diff --git a/tools/clis/g2.js b/tools/clis/g2.jsindex e7949de..c8e6eff 100755--- a/tools/clis/g2.js+++ b/tools/clis/g2.js@@ -9,11 +9,22 @@ if ((!API_TOKEN) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/vnd.api+json', Accept: 'application/vnd.api+json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Token token=${API_TOKEN}`,diff --git a/tools/clis/ga4.js b/tools/clis/ga4.jsindex ff7765a..86359ac 100755--- a/tools/clis/ga4.js+++ b/tools/clis/ga4.js@@ -6,11 +6,22 @@ const DATA_API = 'https://analyticsdata.googleapis.com/v1beta'const ADMIN_API = 'https://analyticsadmin.googleapis.com/v1beta'const MP_URL = 'https://www.google-analytics.com/mp/collect'++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, baseUrl, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${baseUrl}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${baseUrl}${path}`, {+ const res = await fetch(`${baseUrl}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${ACCESS_TOKEN}`,@@ -31,7 +42,7 @@ async function mpApi(measurementId, apiSecret, body) {if (args['dry-run']) {return { _dry_run: true, method: 'POST', url: `${MP_URL}?${new URLSearchParams({ measurement_id: measurementId, api_secret: '***' })}`, headers: { 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${MP_URL}?${params}`, {+ const res = await fetch(`${MP_URL}?${params}`, { signal: requestSignal(),method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify(body),diff --git a/tools/clis/github-prospects.js b/tools/clis/github-prospects.jsindex 53bced5..c7157a8 100755--- a/tools/clis/github-prospects.js+++ b/tools/clis/github-prospects.js@@ -26,6 +26,17 @@ function parseArgs(args) {const args = parseArgs(process.argv.slice(2))++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(path, opts = {}) {const url = path.startsWith('http') ? path : `${BASE_URL}${path}`const headers = {@@ -44,7 +55,7 @@ async function api(path, opts = {}) {}}- const res = await fetch(url, { headers })+ const res = await fetch(url, { signal: requestSignal(), headers })const rateLimitRemaining = res.headers.get('x-ratelimit-remaining')const rateLimitReset = res.headers.get('x-ratelimit-reset')diff --git a/tools/clis/google-ads.js b/tools/clis/google-ads.jsindex 6aac5e8..53f4b29 100755--- a/tools/clis/google-ads.js+++ b/tools/clis/google-ads.js@@ -12,6 +12,17 @@ if ((!TOKEN || !CUSTOMER_ID) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const headers = {'Authorization': `Bearer ${TOKEN}`,@@ -22,7 +33,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***', ...(DEV_TOKEN ? { 'developer-token': '***' } : {}) }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/google-search-console.js b/tools/clis/google-search-console.jsindex 9ffed69..9f2cf7a 100755--- a/tools/clis/google-search-console.js+++ b/tools/clis/google-search-console.js@@ -9,11 +9,22 @@ if ((!ACCESS_TOKEN) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${ACCESS_TOKEN}`,diff --git a/tools/clis/hotjar.js b/tools/clis/hotjar.jsindex cdcfb0c..817bbd1 100755--- a/tools/clis/hotjar.js+++ b/tools/clis/hotjar.js@@ -13,9 +13,20 @@ if ((!CLIENT_ID || !CLIENT_SECRET) && rawArgs.length > 0) {let cachedToken = null++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function getToken() {if (cachedToken) return cachedToken- const res = await fetch(`${OAUTH_URL}/oauth/token`, {+ const res = await fetch(`${OAUTH_URL}/oauth/token`, { signal: requestSignal(),method: 'POST',headers: { 'Content-Type': 'application/x-www-form-urlencoded' },body: `grant_type=client_credentials&client_id=${encodeURIComponent(CLIENT_ID)}&client_secret=${encodeURIComponent(CLIENT_SECRET)}`,@@ -33,7 +44,7 @@ async function api(method, path) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', Accept: 'application/json' } }}const token = await getToken()- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${token}`,diff --git a/tools/clis/hunter.js b/tools/clis/hunter.jsindex c720477..9f0a8e6 100755--- a/tools/clis/hunter.js+++ b/tools/clis/hunter.js@@ -9,6 +9,15 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function api(method, path, body) {const url = new URL(`${BASE_URL}${path}`)url.searchParams.set('api_key', API_KEY)@@ -16,7 +25,7 @@ async function api(method, path, body) {url.searchParams.set('api_key', '***')return { _dry_run: true, method, url: url.toString(), headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(url.toString(), {+ const res = await fetch(url.toString(), { signal: requestSignal(),method,headers: {'Content-Type': 'application/json',diff --git a/tools/clis/instantly.js b/tools/clis/instantly.jsindex b53d1d9..e517d48 100755--- a/tools/clis/instantly.js+++ b/tools/clis/instantly.js@@ -24,13 +24,22 @@ const INTEREST_STATUSES = {'no-show': -4,}+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function api(method, path, body) {const url = `${BASE_URL}${path}`const headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' }if (args['dry-run']) {return { _dry_run: true, method, url, headers: { ...headers, Authorization: 'Bearer ***' }, body: body || undefined }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers: { ...headers, Authorization: `Bearer ${API_KEY}` },body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/intercom.js b/tools/clis/intercom.jsindex 79bddb1..fe40211 100755--- a/tools/clis/intercom.js+++ b/tools/clis/intercom.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', Accept: 'application/json', 'Intercom-Version': '2.11' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/keywords-everywhere.js b/tools/clis/keywords-everywhere.jsindex 12c886a..4d2c150 100755--- a/tools/clis/keywords-everywhere.js+++ b/tools/clis/keywords-everywhere.js@@ -9,6 +9,17 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const headers = {'Authorization': `Bearer ${API_KEY}`,@@ -18,7 +29,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/kit.js b/tools/clis/kit.jsindex 97ce8b9..1001183 100755--- a/tools/clis/kit.js+++ b/tools/clis/kit.js@@ -10,6 +10,17 @@ if ((!API_SECRET && !API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body, useSecret = true) {const url = new URL(`${BASE_URL}${path}`)if (method === 'GET' || method === 'DELETE') {@@ -52,7 +63,7 @@ async function api(method, path, body, useSecret = true) {}return { _dry_run: true, method, url: dryRunUrl, headers: dryRunHeaders, body: dryRunBody }}- const res = await fetch(url.toString(), opts)+ const res = await fetch(url.toString(), { ...opts, signal: requestSignal() })const text = await res.text()try {return JSON.parse(text)diff --git a/tools/clis/klaviyo.js b/tools/clis/klaviyo.jsindex 023278d..2b45c24 100755--- a/tools/clis/klaviyo.js+++ b/tools/clis/klaviyo.js@@ -10,6 +10,17 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const headers = {'Authorization': `Klaviyo-API-Key ${API_KEY}`,@@ -20,7 +31,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/lemlist.js b/tools/clis/lemlist.jsindex f180679..ba49ece 100755--- a/tools/clis/lemlist.js+++ b/tools/clis/lemlist.js@@ -11,11 +11,22 @@ if ((!API_KEY) && rawArgs.length > 0) {const AUTH = 'Basic ' + Buffer.from(`:${API_KEY}`).toString('base64')++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': AUTH,diff --git a/tools/clis/linkedin-ads.js b/tools/clis/linkedin-ads.jsindex 10c0d4f..bf38ce5 100755--- a/tools/clis/linkedin-ads.js+++ b/tools/clis/linkedin-ads.js@@ -14,6 +14,15 @@ if ((!TOKEN) && rawArgs.length > 0) {process.exit(1)}+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function api(method, path, body, extraHeaders = {}) {const headers = {'Authorization': `Bearer ${TOKEN}`,@@ -25,7 +34,7 @@ async function api(method, path, body, extraHeaders = {}) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: 'Bearer ***' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/livestorm.js b/tools/clis/livestorm.jsindex 0f51144..47cd6b4 100755--- a/tools/clis/livestorm.js+++ b/tools/clis/livestorm.js@@ -9,6 +9,17 @@ if ((!API_TOKEN) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const headers = {'Authorization': API_TOKEN,@@ -18,7 +29,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/mailchimp.js b/tools/clis/mailchimp.jsindex dbe8f72..1da8956 100755--- a/tools/clis/mailchimp.js+++ b/tools/clis/mailchimp.js@@ -11,6 +11,17 @@ if ((!API_KEY) && rawArgs.length > 0) {const dc = API_KEY ? API_KEY.split('-').pop() : ''const BASE_URL = `https://${dc}.api.mailchimp.com/3.0`++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const auth = 'Basic ' + Buffer.from(`anystring:${API_KEY}`).toString('base64')const headers = {@@ -20,7 +31,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/mention-me.js b/tools/clis/mention-me.jsindex e49a7c9..e04ee84 100755--- a/tools/clis/mention-me.js+++ b/tools/clis/mention-me.js@@ -9,6 +9,17 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const headers = {'Authorization': `Bearer ${API_KEY}`,@@ -17,7 +28,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/meta-ads.js b/tools/clis/meta-ads.jsindex 3145eb3..182db11 100755--- a/tools/clis/meta-ads.js+++ b/tools/clis/meta-ads.js@@ -10,6 +10,17 @@ if ((!TOKEN) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const url = `${BASE_URL}${path}`const opts = {@@ -23,7 +34,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url, headers: { ...opts.headers, Authorization: '***' }, body: body || undefined }}- const res = await fetch(url, opts)+ const res = await fetch(url, { ...opts, signal: requestSignal() })if (!res.ok) process.exitCode = 1const text = await res.text()try {diff --git a/tools/clis/mixpanel.js b/tools/clis/mixpanel.jsindex 32e1fb9..0572706 100755--- a/tools/clis/mixpanel.js+++ b/tools/clis/mixpanel.js@@ -14,6 +14,17 @@ if ((!TOKEN && !API_KEY && !SECRET && !PROJECT_SECRET) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function ingestApi(method, path, body) {const headers = { 'Content-Type': 'application/json' }if (args['dry-run']) {@@ -24,7 +35,7 @@ async function ingestApi(method, path, body) {})return { _dry_run: true, method, url: `${INGESTION_URL}${path}`, headers, body: maskedBody }}- const res = await fetch(`${INGESTION_URL}${path}`, {+ const res = await fetch(`${INGESTION_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,@@ -63,7 +74,7 @@ async function queryApi(method, baseUrl, path, params) {if (args['dry-run']) {return { _dry_run: true, method, url, headers: { ...headers, Authorization: '***' } }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers,})@@ -84,7 +95,7 @@ async function queryApiPost(path, body) {if (args['dry-run']) {return { _dry_run: true, method: 'POST', url: `${QUERY_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined }}- const res = await fetch(`${QUERY_URL}${path}`, {+ const res = await fetch(`${QUERY_URL}${path}`, { signal: requestSignal(),method: 'POST',headers,body: JSON.stringify(body),diff --git a/tools/clis/onesignal.js b/tools/clis/onesignal.jsindex d59b142..aebb33f 100755--- a/tools/clis/onesignal.js+++ b/tools/clis/onesignal.js@@ -15,6 +15,17 @@ if ((!APP_ID) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const headers = {'Authorization': `Key ${REST_API_KEY}`,@@ -24,7 +35,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/optimizely.js b/tools/clis/optimizely.jsindex 13cfd1c..75070be 100755--- a/tools/clis/optimizely.js+++ b/tools/clis/optimizely.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/outreach.js b/tools/clis/outreach.jsindex b1b791e..fe9bb28 100755--- a/tools/clis/outreach.js+++ b/tools/clis/outreach.js@@ -9,12 +9,23 @@ if ((!ACCESS_TOKEN) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const url = `${BASE_URL}${path}`if (args['dry-run']) {return { _dry_run: true, method, url, headers: { 'Authorization': 'Bearer ***', 'Content-Type': 'application/vnd.api+json', 'Accept': 'application/vnd.api+json' }, body: body || undefined }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${ACCESS_TOKEN}`,diff --git a/tools/clis/paddle.js b/tools/clis/paddle.jsindex bcab27d..a8b1f4c 100755--- a/tools/clis/paddle.js+++ b/tools/clis/paddle.js@@ -11,11 +11,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/partnerstack.js b/tools/clis/partnerstack.jsindex 2ebe2d0..8389b53 100755--- a/tools/clis/partnerstack.js+++ b/tools/clis/partnerstack.js@@ -12,11 +12,22 @@ if ((!PUBLIC_KEY || !SECRET_KEY) && rawArgs.length > 0) {const AUTH = 'Basic ' + Buffer.from(`${PUBLIC_KEY}:${SECRET_KEY}`).toString('base64')++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': AUTH,diff --git a/tools/clis/pendo.js b/tools/clis/pendo.jsindex 9aa104f..bbacdd0 100755--- a/tools/clis/pendo.js+++ b/tools/clis/pendo.js@@ -9,12 +9,23 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const url = `${BASE_URL}${path}`if (args['dry-run']) {return { _dry_run: true, method, url, headers: { 'Content-Type': 'application/json', 'x-pendo-integration-key': '***' }, body: body || undefined }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers: {'Content-Type': 'application/json',diff --git a/tools/clis/plausible.js b/tools/clis/plausible.jsindex 4533001..0f8846f 100755--- a/tools/clis/plausible.js+++ b/tools/clis/plausible.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/postmark.js b/tools/clis/postmark.jsindex fe48a9c..9106df9 100755--- a/tools/clis/postmark.js+++ b/tools/clis/postmark.js@@ -9,6 +9,17 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body, useAccountToken) {if (args['dry-run']) {const maskedHeaders = { 'Content-Type': 'application/json', 'Accept': 'application/json' }@@ -28,7 +39,7 @@ async function api(method, path, body, useAccountToken) {} else {headers['X-Postmark-Server-Token'] = API_KEY}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/rankparse.js b/tools/clis/rankparse.jsindex 5872402..d54f729 100755--- a/tools/clis/rankparse.js+++ b/tools/clis/rankparse.js@@ -9,6 +9,17 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'X-API-Key': '***', 'Content-Type': 'application/json' }, body }@@ -21,7 +32,7 @@ async function api(method, path, body) {},}if (body) init.body = JSON.stringify(body)- const res = await fetch(`${BASE_URL}${path}`, init)+ const res = await fetch(`${BASE_URL}${path}`, { ...init, signal: requestSignal() })if (!res.ok) process.exitCode = 1const text = await res.text()try {diff --git a/tools/clis/resend.js b/tools/clis/resend.jsindex e2bf2d4..39908a2 100755--- a/tools/clis/resend.js+++ b/tools/clis/resend.js@@ -9,11 +9,20 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function api(method, path, body, extraHeaders = {}) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', ...extraHeaders }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/rewardful.js b/tools/clis/rewardful.jsindex 3cdb385..882e694 100755--- a/tools/clis/rewardful.js+++ b/tools/clis/rewardful.js@@ -9,13 +9,24 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const auth = 'Basic ' + Buffer.from(`${API_KEY}:`).toString('base64')const encodedBody = body ? new URLSearchParams(body).toString() : undefinedif (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/x-www-form-urlencoded' }, body: encodedBody }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': auth,diff --git a/tools/clis/savvycal.js b/tools/clis/savvycal.jsindex 88f7b1a..6daf916 100755--- a/tools/clis/savvycal.js+++ b/tools/clis/savvycal.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/segment.js b/tools/clis/segment.jsindex a2277ba..21a6977 100755--- a/tools/clis/segment.js+++ b/tools/clis/segment.js@@ -11,6 +11,17 @@ if ((!WRITE_KEY && !ACCESS_TOKEN) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function trackApi(method, path, body) {if (!WRITE_KEY) {return { error: 'SEGMENT_WRITE_KEY required for tracking operations' }@@ -19,7 +30,7 @@ async function trackApi(method, path, body) {return { _dry_run: true, method, url: `${TRACKING_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined }}const auth = Buffer.from(`${WRITE_KEY}:`).toString('base64')- const res = await fetch(`${TRACKING_URL}${path}`, {+ const res = await fetch(`${TRACKING_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Basic ${auth}`,@@ -44,7 +55,7 @@ async function profileApi(method, path) {return { _dry_run: true, method, url: `${PROFILE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' } }}const auth = Buffer.from(`${ACCESS_TOKEN}:`).toString('base64')- const res = await fetch(`${PROFILE_URL}${path}`, {+ const res = await fetch(`${PROFILE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Basic ${auth}`,diff --git a/tools/clis/semrush.js b/tools/clis/semrush.jsindex f6ca1e1..529540d 100755--- a/tools/clis/semrush.js+++ b/tools/clis/semrush.js@@ -46,6 +46,15 @@ function parseCSV(text) {return rows.map(cells => Object.fromEntries(headers.map((header, index) => [header, cells[index] || ''])))}+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function api(params, baseUrl = BASE_URL) {params.set('key', API_KEY)params.set('export_escape', '1')@@ -54,7 +63,7 @@ async function api(params, baseUrl = BASE_URL) {maskedParams.set('key', '***')return { _dry_run: true, method: 'GET', url: `${baseUrl}?${maskedParams}`, headers: {}, body: undefined }}- const res = await fetch(`${baseUrl}?${params}`)+ const res = await fetch(`${baseUrl}?${params}`, { signal: requestSignal() })const text = await res.text()if (!res.ok) {process.exitCode = 1diff --git a/tools/clis/sendgrid.js b/tools/clis/sendgrid.jsindex 31430ca..06e36e9 100755--- a/tools/clis/sendgrid.js+++ b/tools/clis/sendgrid.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/similarweb.js b/tools/clis/similarweb.jsindex 4880670..1078457 100755--- a/tools/clis/similarweb.js+++ b/tools/clis/similarweb.js@@ -9,6 +9,15 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function api(method, path, body, version = 'v1') {const url = new URL(`${BASE_URL}/${version}${path}`)url.searchParams.set('api_key', API_KEY)@@ -17,7 +26,7 @@ async function api(method, path, body, version = 'v1') {previewUrl.searchParams.set('api_key', '***')return { _dry_run: true, method, url: previewUrl.toString(), headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers: {'Content-Type': 'application/json',diff --git a/tools/clis/snov.js b/tools/clis/snov.jsindex 7e37636..203d04d 100755--- a/tools/clis/snov.js+++ b/tools/clis/snov.js@@ -12,9 +12,18 @@ if ((!CLIENT_ID || !CLIENT_SECRET) && rawArgs.length > 0) {let cachedToken = null+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function getToken() {if (cachedToken) return cachedToken- const res = await fetch('https://api.snov.io/v1/oauth/access_token', {+ const res = await fetch('https://api.snov.io/v1/oauth/access_token', { signal: requestSignal(),method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ grant_type: 'client_credentials', client_id: CLIENT_ID, client_secret: CLIENT_SECRET }),@@ -41,7 +50,7 @@ async function api(method, path, body, base = BASE_URL) {},}if (body) opts.body = JSON.stringify(body)- const res = await fetch(`${base}${path}`, opts)+ const res = await fetch(`${base}${path}`, { ...opts, signal: requestSignal() })const text = await res.text()try {return JSON.parse(text)diff --git a/tools/clis/supermetrics.js b/tools/clis/supermetrics.jsindex e38e0f1..ec6243c 100755--- a/tools/clis/supermetrics.js+++ b/tools/clis/supermetrics.js@@ -9,6 +9,17 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const url = `${BASE_URL}${path}`const headers = {@@ -19,7 +30,7 @@ async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url, headers: { ...headers, Authorization: 'Bearer ***' }, body: body || undefined }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/tiktok-ads.js b/tools/clis/tiktok-ads.jsindex 9a9ecd1..c43f12f 100755--- a/tools/clis/tiktok-ads.js+++ b/tools/clis/tiktok-ads.js@@ -10,6 +10,17 @@ if ((!TOKEN) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Access-Token': '***', 'Content-Type': 'application/json' }, body: body || undefined }@@ -24,7 +35,7 @@ async function api(method, path, body) {if (body && method === 'POST') {opts.body = JSON.stringify(body)}- const res = await fetch(`${BASE_URL}${path}`, opts)+ const res = await fetch(`${BASE_URL}${path}`, { ...opts, signal: requestSignal() })const text = await res.text()let resulttry {diff --git a/tools/clis/tolt.js b/tools/clis/tolt.jsindex e332ed4..b8381c7 100755--- a/tools/clis/tolt.js+++ b/tools/clis/tolt.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/trustpilot.js b/tools/clis/trustpilot.jsindex a83a0d2..2faa34b 100755--- a/tools/clis/trustpilot.js+++ b/tools/clis/trustpilot.js@@ -14,10 +14,19 @@ if ((!API_KEY) && rawArgs.length > 0) {let accessToken = null+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function getAccessToken() {if (accessToken) return accessTokenif (!API_SECRET) return null- const res = await fetch(`${BASE_URL}/oauth/oauth-business-users-for-applications/accesstoken`, {+ const res = await fetch(`${BASE_URL}/oauth/oauth-business-users-for-applications/accesstoken`, { signal: requestSignal(),method: 'POST',headers: {'Authorization': 'Basic ' + Buffer.from(`${API_KEY}:${API_SECRET}`).toString('base64'),@@ -58,7 +67,7 @@ async function api(method, path, body, auth = 'apikey', baseUrl = BASE_URL) {headers['apikey'] = API_KEY}if (baseUrl === INVITATIONS_URL && args['business-user-id']) headers['x-business-user-id'] = args['business-user-id']- const res = await fetch(`${baseUrl}${path}`, {+ const res = await fetch(`${baseUrl}${path}`, { signal: requestSignal(),method,headers,body: body ? JSON.stringify(body) : undefined,diff --git a/tools/clis/typeform.js b/tools/clis/typeform.jsindex 19149f0..181cbed 100755--- a/tools/clis/typeform.js+++ b/tools/clis/typeform.js@@ -9,11 +9,22 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': `Bearer ${API_KEY}`,diff --git a/tools/clis/wistia.js b/tools/clis/wistia.jsindex 67b1f55..54ab164 100755--- a/tools/clis/wistia.js+++ b/tools/clis/wistia.js@@ -9,12 +9,23 @@ if ((!API_KEY) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function api(method, path, body) {const auth = `Bearer ${API_KEY}`if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': 'Bearer ***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Authorization': auth,diff --git a/tools/clis/zapier.js b/tools/clis/zapier.jsindex 42d60f1..7ef1b04 100755--- a/tools/clis/zapier.js+++ b/tools/clis/zapier.js@@ -4,12 +4,21 @@ const rawArgs = process.argv.slice(2)const API_KEY = process.env.ZAPIER_API_KEYconst BASE_URL = 'https://api.zapier.com/v1'+function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}+async function api(method, path, body) {if (!API_KEY) throw new Error('ZAPIER_API_KEY environment variable required')if (args['dry-run']) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'X-API-Key': '***', 'Content-Type': 'application/json' }, body: body || undefined }}- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'X-API-Key': API_KEY,@@ -29,7 +38,7 @@ async function webhookPost(url, data) {if (args['dry-run']) {return { _dry_run: true, method: 'POST', url, headers: { 'Content-Type': 'application/json' }, body: data || undefined }}- const res = await fetch(url, {+ const res = await fetch(url, { signal: requestSignal(),method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify(data),diff --git a/tools/clis/zoominfo.js b/tools/clis/zoominfo.jsindex 2dc54c9..2d2aa2f 100755--- a/tools/clis/zoominfo.js+++ b/tools/clis/zoominfo.js@@ -10,6 +10,17 @@ if ((!ACCESS_TOKEN && !process.env.ZOOMINFO_USERNAME) && rawArgs.length > 0) {process.exit(1)}++function requestSignal() {+ const raw = args['timeout-ms'] ?? '30000'+ const ms = Number(raw)+ if (typeof raw !== 'string' || !/^\d+$/.test(raw) || !Number.isSafeInteger(ms) || ms < 1 || ms > 600000) {+ throw new Error('--timeout-ms must be an integer from 1 to 600000')+ }+ return AbortSignal.timeout(ms)+}++async function authenticate() {if (ACCESS_TOKEN) return ACCESS_TOKENconst username = process.env.ZOOMINFO_USERNAME@@ -42,7 +53,7 @@ async function authenticate() {if (!password) throw new Error('ZOOMINFO_PASSWORD or ZOOMINFO_PRIVATE_KEY + ZOOMINFO_CLIENT_ID required for authentication')body = JSON.stringify({ username, password })}- const res = await fetch(`${BASE_URL}/authenticate`, {+ const res = await fetch(`${BASE_URL}/authenticate`, { signal: requestSignal(),method: 'POST',headers,body,@@ -67,7 +78,7 @@ async function api(method, path, body) {return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ***' }, body }}const token = await authenticate()- const res = await fetch(`${BASE_URL}${path}`, {+ const res = await fetch(`${BASE_URL}${path}`, { signal: requestSignal(),method,headers: {'Content-Type': 'application/json',