@dimension-studios/ttk-proxy 1.202.0 → 1.203.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 +4 -5
- package/dist/index.mjs +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -181,20 +181,20 @@ Set a configuration value.
|
|
|
181
181
|
bun install
|
|
182
182
|
|
|
183
183
|
# Build the package
|
|
184
|
-
bun run --cwd
|
|
184
|
+
bun run --cwd tools/ttk-proxy build
|
|
185
185
|
|
|
186
186
|
# Run type checking
|
|
187
|
-
bun run --cwd
|
|
187
|
+
bun run --cwd tools/ttk-proxy type-check
|
|
188
188
|
|
|
189
189
|
# Development mode (watch)
|
|
190
|
-
bun run --cwd
|
|
190
|
+
bun run --cwd tools/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
|
|
197
|
+
node tools/ttk-proxy/bin/cli.js --help
|
|
198
198
|
```
|
|
199
199
|
|
|
200
200
|
## License
|
|
@@ -208,4 +208,3 @@ Dimension Studios
|
|
|
208
208
|
## Support
|
|
209
209
|
|
|
210
210
|
For issues and questions, please open an issue on the GitHub repository.
|
|
211
|
-
|
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";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(`
|
|
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 await 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
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
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
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(`
|
package/package.json
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimension-studios/ttk-proxy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.203.0",
|
|
4
4
|
"description": "CLI tool for TikTok proxy API",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"proxy",
|
|
6
|
+
"api",
|
|
8
7
|
"cli",
|
|
9
|
-
"
|
|
8
|
+
"proxy",
|
|
9
|
+
"tiktok"
|
|
10
10
|
],
|
|
11
|
-
"author": "Dimension Studios",
|
|
12
11
|
"license": "ISC",
|
|
12
|
+
"author": "Dimension Studios",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/dimension-studios-inc/dimension.git",
|
|
16
|
-
"directory": "
|
|
17
|
-
},
|
|
18
|
-
"publishConfig": {
|
|
19
|
-
"access": "public"
|
|
16
|
+
"directory": "tools/ttk-proxy"
|
|
20
17
|
},
|
|
21
|
-
"type": "module",
|
|
22
18
|
"bin": {
|
|
23
19
|
"ttk-proxy": "bin/cli.js"
|
|
24
20
|
},
|
|
@@ -26,17 +22,21 @@
|
|
|
26
22
|
"dist",
|
|
27
23
|
"bin"
|
|
28
24
|
],
|
|
25
|
+
"type": "module",
|
|
29
26
|
"exports": {
|
|
30
27
|
".": {
|
|
31
28
|
"types": "./dist/index.d.mts",
|
|
32
29
|
"import": "./dist/index.mjs"
|
|
33
30
|
}
|
|
34
31
|
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
35
|
"scripts": {
|
|
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": "bun check",
|
|
40
40
|
"debug": "bun debug/index.ts",
|
|
41
41
|
"prepublishOnly": "bun run build"
|
|
42
42
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "24.13.6",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
51
|
+
"tsdown": "0.23.0",
|
|
52
|
+
"typescript": "7.0.2"
|
|
53
53
|
}
|
|
54
54
|
}
|