connect-api-cli 1.1.9 → 1.1.11

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
@@ -42,6 +42,8 @@ interface OAuthRefreshResponse {
42
42
  ret: ConnectRet;
43
43
  accessToken: string;
44
44
  expireTime: number;
45
+ /** 刷新接口通常不返回新值;若返回则覆盖旧的 refreshToken */
46
+ refreshToken?: string;
45
47
  }
46
48
  /** HarmonyOS 开发者中心下载的 Service Account 凭据(*_private.json) */
47
49
  interface ServiceAccountCredentials {
@@ -55,6 +57,23 @@ interface ServiceAccountCredentials {
55
57
  client_cert_uri?: string;
56
58
  }
57
59
 
60
+ /** 刷新被服务端拒绝(refreshToken 失效),调用方应提示重新登录,不要打开浏览器。 */
61
+ declare class OAuthRefreshRejectedError extends Error {
62
+ constructor(message: string);
63
+ }
64
+ interface NormalizedOAuthToken {
65
+ accessToken: string;
66
+ /** 秒。服务端没给、给了 0 或字段名对不上时为 0,表示没有过期时间。 */
67
+ expireTime: number;
68
+ refreshToken?: string;
69
+ }
70
+ /**
71
+ * 换票 / 刷新响应的字段名并不稳定。
72
+ * 同时认 expireTime / expiresTime / expiresIn / expires_in 与 refreshToken / refresh_token。
73
+ */
74
+ declare function normalizeOAuthToken(data: unknown, previousRefreshToken?: string): NormalizedOAuthToken;
75
+ /** HTTP 4xx 或业务码拒绝都算 refreshToken 失效;超时和断网不是。 */
76
+ declare function isDefinitiveOAuthRefreshFailure(err: unknown): boolean;
58
77
  declare class AuthService {
59
78
  /**
60
79
  * 获取访问API的Token(service to service,client_credentials 模式)
@@ -742,7 +761,7 @@ interface AgcConfig {
742
761
  oauth: OAuthConfig;
743
762
  /**
744
763
  * OAuth 模式下多数 Publish/证书等接口需要的 teamId。
745
- * 来自 AGC_TEAM_ID;未设置时由运行时在仅有一个团队时自动选定。
764
+ * 来自 AGC_TEAM_ID;未设置时自动选用团队列表中的第一个。
746
765
  */
747
766
  teamId?: string;
748
767
  serviceAccount?: ServiceAccountConfig;
@@ -750,4 +769,4 @@ interface AgcConfig {
750
769
  }
751
770
  declare function getConfig(authMode?: AuthMode): AgcConfig;
752
771
 
753
- export { type AgcConfig, type AuthMode, AuthService, type DevecoConfig, type OAuthConfig, ProjectService, ProvisionService, PublishService, type ServiceAccountConfig, UploadService, connectApiClient, getConfig };
772
+ export { type AgcConfig, type AuthMode, AuthService, type DevecoConfig, type NormalizedOAuthToken, type OAuthConfig, OAuthRefreshRejectedError, ProjectService, ProvisionService, PublishService, type ServiceAccountConfig, UploadService, connectApiClient, getConfig, isDefinitiveOAuthRefreshFailure, normalizeOAuthToken };
package/dist/index.d.ts CHANGED
@@ -42,6 +42,8 @@ interface OAuthRefreshResponse {
42
42
  ret: ConnectRet;
43
43
  accessToken: string;
44
44
  expireTime: number;
45
+ /** 刷新接口通常不返回新值;若返回则覆盖旧的 refreshToken */
46
+ refreshToken?: string;
45
47
  }
46
48
  /** HarmonyOS 开发者中心下载的 Service Account 凭据(*_private.json) */
47
49
  interface ServiceAccountCredentials {
@@ -55,6 +57,23 @@ interface ServiceAccountCredentials {
55
57
  client_cert_uri?: string;
56
58
  }
57
59
 
60
+ /** 刷新被服务端拒绝(refreshToken 失效),调用方应提示重新登录,不要打开浏览器。 */
61
+ declare class OAuthRefreshRejectedError extends Error {
62
+ constructor(message: string);
63
+ }
64
+ interface NormalizedOAuthToken {
65
+ accessToken: string;
66
+ /** 秒。服务端没给、给了 0 或字段名对不上时为 0,表示没有过期时间。 */
67
+ expireTime: number;
68
+ refreshToken?: string;
69
+ }
70
+ /**
71
+ * 换票 / 刷新响应的字段名并不稳定。
72
+ * 同时认 expireTime / expiresTime / expiresIn / expires_in 与 refreshToken / refresh_token。
73
+ */
74
+ declare function normalizeOAuthToken(data: unknown, previousRefreshToken?: string): NormalizedOAuthToken;
75
+ /** HTTP 4xx 或业务码拒绝都算 refreshToken 失效;超时和断网不是。 */
76
+ declare function isDefinitiveOAuthRefreshFailure(err: unknown): boolean;
58
77
  declare class AuthService {
59
78
  /**
60
79
  * 获取访问API的Token(service to service,client_credentials 模式)
@@ -742,7 +761,7 @@ interface AgcConfig {
742
761
  oauth: OAuthConfig;
743
762
  /**
744
763
  * OAuth 模式下多数 Publish/证书等接口需要的 teamId。
745
- * 来自 AGC_TEAM_ID;未设置时由运行时在仅有一个团队时自动选定。
764
+ * 来自 AGC_TEAM_ID;未设置时自动选用团队列表中的第一个。
746
765
  */
747
766
  teamId?: string;
748
767
  serviceAccount?: ServiceAccountConfig;
@@ -750,4 +769,4 @@ interface AgcConfig {
750
769
  }
751
770
  declare function getConfig(authMode?: AuthMode): AgcConfig;
752
771
 
753
- export { type AgcConfig, type AuthMode, AuthService, type DevecoConfig, type OAuthConfig, ProjectService, ProvisionService, PublishService, type ServiceAccountConfig, UploadService, connectApiClient, getConfig };
772
+ export { type AgcConfig, type AuthMode, AuthService, type DevecoConfig, type NormalizedOAuthToken, type OAuthConfig, OAuthRefreshRejectedError, ProjectService, ProvisionService, PublishService, type ServiceAccountConfig, UploadService, connectApiClient, getConfig, isDefinitiveOAuthRefreshFailure, normalizeOAuthToken };