@dimension-studios/ttk-proxy 1.81.2 → 1.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -1
- package/dist/index.mjs +2 -2
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
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
|
|
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
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
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
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{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimension-studios/ttk-proxy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.82.0",
|
|
4
4
|
"description": "CLI tool for TikTok proxy API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tiktok",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"build": "tsdown && chmod +x bin/cli.js",
|
|
37
37
|
"clean": "rm -rf dist",
|
|
38
38
|
"dev": "tsdown --watch",
|
|
39
|
-
"type-check": "
|
|
39
|
+
"type-check": "tsgo --noEmit",
|
|
40
40
|
"debug": "dotenv -- tsx debug/index.ts",
|
|
41
41
|
"prepublishOnly": "npm run build"
|
|
42
42
|
},
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"commander": "^14.0.0",
|
|
46
46
|
"conf": "^15.0.0",
|
|
47
47
|
"dotenv": "17.2.3",
|
|
48
|
-
"tsdown": "0.
|
|
48
|
+
"tsdown": "0.20.3",
|
|
49
49
|
"undici": "^7.2.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "24.10.9",
|
|
53
53
|
"dotenv-cli": "11.0.0",
|
|
54
54
|
"tsx": "4.21.0",
|
|
55
|
-
"typescript": "
|
|
55
|
+
"@typescript/native-preview": "7.0.0-dev.20260210.1"
|
|
56
56
|
}
|
|
57
57
|
}
|