@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/app",
3
- "version": "3.3.8",
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.8",
47
- "@cloudbase/utilities": "3.3.8"
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": "4f541a7d5c351d74996ebbde2deeac3bc3ee9eb1"
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 || 'CLOUD_API'
104
+ config.endPointMode = config.endPointMode || 'GATEWAY'
105
105
 
106
106
  // 初始化时若未兼容平台,则使用默认adapter
107
107
  if (!Platform.adapter) {
@@ -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 () => this.reqClass.fetch({
351
- headers: {
352
- // 'Content-Type': 'application/json',
353
- // 'X-Request-Id': `${utils.generateRequestId()}`,
354
- // 'X-Request-Timestamp': `${Date.now()}`,
355
- 'X-SDK-Version': `@cloudbase/js-sdk/${getSdkVersion()}`,
356
- Authorization: `Bearer ${await this.getAccessToken(token)}`,
357
- ...this.getDefaultHeaders(),
358
- ...headers,
359
- },
360
- ...restOptions,
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()