@dimension-studios/ttk-proxy 1.28.0-preprod-release.60

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 ADDED
@@ -0,0 +1,181 @@
1
+ # @dimension-studios/ttk-proxy
2
+
3
+ CLI tool for TikTok Proxy API - A simple command-line interface to interact with the TikTok proxy service.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @dimension-studios/ttk-proxy
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ The CLI uses `conf` to store your API credentials. You can configure it in two ways:
14
+
15
+ ### 1. Using Environment Variables (Recommended)
16
+
17
+ Set the following environment variables:
18
+
19
+ ```bash
20
+ export TTK_FETCH_API_URL="https://your-api-url.com"
21
+ export TTK_FETCH_API_KEY="your-api-key"
22
+ export TTK_FETCH_API_SECRET="your-api-secret"
23
+ ```
24
+
25
+ Then run the config command to save them:
26
+
27
+ ```bash
28
+ ttk-proxy config
29
+ ```
30
+
31
+ ### 2. Using the CLI
32
+
33
+ ```bash
34
+ ttk-proxy config:set apiUrl "https://your-api-url.com"
35
+ ttk-proxy config:set apiKey "your-api-key"
36
+ ttk-proxy config:set apiSecret "your-api-secret"
37
+ ```
38
+
39
+ ### View Current Configuration
40
+
41
+ ```bash
42
+ ttk-proxy config --show
43
+ ```
44
+
45
+ ### Clear Configuration
46
+
47
+ ```bash
48
+ ttk-proxy config --clear
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ ### Call the TikTok Proxy API
54
+
55
+ Make a call to the TikTok proxy API with a JSON body:
56
+
57
+ ```bash
58
+ ttk-proxy call '{"shopId":"your-shop-id","url":"https://api.tiktok.com/endpoint","method":"GET"}'
59
+ ```
60
+
61
+ Example with more complex body:
62
+
63
+ ```bash
64
+ ttk-proxy call '{
65
+ "shopId": "shop-123",
66
+ "url": "https://api.tiktok.com/v1/shops/products",
67
+ "method": "GET",
68
+ "headers": {
69
+ "Content-Type": "application/json"
70
+ },
71
+ "unofficialApi": {
72
+ "addCookieToHeaders": true,
73
+ "signUrl": true
74
+ }
75
+ }'
76
+ ```
77
+
78
+ ### List TikTok Proxy Tokens
79
+
80
+ List all available TikTok proxy tokens:
81
+
82
+ ```bash
83
+ ttk-proxy list
84
+ ```
85
+
86
+ ## Output
87
+
88
+ The CLI provides beautiful, color-coded output using `@rharkor/logger`:
89
+
90
+ - ✅ Success messages in green
91
+ - ❌ Error messages in red
92
+ - ℹ️ Info messages in blue
93
+ - ⚠️ Warning messages in yellow
94
+
95
+ Example output:
96
+
97
+ ```
98
+ 🚀 Calling TikTok Proxy API...
99
+ ✅ Status: 200 OK
100
+
101
+ 📦 Response:
102
+ {
103
+ "code": 0,
104
+ "data": {
105
+ "products": [...]
106
+ },
107
+ "message": "success"
108
+ }
109
+ ```
110
+
111
+ ## API Reference
112
+
113
+ ### Commands
114
+
115
+ #### `ttk-proxy call <body>`
116
+
117
+ Call the TikTok proxy API with a JSON body.
118
+
119
+ - **Arguments:**
120
+ - `body` (string): Stringified JSON body for the request
121
+
122
+ #### `ttk-proxy list`
123
+
124
+ List all TikTok proxy tokens.
125
+
126
+ #### `ttk-proxy config [options]`
127
+
128
+ Manage configuration.
129
+
130
+ - **Options:**
131
+ - `-s, --show`: Show current configuration
132
+ - `-c, --clear`: Clear all configuration
133
+
134
+ #### `ttk-proxy config:set <key> <value>`
135
+
136
+ Set a configuration value.
137
+
138
+ - **Arguments:**
139
+ - `key` (string): Configuration key (`apiUrl`, `apiKey`, or `apiSecret`)
140
+ - `value` (string): Configuration value
141
+
142
+ ## Development
143
+
144
+ ### Setup
145
+
146
+ ```bash
147
+ # Install dependencies
148
+ npm install
149
+
150
+ # Build the package
151
+ npm run build
152
+
153
+ # Run type checking
154
+ npm run type-check
155
+
156
+ # Development mode (watch)
157
+ npm run dev
158
+ ```
159
+
160
+ ### Testing Locally
161
+
162
+ ```bash
163
+ # Link the package globally
164
+ npm link
165
+
166
+ # Now you can use ttk-proxy command
167
+ ttk-proxy --help
168
+ ```
169
+
170
+ ## License
171
+
172
+ ISC
173
+
174
+ ## Author
175
+
176
+ Dimension Studios
177
+
178
+ ## Support
179
+
180
+ For issues and questions, please open an issue on the GitHub repository.
181
+
package/bin/cli.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ import("../dist/index.mjs").catch((err) => {
4
+ console.error("Failed to load CLI:", err)
5
+ process.exit(1)
6
+ })
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "dotenv/config";
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
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=>{try{return JSON.parse(e)}catch{let t=`"${e}"`;return JSON.parse(JSON.parse(t))}};async function l(t){let r=a();try{let e=c(t),i=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(e),signal:AbortSignal.timeout(1e4)});if(i.ok){let e=await i.json();console.log(`
3
+ 📋 Curl command:`),console.log(e.curl),console.log(``)}let a=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(e),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 u(){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 d(t){try{e.info(`🚀 Calling TikTok Proxy API...`);let n=await l(t);e.success(`✅ Status: ${n.status} ${n.statusText}`),e.info(`
4
+ 📦 Response:`),console.log(JSON.stringify(n.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
+ 📋 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 ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@dimension-studios/ttk-proxy",
3
+ "version": "1.28.0-preprod-release.60",
4
+ "description": "CLI tool for TikTok proxy API",
5
+ "keywords": [
6
+ "tiktok",
7
+ "proxy",
8
+ "cli",
9
+ "api"
10
+ ],
11
+ "author": "Dimension Studios",
12
+ "license": "ISC",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/dimension-studios/dimension.git",
16
+ "directory": "packages/ttk-proxy-cli"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "type": "module",
22
+ "bin": {
23
+ "ttk-proxy": "./bin/cli.js"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "bin"
28
+ ],
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.mts",
32
+ "import": "./dist/index.mjs"
33
+ }
34
+ },
35
+ "scripts": {
36
+ "build": "tsdown && chmod +x bin/cli.js",
37
+ "clean": "rm -rf dist",
38
+ "dev": "tsdown --watch",
39
+ "type-check": "tsc --noEmit",
40
+ "debug": "dotenv -- tsx src/index.ts",
41
+ "prepublishOnly": "npm run build"
42
+ },
43
+ "dependencies": {
44
+ "@rharkor/logger": "1.3.3",
45
+ "commander": "^14.0.0",
46
+ "conf": "^15.0.0",
47
+ "dotenv": "17.2.3",
48
+ "tsdown": "0.16.6",
49
+ "undici": "^7.2.2"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "24.10.1",
53
+ "dotenv-cli": "11.0.0",
54
+ "tsx": "4.20.6",
55
+ "typescript": "5.9.3"
56
+ }
57
+ }