@cloudbase/types 3.0.3 → 3.0.5

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'>
@@ -86,8 +118,36 @@ export interface ICloudbase {
86
118
  }
87
119
  auth?: (options?: { persistence: cloudbase.auth.Persistence }) => cloudbase.auth.App
88
120
  }
121
+
122
+ /**
123
+ * Node.js 端适配器扩展方法
124
+ */
125
+ export interface INodeAdapterExtend {
126
+ /**
127
+ * 从环境变量中获取腾讯云临时密钥信息
128
+ * 用于 API 请求签名
129
+ */
130
+ getSecretInfo?: (config?: ICloudbaseConfig) => {
131
+ env: string
132
+ secretId: string
133
+ secretKey: string
134
+ sessionToken: string
135
+ accessKey: string
136
+ secretType: string
137
+ }
138
+ /**
139
+ * 初始化 Node.js 端工具方法,挂载到 js-sdk app 实例上
140
+ * 包含:auth 相关方法、模板消息推送、context 解析
141
+ */
142
+ nodeTool?: (
143
+ /** js-sdk cloudbase 实例 */
144
+ app: any,
145
+ /** 配置信息,包含认证凭证和环境 ID */
146
+ config: ICloudbaseConfig,
147
+ ) => void
148
+ }
89
149
  export interface ICloudbasePlatformInfo {
90
- adapter?: SDKAdapterInterface
150
+ adapter?: SDKAdapterInterface & INodeAdapterExtend
91
151
  runtime?: string
92
152
  }
93
153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/types",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
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": "f636691d8dd8edef8c44e788512fa5a1bbbb11af"
46
+ "gitHead": "5f712e638aa0a0f082986a31c6288b18125a3e24"
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>;