@cloudbase/types 2.26.1 → 2.26.2

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/auth.d.ts CHANGED
@@ -15,6 +15,7 @@ ICloudbaseConfig,
15
15
  | 'i18n'
16
16
  | 'accessKey'
17
17
  | 'useWxCloud'
18
+ | 'auth'
18
19
  > &
19
20
  ICloudbaseConfig['auth']
20
21
  & {eventBus?: ICloudbaseEventEmitter}
package/index.d.ts CHANGED
@@ -22,6 +22,16 @@ export interface KVstring {
22
22
 
23
23
  export type EndPointKey = 'CLOUD_API' | 'GATEWAY'
24
24
 
25
+ /** 自定义登录凭证信息(从控制台下载的私钥文件) */
26
+ export interface ICredentialsInfo {
27
+ /** 私钥 ID */
28
+ private_key_id: string;
29
+ /** RSA 私钥内容 */
30
+ private_key: string;
31
+ /** 所属环境 ID */
32
+ env_id: string;
33
+ }
34
+
25
35
  export interface ICloudbaseConfig {
26
36
  env: string
27
37
  region?: string
@@ -43,7 +53,29 @@ export interface ICloudbaseConfig {
43
53
  useWxCloud?: boolean // 是否使用微信云开发链路
44
54
  auth?: {
45
55
  detectSessionInUrl?: boolean
56
+ secretId?: string
57
+ secretKey?: string
58
+ sessionToken?: string
59
+ secretType?: 'SESSION_SECRET' | 'SECRET'
60
+ credentials?: ICredentialsInfo // 自定义登录私钥信息,node端使用
46
61
  }
62
+ // @cloudbase/functions-framework 函数上下文,只要求部分字段,只在云函数或云托管中有效
63
+ context?: Readonly<{
64
+ eventID: string
65
+ extendedContext?: {
66
+ envId: string // 环境 ID
67
+ // uin: string // 请求的 UIN
68
+ source: string // 请求来源,如 wx
69
+ accessToken?: string // 调用请求时的 AccessToken
70
+ userId?: string // 请求的用户 ID
71
+ tmpSecret?: {
72
+ // 临时凭证
73
+ secretId: string // secretId
74
+ secretKey: string // secretKey
75
+ token: string // token
76
+ }
77
+ }
78
+ }>
47
79
  }
48
80
  // 可更新的配置字段
49
81
  export type ICloudbaseUpgradedConfig = Pick<ICloudbaseConfig, 'persistence' | 'region' | 'debug'>
@@ -80,14 +112,47 @@ export interface ICloudbase {
80
112
  registerVersion: (version: string) => void
81
113
  fire?: (...args: any[]) => void
82
114
  updateLang?: (lang: LANGS) => void
115
+ /**
116
+ * 检查当前 Cloudbase 实例是否已完成初始化
117
+ * @returns 是否已初始化
118
+ */
119
+ isInitialized?: () => boolean
83
120
  getEndPointWithKey?: (key: EndPointKey) => {
84
121
  BASE_URL: string
85
122
  PROTOCOL: string
86
123
  }
87
124
  auth?: (options?: { persistence: cloudbase.auth.Persistence }) => cloudbase.auth.App
88
125
  }
126
+
127
+ /**
128
+ * Node.js 端适配器扩展方法
129
+ */
130
+ export interface INodeAdapterExtend {
131
+ /**
132
+ * 从环境变量中获取腾讯云临时密钥信息
133
+ * 用于 API 请求签名
134
+ */
135
+ getSecretInfo?: (config?: ICloudbaseConfig) => {
136
+ env: string
137
+ secretId: string
138
+ secretKey: string
139
+ sessionToken: string
140
+ accessKey: string
141
+ secretType: string
142
+ }
143
+ /**
144
+ * 初始化 Node.js 端工具方法,挂载到 js-sdk app 实例上
145
+ * 包含:auth 相关方法、模板消息推送、context 解析
146
+ */
147
+ nodeTool?: (
148
+ /** js-sdk cloudbase 实例 */
149
+ app: any,
150
+ /** 配置信息,包含认证凭证和环境 ID */
151
+ config: ICloudbaseConfig,
152
+ ) => void
153
+ }
89
154
  export interface ICloudbasePlatformInfo {
90
- adapter?: SDKAdapterInterface
155
+ adapter?: SDKAdapterInterface & INodeAdapterExtend
91
156
  runtime?: string
92
157
  }
93
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/types",
3
- "version": "2.26.1",
3
+ "version": "2.26.2",
4
4
  "description": "cloudbase javascript sdk types",
5
5
  "files": [
6
6
  "index.js",
@@ -43,5 +43,5 @@
43
43
  "lint": "eslint --fix \"./**/*.ts\"",
44
44
  "precommit": "npm run lint"
45
45
  },
46
- "gitHead": "e1fabef412c8dad7e66ea8a40dab53839119d4e5"
46
+ "gitHead": "af397dd45339057868b98ac09c417d352e56a217"
47
47
  }
package/request.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface IGetAccessTokenResult {
10
10
  accessTokenExpire: number;
11
11
  }
12
12
 
13
- export type ICloudbaseRequestConfig = Pick<ICloudbaseConfig, 'env' | 'region' | 'timeout' | 'oauthClient' | '_fromApp' | 'i18n' | 'endPointMode'>;
13
+ export type ICloudbaseRequestConfig = Pick<ICloudbaseConfig, 'env' | 'region' | 'timeout' | 'oauthClient' | '_fromApp' | 'i18n' | 'endPointMode' | 'auth'>;
14
14
 
15
15
  export interface IAppendedRequestInfo {
16
16
  data: KV<any>;