connect-api-cli 1.1.8 → 1.1.10

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/dist/index.mjs CHANGED
@@ -48,12 +48,11 @@ function loadServiceAccountCredentials(filePath) {
48
48
  client_cert_uri: creds.client_cert_uri
49
49
  };
50
50
  }
51
- function getConfig() {
51
+ function getConfig(authMode = process.env.AGC_AUTH_MODE ?? "deveco") {
52
52
  const clientId = process.env.AGC_CLIENT_ID;
53
53
  const clientSecret = process.env.AGC_CLIENT_SECRET;
54
- const authMode = process.env.AGC_AUTH_MODE ?? "client_credentials";
55
54
  if (authMode === "client_credentials" && (!clientId || !clientSecret)) {
56
- throw new Error("Missing AGC credentials. Please set AGC_CLIENT_ID and AGC_CLIENT_SECRET environment variables.");
55
+ throw new Error("Missing credentials. Please set AGC_CLIENT_ID and AGC_CLIENT_SECRET environment variables.");
57
56
  }
58
57
  if (authMode === "service_account" && !process.env.AGC_SA_CREDENTIALS) {
59
58
  throw new Error(
@@ -76,7 +75,22 @@ function getConfig() {
76
75
  credentials: loadServiceAccountCredentials(credentialsPath)
77
76
  };
78
77
  }
79
- const resolvedClientId = authMode === "oauth" ? oauth.clientId : authMode === "service_account" ? serviceAccount.credentials.key_id : clientId || "";
78
+ let deveco;
79
+ if (authMode === "deveco") {
80
+ const sourceEnv = process.env.AGC_DEVECO_SOURCE;
81
+ const devecoSources = ["cli", "deveco", "deveco-cli", "deveco-code"];
82
+ if (sourceEnv && !devecoSources.includes(sourceEnv)) {
83
+ throw new Error(
84
+ `Invalid AGC_DEVECO_SOURCE: ${sourceEnv} (expected ${devecoSources.join(" / ")})`
85
+ );
86
+ }
87
+ const authDirEnv = process.env.AGC_DEVECO_AUTH_DIR?.trim();
88
+ deveco = {
89
+ source: sourceEnv || "cli",
90
+ authDir: authDirEnv ? path.resolve(authDirEnv) : void 0
91
+ };
92
+ }
93
+ const resolvedClientId = authMode === "oauth" ? oauth.clientId : authMode === "service_account" ? serviceAccount.credentials.key_id : authMode === "deveco" ? deveco.authDir ? `deveco:${deveco.source}:${deveco.authDir}` : `deveco:${deveco.source}` : clientId || "";
80
94
  return {
81
95
  clientId: resolvedClientId,
82
96
  clientSecret: clientSecret || "",
@@ -84,19 +98,22 @@ function getConfig() {
84
98
  authMode,
85
99
  oauth,
86
100
  teamId: process.env.AGC_TEAM_ID || void 0,
87
- serviceAccount
101
+ serviceAccount,
102
+ deveco
88
103
  };
89
104
  }
90
105
 
91
106
  // src/services/auth.ts
92
107
  var SA_AUD = "https://oauth-login.cloud.huawei.com/oauth2/v3/token";
93
108
  var SA_JWT_TTL_SEC = 3600;
109
+ var DEVECO_CHECK_URL = process.env.AGC_DEVECO_CHECK_URL || "https://cn.devecostudio.huawei.com/authrouter/auth/api/jwToken/check";
110
+ var DEVECO_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
94
111
  var AuthService = class {
95
112
  /**
96
113
  * 获取访问API的Token(service to service,client_credentials 模式)
97
114
  */
98
115
  static async getToken() {
99
- const config2 = getConfig();
116
+ const config2 = getConfig("client_credentials");
100
117
  const url = `https://${config2.domain}/api/oauth2/v1/token`;
101
118
  const payload = {
102
119
  grant_type: "client_credentials",
@@ -151,7 +168,7 @@ var AuthService = class {
151
168
  * 拼装 OAuth 授权 URL(含随机 state 防 CSRF)
152
169
  */
153
170
  static buildAuthUrl(state) {
154
- const cfg = getConfig();
171
+ const cfg = getConfig("oauth");
155
172
  const url = new URL(cfg.oauth.authUrl);
156
173
  url.searchParams.set("client_id", cfg.oauth.clientId);
157
174
  url.searchParams.set("redirect_uri", cfg.oauth.redirectUri);
@@ -165,7 +182,7 @@ var AuthService = class {
165
182
  * 用授权码换取 OAuth token(与插件 /access-token/generate 对齐)
166
183
  */
167
184
  static async getOAuthToken(code, redirectUri) {
168
- const cfg = getConfig();
185
+ const cfg = getConfig("oauth");
169
186
  const controller = new AbortController();
170
187
  const timeoutId = setTimeout(() => controller.abort(), 3e4);
171
188
  try {
@@ -192,7 +209,7 @@ var AuthService = class {
192
209
  * 刷新接口只返回新的 accessToken,refreshToken 沿用旧值。
193
210
  */
194
211
  static async refreshOAuthToken(refreshToken) {
195
- const cfg = getConfig();
212
+ const cfg = getConfig("oauth");
196
213
  const controller = new AbortController();
197
214
  const timeoutId = setTimeout(() => controller.abort(), 3e4);
198
215
  try {
@@ -214,6 +231,39 @@ var AuthService = class {
214
231
  clearTimeout(timeoutId);
215
232
  }
216
233
  }
234
+ /**
235
+ * 用本地解密的 deveco JWT 调 jwToken/check 换取 access token
236
+ * (复刻 DevEco loginService.getUserInfo() / tokenChecker.checkJwtToken())。
237
+ * refresh=true 时服务端会刷新 accessToken;JWT 失效时抛错并提示重新登录 DevEco 工具。
238
+ */
239
+ static async checkDevecoJwtToken(jwtToken, refresh) {
240
+ const controller = new AbortController();
241
+ const timeoutId = setTimeout(() => controller.abort(), 3e4);
242
+ try {
243
+ const res = await axios.get(DEVECO_CHECK_URL, {
244
+ maxRedirects: 0,
245
+ headers: {
246
+ refresh: String(refresh),
247
+ jwtToken,
248
+ "User-Agent": DEVECO_USER_AGENT,
249
+ "accept-language": "zh-CN"
250
+ },
251
+ signal: controller.signal
252
+ });
253
+ const userInfo = res.data.userInfo;
254
+ if (!res.data.status || !userInfo?.accessToken) {
255
+ throw new Error("\u672C\u5730 DevEco \u767B\u5F55\u6001\u5DF2\u5931\u6548\uFF08jwToken/check \u5224\u5B9A\u65E0\u6548\uFF09\uFF0C\u8BF7\u5728 DevEco \u5DE5\u5177\u4E2D\u91CD\u65B0\u767B\u5F55");
256
+ }
257
+ return userInfo.accessToken;
258
+ } catch (err) {
259
+ if (err instanceof Error && err.name === "AbortError") {
260
+ throw new Error("\u8BF7\u6C42 jwToken/check \u8D85\u65F6\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5");
261
+ }
262
+ throw err;
263
+ } finally {
264
+ clearTimeout(timeoutId);
265
+ }
266
+ }
217
267
  };
218
268
  function base64UrlEncode(buf) {
219
269
  return buf.toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
@@ -283,8 +333,8 @@ async function resolveOAuthTeamId(cfg, accessToken) {
283
333
  if (cfg.teamId) {
284
334
  return cfg.teamId;
285
335
  }
286
- if (cachedTeamId !== void 0) {
287
- return cachedTeamId || void 0;
336
+ if (cachedTeamId) {
337
+ return cachedTeamId;
288
338
  }
289
339
  const persisted = readPersistedTeamId();
290
340
  if (persisted) {
@@ -302,29 +352,187 @@ async function resolveOAuthTeamId(cfg, accessToken) {
302
352
  maxRedirects: 0
303
353
  }
304
354
  );
305
- const teams = res.data.teams || [];
306
355
  if (res.data.ret && res.data.ret.code !== 0) {
307
356
  throw new Error(
308
357
  `Failed to list teams for OAuth teamId: ${res.data.ret.msg || JSON.stringify(res.data.ret)}`
309
358
  );
310
359
  }
311
- if (teams.length === 0) {
312
- cachedTeamId = null;
360
+ const firstTeam = res.data.teams?.[0];
361
+ if (!firstTeam?.id) {
313
362
  throw new Error("OAuth account has no teams. Cannot set teamId for API calls.");
314
363
  }
315
- if (teams.length === 1) {
316
- cachedTeamId = teams[0].id;
317
- writePersistedTeamId(cachedTeamId);
318
- return cachedTeamId;
364
+ cachedTeamId = firstTeam.id;
365
+ writePersistedTeamId(cachedTeamId);
366
+ return cachedTeamId;
367
+ }
368
+ function clearOAuthTeamIdCache() {
369
+ cachedTeamId = void 0;
370
+ }
371
+
372
+ // src/core/deveco-token.ts
373
+ import { createDecipheriv } from "crypto";
374
+ import { existsSync, readFileSync } from "fs";
375
+ import { homedir } from "os";
376
+ import { join, resolve } from "path";
377
+ var ALGORITHM = "aes-256-gcm";
378
+ var KEY_LENGTH = 32;
379
+ var KEK_VERSIONS = ["kek-v1", "kek-v2", "kek-v3"];
380
+ var CLI_SOURCE_ALIASES = ["cli", "deveco", "deveco-cli"];
381
+ var SOURCE_APP_NAMES = {
382
+ "deveco-code": "deveco"
383
+ };
384
+ function decryptAesGcm(ciphertext, key, iv, authTag) {
385
+ const decipher = createDecipheriv(ALGORITHM, key, iv);
386
+ decipher.setAuthTag(authTag);
387
+ return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
388
+ }
389
+ function readJson(filePath) {
390
+ return JSON.parse(readFileSync(filePath, "utf8"));
391
+ }
392
+ function requireFile(filePath, label) {
393
+ try {
394
+ return readFileSync(filePath);
395
+ } catch (err) {
396
+ const code = err.code;
397
+ if (code === "ENOENT") {
398
+ throw new Error(`\u627E\u4E0D\u5230 ${label}: ${filePath}`);
399
+ }
400
+ if (code === "EACCES" || code === "EPERM") {
401
+ throw new Error(`\u65E0\u6743\u9650\u8BFB\u53D6 ${label}: ${filePath}`);
402
+ }
403
+ throw err;
404
+ }
405
+ }
406
+ function loadKek(kekId, keysDir) {
407
+ if (!KEK_VERSIONS.includes(kekId)) {
408
+ throw new Error(`\u975E\u6CD5 kekId: ${kekId}\uFF08\u671F\u671B ${KEK_VERSIONS.join("/")}\uFF09`);
409
+ }
410
+ const rootKeyPath = resolve(join(keysDir, `${kekId}.bin`));
411
+ const keysDirBase = resolve(keysDir);
412
+ if (!rootKeyPath.startsWith(keysDirBase)) {
413
+ throw new Error("kekId \u89E3\u6790\u7ED3\u679C\u8D85\u51FA keys \u76EE\u5F55\u8303\u56F4");
319
414
  }
320
- cachedTeamId = null;
321
- const preview = teams.slice(0, 8).map((t) => `${t.id}${t.name ? `(${t.name})` : ""}`).join(", ");
415
+ const kek = requireFile(rootKeyPath, "KEK \u6839\u5BC6\u94A5");
416
+ if (kek.length !== KEY_LENGTH) {
417
+ throw new Error(`KEK \u957F\u5EA6\u5F02\u5E38: ${kek.length} \u5B57\u8282\uFF08\u671F\u671B ${KEY_LENGTH}\uFF09`);
418
+ }
419
+ return kek;
420
+ }
421
+ function decryptToken(tokenDir, keysDir) {
422
+ const blob = readJson(join(tokenDir, "token.enc"));
423
+ if (blob.algorithm !== ALGORITHM) {
424
+ throw new Error(`\u672A\u77E5\u7B97\u6CD5: ${blob.algorithm}`);
425
+ }
426
+ if (!blob.ciphertext || !blob.iv || !blob.authTag) {
427
+ throw new Error(`token.enc \u683C\u5F0F\u5F02\u5E38\uFF08\u7F3A\u5C11 ciphertext/iv/authTag\uFF09: ${join(tokenDir, "token.enc")}`);
428
+ }
429
+ const wrapped = readJson(join(tokenDir, "token.dek"));
430
+ if (!wrapped.encryptedDek || !wrapped.iv || !wrapped.authTag) {
431
+ throw new Error(`token.dek \u683C\u5F0F\u5F02\u5E38\uFF08\u7F3A\u5C11 encryptedDek/iv/authTag\uFF09: ${join(tokenDir, "token.dek")}`);
432
+ }
433
+ const kek = loadKek(wrapped.kekId, keysDir);
434
+ const dek = decryptAesGcm(
435
+ Buffer.from(wrapped.encryptedDek, "base64"),
436
+ kek,
437
+ Buffer.from(wrapped.iv, "base64"),
438
+ Buffer.from(wrapped.authTag, "base64")
439
+ );
440
+ if (dek.length !== KEY_LENGTH) {
441
+ throw new Error(`DEK \u957F\u5EA6\u5F02\u5E38: ${dek.length} \u5B57\u8282\uFF08\u671F\u671B ${KEY_LENGTH}\uFF09`);
442
+ }
443
+ return decryptAesGcm(
444
+ Buffer.from(blob.ciphertext, "base64"),
445
+ dek,
446
+ Buffer.from(blob.iv, "base64"),
447
+ Buffer.from(blob.authTag, "base64")
448
+ ).toString("utf8");
449
+ }
450
+ function extractJwt(plaintext) {
451
+ let jwt = plaintext;
452
+ try {
453
+ const parsed = JSON.parse(plaintext);
454
+ if (parsed && typeof parsed.access_token === "string") {
455
+ jwt = parsed.access_token;
456
+ }
457
+ } catch {
458
+ }
459
+ const parts = jwt.split(".");
460
+ if (parts.length !== 3) {
461
+ throw new Error("\u89E3\u5BC6\u7ED3\u679C\u4E0D\u662F JWT \u683C\u5F0F\uFF0C\u672C\u5730\u767B\u5F55\u6001\u53EF\u80FD\u5DF2\u635F\u574F\uFF0C\u8BF7\u5728 DevEco \u5DE5\u5177\u4E2D\u91CD\u65B0\u767B\u5F55");
462
+ }
463
+ try {
464
+ const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
465
+ if (typeof payload.exp === "number") {
466
+ return { jwt, expMs: payload.exp * 1e3 };
467
+ }
468
+ } catch {
469
+ }
470
+ return { jwt };
471
+ }
472
+ function configHome() {
473
+ return process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
474
+ }
475
+ function candidatesFor(source) {
476
+ const home = homedir();
477
+ if (CLI_SOURCE_ALIASES.includes(source)) {
478
+ if (process.env.DEVECO_CLI_AUTH_SOURCE?.trim() === "deveco-code") {
479
+ return candidatesFor("deveco-code").map((c) => ({
480
+ ...c,
481
+ source,
482
+ via: "DEVECO_CLI_AUTH_SOURCE=deveco-code"
483
+ }));
484
+ }
485
+ return [
486
+ {
487
+ source,
488
+ tokenDir: process.env.DEVECO_CLI_DATA_DIR || join(home, ".config", "deveco-cli"),
489
+ keysDir: join(home, ".local", "share", "deveco-cli", "keys"),
490
+ via: process.env.DEVECO_CLI_DATA_DIR ? "DEVECO_CLI_DATA_DIR" : "\u5E73\u53F0\u9ED8\u8BA4\u8DEF\u5F84"
491
+ }
492
+ ];
493
+ }
494
+ const appName = SOURCE_APP_NAMES[source];
495
+ const viaEnv = process.env.DEVECO_CODE_AUTH_DIR?.trim();
496
+ if (source === "deveco-code" && viaEnv) {
497
+ const tokenDir = resolve(viaEnv);
498
+ return [{ source, tokenDir, keysDir: join(tokenDir, "keys"), via: "DEVECO_CODE_AUTH_DIR" }];
499
+ }
500
+ let dirs;
501
+ if (process.platform === "win32") {
502
+ const appData = process.env.APPDATA || join(home, "AppData", "Roaming");
503
+ dirs = [join(appData, appName), join(home, ".config", appName)];
504
+ } else if (process.platform === "darwin") {
505
+ dirs = [
506
+ join(configHome(), appName),
507
+ join(home, "Library", "Application Support", appName)
508
+ ];
509
+ } else {
510
+ dirs = [join(configHome(), appName)];
511
+ }
512
+ return dirs.map((tokenDir) => ({
513
+ source,
514
+ tokenDir,
515
+ keysDir: join(tokenDir, "keys"),
516
+ via: "\u5E73\u53F0\u9ED8\u8BA4\u8DEF\u5F84"
517
+ }));
518
+ }
519
+ function resolveLocation(source) {
520
+ const candidates = candidatesFor(source);
521
+ const hit = candidates.find((c) => existsSync(join(c.tokenDir, "token.enc")));
522
+ if (hit) {
523
+ return hit;
524
+ }
525
+ const tried = candidates.map((c) => ` - ${c.tokenDir}`).join("\n");
322
526
  throw new Error(
323
- `Multiple teams found (${teams.length}). Set AGC_TEAM_ID to one of: ${preview}`
527
+ `[${source}] \u672A\u627E\u5230\u672C\u5730\u767B\u5F55\u6001 token.enc\uFF0C\u8BF7\u5148\u7528\u5BF9\u5E94 DevEco \u5DE5\u5177\u767B\u5F55\u3002\u5DF2\u63A2\u6D4B\u4EE5\u4E0B\u4F4D\u7F6E\uFF1A
528
+ ${tried}`
324
529
  );
325
530
  }
326
- function clearOAuthTeamIdCache() {
327
- cachedTeamId = void 0;
531
+ function loadDevecoLocalToken(source, authDir) {
532
+ const location = authDir ? { source: "dir", tokenDir: authDir, keysDir: join(authDir, "keys"), via: "AGC_DEVECO_AUTH_DIR" } : resolveLocation(source);
533
+ const plaintext = decryptToken(location.tokenDir, location.keysDir);
534
+ const { jwt, expMs } = extractJwt(plaintext);
535
+ return { jwt, expMs, location };
328
536
  }
329
537
 
330
538
  // src/core/auth-mgr.ts
@@ -334,18 +542,24 @@ import { exec } from "child_process";
334
542
  import fs4 from "fs";
335
543
  import path3 from "path";
336
544
  import os2 from "os";
545
+ var DEVECO_CACHE_TTL_MS = 30 * 60 * 1e3;
337
546
  var AuthManager = class {
338
547
  static cacheFile = path3.join(os2.homedir(), ".connect-api-cli-token.json");
548
+ static pendingOAuthLogin;
339
549
  /**
340
550
  * 获取当前生效的 access token,并具备自动刷新能力:
341
551
  * - OAuth 模式:token 过期时优先用 refreshToken 自动刷新,无需重新登录
342
552
  * - client_credentials / service_account:过期后重新换取 / 重新签 JWT
553
+ * - deveco:过期后重新解密本地登录态并 refresh 换取
554
+ *
555
+ * force 跳过缓存(供 DevEco 和自动模式的 401 重试使用)。
343
556
  */
344
- static async getAccessToken() {
345
- const cfg = getConfig();
346
- const cache = this.readCache();
347
- const sameCredential = cache && cache.clientId === cfg.clientId && cache.domain === cfg.domain && cache.authMode === cfg.authMode;
348
- if (sameCredential && cache.expiresAt > Date.now() + 5 * 60 * 1e3) {
557
+ static async getAccessToken(force = false) {
558
+ const { config: config2, cache } = this.getStatus();
559
+ return this.getToken(config2, cache, force);
560
+ }
561
+ static async getToken(cfg, cache, force = false) {
562
+ if (!force && cache && cache.expiresAt > Date.now() + 5 * 60 * 1e3) {
349
563
  return cache.accessToken;
350
564
  }
351
565
  if (cfg.authMode === "oauth" && cache?.refreshToken) {
@@ -367,18 +581,31 @@ var AuthManager = class {
367
581
  this.clearCache();
368
582
  }
369
583
  }
370
- return this.acquire();
584
+ return this.acquire(cfg);
371
585
  }
372
586
  /** 登录入口:按当前认证模式获取并缓存 token */
373
587
  static async login() {
374
588
  clearOAuthTeamIdCache();
375
- return this.acquire();
589
+ return this.acquire(getConfig());
376
590
  }
377
- /** 按当前认证模式获取 token(client_credentials / service_account / oauth) */
378
- static async acquire() {
379
- const cfg = getConfig();
591
+ /** 按当前认证模式获取 token(client_credentials / service_account / oauth / deveco) */
592
+ static async acquire(cfg) {
380
593
  if (cfg.authMode === "oauth") {
381
- return this.loginOAuth();
594
+ this.pendingOAuthLogin ??= this.loginOAuth(cfg).finally(() => {
595
+ this.pendingOAuthLogin = void 0;
596
+ });
597
+ return this.pendingOAuthLogin;
598
+ }
599
+ if (cfg.authMode === "deveco") {
600
+ try {
601
+ return await this.acquireDevecoToken(cfg);
602
+ } catch (err) {
603
+ if (process.env.AGC_AUTH_MODE !== void 0) throw err;
604
+ const oauthConfig = getConfig("oauth");
605
+ const cache = this.matchingCache(oauthConfig, this.readCache());
606
+ console.error("\u65E0\u6CD5\u4F7F\u7528\u672C\u5730 DevEco \u767B\u5F55\u6001\uFF0C\u6539\u7528\u534E\u4E3A\u8D26\u53F7 OAuth\u3002");
607
+ return this.getToken(oauthConfig, cache);
608
+ }
382
609
  }
383
610
  if (cfg.authMode === "service_account") {
384
611
  if (!cfg.serviceAccount) {
@@ -409,9 +636,8 @@ var AuthManager = class {
409
636
  throw new Error(`Failed to get token: ${JSON.stringify(res.ret)}`);
410
637
  }
411
638
  /** OAuth 授权码登录:启动本地回调服务器 + 打开浏览器 */
412
- static loginOAuth() {
413
- return new Promise((resolve, reject) => {
414
- const cfg = getConfig();
639
+ static loginOAuth(cfg) {
640
+ return new Promise((resolve2, reject) => {
415
641
  const redirectUri = cfg.oauth.redirectUri;
416
642
  const port = Number(new URL(redirectUri).port || 80);
417
643
  const state = crypto2.randomBytes(32).toString("hex");
@@ -427,6 +653,7 @@ var AuthManager = class {
427
653
  }
428
654
  const token = await AuthService.getOAuthToken(code, redirectUri);
429
655
  const expiresAt = Date.now() + token.expireTime * 1e3;
656
+ clearOAuthTeamIdCache();
430
657
  this.writeCache({
431
658
  accessToken: token.accessToken,
432
659
  expiresAt,
@@ -438,7 +665,7 @@ var AuthManager = class {
438
665
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
439
666
  res.end('<!DOCTYPE html><html><body style="font-family:sans-serif;padding:40px;text-align:center"><h2>\u767B\u5F55\u6210\u529F\uFF0C\u53EF\u5173\u95ED\u6B64\u7A97\u53E3</h2></body></html>');
440
667
  server.close();
441
- resolve(token.accessToken);
668
+ resolve2(token.accessToken);
442
669
  } catch (err) {
443
670
  server.close();
444
671
  reject(err instanceof Error ? err : new Error(String(err)));
@@ -450,15 +677,44 @@ var AuthManager = class {
450
677
  });
451
678
  server.listen(port, () => {
452
679
  const authUrl = AuthService.buildAuthUrl(state);
453
- console.log("\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u5B8C\u6210\u534E\u4E3A\u8D26\u53F7\u6388\u6743...");
454
- console.log(`\u82E5\u6D4F\u89C8\u5668\u672A\u81EA\u52A8\u6253\u5F00\uFF0C\u8BF7\u8BBF\u95EE: ${authUrl}`);
680
+ console.error("\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u5B8C\u6210\u534E\u4E3A\u8D26\u53F7\u6388\u6743...");
681
+ console.error(`\u82E5\u6D4F\u89C8\u5668\u672A\u81EA\u52A8\u6253\u5F00\uFF0C\u8BF7\u8BBF\u95EE: ${authUrl}`);
455
682
  openBrowser(authUrl);
456
683
  });
457
684
  });
458
685
  }
459
- /** 查询缓存状态(供 status 命令显示) */
686
+ /**
687
+ * deveco 模式:解密本地 DevEco 工具链登录态(只读),
688
+ * 用 JWT 调 jwToken/check(refresh=true)换取 access token 并缓存。
689
+ * 服务端不返回有效期:缓存取「本地 JWT 剩余寿命」与「30 分钟上限」的较小值。
690
+ */
691
+ static async acquireDevecoToken(cfg) {
692
+ const deveco = cfg.deveco;
693
+ const local = loadDevecoLocalToken(deveco.source, deveco.authDir);
694
+ const accessToken = await AuthService.checkDevecoJwtToken(local.jwt, true);
695
+ const jwtLimit = local.expMs !== void 0 ? local.expMs - 5 * 60 * 1e3 : Infinity;
696
+ this.writeCache({
697
+ accessToken,
698
+ expiresAt: Math.min(Date.now() + DEVECO_CACHE_TTL_MS, jwtLimit),
699
+ clientId: cfg.clientId,
700
+ domain: cfg.domain,
701
+ authMode: cfg.authMode
702
+ });
703
+ return accessToken;
704
+ }
705
+ /** 默认模式回退到 OAuth 后,后续命令继续使用该 OAuth 会话。 */
460
706
  static getStatus() {
461
- return this.readCache();
707
+ const config2 = getConfig();
708
+ const cache = this.readCache();
709
+ if (process.env.AGC_AUTH_MODE === void 0 && cache?.authMode === "oauth") {
710
+ const oauthConfig = getConfig("oauth");
711
+ const oauthCache = this.matchingCache(oauthConfig, cache);
712
+ if (oauthCache) return { config: oauthConfig, cache: oauthCache };
713
+ }
714
+ return { config: config2, cache: this.matchingCache(config2, cache) };
715
+ }
716
+ static matchingCache(cfg, cache) {
717
+ return cache?.authMode === cfg.authMode && cache.clientId === cfg.clientId && cache.domain === cfg.domain ? cache : null;
462
718
  }
463
719
  static readCache() {
464
720
  try {
@@ -644,7 +900,7 @@ function getRequestSource() {
644
900
  return agent ? `${agent}-skill` : SKILL_CHANNEL;
645
901
  }
646
902
  function readVersion() {
647
- const fromBuild = injected(true ? "1.1.8" : void 0);
903
+ const fromBuild = injected(true ? "1.1.10" : void 0);
648
904
  if (fromBuild) return fromBuild;
649
905
  const candidates = [
650
906
  path4.join(__dirname, "..", "..", "package.json"),
@@ -676,7 +932,7 @@ function applySourceHeaders(headers) {
676
932
  }
677
933
 
678
934
  // src/core/http.ts
679
- var agcClient = axios3.create({ maxRedirects: 0 });
935
+ var connectApiClient = axios3.create({ maxRedirects: 0 });
680
936
  function setHeader(headers, name, value) {
681
937
  if (typeof headers?.set === "function") {
682
938
  headers.set(name, value);
@@ -698,7 +954,7 @@ function getHeader(headers, name) {
698
954
  return headers?.[name] ?? headers?.[name.toLowerCase()];
699
955
  }
700
956
  function applyAuthHeaders(headers, token, cfg, force = false) {
701
- if (cfg.authMode === "oauth") {
957
+ if (cfg.authMode === "oauth" || cfg.authMode === "deveco") {
702
958
  deleteHeader(headers, "Authorization");
703
959
  deleteHeader(headers, "client_id");
704
960
  setHeader(headers, "oauth2Token", token);
@@ -712,7 +968,7 @@ function applyAuthHeaders(headers, token, cfg, force = false) {
712
968
  setHeader(headers, "client_id", cfg.clientId);
713
969
  }
714
970
  }
715
- agcClient.interceptors.request.use(async (config2) => {
971
+ connectApiClient.interceptors.request.use(async (config2) => {
716
972
  const cfg = getConfig();
717
973
  if (!config2.baseURL) {
718
974
  config2.baseURL = `https://${cfg.domain}`;
@@ -723,10 +979,11 @@ agcClient.interceptors.request.use(async (config2) => {
723
979
  }
724
980
  applySourceHeaders(config2.headers);
725
981
  applyAuthHeaders(config2.headers, token, cfg);
726
- if (cfg.authMode === "oauth" && !getHeader(config2.headers, "teamId")) {
982
+ if ((cfg.authMode === "oauth" || cfg.authMode === "deveco") && !getHeader(config2.headers, "teamId")) {
727
983
  const teamId = await resolveOAuthTeamId(cfg, token);
728
984
  if (teamId) {
729
985
  setHeader(config2.headers, "teamId", teamId);
986
+ config2._autoTeamId = true;
730
987
  }
731
988
  }
732
989
  if (config2.data !== void 0 && !getHeader(config2.headers, "Content-Type")) {
@@ -736,7 +993,7 @@ agcClient.interceptors.request.use(async (config2) => {
736
993
  }, (error) => {
737
994
  return Promise.reject(error);
738
995
  });
739
- agcClient.interceptors.response.use(
996
+ connectApiClient.interceptors.response.use(
740
997
  (res) => res,
741
998
  async (err) => {
742
999
  const original = err.config;
@@ -745,12 +1002,13 @@ agcClient.interceptors.response.use(
745
1002
  original._retry = true;
746
1003
  try {
747
1004
  const cfg = getConfig();
748
- const newToken = await AuthManager.getAccessToken();
1005
+ const newToken = await AuthManager.getAccessToken(cfg.authMode === "deveco");
749
1006
  if (!original.headers) {
750
1007
  original.headers = {};
751
1008
  }
752
1009
  applyAuthHeaders(original.headers, newToken, cfg, true);
753
- return agcClient(original);
1010
+ if (original._autoTeamId) deleteHeader(original.headers, "teamId");
1011
+ return connectApiClient(original);
754
1012
  } catch (e) {
755
1013
  return Promise.reject(err);
756
1014
  }
@@ -779,7 +1037,7 @@ function withOptionalParams(base) {
779
1037
  var PublishService = class {
780
1038
  /** 查询应用包名对应的 appid */
781
1039
  static async getAppIdList(packageName, packageTypes) {
782
- const response = await agcClient.get("/api/publish/v2/appid-list", {
1040
+ const response = await connectApiClient.get("/api/publish/v2/appid-list", {
783
1041
  params: withOptionalParams({ packageName, packageTypes })
784
1042
  });
785
1043
  return response.data;
@@ -794,14 +1052,14 @@ var PublishService = class {
794
1052
  if (req.installationFree === 0 && packageName) {
795
1053
  body.packageName = packageName;
796
1054
  }
797
- const response = projectId ? await agcClient.post("/api/publish/v3/app", body, {
1055
+ const response = projectId ? await connectApiClient.post("/api/publish/v3/app", body, {
798
1056
  params: { projectId }
799
- }) : await agcClient.post("/api/publish/v3/app", body);
1057
+ }) : await connectApiClient.post("/api/publish/v3/app", body);
800
1058
  return response.data;
801
1059
  }
802
1060
  /** 查询团队账号下的成员角色列表 */
803
1061
  static async getMembersRoleList(req) {
804
- const response = await agcClient.get(
1062
+ const response = await connectApiClient.get(
805
1063
  "/api/publish/v3/members-role-list",
806
1064
  {
807
1065
  params: {
@@ -816,7 +1074,7 @@ var PublishService = class {
816
1074
  /** 查询应用信息 */
817
1075
  static async getAppInfo(appIdOrReq, lang) {
818
1076
  const req = typeof appIdOrReq === "string" ? { appId: appIdOrReq, lang } : appIdOrReq;
819
- const response = await agcClient.get("/api/publish/v3/app-info", {
1077
+ const response = await connectApiClient.get("/api/publish/v3/app-info", {
820
1078
  params: withOptionalParams({
821
1079
  appId: req.appId,
822
1080
  lang: req.lang,
@@ -829,7 +1087,7 @@ var PublishService = class {
829
1087
  /** 更新应用基本信息 */
830
1088
  static async updateAppInfo(req) {
831
1089
  const { appId, releaseType, releasePhase, ...body } = req;
832
- const response = await agcClient.put(
1090
+ const response = await connectApiClient.put(
833
1091
  "/api/publish/v3/app-info",
834
1092
  body,
835
1093
  {
@@ -841,7 +1099,7 @@ var PublishService = class {
841
1099
  /** 更新应用语言信息 */
842
1100
  static async updateLanguageInfo(req) {
843
1101
  const { appId, releaseType, releasePhase, ...body } = req;
844
- const response = await agcClient.put(
1102
+ const response = await connectApiClient.put(
845
1103
  "/api/publish/v3/app-language-info",
846
1104
  body,
847
1105
  {
@@ -852,7 +1110,7 @@ var PublishService = class {
852
1110
  }
853
1111
  /** 删除应用语言信息 */
854
1112
  static async deleteLanguageInfo(req) {
855
- const response = await agcClient.delete(
1113
+ const response = await connectApiClient.delete(
856
1114
  "/api/publish/v2/app-language-info",
857
1115
  {
858
1116
  params: withOptionalParams({
@@ -867,7 +1125,7 @@ var PublishService = class {
867
1125
  /** 更新应用文件信息(图标/截图/视频等) */
868
1126
  static async updateAppFileInfo(req) {
869
1127
  const { appId, releaseType, releasePhase, ...body } = req;
870
- const response = await agcClient.put(
1128
+ const response = await connectApiClient.put(
871
1129
  "/api/publish/v3/app-file-info",
872
1130
  body,
873
1131
  {
@@ -879,7 +1137,7 @@ var PublishService = class {
879
1137
  /** 更新应用软件包信息(OBS 上传后上报,HarmonyOS 开发者中心才会出现记录) */
880
1138
  static async updateAppPackageInfo(req) {
881
1139
  const { appId, releaseType, releasePhase, fileName, objectId } = req;
882
- const response = await agcClient.put(
1140
+ const response = await connectApiClient.put(
883
1141
  "/api/publish/v3/app-package-info",
884
1142
  { fileName, objectId },
885
1143
  {
@@ -891,7 +1149,7 @@ var PublishService = class {
891
1149
  /** 更新版本上架时间 */
892
1150
  static async updateReleaseTime(req) {
893
1151
  const { appId, ...body } = req;
894
- const response = await agcClient.put(
1152
+ const response = await connectApiClient.put(
895
1153
  "/api/publish/v2/on-shelf-time",
896
1154
  body,
897
1155
  { params: { appId } }
@@ -901,7 +1159,7 @@ var PublishService = class {
901
1159
  /** 更新分阶段发布 */
902
1160
  static async updatePhasedRelease(req) {
903
1161
  const { appId, ...body } = req;
904
- const response = await agcClient.put(
1162
+ const response = await connectApiClient.put(
905
1163
  "/api/publish/v2/version/phased-release",
906
1164
  body,
907
1165
  { headers: appIdHeaders(appId) }
@@ -910,7 +1168,7 @@ var PublishService = class {
910
1168
  }
911
1169
  /** 查询应用软件包信息 */
912
1170
  static async getPackageInfo(req) {
913
- const response = await agcClient.get(
1171
+ const response = await connectApiClient.get(
914
1172
  "/api/publish/v2/app-package-info",
915
1173
  {
916
1174
  params: { packageId: req.packageId },
@@ -921,7 +1179,7 @@ var PublishService = class {
921
1179
  }
922
1180
  /** 查询软件包编译状态 */
923
1181
  static async getCompileStatus(req) {
924
- const response = await agcClient.get(
1182
+ const response = await connectApiClient.get(
925
1183
  "/api/publish/v3/package/compile/status",
926
1184
  { params: { appId: req.appId, pkgIds: req.pkgIds } }
927
1185
  );
@@ -930,7 +1188,7 @@ var PublishService = class {
930
1188
  /** 查询应用所有版本类型的版本列表 */
931
1189
  static async queryBriefInfoList(req) {
932
1190
  const { appId, ...body } = req;
933
- const response = await agcClient.post(
1191
+ const response = await connectApiClient.post(
934
1192
  "/api/publish/v3/version/brief-info/list",
935
1193
  body,
936
1194
  { headers: appIdHeaders(appId) }
@@ -940,7 +1198,7 @@ var PublishService = class {
940
1198
  /** 查询应用未处理的问题工单 */
941
1199
  static async queryVersionVoc(req) {
942
1200
  const { appId, ...body } = req;
943
- const response = await agcClient.post(
1201
+ const response = await connectApiClient.post(
944
1202
  "/api/publish/v1/app-voc/version-voc",
945
1203
  body,
946
1204
  { headers: appIdHeaders(appId) }
@@ -949,7 +1207,7 @@ var PublishService = class {
949
1207
  }
950
1208
  /** 查询需要上传的资质文件信息 */
951
1209
  static async queryTagQualDependent() {
952
- const response = await agcClient.get(
1210
+ const response = await connectApiClient.get(
953
1211
  "/api/publish/v2/tag-qual-dependent"
954
1212
  );
955
1213
  return response.data;
@@ -957,7 +1215,7 @@ var PublishService = class {
957
1215
  /** 提交资质审核任务 */
958
1216
  static async submitQualificationReview(req) {
959
1217
  const { appId, ...body } = req;
960
- const response = await agcClient.post(
1218
+ const response = await connectApiClient.post(
961
1219
  "/api/publish/v2/qualification-review-task",
962
1220
  body,
963
1221
  { headers: appIdHeaders(appId) }
@@ -966,7 +1224,7 @@ var PublishService = class {
966
1224
  }
967
1225
  /** 查询资质审核任务详情 */
968
1226
  static async getQualificationReview(req) {
969
- const response = await agcClient.get(
1227
+ const response = await connectApiClient.get(
970
1228
  "/api/publish/v2/qualification-review-task",
971
1229
  {
972
1230
  params: { tagIds: req.tagIds },
@@ -978,7 +1236,7 @@ var PublishService = class {
978
1236
  /** 修改资质审核任务 */
979
1237
  static async updateQualificationReview(req) {
980
1238
  const { appId, ...body } = req;
981
- const response = await agcClient.put(
1239
+ const response = await connectApiClient.put(
982
1240
  "/api/publish/v2/qualification-review-task",
983
1241
  body,
984
1242
  { headers: appIdHeaders(appId) }
@@ -987,7 +1245,7 @@ var PublishService = class {
987
1245
  }
988
1246
  /** 撤销资质审核任务 */
989
1247
  static async cancelQualificationReview(req) {
990
- const response = await agcClient.put(
1248
+ const response = await connectApiClient.put(
991
1249
  "/api/publish/v2/qualification-review-task/cancel",
992
1250
  { taskId: req.taskId },
993
1251
  { headers: appIdHeaders(req.appId) }
@@ -996,7 +1254,7 @@ var PublishService = class {
996
1254
  }
997
1255
  /** 删除资质审核任务 */
998
1256
  static async deleteQualificationReview(req) {
999
- const response = await agcClient.delete(
1257
+ const response = await connectApiClient.delete(
1000
1258
  "/api/publish/v2/qualification-review-task",
1001
1259
  {
1002
1260
  data: { tagIds: req.tagIds },
@@ -1008,7 +1266,7 @@ var PublishService = class {
1008
1266
  /** 新建用户协议 / 隐私政策协议(body.type 区分) */
1009
1267
  static async createAgreement(req) {
1010
1268
  const { appId, ...body } = req;
1011
- const response = await agcClient.post(
1269
+ const response = await connectApiClient.post(
1012
1270
  "/api/publish/v2/agreement",
1013
1271
  body,
1014
1272
  { headers: appIdHeaders(appId) }
@@ -1018,7 +1276,7 @@ var PublishService = class {
1018
1276
  /** 查询用户协议 / 隐私政策协议列表(body.type 区分) */
1019
1277
  static async listAgreements(req) {
1020
1278
  const { appId, ...body } = req;
1021
- const response = await agcClient.post(
1279
+ const response = await connectApiClient.post(
1022
1280
  "/api/publish/v2/agreement/list",
1023
1281
  body,
1024
1282
  { headers: appIdHeaders(appId) }
@@ -1028,7 +1286,7 @@ var PublishService = class {
1028
1286
  /** 更新用户协议 / 隐私政策协议 */
1029
1287
  static async updateAgreement(req) {
1030
1288
  const { appId, ...body } = req;
1031
- const response = await agcClient.put(
1289
+ const response = await connectApiClient.put(
1032
1290
  "/api/publish/v2/agreement",
1033
1291
  body,
1034
1292
  { headers: appIdHeaders(appId) }
@@ -1038,7 +1296,7 @@ var PublishService = class {
1038
1296
  /** 提交隐私政策协议 */
1039
1297
  static async submitPrivacyAgreement(req) {
1040
1298
  const { appId, ...body } = req;
1041
- const response = await agcClient.put(
1299
+ const response = await connectApiClient.put(
1042
1300
  "/api/publish/v2/agreement/submit",
1043
1301
  body,
1044
1302
  { headers: appIdHeaders(appId) }
@@ -1048,7 +1306,7 @@ var PublishService = class {
1048
1306
  /** 申请年龄分级 */
1049
1307
  static async applyAgeRating(req) {
1050
1308
  const { appId, releaseType, releasePhase, ...body } = req;
1051
- const response = await agcClient.post(
1309
+ const response = await connectApiClient.post(
1052
1310
  "/api/publish/v2/app-age-rating",
1053
1311
  body,
1054
1312
  {
@@ -1061,16 +1319,16 @@ var PublishService = class {
1061
1319
  /** 提交发布 */
1062
1320
  static async submitApp(req) {
1063
1321
  const { appId, ...body } = req;
1064
- const response = await agcClient.post(
1322
+ const response = await connectApiClient.post(
1065
1323
  "/api/publish/v3/app-submit",
1066
1324
  body,
1067
- { headers: appIdHeaders(appId) }
1325
+ { params: { appId } }
1068
1326
  );
1069
1327
  return response.data;
1070
1328
  }
1071
1329
  /** 撤销审核 */
1072
1330
  static async cancelReview(req) {
1073
- const response = await agcClient.put(
1331
+ const response = await connectApiClient.put(
1074
1332
  "/api/publish/v3/version/on-shelf/cancel",
1075
1333
  { versionId: req.versionId },
1076
1334
  { headers: appIdHeaders(req.appId) }
@@ -1079,7 +1337,7 @@ var PublishService = class {
1079
1337
  }
1080
1338
  /** 下架应用 */
1081
1339
  static async shelfOff(req) {
1082
- const response = await agcClient.post(
1340
+ const response = await connectApiClient.post(
1083
1341
  "/api/publish/v2/app-shelf-off",
1084
1342
  null,
1085
1343
  {
@@ -1098,7 +1356,7 @@ var PublishService = class {
1098
1356
  var ProjectService = class {
1099
1357
  /** 查询团队下的项目列表(Project Management API) */
1100
1358
  static async listProjects() {
1101
- const response = await agcClient.get("/api/project-service/v1/projects");
1359
+ const response = await connectApiClient.get("/api/project-service/v1/projects");
1102
1360
  return response.data;
1103
1361
  }
1104
1362
  };
@@ -1113,27 +1371,27 @@ function pickObjectId(res) {
1113
1371
  var UploadService = class {
1114
1372
  // ================= Raw APIs =================
1115
1373
  static async getUploadUrl(req) {
1116
- const response = await agcClient.get("/api/publish/v2/upload-url/for-obs", {
1374
+ const response = await connectApiClient.get("/api/publish/v2/upload-url/for-obs", {
1117
1375
  params: req
1118
1376
  });
1119
1377
  return response.data;
1120
1378
  }
1121
1379
  static async initMultipart(req) {
1122
- const response = await agcClient.post("/api/publish/v2/upload/multipart/init", null, {
1380
+ const response = await connectApiClient.post("/api/publish/v2/upload/multipart/init", null, {
1123
1381
  params: req
1124
1382
  });
1125
1383
  return response.data;
1126
1384
  }
1127
1385
  static async getMultipartParts(req) {
1128
1386
  const { objectId, nspUploadId, parts } = req;
1129
- const response = await agcClient.post("/api/publish/v2/upload/multipart/parts", parts, {
1387
+ const response = await connectApiClient.post("/api/publish/v2/upload/multipart/parts", parts, {
1130
1388
  params: { objectId, nspUploadId }
1131
1389
  });
1132
1390
  return response.data;
1133
1391
  }
1134
1392
  static async composeMultipart(req) {
1135
1393
  const { objectId, nspUploadId, parts } = req;
1136
- const response = await agcClient.post("/api/publish/v2/upload/multipart/compose", parts, {
1394
+ const response = await connectApiClient.post("/api/publish/v2/upload/multipart/compose", parts, {
1137
1395
  params: { objectId, nspUploadId }
1138
1396
  });
1139
1397
  return response.data;
@@ -1263,20 +1521,20 @@ var UploadService = class {
1263
1521
  var ProvisionService = class {
1264
1522
  // ================= Certificates =================
1265
1523
  static async createCert(req) {
1266
- const response = await agcClient.post("/api/publish/v3/cert", req);
1524
+ const response = await connectApiClient.post("/api/publish/v3/cert", req);
1267
1525
  return response.data;
1268
1526
  }
1269
1527
  static async getCertList(req) {
1270
- const response = await agcClient.post("/api/publish/v3/cert/list", req);
1528
+ const response = await connectApiClient.post("/api/publish/v3/cert/list", req);
1271
1529
  return response.data;
1272
1530
  }
1273
1531
  static async deleteCert(req) {
1274
- const response = await agcClient.post("/api/publish/v2/cert/delete", req);
1532
+ const response = await connectApiClient.post("/api/publish/v2/cert/delete", req);
1275
1533
  return response.data;
1276
1534
  }
1277
1535
  // ================= Devices =================
1278
1536
  static async addDevice(req) {
1279
- const response = await agcClient.post("/api/publish/v2/device", req);
1537
+ const response = await connectApiClient.post("/api/publish/v2/device", req);
1280
1538
  return response.data;
1281
1539
  }
1282
1540
  static async getDeviceList(req) {
@@ -1285,16 +1543,16 @@ var ProvisionService = class {
1285
1543
  if (req.fromRecCount !== void 0) params.fromRecCount = req.fromRecCount;
1286
1544
  if (req.maxReqCount !== void 0) params.maxReqCount = req.maxReqCount;
1287
1545
  if (req.order !== void 0) params.order = req.order;
1288
- const response = await agcClient.get("/api/publish/v2/device/list", { params });
1546
+ const response = await connectApiClient.get("/api/publish/v2/device/list", { params });
1289
1547
  return response.data;
1290
1548
  }
1291
1549
  static async deleteDevice(req) {
1292
- const response = await agcClient.post("/api/publish/v2/device/delete", req);
1550
+ const response = await connectApiClient.post("/api/publish/v2/device/delete", req);
1293
1551
  return response.data;
1294
1552
  }
1295
1553
  // ================= Profile / Provision =================
1296
1554
  static async createProvision(req) {
1297
- const response = await agcClient.post("/api/publish/v3/provision", req);
1555
+ const response = await connectApiClient.post("/api/publish/v3/provision", req);
1298
1556
  return response.data;
1299
1557
  }
1300
1558
  static async getProvisionList(req) {
@@ -1303,18 +1561,18 @@ var ProvisionService = class {
1303
1561
  if (req.maxReqCount !== void 0) params.maxReqCount = req.maxReqCount;
1304
1562
  const headers = { appId: req.appId };
1305
1563
  if (req.provisionId) headers.provisionId = req.provisionId;
1306
- const response = await agcClient.get("/api/publish/v3/provision/list", {
1564
+ const response = await connectApiClient.get("/api/publish/v3/provision/list", {
1307
1565
  params,
1308
1566
  headers
1309
1567
  });
1310
1568
  return response.data;
1311
1569
  }
1312
1570
  static async updateProvision(req) {
1313
- const response = await agcClient.put("/api/publish/v3/provision", req);
1571
+ const response = await connectApiClient.put("/api/publish/v3/provision", req);
1314
1572
  return response.data;
1315
1573
  }
1316
1574
  static async deleteProvision(req) {
1317
- const response = await agcClient.delete("/api/publish/v2/provision", {
1575
+ const response = await connectApiClient.delete("/api/publish/v2/provision", {
1318
1576
  params: { id: req.id }
1319
1577
  });
1320
1578
  return response.data;
@@ -1322,7 +1580,7 @@ var ProvisionService = class {
1322
1580
  // ================= Fingerprint =================
1323
1581
  static async addFingerprint(req) {
1324
1582
  const { appId, ...body } = req;
1325
- const response = await agcClient.post(
1583
+ const response = await connectApiClient.post(
1326
1584
  "/api/provision/v1/fingerprints",
1327
1585
  body,
1328
1586
  { headers: { appId } }
@@ -1330,14 +1588,14 @@ var ProvisionService = class {
1330
1588
  return response.data;
1331
1589
  }
1332
1590
  static async getFingerprintList(req) {
1333
- const response = await agcClient.get("/api/provision/v1/fingerprints", {
1591
+ const response = await connectApiClient.get("/api/provision/v1/fingerprints", {
1334
1592
  headers: { appId: req.appId }
1335
1593
  });
1336
1594
  return response.data;
1337
1595
  }
1338
1596
  static async deleteFingerprint(req) {
1339
1597
  const { appId, ...body } = req;
1340
- const response = await agcClient.delete(
1598
+ const response = await connectApiClient.delete(
1341
1599
  "/api/provision/v1/fingerprints",
1342
1600
  { headers: { appId }, data: body }
1343
1601
  );
@@ -1347,7 +1605,7 @@ var ProvisionService = class {
1347
1605
  /** 查询可申请的 ACL 权限列表 */
1348
1606
  static async getEligibleACL(req) {
1349
1607
  const { appId, ...body } = req;
1350
- const response = await agcClient.post(
1608
+ const response = await connectApiClient.post(
1351
1609
  "/api/provision/v1/user/permission/apply/list",
1352
1610
  body,
1353
1611
  { headers: { appId } }
@@ -1356,7 +1614,7 @@ var ProvisionService = class {
1356
1614
  }
1357
1615
  static async applyACL(req) {
1358
1616
  const { appId, ...body } = req;
1359
- const response = await agcClient.post(
1617
+ const response = await connectApiClient.post(
1360
1618
  "/api/provision/v1/user/permission/apply",
1361
1619
  body,
1362
1620
  { headers: { appId } }
@@ -1364,14 +1622,14 @@ var ProvisionService = class {
1364
1622
  return response.data;
1365
1623
  }
1366
1624
  static async getACLStatus(req) {
1367
- const response = await agcClient.get(
1625
+ const response = await connectApiClient.get(
1368
1626
  "/api/provision/v1/user/permission/apply/status",
1369
1627
  { headers: { appId: req.appId } }
1370
1628
  );
1371
1629
  return response.data;
1372
1630
  }
1373
1631
  static async getACLQuery(req) {
1374
- const response = await agcClient.get("/api/provision/v1/user/permission", {
1632
+ const response = await connectApiClient.get("/api/provision/v1/user/permission", {
1375
1633
  headers: { appId: req.appId }
1376
1634
  });
1377
1635
  return response.data;
@@ -1383,6 +1641,6 @@ export {
1383
1641
  ProvisionService,
1384
1642
  PublishService,
1385
1643
  UploadService,
1386
- agcClient,
1644
+ connectApiClient,
1387
1645
  getConfig
1388
1646
  };