eprolo-cli 1.0.81 → 1.0.82

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 +7 -18
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -100,7 +100,7 @@ async function postJsonWithRetry(url, body, config, method = "POST") {
100
100
  body.sign = config.accessToken;
101
101
  }
102
102
  let result = await postJson(url, body, headers, method);
103
- if (result.data.code == 400) {
103
+ if (result.data.code == '-1') {
104
104
  // 刷新 token
105
105
  const refreshRes = await postJson(REFRESH_API, {},{
106
106
  refreshToken: config.refreshToken
@@ -108,25 +108,14 @@ async function postJsonWithRetry(url, body, config, method = "POST") {
108
108
 
109
109
  if (refreshRes.data.code == 0 && refreshRes.data.data.accessToken) {
110
110
  // 更新凭据文件
111
- config.accessToken = refreshRes.data.data.accessToken;
112
- if (refreshRes.data.data.account) config.account = refreshRes.data.data.account;
113
- writeConfig(config);
111
+ body.timestamp = data.data.timestamp;
112
+ body.sign = data.data.accessToken;
113
+ writeConfig(data.data);
114
114
 
115
115
  // 用新 token 重试
116
- headers["accessToken"] = `${config.accessToken}`;
117
- result = await postJson(url, body, headers);
118
- }else if (refreshRes.data.code == 400) {
119
- const res = await postJson(LOGIN_API, { openApiKey: config.openApiKey });
120
- if (res.data.code != 0) {
121
- const err = new Error(`HTTP ${res.statusCode}`);
122
- err.response = res.data.data.msg;
123
- throw err;
124
- }
125
- res.data.data.openApiKey = config.openApiKey;
126
- writeConfig(res.data.data);
127
- headers["accessToken"] = `${res.data.data.accessToken}`;
128
- result = await postJson(url, body, headers);
129
- }
116
+ headers["apiKey"] = `${config.apiKey}`;
117
+ result = await postJson(url, body, headers,method);
118
+ }
130
119
  else {
131
120
  const err = new Error("Token 刷新失败,请重新登录授权");
132
121
  err.response = refreshRes.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.81",
3
+ "version": "1.0.82",
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"