@dimension-studios/ttk-proxy 1.200.0 → 1.202.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 +5 -5
- package/dist/index.mjs +6 -6
- package/package.json +8 -11
package/README.md
CHANGED
|
@@ -178,23 +178,23 @@ Set a configuration value.
|
|
|
178
178
|
|
|
179
179
|
```bash
|
|
180
180
|
# Install dependencies (repo root)
|
|
181
|
-
|
|
181
|
+
bun install
|
|
182
182
|
|
|
183
183
|
# Build the package
|
|
184
|
-
|
|
184
|
+
bun run --cwd packages/ttk-proxy build
|
|
185
185
|
|
|
186
186
|
# Run type checking
|
|
187
|
-
|
|
187
|
+
bun run --cwd packages/ttk-proxy type-check
|
|
188
188
|
|
|
189
189
|
# Development mode (watch)
|
|
190
|
-
|
|
190
|
+
bun run --cwd packages/ttk-proxy dev
|
|
191
191
|
```
|
|
192
192
|
|
|
193
193
|
### Testing Locally
|
|
194
194
|
|
|
195
195
|
```bash
|
|
196
196
|
# After building, run the CLI from the repo root
|
|
197
|
-
node packages/ttk-proxy
|
|
197
|
+
node packages/ttk-proxy/bin/cli.js --help
|
|
198
198
|
```
|
|
199
199
|
|
|
200
200
|
## License
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +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
|
|
3
|
-
📋 Curl command:`),console.log(e.curl),console.log(``)}else
|
|
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(r,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)}}async function
|
|
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(),
|
|
2
|
+
import{logger as e}from"@rharkor/logger";import{program as t}from"commander";import"dotenv/config";import n from"conf";const r=new n({projectName:`ttk-proxy`});function i(){let e=r.get(`apiUrl`),t=r.get(`apiKey`),n=r.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 a(e){e.apiUrl&&r.set(`apiUrl`,e.apiUrl),e.apiKey&&r.set(`apiKey`,e.apiKey),e.apiSecret&&r.set(`apiSecret`,e.apiSecret)}function o(){let e=process.env.TTK_FETCH_API_URL,t=process.env.TTK_FETCH_API_KEY,n=process.env.TTK_FETCH_API_SECRET;e&&r.set(`apiUrl`,e),t&&r.set(`apiKey`,t),n&&r.set(`apiSecret`,n)}const s=e=>!(e.length<4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e)||e.startsWith(`{`)||e.startsWith(`[`)),c=e=>{try{let t=Buffer.from(e,`base64`).toString(`utf-8`);return JSON.parse(t)}catch{return null}},l=t=>{if(s(t)){let n=c(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 u(t,{allowInvalid:n=!1}={}){let r=i();try{let e=await fetch(`${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,allowInvalid:n}),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 d(t){let n=i();try{let e=new URLSearchParams({q:t.trim()}),r=await fetch(`${n.apiUrl}/ttk-proxy/shops/search?${e}`,{method:`GET`,headers:{"X-Api-Key":n.apiKey,"X-Api-Secret":n.apiSecret},signal:AbortSignal.timeout(1e4)});if(!r.ok){let e=await r.text();throw Error(`HTTP ${r.status}: ${e||r.statusText}`)}return(await r.json()).shops}catch(t){throw e.error(`Failed to search shops`,t),t}}async function f(t){let n=i();try{let r=l(t),i=await fetch(`${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(r),signal:AbortSignal.timeout(1e4)});if(i.ok){let e=await i.json();console.log(`
|
|
3
|
+
📋 Curl command:`),console.log(e.curl),console.log(``)}else i.status===403&&e.warn(`⚠️ Curl command not available (requires all shops access)`);let a=await fetch(`${n.apiUrl}/ttk-proxy`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Api-Key":n.apiKey,"X-Api-Secret":n.apiSecret},body:JSON.stringify(r),signal:AbortSignal.timeout(1e4)}),o=await a.text(),s;try{s=JSON.parse(o)}catch{s=o}return{status:a.status,statusText:a.statusText,body:s}}catch(t){throw e.error(`Failed to call TikTok proxy API`,t),t}}async function p(){let t=i();try{e.debug(`Listing TikTok proxy tokens`,{url:t.apiUrl});let n=await fetch(`${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=i();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){r.clear(),e.success(`✅ Configuration cleared`);return}if(t.show){let t=r.store;e.info(`📋 Current configuration:`),console.log(JSON.stringify(t,null,2));return}o();let n=r.get(`apiUrl`),i=r.get(`apiKey`),a=r.get(`apiSecret`);(!n||!i||!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: ${i}`),e.info(` API Secret: ${s(a)}`);function s(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)),a({[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,n){try{e.info(`🔍 Listing TikTok Proxy tokens...`);let{cookies:r}=await u(t,n);if(r.length===0){e.warn(`⚠️ No tokens found`);return}e.success(`✅ Found ${r.length} cookie(s)`),e.info(`
|
|
5
|
+
📋 Cookies:`),console.log(JSON.stringify(r,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)}}async function y(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 d(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(),o(),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`).option(`-i, --allow-invalid`,`Return the stored cookie even if no slot is marked valid`).action(async(e,t)=>{await _(e,t)}),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 y(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.202.0",
|
|
4
4
|
"description": "CLI tool for TikTok proxy API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tiktok",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/dimension-studios-inc/dimension.git",
|
|
16
|
-
"directory": "packages/ttk-proxy
|
|
16
|
+
"directory": "packages/ttk-proxy"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
@@ -37,21 +37,18 @@
|
|
|
37
37
|
"clean": "rm -rf dist",
|
|
38
38
|
"dev": "tsdown --watch",
|
|
39
39
|
"type-check": "tsc --noEmit",
|
|
40
|
-
"debug": "
|
|
41
|
-
"prepublishOnly": "
|
|
40
|
+
"debug": "bun debug/index.ts",
|
|
41
|
+
"prepublishOnly": "bun run build"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@rharkor/logger": "1.3.3",
|
|
45
45
|
"commander": "15.0.0",
|
|
46
46
|
"conf": "15.1.0",
|
|
47
|
-
"dotenv": "17.4.2"
|
|
48
|
-
"undici": "8.10.2"
|
|
47
|
+
"dotenv": "17.4.2"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@types/node": "
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"typescript": "catalog:",
|
|
55
|
-
"tsdown": "catalog:"
|
|
50
|
+
"@types/node": "24.13.6",
|
|
51
|
+
"typescript": "7.0.2",
|
|
52
|
+
"tsdown": "0.23.0"
|
|
56
53
|
}
|
|
57
54
|
}
|