@dimension-studios/ttk-proxy 1.69.3 → 1.70.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/README.md +15 -1
- package/dist/index.mjs +5 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -75,6 +75,20 @@ ttk-proxy call '{
|
|
|
75
75
|
}'
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
#### Base64 Support
|
|
79
|
+
|
|
80
|
+
You can also pass the JSON body as a base64-encoded string. The CLI will automatically detect and decode it:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# First encode your JSON to base64
|
|
84
|
+
echo -n '{"shopId":"shop-123","url":"https://api.tiktok.com/endpoint","method":"GET"}' | base64
|
|
85
|
+
|
|
86
|
+
# Then pass it directly to the CLI
|
|
87
|
+
ttk-proxy call "eyJzaG9wSWQiOiJzaG9wLTEyMyIsInVybCI6Imh0dHBzOi8vYXBpLnRpa3Rvay5jb20vZW5kcG9pbnQiLCJtZXRob2QiOiJHRVQifQ=="
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
This is useful when copying request bodies from logs or other sources where the JSON is already base64-encoded.
|
|
91
|
+
|
|
78
92
|
### List TikTok Proxy Tokens
|
|
79
93
|
|
|
80
94
|
List all available TikTok proxy tokens:
|
|
@@ -117,7 +131,7 @@ Example output:
|
|
|
117
131
|
Call the TikTok proxy API with a JSON body.
|
|
118
132
|
|
|
119
133
|
- **Arguments:**
|
|
120
|
-
- `body` (string): Stringified JSON body for the request
|
|
134
|
+
- `body` (string): Stringified JSON body for the request (can be raw JSON or base64-encoded JSON)
|
|
121
135
|
|
|
122
136
|
#### `ttk-proxy list`
|
|
123
137
|
|
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 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
|
|
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(),
|
|
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
|
|
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
|
|
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`).argument(`<body>`,`Stringified JSON body for the request`).action(async e=>{await
|
|
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=>!(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 n=a();try{let e=await r(`${n.apiUrl}/ttk-proxy/get-cookies`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":n.apiKey,"X-Api-Secret":n.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 n=a();try{let i=u(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(),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 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 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{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimension-studios/ttk-proxy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.70.0",
|
|
4
4
|
"description": "CLI tool for TikTok proxy API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tiktok",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"clean": "rm -rf dist",
|
|
38
38
|
"dev": "tsdown --watch",
|
|
39
39
|
"type-check": "tsc --noEmit",
|
|
40
|
-
"debug": "dotenv -- tsx
|
|
40
|
+
"debug": "dotenv -- tsx debug/index.ts",
|
|
41
41
|
"prepublishOnly": "npm run build"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"commander": "^14.0.0",
|
|
46
46
|
"conf": "^15.0.0",
|
|
47
47
|
"dotenv": "17.2.3",
|
|
48
|
-
"tsdown": "0.
|
|
48
|
+
"tsdown": "0.19.0",
|
|
49
49
|
"undici": "^7.2.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/node": "24.10.
|
|
52
|
+
"@types/node": "24.10.8",
|
|
53
53
|
"dotenv-cli": "11.0.0",
|
|
54
54
|
"tsx": "4.21.0",
|
|
55
55
|
"typescript": "5.9.3"
|