eprolo-cli 1.0.98 → 1.0.100
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/bin/eprolo-cli.js +8 -8
- package/package.json +1 -1
package/bin/eprolo-cli.js
CHANGED
|
@@ -48,8 +48,14 @@ function readFlag(argv, flag) {
|
|
|
48
48
|
// ---------------------------------------------------------------------------
|
|
49
49
|
|
|
50
50
|
function postJson(url, body, headers = {},method = "POST") {
|
|
51
|
+
const config = readConfig();
|
|
52
|
+
let signValue={}
|
|
53
|
+
if(config.timestamp){
|
|
54
|
+
signValue.timestamp = config.timestamp;
|
|
55
|
+
signValue.sign = config.accessToken;
|
|
56
|
+
}
|
|
57
|
+
url += "?" + new URLSearchParams(signValue).toString();
|
|
51
58
|
if(method == "GET") {
|
|
52
|
-
url += "?" + new URLSearchParams(body).toString();
|
|
53
59
|
body = {};
|
|
54
60
|
}
|
|
55
61
|
return new Promise((resolve, reject) => {
|
|
@@ -99,19 +105,13 @@ function postJson(url, body, headers = {},method = "POST") {
|
|
|
99
105
|
async function postJsonWithRetry(url, body, config, method = "POST") {
|
|
100
106
|
let headers = {};
|
|
101
107
|
if (config.apiKey) headers["apiKey"] = `${config.apiKey}`;
|
|
102
|
-
if(config.timestamp){
|
|
103
|
-
body.timestamp = config.timestamp;
|
|
104
|
-
body.sign = config.accessToken;
|
|
105
|
-
}
|
|
106
108
|
let result = await postJson(url, body, headers, method);
|
|
107
109
|
if (result.data.code == '-1') {
|
|
108
110
|
// 刷新 token
|
|
109
|
-
const refreshRes = await postJson(LOGIN_API, {
|
|
111
|
+
const refreshRes = await postJson(LOGIN_API, {openApiKey: config.refreshToken});
|
|
110
112
|
|
|
111
113
|
if (refreshRes.data.code == 0) {
|
|
112
114
|
// 更新凭据文件
|
|
113
|
-
body.timestamp = refreshRes.data.data.timestamp;
|
|
114
|
-
body.sign = refreshRes.data.data.accessToken;
|
|
115
115
|
writeConfig(refreshRes.data.data);
|
|
116
116
|
|
|
117
117
|
// 用新 token 重试
|
package/package.json
CHANGED