eprolo-cli 1.0.69 → 1.0.71

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.
Files changed (2) hide show
  1. package/bin/eprolo-cli.js +13 -9
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -6,9 +6,9 @@ const os = require("os");
6
6
  const path = require("path");
7
7
  const https = require("https");
8
8
 
9
- const LOGIN_API = "https://wixtest.eprolo.com/v1/auth/verify-code";
9
+ const LOGIN_API = "https://wixtest.eprolo.com/v1/auth/verifyCode.stm";
10
10
  const REFRESH_API = "https://wixtest.eprolo.com/v1/auth/refresh-code";
11
- const ORDERS_API = "https://wixtest.eprolo.com/test/orders";
11
+ const ORDERS_API = "https://wixtest.eprolo.com/order_list.html";
12
12
  const CONFIG_DIR = path.join(os.homedir(), ".eprolo-toolkit");
13
13
  const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
14
14
 
@@ -44,7 +44,11 @@ function readFlag(argv, flag) {
44
44
  // HTTPS POST 请求
45
45
  // ---------------------------------------------------------------------------
46
46
 
47
- function postJson(url, body, headers = {}) {
47
+ function postJson(url, body, headers = {},method = "POST") {
48
+ if(method == "GET") {
49
+ url += "?" + new URLSearchParams(body).toString();
50
+ body = {};
51
+ }
48
52
  return new Promise((resolve, reject) => {
49
53
  const target = new URL(url);
50
54
  const payload = JSON.stringify(body);
@@ -52,7 +56,7 @@ function postJson(url, body, headers = {}) {
52
56
  hostname: target.hostname,
53
57
  port: target.port || 443,
54
58
  path: `${target.pathname}${target.search}`,
55
- method: "POST",
59
+ method: method,
56
60
  headers: {
57
61
  "content-type": "application/json",
58
62
  "content-length": Buffer.byteLength(payload),
@@ -85,11 +89,11 @@ function postJson(url, body, headers = {}) {
85
89
  // 3. 仍然 401 → 抛错
86
90
  // ---------------------------------------------------------------------------
87
91
 
88
- async function postJsonWithRetry(url, body, config) {
92
+ async function postJsonWithRetry(url, body, config, method = "POST") {
89
93
  let headers = {};
90
- if (config.accessToken) headers["accessToken"] = `${config.accessToken}`;
94
+ if (config.apiKey) headers["apiKey"] = `${config.apiKey}`;
91
95
 
92
- let result = await postJson(url, body, headers);
96
+ let result = await postJson(url, body, headers, method);
93
97
  if (result.data.code == 400) {
94
98
  // 刷新 token
95
99
  const refreshRes = await postJson(REFRESH_API, {},{
@@ -150,7 +154,7 @@ async function login(argv) {
150
154
  }));
151
155
  process.exit(1);
152
156
  }
153
- res.data.data.openApiKey = userCode;
157
+ // res.data.data.openApiKey = userCode;
154
158
  // const { account, accessToken, accountId, shopId } = res.data;
155
159
  // const config = { account, accessToken, defaultShop, accountId, shopId, version: 1 };
156
160
  writeConfig(res.data.data);
@@ -198,7 +202,7 @@ async function queryOrders(orderId) {
198
202
  console.error(JSON.stringify({ success: false, errorMessage: "缺少订单 ID" }));
199
203
  process.exit(1);
200
204
  }
201
- const data = await postJsonWithRetry(ORDERS_API, {id:orderId}, config);
205
+ const data = await postJsonWithRetry(ORDERS_API, {timestamp:config.timestamp,sign:config.accessToken}, config, "GET");
202
206
  console.log(JSON.stringify(data, null, 2));
203
207
  process.exit(0);
204
208
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.69",
3
+ "version": "1.0.71",
4
4
  "description": "CLI for Dianxiaobao ICBU AI publishing, authorization profile management, task submission, and task status checks.",
5
5
  "bin": {
6
6
  "eprolo": "bin/eprolo-cli.js"