@dimension-studios/ttk-proxy 1.125.0 → 1.125.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,6 +50,22 @@ ttk-proxy config --clear
50
50
 
51
51
  ## Usage
52
52
 
53
+ ### List TikTok Proxy Tokens
54
+
55
+ List all available TikTok proxy tokens:
56
+
57
+ ```bash
58
+ ttk-proxy list
59
+ ```
60
+
61
+ ### Search shops (by name or slug)
62
+
63
+ Search shops your API token can access (requires `GET /ttk-proxy/shops/search` on the Node API):
64
+
65
+ ```bash
66
+ ttk-proxy shops coffee
67
+ ```
68
+
53
69
  ### Call the TikTok Proxy API
54
70
 
55
71
  Make a call to the TikTok proxy API with a JSON body:
@@ -89,14 +105,6 @@ ttk-proxy call "eyJzaG9wSWQiOiJzaG9wLTEyMyIsInVybCI6Imh0dHBzOi8vYXBpLnRpa3Rvay5j
89
105
 
90
106
  This is useful when copying request bodies from logs or other sources where the JSON is already base64-encoded.
91
107
 
92
- ### List TikTok Proxy Tokens
93
-
94
- List all available TikTok proxy tokens:
95
-
96
- ```bash
97
- ttk-proxy list
98
- ```
99
-
100
108
  ## Output
101
109
 
102
110
  The CLI provides beautiful, color-coded output using `@rharkor/logger`:
@@ -137,7 +145,13 @@ Call the TikTok proxy API with a JSON body.
137
145
 
138
146
  List all TikTok proxy tokens.
139
147
 
140
- #### `ttk-proxy config [options]`
148
+ #### `ttk-proxy shops <query>`
149
+
150
+ Search shops authorized for your API token (`GET /ttk-proxy/shops/search` on your Node API). Use at least 2 characters in `query`.
151
+
152
+ #### `ttk-proxy get-cookies`
153
+
154
+ Fetch cookies JSON for the given shop ID (calls `POST /ttk-proxy/get-cookies`).
141
155
 
142
156
  Manage configuration.
143
157
 
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import{logger as e}from"@rharkor/logger";import{program as t}from"commander";import"dotenv/config";import{fetch as n}from"undici";import r from"conf";const i=new r({projectName:`ttk-proxy`});function a(){let e=i.get(`apiUrl`),t=i.get(`apiKey`),n=i.get(`apiSecret`);if(!e||!t||!n)throw Error(`Missing configuration. Please set apiUrl, apiKey, and apiSecret using environment variables or the config command.`);return{apiUrl:e,apiKey:t,apiSecret:n}}function o(e){e.apiUrl&&i.set(`apiUrl`,e.apiUrl),e.apiKey&&i.set(`apiKey`,e.apiKey),e.apiSecret&&i.set(`apiSecret`,e.apiSecret)}function s(){let e=process.env.TTK_FETCH_API_URL,t=process.env.TTK_FETCH_API_KEY,n=process.env.TTK_FETCH_API_SECRET;e&&i.set(`apiUrl`,e),t&&i.set(`apiKey`,t),n&&i.set(`apiSecret`,n)}const c=e=>!(e.length<4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e)||e.startsWith(`{`)||e.startsWith(`[`)),l=e=>{try{let t=Buffer.from(e,`base64`).toString(`utf-8`);return JSON.parse(t)}catch{return null}},u=t=>{if(c(t)){let n=l(t);if(n!==null)return e.debug(`🔓 Detected and decoded base64 input`),n}try{return JSON.parse(t)}catch{let e=`"${t}"`;return JSON.parse(JSON.parse(e))}};async function d(t){let r=a();try{let e=await n(`${r.apiUrl}/ttk-proxy/get-cookies`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":r.apiKey,"X-Api-Secret":r.apiSecret},body:JSON.stringify({shopId:t}),signal:AbortSignal.timeout(1e4)});if(!e.ok)throw Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}catch(t){throw e.error(`Failed to get cookies`,t),t}}async function f(t){let r=a();try{let i=u(t),a=await n(`${r.apiUrl}/ttk-proxy/get-curl`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":r.apiKey,"X-Api-Secret":r.apiSecret},body:JSON.stringify(i),signal:AbortSignal.timeout(1e4)});if(a.ok){let e=await a.json();console.log(`
3
- 📋 Curl command:`),console.log(e.curl),console.log(``)}else a.status===403&&e.warn(`⚠️ Curl command not available (requires all shops access)`);let o=await n(`${r.apiUrl}/ttk-proxy`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":r.apiKey,"X-Api-Secret":r.apiSecret},body:JSON.stringify(i),signal:AbortSignal.timeout(1e4)}),s=await o.text(),c;try{c=JSON.parse(s)}catch{c=s}return{status:o.status,statusText:o.statusText,body:c}}catch(t){throw e.error(`Failed to call TikTok proxy API`,t),t}}async function p(){let t=a();try{e.debug(`Listing TikTok proxy tokens`,{url:t.apiUrl});let r=await n(`${t.apiUrl}/ttk-proxy/list`,{method:`GET`,headers:{"X-Api-Key":t.apiKey,"X-Api-Secret":t.apiSecret},signal:AbortSignal.timeout(1e4)});if(!r.ok){let e=await r.text();throw Error(`HTTP ${r.status}: ${e}`)}return await r.json()}catch(t){throw e.error(`Failed to list TikTok proxy tokens`,t),t}}async function m(t){try{let n=a();e.info(`🚀 Calling TikTok Proxy API at ${n.apiUrl}...`);let r=await f(t);e.success(`✅ Status: ${r.status} ${r.statusText}`),e.info(`
4
- 📦 Response:`),console.log(JSON.stringify(r.body,null,2))}catch(t){e.error(`❌ Failed to call TikTok Proxy API`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}function h(t){try{if(t.clear){i.clear(),e.success(`✅ Configuration cleared`);return}if(t.show){let t=i.store;e.info(`📋 Current configuration:`),console.log(JSON.stringify(t,null,2));return}s();let n=i.get(`apiUrl`),r=i.get(`apiKey`),a=i.get(`apiSecret`);(!n||!r||!a)&&(e.error(`❌ Missing configuration`),e.info(`Please set the following environment variables:`),e.info(` - TTK_FETCH_API_URL`),e.info(` - TTK_FETCH_API_KEY`),e.info(` - TTK_FETCH_API_SECRET`),e.info(`Or manually set them using:`),e.info(` config:set apiUrl 'your-url'`),e.info(` config:set apiKey 'your-key'`),e.info(` config:set apiSecret 'your-secret'`),process.exit(1)),e.success(`✅ Configuration loaded successfully`),e.info(`📋 Current configuration:`),e.info(` API URL: ${n}`),e.info(` API Key: ${r}`),e.info(` API Secret: ${o(a)}`);function o(e){return!e||e.length<8?`*`.repeat(e.length):`${e.slice(0,4)}${`*`.repeat(e.length-8)}${e.slice(-4)}`}}catch(t){e.error(`❌ Failed to manage configuration`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}function g(t,n){try{[`apiUrl`,`apiKey`,`apiSecret`].includes(t)||(e.error(`❌ Invalid config key: ${t}`),e.info(`Valid keys: apiUrl, apiKey, apiSecret`),process.exit(1)),o({[t]:n}),e.success(`✅ Set ${t} successfully`)}catch(t){e.error(`❌ Failed to set configuration`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}async function _(t){try{e.info(`🔍 Listing TikTok Proxy tokens...`);let{cookies:n}=await d(t);if(n.length===0){e.warn(`⚠️ No tokens found`);return}e.success(`✅ Found ${n.length} cookie(s)`),e.info(`
5
- 📋 Cookies:`),console.log(JSON.stringify(n,null,2))}catch(t){e.error(`❌ Failed to list TikTok Proxy tokens`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}async function v(){try{e.info(`🔍 Listing TikTok Proxy tokens...`);let t=await p();if(t.length===0){e.warn(`⚠️ No tokens found`);return}e.success(`✅ Found ${t.length} token(s)`),e.info(`
6
- 📋 Tokens:`),console.log(JSON.stringify(t,null,2))}catch(t){e.error(`❌ Failed to list TikTok Proxy tokens`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}await e.init(),s(),t.name(`ttk-proxy`).description(`CLI tool for TikTok Proxy API`).version(`1.0.0`),t.command(`call`).description(`Call the TikTok Proxy API with a JSON body (supports base64-encoded input)`).argument(`<body>`,`Stringified JSON body for the request (raw JSON or base64-encoded)`).action(async e=>{await m(e)}),t.command(`list`).description(`List all TikTok Proxy tokens`).action(async()=>{await v()}),t.command(`get-cookies`).description(`Get cookies for a given shop ID`).argument(`<shopId>`,`Shop ID`).action(async e=>{await _(e)}),t.command(`config`).description(`Manage configuration`).option(`-s, --show`,`Show current configuration`).option(`-c, --clear`,`Clear all configuration`).action(e=>{h(e)}),t.command(`config:set`).description(`Set a configuration value`).argument(`<key>`,`Configuration key (apiUrl, apiKey, apiSecret)`).argument(`<value>`,`Configuration value`).action((e,t)=>{g(e,t)}),t.parse();export{};
2
+ import{logger as e}from"@rharkor/logger";import{program as t}from"commander";import"dotenv/config";import{fetch as n}from"undici";import r from"conf";const i=new r({projectName:`ttk-proxy`});function a(){let e=i.get(`apiUrl`),t=i.get(`apiKey`),n=i.get(`apiSecret`);if(!e||!t||!n)throw Error(`Missing configuration. Please set apiUrl, apiKey, and apiSecret using environment variables or the config command.`);return{apiUrl:e,apiKey:t,apiSecret:n}}function o(e){e.apiUrl&&i.set(`apiUrl`,e.apiUrl),e.apiKey&&i.set(`apiKey`,e.apiKey),e.apiSecret&&i.set(`apiSecret`,e.apiSecret)}function s(){let e=process.env.TTK_FETCH_API_URL,t=process.env.TTK_FETCH_API_KEY,n=process.env.TTK_FETCH_API_SECRET;e&&i.set(`apiUrl`,e),t&&i.set(`apiKey`,t),n&&i.set(`apiSecret`,n)}const c=e=>!(e.length<4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e)||e.startsWith(`{`)||e.startsWith(`[`)),l=e=>{try{let t=Buffer.from(e,`base64`).toString(`utf-8`);return JSON.parse(t)}catch{return null}},u=t=>{if(c(t)){let n=l(t);if(n!==null)return e.debug(`🔓 Detected and decoded base64 input`),n}try{return JSON.parse(t)}catch{let e=`"${t}"`;return JSON.parse(JSON.parse(e))}};async function d(t){let r=a();try{let e=await n(`${r.apiUrl}/ttk-proxy/get-cookies`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":r.apiKey,"X-Api-Secret":r.apiSecret},body:JSON.stringify({shopId:t}),signal:AbortSignal.timeout(1e4)});if(!e.ok)throw Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}catch(t){throw e.error(`Failed to get cookies`,t),t}}async function f(t){let r=a();try{let e=new URLSearchParams({q:t.trim()}),i=await n(`${r.apiUrl}/ttk-proxy/shops/search?${e}`,{method:`GET`,headers:{"X-Api-Key":r.apiKey,"X-Api-Secret":r.apiSecret},signal:AbortSignal.timeout(1e4)});if(!i.ok){let e=await i.text();throw Error(`HTTP ${i.status}: ${e||i.statusText}`)}return(await i.json()).shops}catch(t){throw e.error(`Failed to search shops`,t),t}}async function p(t){let r=a();try{let i=u(t),a=await n(`${r.apiUrl}/ttk-proxy/get-curl`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":r.apiKey,"X-Api-Secret":r.apiSecret},body:JSON.stringify(i),signal:AbortSignal.timeout(1e4)});if(a.ok){let e=await a.json();console.log(`
3
+ 📋 Curl command:`),console.log(e.curl),console.log(``)}else a.status===403&&e.warn(`⚠️ Curl command not available (requires all shops access)`);let o=await n(`${r.apiUrl}/ttk-proxy`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":r.apiKey,"X-Api-Secret":r.apiSecret},body:JSON.stringify(i),signal:AbortSignal.timeout(1e4)}),s=await o.text(),c;try{c=JSON.parse(s)}catch{c=s}return{status:o.status,statusText:o.statusText,body:c}}catch(t){throw e.error(`Failed to call TikTok proxy API`,t),t}}async function m(){let t=a();try{e.debug(`Listing TikTok proxy tokens`,{url:t.apiUrl});let r=await n(`${t.apiUrl}/ttk-proxy/list`,{method:`GET`,headers:{"X-Api-Key":t.apiKey,"X-Api-Secret":t.apiSecret},signal:AbortSignal.timeout(1e4)});if(!r.ok){let e=await r.text();throw Error(`HTTP ${r.status}: ${e}`)}return await r.json()}catch(t){throw e.error(`Failed to list TikTok proxy tokens`,t),t}}async function h(t){try{let n=a();e.info(`🚀 Calling TikTok Proxy API at ${n.apiUrl}...`);let r=await p(t);e.success(`✅ Status: ${r.status} ${r.statusText}`),e.info(`
4
+ 📦 Response:`),console.log(JSON.stringify(r.body,null,2))}catch(t){e.error(`❌ Failed to call TikTok Proxy API`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}function g(t){try{if(t.clear){i.clear(),e.success(`✅ Configuration cleared`);return}if(t.show){let t=i.store;e.info(`📋 Current configuration:`),console.log(JSON.stringify(t,null,2));return}s();let n=i.get(`apiUrl`),r=i.get(`apiKey`),a=i.get(`apiSecret`);(!n||!r||!a)&&(e.error(`❌ Missing configuration`),e.info(`Please set the following environment variables:`),e.info(` - TTK_FETCH_API_URL`),e.info(` - TTK_FETCH_API_KEY`),e.info(` - TTK_FETCH_API_SECRET`),e.info(`Or manually set them using:`),e.info(` config:set apiUrl 'your-url'`),e.info(` config:set apiKey 'your-key'`),e.info(` config:set apiSecret 'your-secret'`),process.exit(1)),e.success(`✅ Configuration loaded successfully`),e.info(`📋 Current configuration:`),e.info(` API URL: ${n}`),e.info(` API Key: ${r}`),e.info(` API Secret: ${o(a)}`);function o(e){return!e||e.length<8?`*`.repeat(e.length):`${e.slice(0,4)}${`*`.repeat(e.length-8)}${e.slice(-4)}`}}catch(t){e.error(`❌ Failed to manage configuration`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}function _(t,n){try{[`apiUrl`,`apiKey`,`apiSecret`].includes(t)||(e.error(`❌ Invalid config key: ${t}`),e.info(`Valid keys: apiUrl, apiKey, apiSecret`),process.exit(1)),o({[t]:n}),e.success(`✅ Set ${t} successfully`)}catch(t){e.error(`❌ Failed to set configuration`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}async function v(t){try{e.info(`🔍 Listing TikTok Proxy tokens...`);let{cookies:n}=await d(t);if(n.length===0){e.warn(`⚠️ No tokens found`);return}e.success(`✅ Found ${n.length} cookie(s)`),e.info(`
5
+ 📋 Cookies:`),console.log(JSON.stringify(n,null,2))}catch(t){e.error(`❌ Failed to list TikTok Proxy tokens`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}async function y(){try{e.info(`🔍 Listing TikTok Proxy tokens...`);let t=await m();if(t.length===0){e.warn(`⚠️ No tokens found`);return}e.success(`✅ Found ${t.length} token(s)`),e.info(`
6
+ 📋 Tokens:`),console.log(JSON.stringify(t,null,2))}catch(t){e.error(`❌ Failed to list TikTok Proxy tokens`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}async function b(t){try{let n=t.trim();n.length<2&&(e.warn(`⚠️ Enter at least 2 characters to search`),process.exit(1)),e.info(`🔍 Searching shops for "${n}"...`);let r=await f(n);if(r.length===0){e.warn(`⚠️ No shops found`);return}e.success(`✅ Found ${r.length} shop(s)`),e.info(`
7
+ 📋 Shops:`),console.log(JSON.stringify(r,null,2))}catch(t){e.error(`❌ Failed to search shops`),t instanceof Error?e.error(t.message):e.error(String(t)),process.exit(1)}}await e.init(),s(),t.name(`ttk-proxy`).description(`CLI tool for TikTok Proxy API`).version(`1.0.0`),t.command(`call`).description(`Call the TikTok Proxy API with a JSON body (supports base64-encoded input)`).argument(`<body>`,`Stringified JSON body for the request (raw JSON or base64-encoded)`).action(async e=>{await h(e)}),t.command(`list`).description(`List all TikTok Proxy tokens`).action(async()=>{await y()}),t.command(`get-cookies`).description(`Get cookies for a given shop ID`).argument(`<shopId>`,`Shop ID`).action(async e=>{await v(e)}),t.command(`shops`).description(`Search shops visible to your API token by name or slug`).argument(`<query>`,`Search string (minimum 2 characters)`).action(async e=>{await b(e)}),t.command(`config`).description(`Manage configuration`).option(`-s, --show`,`Show current configuration`).option(`-c, --clear`,`Clear all configuration`).action(e=>{g(e)}),t.command(`config:set`).description(`Set a configuration value`).argument(`<key>`,`Configuration key (apiUrl, apiKey, apiSecret)`).argument(`<value>`,`Configuration value`).action((e,t)=>{_(e,t)}),t.parse();export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimension-studios/ttk-proxy",
3
- "version": "1.125.0",
3
+ "version": "1.125.1",
4
4
  "description": "CLI tool for TikTok proxy API",
5
5
  "keywords": [
6
6
  "tiktok",
@@ -46,12 +46,12 @@
46
46
  "conf": "15.1.0",
47
47
  "dotenv": "17.4.2",
48
48
  "tsdown": "0.21.7",
49
- "undici": "8.0.3"
49
+ "undici": "8.1.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/node": "24.12.2",
53
53
  "dotenv-cli": "11.0.0",
54
54
  "tsx": "4.21.0",
55
- "@typescript/native-preview": "7.0.0-dev.20260414.1"
55
+ "@typescript/native-preview": "7.0.0-dev.20260415.1"
56
56
  }
57
57
  }