eprolo-cli 1.0.33 → 1.0.35

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 +11 -55
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -113,64 +113,20 @@ function postJson(url, body) {
113
113
  // ---------------------------------------------------------------------------
114
114
 
115
115
  async function login(argv) {
116
- // env 通道:框架通过 fieldInjection 注入 DXB_USER_CODE
117
- const userCode = process.env.DXB_USER_CODE || readFlag(argv, "--user-code") || readFlag(argv, "--user-code");
118
-
119
- // arg 通道:框架通过 fieldInjection 追加 --default-shop
120
- const defaultShop =
121
- readFlag(argv, "--default-shop") ||
122
- readFlag(argv, "--default-store-name") ||
123
- readFlag(argv, "--store-name") ||
124
- process.env.DXB_STORE_NAME ||
125
- null;
126
-
127
- // 账号标识
128
- const account =
129
- readFlag(argv, "--account") ||
130
- process.env.DXB_ACCOUNT ||
131
- defaultShop ||
132
- null;
133
-
134
- if (!userCode) {
135
- console.error(JSON.stringify({
136
- success: false,
137
- errorMessage: "缺少用户密文:请在授权弹窗中填写"
138
- }));
139
- process.exit(2);
140
- }
141
-
142
- // 调用登录接口验证密文
143
- let loginResult;
144
- try {
145
- loginResult = await postJson(LOGIN_API, { userCode, defaultShop });
146
- } catch (err) {
147
- console.error(JSON.stringify({
148
- success: false,
149
- errorMessage: "密文验证失败,请到账号设置页重新复制",
150
- detail: err.message,
151
- response: err.response || null
152
- }));
153
- process.exit(1);
154
- }
116
+ const userCode = process.env.DXB_USER_CODE; // env 通道
117
+ if (!userCode) { console.error("缺少用户密文:请在授权弹窗中填写"); process.exit(2); }
155
118
 
156
- // 写凭据文件(D3 契约:顶层明文 account + version)
157
- const finalAccount = account || loginResult.account || "unknown";
158
- const config = {
159
- account: finalAccount,
160
- userCode,
161
- version: 1
162
- };
163
- if (defaultShop) config.defaultShop = defaultShop;
164
- if (loginResult.accessToken) config.accessToken = loginResult.accessToken;
119
+ const defaultShop = readFlag(argv, "--default-shop"); // arg 通道,可能不存在
165
120
 
166
- writeConfig(config);
121
+ const res = await fetch(LOGIN_API, {
122
+ method: "POST", headers: { "Content-Type": "application/json" },
123
+ body: JSON.stringify({ userCode }),
124
+ });
125
+ // if (!res.ok) { console.error("密文无效或已吊销,请到账号设置页重新复制"); process.exit(1); }
167
126
 
168
- console.log(JSON.stringify({
169
- success: true,
170
- connected: true,
171
- account: config.account,
172
- defaultShop: config.defaultShop || null
173
- }, null, 2));
127
+ const { account, accessToken } = await res.json();
128
+ await writeCredentialFile({ account, accessToken, defaultShop }); // → D3
129
+ console.log("login ok"); // 不打印任何敏感值
174
130
  process.exit(0);
175
131
  }
176
132
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
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"