@tarojs/taro 3.4.1 → 3.4.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.
Files changed (88) hide show
  1. package/package.json +5 -5
  2. package/types/api/ai/face.d.ts +133 -0
  3. package/types/api/ai/visionkit.d.ts +303 -0
  4. package/types/api/base/crypto.d.ts +90 -0
  5. package/types/api/base/debug.d.ts +152 -13
  6. package/types/api/base/env.d.ts +2 -1
  7. package/types/api/base/index.d.ts +10 -2
  8. package/types/api/base/performance.d.ts +195 -0
  9. package/types/api/base/system.d.ts +539 -101
  10. package/types/api/base/update.d.ts +59 -7
  11. package/types/api/base/weapp/app-event.d.ts +46 -23
  12. package/types/api/base/weapp/life-cycle.d.ts +141 -1
  13. package/types/api/canvas/index.d.ts +150 -136
  14. package/types/api/cloud/index.d.ts +2 -2
  15. package/types/api/device/accelerometer.d.ts +3 -3
  16. package/types/api/device/accessibility.d.ts +26 -0
  17. package/types/api/device/battery.d.ts +2 -2
  18. package/types/api/device/{ble.d.ts → bluetooth-ble.d.ts} +228 -62
  19. package/types/api/device/bluetooth-peripheral.d.ts +430 -0
  20. package/types/api/device/bluetooth.d.ts +67 -2
  21. package/types/api/device/calendar.d.ts +88 -0
  22. package/types/api/device/contact.d.ts +74 -50
  23. package/types/api/device/gyroscope.d.ts +5 -5
  24. package/types/api/device/iBeacon.d.ts +33 -19
  25. package/types/api/{ui → device}/keyboard.d.ts +0 -0
  26. package/types/api/device/{performance.d.ts → memory.d.ts} +4 -4
  27. package/types/api/device/motion.d.ts +3 -3
  28. package/types/api/device/network.d.ts +53 -12
  29. package/types/api/device/nfc.d.ts +1089 -13
  30. package/types/api/device/scan.d.ts +1 -1
  31. package/types/api/device/screen.d.ts +40 -12
  32. package/types/api/device/wifi.d.ts +41 -6
  33. package/types/api/files/index.d.ts +371 -184
  34. package/types/api/location/index.d.ts +116 -55
  35. package/types/api/media/audio.d.ts +629 -38
  36. package/types/api/media/background-audio.d.ts +8 -8
  37. package/types/api/media/camera.d.ts +38 -19
  38. package/types/api/media/editor.d.ts +22 -2
  39. package/types/api/media/image.d.ts +61 -32
  40. package/types/api/media/live.d.ts +66 -6
  41. package/types/api/media/map.d.ts +469 -49
  42. package/types/api/media/media-recorder.d.ts +92 -0
  43. package/types/api/media/recorder.d.ts +20 -20
  44. package/types/api/media/video-decoder.d.ts +117 -0
  45. package/types/api/media/video-processing.d.ts +11 -7
  46. package/types/api/media/video.d.ts +45 -16
  47. package/types/api/media/voip.d.ts +290 -0
  48. package/types/api/{open-api/navigate.d.ts → navigate/index.d.ts} +63 -25
  49. package/types/api/network/download.d.ts +39 -16
  50. package/types/api/network/request.d.ts +125 -37
  51. package/types/api/network/tcp.d.ts +181 -0
  52. package/types/api/network/udp.d.ts +154 -83
  53. package/types/api/network/upload.d.ts +41 -25
  54. package/types/api/network/websocket.d.ts +16 -15
  55. package/types/api/open-api/authorize.d.ts +41 -2
  56. package/types/api/open-api/channels.d.ts +178 -0
  57. package/types/api/open-api/facial.d.ts +3 -0
  58. package/types/api/open-api/favorites.d.ts +100 -0
  59. package/types/api/open-api/group.d.ts +59 -0
  60. package/types/api/open-api/invoice.d.ts +2 -2
  61. package/types/api/open-api/license-plate.d.ts +27 -0
  62. package/types/api/open-api/login.d.ts +21 -0
  63. package/types/api/open-api/redpackage.d.ts +24 -0
  64. package/types/api/open-api/settings.d.ts +76 -14
  65. package/types/api/open-api/soter.d.ts +2 -2
  66. package/types/api/open-api/subscribe-message.d.ts +88 -3
  67. package/types/api/open-api/user-info.d.ts +55 -18
  68. package/types/api/open-api/werun.d.ts +33 -6
  69. package/types/api/payment/index.d.ts +119 -0
  70. package/types/api/route/index.d.ts +13 -9
  71. package/types/api/share/index.d.ts +192 -9
  72. package/types/api/storage/index.d.ts +29 -83
  73. package/types/api/swan/index.d.ts +1 -1
  74. package/types/api/ui/animation.d.ts +84 -70
  75. package/types/api/ui/background.d.ts +4 -2
  76. package/types/api/ui/custom-component.d.ts +1 -1
  77. package/types/api/ui/fonts.d.ts +27 -31
  78. package/types/api/ui/navigation-bar.d.ts +1 -0
  79. package/types/api/ui/scroll.d.ts +73 -7
  80. package/types/api/ui/sticky.d.ts +4 -4
  81. package/types/api/ui/tab-bar.d.ts +7 -7
  82. package/types/api/ui/window.d.ts +22 -2
  83. package/types/api/worker/index.d.ts +9 -1
  84. package/types/api/wxml/index.d.ts +111 -107
  85. package/types/compile.d.ts +5 -0
  86. package/types/global.d.ts +142 -111
  87. package/types/taro.api.d.ts +79 -62
  88. package/types/api/open-api/payment.d.ts +0 -61
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/taro",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -24,9 +24,9 @@
24
24
  "author": "O2Team",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
- "@tarojs/api": "3.4.1",
28
- "@tarojs/runtime": "3.4.1",
29
- "@tarojs/taro-h5": "3.4.1"
27
+ "@tarojs/api": "3.4.2",
28
+ "@tarojs/runtime": "3.4.2",
29
+ "@tarojs/taro-h5": "3.4.2"
30
30
  },
31
- "gitHead": "a2437215b1966fd0b6dd09311bcb4fd894a871d0"
31
+ "gitHead": "26b329326c6a7da652e8d712ee33df01ab8d2d0e"
32
32
  }
@@ -0,0 +1,133 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace stopFaceDetect {
5
+ interface Option {
6
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
7
+ complete?: (res: TaroGeneral.CallbackResult) => void
8
+ /** 接口调用失败的回调函数 */
9
+ fail?: (res: TaroGeneral.CallbackResult) => void
10
+ /** 接口调用成功的回调函数 */
11
+ success?: (res: TaroGeneral.CallbackResult) => void
12
+ }
13
+ }
14
+
15
+ namespace initFaceDetect {
16
+ interface Option {
17
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
18
+ complete?: (res: TaroGeneral.CallbackResult) => void
19
+ /** 接口调用失败的回调函数 */
20
+ fail?: (res: TaroGeneral.CallbackResult) => void
21
+ /** 接口调用成功的回调函数 */
22
+ success?: (res: TaroGeneral.CallbackResult) => void
23
+ }
24
+ }
25
+
26
+ namespace faceDetect {
27
+ interface Option {
28
+ /** 图像像素点数据,每四项表示一个像素点的 RGBA */
29
+ frameBuffer: ArrayBuffer
30
+ /** 图像宽度 */
31
+ width: number
32
+ /** 图像高度 */
33
+ height: number
34
+ /** 是否返回当前图像的人脸(106 个点)
35
+ * @default false
36
+ */
37
+ enablePoint?: boolean
38
+ /** 是否返回当前图像的人脸的置信度(可表示器官遮挡情况)
39
+ * @default false
40
+ */
41
+ enableConf?: boolean
42
+ /** 是否返回当前图像的人脸角度信息
43
+ * @default false
44
+ */
45
+ enableAngle?: boolean
46
+ /** 是否返回多张人脸的信息
47
+ * @default false
48
+ */
49
+ enableMultiFace?: boolean
50
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
51
+ complete?: (res: TaroGeneral.CallbackResult) => void
52
+ /** 接口调用失败的回调函数 */
53
+ fail?: (res: TaroGeneral.CallbackResult) => void
54
+ /** 接口调用成功的回调函数 */
55
+ success?: (res: SuccessCallbackOption) => void
56
+ }
57
+
58
+ interface SuccessCallbackOption extends face {
59
+ /** 多人模式(enableMultiFace)下的人脸信息,每个对象包含上述其它属性 */
60
+ faceInfo?: face
61
+ }
62
+
63
+ interface face {
64
+ /** 脸部正方框数值,对象包含 height, weight, originX, originY 四个属性 */
65
+ detectRect: detectRect
66
+ /** 脸部中心点横坐标,检测不到人脸则为 -1 */
67
+ x: number
68
+ /** 脸部中心点纵坐标,检测不到人脸则为 -1 */
69
+ y: number
70
+ /** 人脸 106 个点位置数组,数组每个对象包含 x 和 y */
71
+ pointArray: point[]
72
+ /** 人脸置信度,取值范围 [0, 1],数值越大置信度越高(遮挡越少) */
73
+ confArray: conf[]
74
+ /** 人脸角度信息,取值范围 [-1, 1],数值越接近 0 表示越正对摄像头 */
75
+ angleArray: angle[]
76
+ }
77
+
78
+ /** 脸部正方框数值 */
79
+ interface detectRect {
80
+ height: number
81
+ weight: number
82
+ originX: number
83
+ originY: number
84
+ }
85
+
86
+ interface point {
87
+ x: number
88
+ y: number
89
+ }
90
+
91
+ interface conf {
92
+ /** 整体可信度 */
93
+ global: number
94
+ /** 左眼可信度 */
95
+ leftEye: number
96
+ /** 右眼可信度 */
97
+ rightEye: number
98
+ /** 嘴巴可信度 */
99
+ mouth: number
100
+ /** 鼻子可信度 */
101
+ nose: number
102
+ }
103
+
104
+ interface angle {
105
+ /** 仰俯角(点头) */
106
+ pitch: number
107
+ /** 偏航角(摇头) */
108
+ yaw: number
109
+ /** 翻滚角(左右倾) */
110
+ roll: number
111
+ }
112
+ }
113
+
114
+ interface TaroStatic {
115
+ /** 停止人脸识别
116
+ * @supported weapp
117
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/face/wx.stopFaceDetect.html
118
+ */
119
+ stopFaceDetect (option: stopFaceDetect.Option): Promise<TaroGeneral.CallbackResult>
120
+
121
+ /** 初始化人脸识别
122
+ * @supported weapp
123
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/face/wx.initFaceDetect.html
124
+ */
125
+ initFaceDetect (option: initFaceDetect.Option): Promise<TaroGeneral.CallbackResult>
126
+
127
+ /** 人脸识别,使用前需要通过 Taro.initFaceDetect 进行一次初始化,推荐使用相机接口返回的帧数据
128
+ * @supported weapp
129
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/face/wx.faceDetect.html
130
+ */
131
+ faceDetect (option: faceDetect.Option): Promise<TaroGeneral.CallbackResult>
132
+ }
133
+ }
@@ -0,0 +1,303 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace isVKSupport {
5
+ /** vision kit 版本 */
6
+ interface Version {
7
+ /** 旧版本 */
8
+ v1
9
+ /** v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 */
10
+ v2
11
+ }
12
+ }
13
+ namespace createVKSession {
14
+ /** vision kit 版本 */
15
+ interface Version {
16
+ /** 旧版本 */
17
+ v1
18
+ /** v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 */
19
+ v2
20
+ }
21
+ /** 跟踪配置 */
22
+ interface Track {
23
+ /** 平面跟踪配置 */
24
+ plane: Plane
25
+ }
26
+ /** 平面跟踪配置 */
27
+ interface Plane {
28
+ /** 平面跟踪配置模式 */
29
+ mode: keyof PlaneMode
30
+ }
31
+ /** 平面跟踪配置模式合法值 */
32
+ interface PlaneMode {
33
+ /** 检测横向平面 */
34
+ 1
35
+ /** 检测纵向平面,只有 v2 版本支持 */
36
+ 2
37
+ /** 检测横向和纵向平面,只有 v2 版本支持 */
38
+ 3
39
+ }
40
+ }
41
+
42
+ /** anchor 对象,只有 v2 版本支持
43
+ * @supported weapp
44
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKAnchor.html
45
+ */
46
+ interface VKAnchor {
47
+ /** 唯一标识 */
48
+ id: number
49
+ /** 类型 */
50
+ type: keyof VKAnchor.Type
51
+ /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */
52
+ transform: Float32Array
53
+ /** 尺寸,只有平面 anchor 支持 */
54
+ size: VKAnchor.Size
55
+ /** 方向,只有平面 anchor 支持 */
56
+ alignment: number
57
+ }
58
+ namespace VKAnchor {
59
+ /** anchor 对象类型合法值 */
60
+ interface Type {
61
+ /** 平面 */
62
+ 0
63
+ }
64
+ /** anchor 对象类型合法值 */
65
+ interface Size {
66
+ /** 宽度 */
67
+ width: number
68
+ /** 高度 */
69
+ height: number
70
+ }
71
+ }
72
+
73
+ /** 相机对象
74
+ * @supported weapp
75
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKCamera.html
76
+ */
77
+ interface VKCamera {
78
+ /** 视图矩阵 */
79
+ viewMatrix: Float32Array
80
+ /** 相机内参,只有 v2 版本支持 */
81
+ intrinsics: Float32Array
82
+ /** 获取投影矩阵
83
+ * @supported weapp
84
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKCamera.getProjectionMatrix.html
85
+ */
86
+ getProjectionMatrix (
87
+ /** 近视点 */
88
+ near: number,
89
+ /** 远视点 */
90
+ far: number
91
+ ): Float32Array
92
+ }
93
+
94
+ /** vision kit 会话对象
95
+ * @supported weapp
96
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.html
97
+ */
98
+ interface VKFrame {
99
+ /** 生成时间 */
100
+ timestamp: number
101
+ /** 相机对象 */
102
+ camera: VKCamera
103
+ /** 获取当前帧纹理,目前只支持 YUV 纹理
104
+ * @supported weapp
105
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraTexture.html
106
+ */
107
+ getCameraTexture(ctx: WebGLRenderingContext): VKFrame.getCameraTextureResult
108
+ /** 获取纹理调整矩阵。默认获取到的纹理是未经裁剪调整的纹理,此矩阵可用于在着色器中根据帧对象尺寸对纹理进行裁剪
109
+ * @supported weapp
110
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getDisplayTransform.html
111
+ */
112
+ getDisplayTransform(): Float32Array
113
+ }
114
+
115
+ namespace VKFrame {
116
+ /** 帧纹理对象 */
117
+ interface getCameraTextureResult {
118
+ /** Y 分量纹理 */
119
+ yTexture: WebGLTexture
120
+ /** UV 分量纹理 */
121
+ uvTexture: WebGLTexture
122
+ }
123
+ }
124
+
125
+ /** vision kit 会话对象
126
+ * @supported weapp
127
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.html
128
+ */
129
+ interface VKSession {
130
+ /** 会话状态 */
131
+ state: keyof VKSession.State
132
+ /** 会话配置 */
133
+ config: VKSession.Config
134
+ /** 相机尺寸 */
135
+ cameraSize: VKSession.Size
136
+ /** 取消由 requestAnimationFrame 添加到计划中的动画帧请求
137
+ * @supported weapp
138
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.cancelAnimationFrame.html
139
+ */
140
+ cancelAnimationFrame(requestID: number): void
141
+ /** 销毁会话
142
+ * @supported weapp
143
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.destroy.html
144
+ */
145
+ destroy(): void
146
+ /** 获取帧对象,每调用一次都会触发一次帧分析过程
147
+ * @supported weapp
148
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getVKFrame.html
149
+ */
150
+ getVKFrame(
151
+ /** 宽度 */
152
+ width: number,
153
+ /** 高度 */
154
+ height: number
155
+ ): VKFrame
156
+ /** 触摸检测,v1 版本只支持单平面(即 hitTest 生成一次平面后,后续 hitTest 均不会再生成平面,而是以之前生成的平面为基础进行检测)。
157
+ *
158
+ * 如果需要重新识别其他平面,可以在调用此方法时将 reset 参数置为 true。
159
+ * @supported weapp
160
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.hitTest.html
161
+ */
162
+ hitTest(
163
+ /** 相对视窗的横坐标,取值范围为 [0, 1],0 为左边缘,1 为右边缘 */
164
+ x: number,
165
+ /** 相对视窗的纵坐标,取值范围为 [0, 1],0 为上边缘,1 为下边缘 */
166
+ y: number,
167
+ /** 是否需要重新识别其他平面,v2 版本不再需要此参数 */
168
+ reset?: boolean
169
+ ): VKSession.hitTestResult[]
170
+ /** 取消监听会话事件。
171
+ * @supported weapp
172
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.off.html
173
+ */
174
+ off(
175
+ /** 事件名称 */
176
+ eventName: string,
177
+ /** 事件监听函数 */
178
+ fn: Function
179
+ ): void
180
+ /** 监听会话事件。
181
+ * @supported weapp
182
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.on.html
183
+ */
184
+ on(
185
+ /** 事件名称 */
186
+ eventName: string,
187
+ /** 事件监听函数 */
188
+ fn: Function
189
+ ): void
190
+ /** 在下次进行重绘时执行。
191
+ * @supported weapp
192
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.requestAnimationFrame.html
193
+ */
194
+ requestAnimationFrame(
195
+ /** 执行函数 */
196
+ callback: Function
197
+ ): number
198
+ /** 开启会话。
199
+ * @supported weapp
200
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.start.html
201
+ */
202
+ start(
203
+ /** 开启会话回调 */
204
+ callback: (status: keyof VKSession.StartStatus) => void
205
+ ): void
206
+ /** 停止会话。
207
+ * @supported weapp
208
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.stop.html
209
+ */
210
+ stop(): void
211
+ }
212
+ namespace VKSession {
213
+ /** state 的合法值 */
214
+ interface State {
215
+ /** 不可用 */
216
+ 0
217
+ /** 运行中 */
218
+ 1
219
+ /** 暂停中 */
220
+ 2
221
+ }
222
+ /** 会话配置 */
223
+ interface Config {
224
+ /** 不可用 */
225
+ version: keyof version
226
+ /** 运行中 */
227
+ track: track
228
+ }
229
+ /** vision kit 版本 */
230
+ interface version {
231
+ /** 旧版本 */
232
+ v1
233
+ /** v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 */
234
+ v2
235
+ }
236
+ /** 跟踪配置 */
237
+ interface track {
238
+ /** 平面跟踪配置 */
239
+ plane: plane
240
+ }
241
+ /** 平面跟踪配置 */
242
+ interface plane {
243
+ /** 平面跟踪配置模式 */
244
+ mode: keyof PlaneMode
245
+ }
246
+ /** 平面跟踪配置模式合法值 */
247
+ interface PlaneMode {
248
+ /** 检测横向平面 */
249
+ 1
250
+ /** 检测纵向平面,只有 v2 版本支持 */
251
+ 2
252
+ /** 检测横向和纵向平面,只有 v2 版本支持 */
253
+ 3
254
+ }
255
+ /** 相机尺寸 */
256
+ interface Size {
257
+ /** 宽度 */
258
+ width: number
259
+ /** 高度 */
260
+ height: number
261
+ }
262
+
263
+ /** hitTest 检测结果 */
264
+ interface hitTestResult {
265
+ /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */
266
+ transform: Float32Array
267
+ }
268
+
269
+ /** start status 的合法值 */
270
+ interface StartStatus {
271
+ /** 成功 */
272
+ 0
273
+ /** 系统错误 */
274
+ 2000000
275
+ /** 参数错误 */
276
+ 2000001
277
+ /** 设备不支持 */
278
+ 2000002
279
+ /** 系统不支持 */
280
+ 2000003
281
+ /** 会话不可用 */
282
+ 2003000
283
+ /** 未开启系统相机权限 */
284
+ 2003001
285
+ /** 未开启小程序相机权限 */
286
+ 2003002
287
+ }
288
+ }
289
+
290
+ interface TaroStatic {
291
+ /** 判断支持版本
292
+ * @supported weapp
293
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.isVKSupport.html
294
+ */
295
+ isVKSupport (version: keyof isVKSupport.Version): boolean /** 是否支持对应版本的 vision kit */
296
+
297
+ /** 创建 vision kit 会话对象
298
+ * @supported weapp
299
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html
300
+ */
301
+ createVKSession (version: keyof createVKSession.Version): VKSession /** vision kit 会话对象 */
302
+ }
303
+ }
@@ -0,0 +1,90 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ /** 用户加密模块
5
+ * @supported weapp
6
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/crypto/UserCryptoManager.html
7
+ */
8
+ interface UserCryptoManager {
9
+ /** 获取最新的用户加密密钥
10
+ * @supported weapp
11
+ * @example
12
+ * ```tsx
13
+ * const userCryptoManager = Taro.getUserCryptoManager()
14
+ * userCryptoManager.getLatestUserKey({
15
+ * success: res => {
16
+ * const { encryptKey, iv, version, expireTime } = res
17
+ * console.log(encryptKey, iv, version, expireTime)
18
+ * }
19
+ * })
20
+ * ```
21
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/crypto/UserCryptoManager.getLatestUserKey.html
22
+ */
23
+ getLatestUserKey(option: UserCryptoManager.getLatestUserKey.Option): Promise<UserCryptoManager.getLatestUserKey.SuccessCallbackResult>
24
+
25
+ /** 获取密码学安全随机数
26
+ * @supported weapp
27
+ * @example
28
+ * ```tsx
29
+ * Taro.getRandomValues({
30
+ * length: 6 // 生成 6 个字节长度的随机数,
31
+ * success: res => {
32
+ * console.log(Taro.arrayBufferToBase64(res.randomValues)) // 转换为 base64 字符串后打印
33
+ * }
34
+ * })
35
+ * ```
36
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/crypto/UserCryptoManager.getRandomValues.html
37
+ */
38
+ getRandomValues(option: UserCryptoManager.getRandomValues.Option): Promise<UserCryptoManager.getRandomValues.SuccessCallbackResult>
39
+ }
40
+
41
+ namespace UserCryptoManager {
42
+ namespace getLatestUserKey {
43
+ interface Option {
44
+ /** 接口调用成功的回调函数 */
45
+ success?: (res: TaroGeneral.CallbackResult) => void
46
+ /** 接口调用失败的回调函数 */
47
+ fail?: (res: TaroGeneral.CallbackResult) => void
48
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
49
+ complete?: (res: SuccessCallbackResult) => void
50
+ }
51
+
52
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
53
+ /** 用户加密密钥 */
54
+ encryptKey: string
55
+ /** 密钥初始向量 */
56
+ iv: string
57
+ /** 密钥版本 */
58
+ version: number
59
+ /** 密钥过期时间 */
60
+ expireTime: number
61
+ }
62
+ }
63
+
64
+ namespace getRandomValues {
65
+ interface Option {
66
+ /** 整数,生成随机数的字节数,最大 1048576 */
67
+ length: number
68
+ /** 接口调用成功的回调函数 */
69
+ success?: (res: TaroGeneral.CallbackResult) => void
70
+ /** 接口调用失败的回调函数 */
71
+ fail?: (res: TaroGeneral.CallbackResult) => void
72
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
73
+ complete?: (res: SuccessCallbackResult) => void
74
+ }
75
+
76
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
77
+ /** 随机数内容,长度为传入的字节数 */
78
+ randomValues: ArrayBuffer
79
+ }
80
+ }
81
+ }
82
+
83
+ interface TaroStatic {
84
+ /** 获取用户加密模块
85
+ * @supported weapp
86
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/crypto/wx.getUserCryptoManager.html
87
+ */
88
+ getUserCryptoManager(): UserCryptoManager
89
+ }
90
+ }