@cloudbase/app 3.3.8 → 3.3.10
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/request.d.ts +1 -0
- package/dist/cjs/libs/request.js +21 -19
- package/dist/esm/index.js +2 -2
- package/dist/esm/libs/request.d.ts +1 -0
- package/dist/esm/libs/request.js +21 -19
- package/dist/miniprogram/index.js +1 -1
- package/package.json +4 -4
- package/src/index.ts +1 -1
- package/src/libs/request.ts +20 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/app",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.10",
|
|
4
4
|
"description": "cloudbase javascript sdk core",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@cloudbase/adapter-interface": "^0.7.1",
|
|
45
45
|
"@cloudbase/adapter-wx_mp": "^1.3.1",
|
|
46
|
-
"@cloudbase/types": "3.3.
|
|
47
|
-
"@cloudbase/utilities": "3.3.
|
|
46
|
+
"@cloudbase/types": "3.3.10",
|
|
47
|
+
"@cloudbase/utilities": "3.3.10"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@cloudbase/signature-nodejs": ">=1.0.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"optional": true
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "70c46f1b2aa84ef7f2f387f7b242495a64986b21"
|
|
66
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -101,7 +101,7 @@ class Cloudbase implements ICloudbase {
|
|
|
101
101
|
],
|
|
102
102
|
})
|
|
103
103
|
public init(config: ICloudbaseConfig & { lang?: LANGS } = { env: '' }): Cloudbase {
|
|
104
|
-
config.endPointMode = config.endPointMode || '
|
|
104
|
+
config.endPointMode = config.endPointMode || 'GATEWAY'
|
|
105
105
|
|
|
106
106
|
// 初始化时若未兼容平台,则使用默认adapter
|
|
107
107
|
if (!Platform.adapter) {
|
package/src/libs/request.ts
CHANGED
|
@@ -344,21 +344,27 @@ export class CloudbaseRequest implements ICloudbaseRequest {
|
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
public async fetch(options: IFetchOptions & { token?: string; customReqOpts?: ICustomReqOpts },): Promise<ResponseObject> {
|
|
348
|
-
const { token, headers = {}, ...restOptions } = options
|
|
347
|
+
public async fetch(options: IFetchOptions & { token?: string; withCredentials?: boolean; customReqOpts?: ICustomReqOpts },): Promise<ResponseObject> {
|
|
348
|
+
const { token, headers = {}, withCredentials = true, ...restOptions } = options
|
|
349
349
|
|
|
350
|
-
const doFetch = async () =>
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
350
|
+
const doFetch = async () => {
|
|
351
|
+
const authHeaders: Record<string, string> = {}
|
|
352
|
+
if (withCredentials) {
|
|
353
|
+
authHeaders.Authorization = `Bearer ${await this.getAccessToken(token)}`
|
|
354
|
+
}
|
|
355
|
+
return this.reqClass.fetch({
|
|
356
|
+
headers: {
|
|
357
|
+
// 'Content-Type': 'application/json',
|
|
358
|
+
// 'X-Request-Id': `${utils.generateRequestId()}`,
|
|
359
|
+
// 'X-Request-Timestamp': `${Date.now()}`,
|
|
360
|
+
'X-SDK-Version': `@cloudbase/js-sdk/${getSdkVersion()}`,
|
|
361
|
+
...authHeaders,
|
|
362
|
+
...this.getDefaultHeaders(),
|
|
363
|
+
...headers,
|
|
364
|
+
},
|
|
365
|
+
...restOptions,
|
|
366
|
+
})
|
|
367
|
+
}
|
|
362
368
|
|
|
363
369
|
try {
|
|
364
370
|
const result = await doFetch()
|