@dimension-studios/shop-browser 1.141.0 → 1.143.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 +24 -2
- package/dist/index.mjs +2 -2
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -70,9 +70,31 @@ shop-browser
|
|
|
70
70
|
|----------|--------|
|
|
71
71
|
| `HEADLESS` | If `true` or `1`, runs Playwright headless (default: visible window). |
|
|
72
72
|
| `EXECUTABLE_PATH` | Path to Chrome/Chromium if the bundled Playwright browser is not used. |
|
|
73
|
+
| `REMOTE_DEBUGGING_PORT` | Exposes a local Chrome DevTools endpoint on `127.0.0.1:<port>` for tools such as Chrome DevTools MCP. |
|
|
73
74
|
|
|
74
75
|
Copy `.env.example` to `.env` only for local development; do not commit real secrets.
|
|
75
76
|
|
|
77
|
+
To attach Chrome DevTools MCP to the opened browser, launch with a debugging port:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
REMOTE_DEBUGGING_PORT=9222 shop-browser
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Then configure Chrome DevTools MCP with:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"chrome-devtools": {
|
|
89
|
+
"command": "npx",
|
|
90
|
+
"args": ["chrome-devtools-mcp@latest", "--browser-url=http://127.0.0.1:9222"]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Close the browser when finished so the debugging port is no longer exposed.
|
|
97
|
+
|
|
76
98
|
### Help and version
|
|
77
99
|
|
|
78
100
|
```bash
|
|
@@ -172,7 +194,7 @@ CI also runs `npm run build:extension` on every pull request (`.github/workflows
|
|
|
172
194
|
On **`main-release`** only, after a successful semantic-release, CI submits the built extension to:
|
|
173
195
|
|
|
174
196
|
- **Chrome Web Store** — upload + publish via `chrome-webstore-upload-cli`
|
|
175
|
-
- **Firefox Add-ons (AMO)** — listed submission via `web-ext sign
|
|
197
|
+
- **Firefox Add-ons (AMO)** — listed submission via `web-ext sign` (submission API is default in web-ext 8+)
|
|
176
198
|
|
|
177
199
|
Preprod (`preprod-release`) still publishes GitHub Release artifacts but does **not** auto-list on stores.
|
|
178
200
|
|
|
@@ -198,7 +220,7 @@ Preprod (`preprod-release`) still publishes GitHub Release artifacts but does **
|
|
|
198
220
|
| `SHOP_BROWSER_CHROME_EXTENSION_ID` | Chrome extension ID (32-char string) |
|
|
199
221
|
| `SHOP_BROWSER_CHROME_PUBLISHER_ID` | Chrome Web Store publisher ID |
|
|
200
222
|
| `SHOP_BROWSER_CHROME_CLIENT_ID` | Google OAuth client ID |
|
|
201
|
-
| `SHOP_BROWSER_CHROME_CLIENT_SECRET` | Google OAuth client secret (
|
|
223
|
+
| `SHOP_BROWSER_CHROME_CLIENT_SECRET` | Google OAuth client secret (plain `GOCSPX-…` value from Google Cloud) |
|
|
202
224
|
| `SHOP_BROWSER_CHROME_REFRESH_TOKEN` | Google OAuth refresh token |
|
|
203
225
|
| `SHOP_BROWSER_AMO_JWT_ISSUER` | AMO JWT issuer (`user:…`) |
|
|
204
226
|
| `SHOP_BROWSER_AMO_JWT_SECRET` | AMO JWT secret |
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as e}from"node:fs";import{dirname as t,join as n}from"node:path";import{fileURLToPath as r}from"node:url";import{logger as i}from"@rharkor/logger";import{program as a}from"commander";import"dotenv/config";import o from"conf";import{setTimeout as s}from"node:timers/promises";import{Separator as c,search as l,select as u}from"@inquirer/prompts";import{chromium as d}from"playwright";const f=[{id:`seller`,name:`Seller Center`,url:`https://seller-us.tiktok.com/homepage`},{id:`affiliate`,name:`Affiliate Center`,url:`https://affiliate-us.tiktok.com`},{id:`support`,name:`Support Messages`,url:`https://seller-us.tiktok.com/chat/inbox/current`}];typeof __APP_API_ORIGIN__==`string`&&__APP_API_ORIGIN__.length>0&&__APP_API_ORIGIN__;function p(e){return e.replace(/\/+$/,``)}const m=new o({projectName:`dimension-shop-browser`});function h(){let e=m.get(`apiUrl`),t=m.get(`apiKey`),n=m.get(`apiSecret`);if(!e||!t||!n)throw Error("Missing API configuration. Run `shop-browser config` or set TTK_FETCH_API_URL, TTK_FETCH_API_KEY, and TTK_FETCH_API_SECRET.");return{apiUrl:p(e),apiKey:t,apiSecret:n}}function g(e){e.apiUrl&&m.set(`apiUrl`,p(e.apiUrl)),e.apiKey&&m.set(`apiKey`,e.apiKey),e.apiSecret&&m.set(`apiSecret`,e.apiSecret)}function _(){let e=process.env.TTK_FETCH_API_URL,t=process.env.TTK_FETCH_API_KEY,n=process.env.TTK_FETCH_API_SECRET;e&&m.set(`apiUrl`,p(e)),t&&m.set(`apiKey`,t),n&&m.set(`apiSecret`,n)}function v(e){try{if(e.clear){m.clear(),i.success(`✅ Configuration cleared`);return}if(e.show){let e=m.store;i.info(`📋 Current configuration:`),console.log(JSON.stringify(e,null,2));return}_();let t=m.get(`apiUrl`),n=m.get(`apiKey`),r=m.get(`apiSecret`);(!t||!n||!r)&&(i.error(`❌ Missing configuration`),i.info(`Please set the following environment variables:`),i.info(` - TTK_FETCH_API_URL`),i.info(` - TTK_FETCH_API_KEY`),i.info(` - TTK_FETCH_API_SECRET`),i.info(`Or manually set them using:`),i.info(` shop-browser config:set apiUrl "your-url"`),i.info(` shop-browser config:set apiKey "your-key"`),i.info(` shop-browser config:set apiSecret "your-secret"`),process.exit(1));let a=t,o=n,s=r;i.success(`✅ Configuration loaded successfully`),i.info(`📋 Current configuration:`),i.info(` API URL: ${a}`),i.info(` API Key: ${o}`),i.info(` API Secret: ${c(s)}`);function c(e){return!e||e.length<8?`*`.repeat(e.length):`${e.slice(0,4)}${`*`.repeat(e.length-8)}${e.slice(-4)}`}}catch(e){i.error(`❌ Failed to manage configuration`),e instanceof Error?i.error(e.message):i.error(String(e)),process.exit(1)}}function y(e,t){try{[`apiUrl`,`apiKey`,`apiSecret`].includes(e)||(i.error(`❌ Invalid config key: ${e}`),i.info(`Valid keys: apiUrl, apiKey, apiSecret`),process.exit(1)),g({[e]:t}),i.success(`✅ Set ${e} successfully`)}catch(e){i.error(`❌ Failed to set configuration`),e instanceof Error?i.error(e.message):i.error(String(e)),process.exit(1)}}function b(e){return{"X-Api-Key":e.apiKey,"X-Api-Secret":e.apiSecret}}function x(e){return p(e.apiUrl)}async function S(e,t){let n=new URLSearchParams({q:t.trim()}),r=x(e),i=await fetch(`${r}/ttk-proxy/shops/search?${n}`,{method:`GET`,headers:b(e),signal:AbortSignal.timeout(15e3)});if(!i.ok){let e=await i.text();throw Error(`Shop search failed (${i.status}): ${e||i.statusText}`)}return(await i.json()).shops}async function C(e,t){let n=x(e),r=await fetch(`${n}/ttk-proxy/get-cookies`,{method:`POST`,headers:{"Content-Type":`application/json`,...b(e)},body:JSON.stringify({shopId:t}),signal:AbortSignal.timeout(15e3)});if(!r.ok){let e=await r.text();throw Error(`Could not fetch cookies (${r.status}): ${e||r.statusText}`)}return(await r.json()).cookies??[]}async function w(e){return S(h(),e)}async function T(e){return C(h(),e)}function E(){h()}function D(){let e=process.env.HEADLESS?.toLowerCase();return e===`true`||e===`1`}function O(){let e=process.env.EXECUTABLE_PATH?.trim();return e?.length?e:void 0}async function
|
|
3
|
-
Received SIGINT. Closing browser...`),
|
|
2
|
+
import{readFileSync as e}from"node:fs";import{dirname as t,join as n}from"node:path";import{fileURLToPath as r}from"node:url";import{logger as i}from"@rharkor/logger";import{program as a}from"commander";import"dotenv/config";import o from"conf";import{setTimeout as s}from"node:timers/promises";import{Separator as c,search as l,select as u}from"@inquirer/prompts";import{chromium as d}from"playwright";const f=[{id:`seller`,name:`Seller Center`,url:`https://seller-us.tiktok.com/homepage`},{id:`affiliate`,name:`Affiliate Center`,url:`https://affiliate-us.tiktok.com`},{id:`support`,name:`Support Messages`,url:`https://seller-us.tiktok.com/chat/inbox/current`}];typeof __APP_API_ORIGIN__==`string`&&__APP_API_ORIGIN__.length>0&&__APP_API_ORIGIN__;function p(e){return e.replace(/\/+$/,``)}const m=new o({projectName:`dimension-shop-browser`});function h(){let e=m.get(`apiUrl`),t=m.get(`apiKey`),n=m.get(`apiSecret`);if(!e||!t||!n)throw Error("Missing API configuration. Run `shop-browser config` or set TTK_FETCH_API_URL, TTK_FETCH_API_KEY, and TTK_FETCH_API_SECRET.");return{apiUrl:p(e),apiKey:t,apiSecret:n}}function g(e){e.apiUrl&&m.set(`apiUrl`,p(e.apiUrl)),e.apiKey&&m.set(`apiKey`,e.apiKey),e.apiSecret&&m.set(`apiSecret`,e.apiSecret)}function _(){let e=process.env.TTK_FETCH_API_URL,t=process.env.TTK_FETCH_API_KEY,n=process.env.TTK_FETCH_API_SECRET;e&&m.set(`apiUrl`,p(e)),t&&m.set(`apiKey`,t),n&&m.set(`apiSecret`,n)}function v(e){try{if(e.clear){m.clear(),i.success(`✅ Configuration cleared`);return}if(e.show){let e=m.store;i.info(`📋 Current configuration:`),console.log(JSON.stringify(e,null,2));return}_();let t=m.get(`apiUrl`),n=m.get(`apiKey`),r=m.get(`apiSecret`);(!t||!n||!r)&&(i.error(`❌ Missing configuration`),i.info(`Please set the following environment variables:`),i.info(` - TTK_FETCH_API_URL`),i.info(` - TTK_FETCH_API_KEY`),i.info(` - TTK_FETCH_API_SECRET`),i.info(`Or manually set them using:`),i.info(` shop-browser config:set apiUrl "your-url"`),i.info(` shop-browser config:set apiKey "your-key"`),i.info(` shop-browser config:set apiSecret "your-secret"`),process.exit(1));let a=t,o=n,s=r;i.success(`✅ Configuration loaded successfully`),i.info(`📋 Current configuration:`),i.info(` API URL: ${a}`),i.info(` API Key: ${o}`),i.info(` API Secret: ${c(s)}`);function c(e){return!e||e.length<8?`*`.repeat(e.length):`${e.slice(0,4)}${`*`.repeat(e.length-8)}${e.slice(-4)}`}}catch(e){i.error(`❌ Failed to manage configuration`),e instanceof Error?i.error(e.message):i.error(String(e)),process.exit(1)}}function y(e,t){try{[`apiUrl`,`apiKey`,`apiSecret`].includes(e)||(i.error(`❌ Invalid config key: ${e}`),i.info(`Valid keys: apiUrl, apiKey, apiSecret`),process.exit(1)),g({[e]:t}),i.success(`✅ Set ${e} successfully`)}catch(e){i.error(`❌ Failed to set configuration`),e instanceof Error?i.error(e.message):i.error(String(e)),process.exit(1)}}function b(e){return{"X-Api-Key":e.apiKey,"X-Api-Secret":e.apiSecret}}function x(e){return p(e.apiUrl)}async function S(e,t){let n=new URLSearchParams({q:t.trim()}),r=x(e),i=await fetch(`${r}/ttk-proxy/shops/search?${n}`,{method:`GET`,headers:b(e),signal:AbortSignal.timeout(15e3)});if(!i.ok){let e=await i.text();throw Error(`Shop search failed (${i.status}): ${e||i.statusText}`)}return(await i.json()).shops}async function C(e,t){let n=x(e),r=await fetch(`${n}/ttk-proxy/get-cookies`,{method:`POST`,headers:{"Content-Type":`application/json`,...b(e)},body:JSON.stringify({shopId:t}),signal:AbortSignal.timeout(15e3)});if(!r.ok){let e=await r.text();throw Error(`Could not fetch cookies (${r.status}): ${e||r.statusText}`)}return(await r.json()).cookies??[]}async function w(e){return S(h(),e)}async function T(e){return C(h(),e)}function E(){h()}function D(){let e=process.env.HEADLESS?.toLowerCase();return e===`true`||e===`1`}function O(){let e=process.env.EXECUTABLE_PATH?.trim();return e?.length?e:void 0}function k(){let e=process.env.REMOTE_DEBUGGING_PORT?.trim();return e?.length?e:void 0}async function A(){E();let e=await T((await l({message:`Select a shop:`,source:async(e,{signal:t})=>{let n=e?.trim();if(t.aborted||!n)return[];if(n.length<2)return[new c(`Enter at least 2 characters to search`)];await s(300);let r=await w(n).catch(e=>(console.error(e instanceof Error?e.message:e),[]));return t.aborted?[]:r.length===0?[new c(`No shops found — try another search`)]:r.map(e=>({name:`${e.name} (${e.slug})`,value:{id:e.id,slug:e.slug,name:e.name}}))}})).id);if(!Array.isArray(e)||e.length===0)throw Error(`No cookies returned for this shop. Check TTK proxy access for this shop.`);let t=e,n=await u({message:`Select the page you want to navigate to:`,choices:f.map(e=>({name:e.name,value:e.url}))}),r=k(),i=await d.launch({headless:D(),executablePath:O(),args:[`--no-sandbox`,`--disable-setuid-sandbox`,`--disable-popup-blocking`,`--disable-external-protocol-handling`,...r?[`--remote-debugging-port=${r}`]:[]]}),a=await i.newContext({viewport:null});await a.addCookies(t);let o=await a.newPage();await o.goto(n),console.warn(`Browser opened. Close the browser window to end the process.`),r&&console.warn(`DevTools endpoint: http://127.0.0.1:${r}`),o.on(`close`,()=>i.close()),process.on(`SIGINT`,()=>{console.warn(`
|
|
3
|
+
Received SIGINT. Closing browser...`),i.close()}),await new Promise(e=>i.on(`disconnected`,e)),console.warn(`Browser closed by user. Exiting...`),process.exit(0)}const j=n(t(r(import.meta.url)),`..`,`package.json`),M=JSON.parse(e(j,`utf8`));await i.init(),_(),a.name(`shop-browser`).description(`Open TikTok shop pages using TTK proxy cookies`).version(M.version),a.command(`config`).description(`Manage TTK Fetch API credentials`).option(`-s, --show`,`Show current configuration`).option(`-c, --clear`,`Clear all configuration`).action(e=>{v(e)}),a.command(`config:set`).description(`Set a configuration value`).argument(`<key>`,`Configuration key (apiUrl, apiKey, apiSecret)`).argument(`<value>`,`Configuration value`).action((e,t)=>{y(e,t)});const N=process.argv.slice(2),P=N[0];if(N.length===0)try{await A()}catch(e){i.error(e instanceof Error?e.message:String(e)),process.exit(1)}else P===`config`||P===`config:set`?a.parse(process.argv):P===`-h`||P===`--help`?(i.info(`\n${a.helpInformation()}`),i.info(`Run "${a.name()}" with no arguments to search for a shop and open Chromium with cookies.\n`)):P===`-V`||P===`--version`?i.info(M.version):(i.error(`Unknown argument: ${P??``}`),process.exit(1));export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimension-studios/shop-browser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.143.0",
|
|
4
4
|
"description": "Open TikTok shop pages in Chromium using TTK proxy cookies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tiktok",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/dimension-studios/dimension.git",
|
|
17
|
+
"url": "git+https://github.com/dimension-studios/dimension.git",
|
|
18
18
|
"directory": "packages/shop-browser"
|
|
19
19
|
},
|
|
20
20
|
"publishConfig": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"bin": {
|
|
25
|
-
"shop-browser": "
|
|
25
|
+
"shop-browser": "bin/cli.js"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
@@ -48,19 +48,21 @@
|
|
|
48
48
|
"prepublishOnly": "npm run build:cli"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
+
"@inquirer/prompts": "8.4.3",
|
|
51
52
|
"@rharkor/logger": "1.3.3",
|
|
52
53
|
"commander": "14.0.3",
|
|
53
54
|
"conf": "15.1.0",
|
|
54
55
|
"dotenv": "17.4.2",
|
|
55
|
-
"@inquirer/prompts": "8.4.3",
|
|
56
56
|
"playwright": "1.60.0",
|
|
57
|
-
"tsdown": "0.22.0"
|
|
57
|
+
"tsdown": "0.22.0",
|
|
58
|
+
"webextension-polyfill": "0.12.0"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@types/node": "24.12.4",
|
|
62
|
+
"@types/webextension-polyfill": "0.12.5",
|
|
63
|
+
"@typescript/native-preview": "7.0.0-dev.20260521.1",
|
|
61
64
|
"dotenv-cli": "11.0.0",
|
|
62
65
|
"tsx": "4.22.3",
|
|
63
|
-
"
|
|
64
|
-
"vite": "8.0.13"
|
|
66
|
+
"vite": "8.0.14"
|
|
65
67
|
}
|
|
66
68
|
}
|