eprolo-cli 1.0.20 → 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.
Files changed (2) hide show
  1. package/bin/eprolo-cli.js +45 -13
  2. 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,21 +211,9 @@ 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;
215
- const auth = requireAuth(args);
216
- const target = requireTaskTarget(args);
217
- printResult(await postJson(baseUrl, "", {
218
- planId: args.planId,
219
- userCode: auth.userCode,
220
- storeName: target.storeName
221
- }), args.json);
222
217
  if (!group || args.help || args.h) {
223
218
  printHelp();
224
219
  return;
@@ -242,6 +237,23 @@ async function main() {
242
237
  if (!userCode) {
243
238
  throw new Error("auth login requires --user-code, DXB_USER_CODE, connector field injection, or an interactive terminal to enter userCode");
244
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
+ }
245
257
  const config = {
246
258
  userCode
247
259
  };
@@ -251,6 +263,7 @@ async function main() {
251
263
  printResult({
252
264
  success: true,
253
265
  connected: true,
266
+ verified: true,
254
267
  account: config.account || null,
255
268
  defaultStoreName: config.defaultStoreName || null
256
269
  }, args.json);
@@ -259,10 +272,29 @@ async function main() {
259
272
 
260
273
  if (group === "auth" && command === "status") {
261
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
+ }
262
292
  printResult({
263
293
  connected: Boolean(config.userCode),
294
+ verified,
264
295
  account: config.account || null,
265
- defaultStoreName: config.defaultStoreName || null
296
+ defaultStoreName: config.defaultStoreName || null,
297
+ verifyMessage
266
298
  }, args.json);
267
299
  return;
268
300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
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"