@cloudbase/app 3.0.5 → 3.0.6
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/cjs/index.js +2 -2
- package/dist/cjs/libs/adapter-node/request.js +14 -6
- package/dist/esm/index.js +2 -2
- package/dist/esm/libs/adapter-node/request.js +14 -6
- package/dist/miniprogram/index.js +1 -1
- package/package.json +4 -4
- package/src/index.ts +1 -1
- package/src/libs/adapter-node/request.ts +14 -8
- package/webpack/web.prod.js +1 -0
- package/webpack/webpack.miniprogram.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/app",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"description": "cloudbase javascript sdk core",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@cloudbase/adapter-interface": "^0.7.1",
|
|
33
33
|
"@cloudbase/adapter-wx_mp": "^1.2.1",
|
|
34
|
-
"@cloudbase/types": "3.0.
|
|
35
|
-
"@cloudbase/utilities": "3.0.
|
|
34
|
+
"@cloudbase/types": "3.0.6",
|
|
35
|
+
"@cloudbase/utilities": "3.0.6"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@cloudbase/signature-nodejs": ">=1.0.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"optional": true
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "157feb77139fd344ddcb80fd3bd94c282e853664"
|
|
54
54
|
}
|
package/src/index.ts
CHANGED
|
@@ -119,7 +119,7 @@ class Cloudbase implements ICloudbase {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
const reqConfig: IRequestConfig & { auth: ICloudbaseConfig['auth'] } = {
|
|
122
|
-
timeout: config.timeout ||
|
|
122
|
+
timeout: config.timeout || 15000,
|
|
123
123
|
timeoutMsg: `[${getSdkName()}][REQUEST TIMEOUT] request had been abort since didn't finished within${
|
|
124
124
|
config.timeout / 1000
|
|
125
125
|
}s`,
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
getCurrRunEnvTag,
|
|
22
22
|
} from './utils'
|
|
23
23
|
import { ICloudbaseConfig } from '@cloudbase/types'
|
|
24
|
+
import { getSdkVersion } from '../../constants/common'
|
|
24
25
|
// 延迟加载,避免非 Node 环境打包时引入此包
|
|
25
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
27
|
let signFn: ((...args: any[]) => any) | null = null
|
|
@@ -133,7 +134,7 @@ export class NodeRequest implements SDKRequestInterface {
|
|
|
133
134
|
|
|
134
135
|
options.headers = {
|
|
135
136
|
...options.headers,
|
|
136
|
-
'User-Agent': `adapter-node/${options.headers?.['X-SDK-Version'] ||
|
|
137
|
+
'User-Agent': `adapter-node/${options.headers?.['X-SDK-Version'] || `@cloudbase/js-sdk/${getSdkVersion()}`}`,
|
|
137
138
|
'X-TCB-Source': SOURCE,
|
|
138
139
|
'X-Client-Timestamp': new Date().valueOf(),
|
|
139
140
|
'X-TCB-Region': INIT_CONFIG.region || getEnv('TENCENTCLOUD_REGION') || '',
|
|
@@ -199,6 +200,10 @@ export class NodeRequest implements SDKRequestInterface {
|
|
|
199
200
|
headers['Content-Type'] = headers['Content-Type'].toLowerCase()
|
|
200
201
|
}
|
|
201
202
|
|
|
203
|
+
if (isAdminPath && !!sessionToken) {
|
|
204
|
+
params.sessionToken = sessionToken
|
|
205
|
+
}
|
|
206
|
+
|
|
202
207
|
const signedParams = {
|
|
203
208
|
secretId,
|
|
204
209
|
secretKey,
|
|
@@ -211,7 +216,6 @@ export class NodeRequest implements SDKRequestInterface {
|
|
|
211
216
|
isCloudApi: !isAdminPath,
|
|
212
217
|
}
|
|
213
218
|
|
|
214
|
-
console.log('======signedParams', signedParams)
|
|
215
219
|
|
|
216
220
|
const sign = await getSign()
|
|
217
221
|
if (!sign) return options
|
|
@@ -219,8 +223,14 @@ export class NodeRequest implements SDKRequestInterface {
|
|
|
219
223
|
const { authorization, timestamp } = sign(signedParams)
|
|
220
224
|
|
|
221
225
|
if (typeof sessionToken === 'string' && sessionToken !== '') {
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
if (isAdminPath) {
|
|
227
|
+
headers.Authorization = `${authorization}`
|
|
228
|
+
headers['X-Timestamp'] = timestamp
|
|
229
|
+
headers['X-Signature-Expires'] = 600
|
|
230
|
+
} else {
|
|
231
|
+
// 临时密钥需要额外附带 Token
|
|
232
|
+
headers.Authorization = `${authorization}, Timestamp=${timestamp}, Token=${sessionToken}`
|
|
233
|
+
}
|
|
224
234
|
} else {
|
|
225
235
|
headers.Authorization = `${authorization}, Timestamp=${timestamp}`
|
|
226
236
|
|
|
@@ -365,8 +375,6 @@ export class NodeRequest implements SDKRequestInterface {
|
|
|
365
375
|
signal: abortController.signal,
|
|
366
376
|
})
|
|
367
377
|
|
|
368
|
-
console.log('======fetchOptions', url, fetchOptions)
|
|
369
|
-
|
|
370
378
|
const res = await fetch(url, fetchOptions as RequestInit)
|
|
371
379
|
.then((x) => {
|
|
372
380
|
clearTimeout(timer)
|
|
@@ -451,8 +459,6 @@ export class NodeRequest implements SDKRequestInterface {
|
|
|
451
459
|
signal,
|
|
452
460
|
})
|
|
453
461
|
|
|
454
|
-
console.log('======requestOptions', realUrl, requestOptions)
|
|
455
|
-
|
|
456
462
|
try {
|
|
457
463
|
const response = await fetch(realUrl, requestOptions as RequestInit)
|
|
458
464
|
const result: ResponseObject = {
|
package/webpack/web.prod.js
CHANGED