@cloudbase/manager-node 4.7.0 → 4.7.1

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/lib/constant.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // static credentail = 'credential'
5
5
  // }
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.COS_SDK_KEEPALIVE = exports.COS_SDK_PROTOCOL = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
7
+ exports.COS_SDK_KEEPALIVE = exports.COS_SDK_PROTOCOL = exports.INTERNAL_ENDPOINT_REGION = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
8
8
  exports.ENV_NAME = {
9
9
  ENV_SECRETID: 'TENCENTCLOUD_SECRETID',
10
10
  ENV_SECRETKEY: 'TENCENTCLOUD_SECRETKEY',
@@ -56,5 +56,6 @@ exports.SCF_STATUS = {
56
56
  };
57
57
  // 是否使用内网域名
58
58
  exports.USE_INTERNAL_ENDPOINT = "USE_INTERNAL_ENDPOINT" in process.env;
59
+ exports.INTERNAL_ENDPOINT_REGION = process.env.INTERNAL_ENDPOINT_REGION;
59
60
  exports.COS_SDK_PROTOCOL = process.env.COS_SDK_PROTOCOL;
60
61
  exports.COS_SDK_KEEPALIVE = process.env.COS_SDK_KEEPALIVE;
package/lib/context.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CloudBaseContext = void 0;
4
4
  const constant_1 = require("./constant");
5
5
  class CloudBaseContext {
6
- constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined }) {
6
+ constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined, internalEndpointRegion = undefined }) {
7
7
  this.secretId = secretId;
8
8
  this.secretKey = secretKey;
9
9
  this.token = token;
@@ -11,9 +11,13 @@ class CloudBaseContext {
11
11
  this.region = region;
12
12
  this.envType = envType;
13
13
  this.useInternalEndpoint = useInternalEndpoint;
14
+ this.internalEndpointRegion = internalEndpointRegion;
14
15
  }
15
16
  isInternalEndpoint() {
16
17
  return this.useInternalEndpoint !== undefined ? this.useInternalEndpoint : constant_1.USE_INTERNAL_ENDPOINT;
17
18
  }
19
+ getInternalEndpointRegion() {
20
+ return this.internalEndpointRegion || constant_1.INTERNAL_ENDPOINT_REGION;
21
+ }
18
22
  }
19
23
  exports.CloudBaseContext = CloudBaseContext;
package/lib/index.js CHANGED
@@ -18,7 +18,7 @@ class CloudBase {
18
18
  }
19
19
  constructor(config = {}) {
20
20
  this.cloudBaseConfig = {};
21
- let { secretId, secretKey, token, envId, proxy, region, envType, useInternalEndpoint } = config;
21
+ let { secretId, secretKey, token, envId, proxy, region, envType, useInternalEndpoint, internalEndpointRegion } = config;
22
22
  // config 中传入的 secretId secretkey 必须同时存在
23
23
  if ((secretId && !secretKey) || (!secretId && secretKey)) {
24
24
  throw new Error('secretId and secretKey must be a pair');
@@ -31,7 +31,8 @@ class CloudBase {
31
31
  envType,
32
32
  proxy,
33
33
  region,
34
- useInternalEndpoint
34
+ useInternalEndpoint,
35
+ internalEndpointRegion,
35
36
  };
36
37
  // 初始化 context
37
38
  this.context = new context_1.CloudBaseContext(this.cloudBaseConfig);
@@ -62,6 +62,7 @@ class CloudService {
62
62
  }
63
63
  get baseUrl() {
64
64
  const internalEndpoint = this.cloudBaseContext.isInternalEndpoint();
65
+ const internalEndpointRegion = this.cloudBaseContext.getInternalEndpointRegion();
65
66
  const tcb = process.env.TCB_BASE_URL || 'https://tcb.tencentcloudapi.com';
66
67
  const urlMap = {
67
68
  tcb,
@@ -76,6 +77,9 @@ class CloudService {
76
77
  [service]: `https://${service}.internal.tencentcloudapi.com`,
77
78
  })).reduce((acc, cur) => (Object.assign(Object.assign({}, acc), cur)), {});
78
79
  if (internalEndpoint) {
80
+ if (internalEndpointRegion) {
81
+ return `https://${this.service}.${internalEndpointRegion}.tencentcloudapi.woa.com`;
82
+ }
79
83
  return intranetUrlMap[this.service] || `https://${this.service}.internal.tencentcloudapi.com`;
80
84
  }
81
85
  if (urlMap[this.service]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "4.7.0",
3
+ "version": "4.7.1",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -41,6 +41,7 @@ export declare const SCF_STATUS: {
41
41
  DELETE_FAILED: string;
42
42
  };
43
43
  export declare const USE_INTERNAL_ENDPOINT: boolean;
44
+ export declare const INTERNAL_ENDPOINT_REGION: string;
44
45
  export declare const enum COS_ENDPOINT {
45
46
  INTERNAL = "{Bucket}.cos-internal.{Region}.tencentcos.cn",
46
47
  PUBLIC = "{Bucket}.cos.{Region}.tencentcos.cn"
@@ -7,7 +7,8 @@ export declare class CloudBaseContext {
7
7
  readonly region: string;
8
8
  readonly envType: string;
9
9
  readonly useInternalEndpoint?: boolean;
10
- constructor({ secretId, secretKey, token, proxy, region, envType, useInternalEndpoint }: {
10
+ readonly internalEndpointRegion?: string;
11
+ constructor({ secretId, secretKey, token, proxy, region, envType, useInternalEndpoint, internalEndpointRegion }: {
11
12
  secretId?: string;
12
13
  secretKey?: string;
13
14
  token?: string;
@@ -15,6 +16,8 @@ export declare class CloudBaseContext {
15
16
  region?: string;
16
17
  envType?: string;
17
18
  useInternalEndpoint?: any;
19
+ internalEndpointRegion?: any;
18
20
  });
19
21
  isInternalEndpoint(): boolean;
22
+ getInternalEndpointRegion(): string;
20
23
  }
package/types/index.d.ts CHANGED
@@ -21,6 +21,7 @@ interface CloudBaseConfig {
21
21
  region?: string;
22
22
  envType?: string;
23
23
  useInternalEndpoint?: boolean;
24
+ internalEndpointRegion?: string;
24
25
  }
25
26
  declare class CloudBase {
26
27
  private static cloudBase;