@dimension-studios/ttk-proxy 1.57.2 → 1.58.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/dist/index.mjs +2 -2
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{logger as e}from"@rharkor/logger";import{program as t}from"commander";import"dotenv/config";import n from"conf";import{fetch as r}from"undici";const i=new n({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=>{try{return JSON.parse(e)}catch{let t=`"${e}"`;return JSON.parse(JSON.parse(t))}};async function l(t){let n=a();try{let
|
|
3
|
-
📋 Curl command:`),console.log(e.curl),console.log(``)}let
|
|
2
|
+
import{logger as e}from"@rharkor/logger";import{program as t}from"commander";import"dotenv/config";import n from"conf";import{fetch as r}from"undici";const i=new n({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=>{try{return JSON.parse(e)}catch{let t=`"${e}"`;return JSON.parse(JSON.parse(t))}};async function l(t){let n=a();try{let i=c(t),a=await r(`${n.apiUrl}/ttk-proxy/get-curl`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":n.apiKey,"X-Api-Secret":n.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 r(`${n.apiUrl}/ttk-proxy`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":n.apiKey,"X-Api-Secret":n.apiSecret},body:JSON.stringify(i),signal:AbortSignal.timeout(1e4)}),s=await o.text(),l;try{l=JSON.parse(s)}catch{l=s}return{status:o.status,statusText:o.statusText,body:l}}catch(t){throw e.error(`Failed to call TikTok proxy API`,t),t}}async function u(){let t=a();try{e.debug(`Listing TikTok proxy tokens`,{url:t.apiUrl});let n=await r(`${t.apiUrl}/ttk-proxy/list`,{method:`GET`,headers:{"X-Api-Key":t.apiKey,"X-Api-Secret":t.apiSecret},signal:AbortSignal.timeout(1e4)});if(!n.ok){let e=await n.text();throw Error(`HTTP ${n.status}: ${e}`)}return await n.json()}catch(t){throw e.error(`Failed to list TikTok proxy tokens`,t),t}}async function d(t){try{let n=a();e.info(`🚀 Calling TikTok Proxy API at ${n.apiUrl}...`);let r=await l(t);e.success(`✅ Status: ${r.status} ${r.statusText}`),e.info(`
|
|
4
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 f(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 p(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 m(){try{e.info(`🔍 Listing TikTok Proxy tokens...`);let t=await u();if(t.length===0){e.warn(`⚠️ No tokens found`);return}e.success(`✅ Found ${t.length} token(s)`),e.info(`
|
|
5
5
|
📋 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`).argument(`<body>`,`Stringified JSON body for the request`).action(async e=>{await d(e)}),t.command(`list`).description(`List all TikTok Proxy tokens`).action(async()=>{await m()}),t.command(`config`).description(`Manage configuration`).option(`-s, --show`,`Show current configuration`).option(`-c, --clear`,`Clear all configuration`).action(e=>{f(e)}),t.command(`config:set`).description(`Set a configuration value`).argument(`<key>`,`Configuration key (apiUrl, apiKey, apiSecret)`).argument(`<value>`,`Configuration value`).action((e,t)=>{p(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.
|
|
3
|
+
"version": "1.58.1",
|
|
4
4
|
"description": "CLI tool for TikTok proxy API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tiktok",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"commander": "^14.0.0",
|
|
46
46
|
"conf": "^15.0.0",
|
|
47
47
|
"dotenv": "17.2.3",
|
|
48
|
-
"tsdown": "0.
|
|
48
|
+
"tsdown": "0.17.0",
|
|
49
49
|
"undici": "^7.2.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|