connect-api-cli 1.1.6 → 1.1.9

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.d.mts CHANGED
@@ -13,8 +13,11 @@ interface ConnectRetOnlyResponse {
13
13
  * - client_credentials:API 客户端(client_id + client_secret)
14
14
  * - oauth:OAuth 授权码(用户身份,平台类工具)
15
15
  * - service_account:Service Account(推荐,本地签 PS256 JWT)
16
+ * - deveco:复用本地 deveco-cli / DevEco Code / CodeGenie 的登录态换取 access token
16
17
  */
17
- type AuthMode = 'client_credentials' | 'oauth' | 'service_account';
18
+ type AuthMode = 'client_credentials' | 'oauth' | 'service_account' | 'deveco';
19
+ /** deveco 模式复用的本地登录态来源 */
20
+ type DevecoTokenSource = 'cli' | 'deveco-code' | 'deveco' | 'deveco-cli';
18
21
  interface TokenResponse {
19
22
  access_token?: string;
20
23
  expires_in?: number;
@@ -79,6 +82,12 @@ declare class AuthService {
79
82
  * 刷新接口只返回新的 accessToken,refreshToken 沿用旧值。
80
83
  */
81
84
  static refreshOAuthToken(refreshToken: string): Promise<OAuthRefreshResponse>;
85
+ /**
86
+ * 用本地解密的 deveco JWT 调 jwToken/check 换取 access token
87
+ * (复刻 DevEco loginService.getUserInfo() / tokenChecker.checkJwtToken())。
88
+ * refresh=true 时服务端会刷新 accessToken;JWT 失效时抛错并提示重新登录 DevEco 工具。
89
+ */
90
+ static checkDevecoJwtToken(jwtToken: string, refresh: boolean): Promise<string>;
82
91
  }
83
92
 
84
93
  interface AppIdPair {
@@ -695,7 +704,7 @@ declare class ProvisionService {
695
704
  static getACLQuery(req: ACLQueryRequest): Promise<ACLQueryResponse>;
696
705
  }
697
706
 
698
- declare const agcClient: axios.AxiosInstance;
707
+ declare const connectApiClient: axios.AxiosInstance;
699
708
 
700
709
  /** OAuth 授权码模式所需的端点与客户端配置 */
701
710
  interface OAuthConfig {
@@ -711,12 +720,20 @@ interface ServiceAccountConfig {
711
720
  credentialsPath: string;
712
721
  credentials: ServiceAccountCredentials;
713
722
  }
723
+ /** deveco 模式:复用本地 DevEco 工具链登录态的配置 */
724
+ interface DevecoConfig {
725
+ /** 本地登录态来源:cli / deveco / deveco-cli(deveco-cli 工具)或 deveco-code(DevEco Code) */
726
+ source: DevecoTokenSource;
727
+ /** 显式指定凭据目录(密钥在其 keys/ 子目录);未设置时按来源探测平台默认路径 */
728
+ authDir?: string;
729
+ }
714
730
  interface AgcConfig {
715
731
  /**
716
732
  * 当前生效的身份标识(用于 token 缓存校验 / status 展示):
717
733
  * - client_credentials:AGC_CLIENT_ID
718
734
  * - oauth:oauth.clientId
719
735
  * - service_account:凭据中的 key_id
736
+ * - deveco:deveco:<source>(切换来源 / 目录时缓存自动失效)
720
737
  */
721
738
  clientId: string;
722
739
  clientSecret: string;
@@ -729,7 +746,8 @@ interface AgcConfig {
729
746
  */
730
747
  teamId?: string;
731
748
  serviceAccount?: ServiceAccountConfig;
749
+ deveco?: DevecoConfig;
732
750
  }
733
- declare function getConfig(): AgcConfig;
751
+ declare function getConfig(authMode?: AuthMode): AgcConfig;
734
752
 
735
- export { type AgcConfig, type AuthMode, AuthService, type OAuthConfig, ProjectService, ProvisionService, PublishService, type ServiceAccountConfig, UploadService, agcClient, getConfig };
753
+ export { type AgcConfig, type AuthMode, AuthService, type DevecoConfig, type OAuthConfig, ProjectService, ProvisionService, PublishService, type ServiceAccountConfig, UploadService, connectApiClient, getConfig };
package/dist/index.d.ts CHANGED
@@ -13,8 +13,11 @@ interface ConnectRetOnlyResponse {
13
13
  * - client_credentials:API 客户端(client_id + client_secret)
14
14
  * - oauth:OAuth 授权码(用户身份,平台类工具)
15
15
  * - service_account:Service Account(推荐,本地签 PS256 JWT)
16
+ * - deveco:复用本地 deveco-cli / DevEco Code / CodeGenie 的登录态换取 access token
16
17
  */
17
- type AuthMode = 'client_credentials' | 'oauth' | 'service_account';
18
+ type AuthMode = 'client_credentials' | 'oauth' | 'service_account' | 'deveco';
19
+ /** deveco 模式复用的本地登录态来源 */
20
+ type DevecoTokenSource = 'cli' | 'deveco-code' | 'deveco' | 'deveco-cli';
18
21
  interface TokenResponse {
19
22
  access_token?: string;
20
23
  expires_in?: number;
@@ -79,6 +82,12 @@ declare class AuthService {
79
82
  * 刷新接口只返回新的 accessToken,refreshToken 沿用旧值。
80
83
  */
81
84
  static refreshOAuthToken(refreshToken: string): Promise<OAuthRefreshResponse>;
85
+ /**
86
+ * 用本地解密的 deveco JWT 调 jwToken/check 换取 access token
87
+ * (复刻 DevEco loginService.getUserInfo() / tokenChecker.checkJwtToken())。
88
+ * refresh=true 时服务端会刷新 accessToken;JWT 失效时抛错并提示重新登录 DevEco 工具。
89
+ */
90
+ static checkDevecoJwtToken(jwtToken: string, refresh: boolean): Promise<string>;
82
91
  }
83
92
 
84
93
  interface AppIdPair {
@@ -695,7 +704,7 @@ declare class ProvisionService {
695
704
  static getACLQuery(req: ACLQueryRequest): Promise<ACLQueryResponse>;
696
705
  }
697
706
 
698
- declare const agcClient: axios.AxiosInstance;
707
+ declare const connectApiClient: axios.AxiosInstance;
699
708
 
700
709
  /** OAuth 授权码模式所需的端点与客户端配置 */
701
710
  interface OAuthConfig {
@@ -711,12 +720,20 @@ interface ServiceAccountConfig {
711
720
  credentialsPath: string;
712
721
  credentials: ServiceAccountCredentials;
713
722
  }
723
+ /** deveco 模式:复用本地 DevEco 工具链登录态的配置 */
724
+ interface DevecoConfig {
725
+ /** 本地登录态来源:cli / deveco / deveco-cli(deveco-cli 工具)或 deveco-code(DevEco Code) */
726
+ source: DevecoTokenSource;
727
+ /** 显式指定凭据目录(密钥在其 keys/ 子目录);未设置时按来源探测平台默认路径 */
728
+ authDir?: string;
729
+ }
714
730
  interface AgcConfig {
715
731
  /**
716
732
  * 当前生效的身份标识(用于 token 缓存校验 / status 展示):
717
733
  * - client_credentials:AGC_CLIENT_ID
718
734
  * - oauth:oauth.clientId
719
735
  * - service_account:凭据中的 key_id
736
+ * - deveco:deveco:<source>(切换来源 / 目录时缓存自动失效)
720
737
  */
721
738
  clientId: string;
722
739
  clientSecret: string;
@@ -729,7 +746,8 @@ interface AgcConfig {
729
746
  */
730
747
  teamId?: string;
731
748
  serviceAccount?: ServiceAccountConfig;
749
+ deveco?: DevecoConfig;
732
750
  }
733
- declare function getConfig(): AgcConfig;
751
+ declare function getConfig(authMode?: AuthMode): AgcConfig;
734
752
 
735
- export { type AgcConfig, type AuthMode, AuthService, type OAuthConfig, ProjectService, ProvisionService, PublishService, type ServiceAccountConfig, UploadService, agcClient, getConfig };
753
+ export { type AgcConfig, type AuthMode, AuthService, type DevecoConfig, type OAuthConfig, ProjectService, ProvisionService, PublishService, type ServiceAccountConfig, UploadService, connectApiClient, getConfig };