eprolo-cli 1.0.21 → 1.0.22
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 +45 -6
- package/package.json +1 -1
package/bin/eprolo-cli.js
CHANGED
|
@@ -131,6 +131,13 @@ function normalizeCredentialValue(value) {
|
|
|
131
131
|
return isTemplatePlaceholder(value) ? "" : value;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
function verifyAuthResponse(data) {
|
|
135
|
+
if (data && data.ok === true) return { verified: true, message: data.message || "Auth verified" };
|
|
136
|
+
if (data && data.success === true) return { verified: true, message: data.message || "Auth verified" };
|
|
137
|
+
const msg = (data && (data.errorMessage || data.message)) || "Verification failed";
|
|
138
|
+
return { verified: false, message: msg };
|
|
139
|
+
}
|
|
140
|
+
|
|
134
141
|
async function postJson(baseUrl, pathName, body) {
|
|
135
142
|
const url = `${baseUrl}`;
|
|
136
143
|
if (typeof fetch === "function") {
|
|
@@ -204,11 +211,6 @@ function printResult(data, jsonOnly) {
|
|
|
204
211
|
}
|
|
205
212
|
|
|
206
213
|
async function main() {
|
|
207
|
-
// await postJson('http://43.153.35.208:8080/aw/auth', "", {
|
|
208
|
-
// userCode: "123456",
|
|
209
|
-
// defaultStoreName: "123456",
|
|
210
|
-
// account: "123456"
|
|
211
|
-
// })
|
|
212
214
|
const args = parseArgs(process.argv.slice(2));
|
|
213
215
|
const [group, command] = args._;
|
|
214
216
|
const baseUrl = args.baseUrl || BASE_URL;
|
|
@@ -235,6 +237,23 @@ async function main() {
|
|
|
235
237
|
if (!userCode) {
|
|
236
238
|
throw new Error("auth login requires --user-code, DXB_USER_CODE, connector field injection, or an interactive terminal to enter userCode");
|
|
237
239
|
}
|
|
240
|
+
console.log("正在验证授权信息...");
|
|
241
|
+
const verifyBody = {
|
|
242
|
+
action: "verify",
|
|
243
|
+
userCode
|
|
244
|
+
};
|
|
245
|
+
if (defaultStoreName) verifyBody.defaultStoreName = defaultStoreName;
|
|
246
|
+
if (account) verifyBody.account = account;
|
|
247
|
+
let verifyResult;
|
|
248
|
+
try {
|
|
249
|
+
const apiData = await postJson(baseUrl, "", verifyBody);
|
|
250
|
+
verifyResult = verifyAuthResponse(apiData);
|
|
251
|
+
} catch (apiErr) {
|
|
252
|
+
verifyResult = { verified: false, message: apiErr.message };
|
|
253
|
+
}
|
|
254
|
+
if (!verifyResult.verified) {
|
|
255
|
+
throw new Error(`Verification failed: ${verifyResult.message}`);
|
|
256
|
+
}
|
|
238
257
|
const config = {
|
|
239
258
|
userCode
|
|
240
259
|
};
|
|
@@ -244,6 +263,7 @@ async function main() {
|
|
|
244
263
|
printResult({
|
|
245
264
|
success: true,
|
|
246
265
|
connected: true,
|
|
266
|
+
verified: true,
|
|
247
267
|
account: config.account || null,
|
|
248
268
|
defaultStoreName: config.defaultStoreName || null
|
|
249
269
|
}, args.json);
|
|
@@ -252,10 +272,29 @@ async function main() {
|
|
|
252
272
|
|
|
253
273
|
if (group === "auth" && command === "status") {
|
|
254
274
|
const config = readConfig();
|
|
275
|
+
if (!config.userCode) {
|
|
276
|
+
printResult({ connected: false, verified: false }, args.json);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
let verified = false;
|
|
280
|
+
let verifyMessage = null;
|
|
281
|
+
try {
|
|
282
|
+
const apiData = await postJson(baseUrl, "", {
|
|
283
|
+
action: "verify",
|
|
284
|
+
userCode: config.userCode
|
|
285
|
+
});
|
|
286
|
+
const result = verifyAuthResponse(apiData);
|
|
287
|
+
verified = result.verified;
|
|
288
|
+
verifyMessage = result.message;
|
|
289
|
+
} catch (apiErr) {
|
|
290
|
+
verifyMessage = apiErr.message;
|
|
291
|
+
}
|
|
255
292
|
printResult({
|
|
256
293
|
connected: Boolean(config.userCode),
|
|
294
|
+
verified,
|
|
257
295
|
account: config.account || null,
|
|
258
|
-
defaultStoreName: config.defaultStoreName || null
|
|
296
|
+
defaultStoreName: config.defaultStoreName || null,
|
|
297
|
+
verifyMessage
|
|
259
298
|
}, args.json);
|
|
260
299
|
return;
|
|
261
300
|
}
|
package/package.json
CHANGED