@cloudbase/manager-node 4.1.1 → 4.1.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.
- package/lib/constant.js +3 -1
- package/lib/env/index.js +6 -2
- package/lib/storage/index.js +6 -2
- package/package.json +1 -1
- package/types/constant.d.ts +1 -0
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.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_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;
|
|
8
8
|
exports.ENV_NAME = {
|
|
9
9
|
ENV_SECRETID: 'TENCENTCLOUD_SECRETID',
|
|
10
10
|
ENV_SECRETKEY: 'TENCENTCLOUD_SECRETKEY',
|
|
@@ -51,3 +51,5 @@ exports.SCF_STATUS = {
|
|
|
51
51
|
};
|
|
52
52
|
// 是否使用内网域名
|
|
53
53
|
exports.USE_INTERNAL_ENDPOINT = "USE_INTERNAL_ENDPOINT" in process.env;
|
|
54
|
+
// 允许通过环境变量指定 COS SDK 的协议为 HTTPS 或 HTTP
|
|
55
|
+
exports.COS_SDK_PROTOCOL = "COS_SDK_PROTOCOL";
|
package/lib/env/index.js
CHANGED
|
@@ -255,12 +255,16 @@ class EnvService {
|
|
|
255
255
|
}
|
|
256
256
|
getCos() {
|
|
257
257
|
const { secretId, secretKey, token } = this.environment.getAuthConfig();
|
|
258
|
-
|
|
258
|
+
const cosConfig = {
|
|
259
259
|
SecretId: secretId,
|
|
260
260
|
SecretKey: secretKey,
|
|
261
261
|
SecurityToken: token,
|
|
262
262
|
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* PUBLIC */
|
|
263
|
-
}
|
|
263
|
+
};
|
|
264
|
+
if (constant_1.COS_SDK_PROTOCOL in process.env && process.env.COS_SDK_PROTOCOL.toLowerCase().startsWith('http')) {
|
|
265
|
+
cosConfig.Protocol = process.env.COS_SDK_PROTOCOL.toLowerCase() + ":";
|
|
266
|
+
}
|
|
267
|
+
return new cos_nodejs_sdk_v5_1.default(cosConfig);
|
|
264
268
|
}
|
|
265
269
|
getStorageConfig() {
|
|
266
270
|
var _a;
|
package/lib/storage/index.js
CHANGED
|
@@ -840,14 +840,18 @@ class StorageService {
|
|
|
840
840
|
getCos(parallel = 20) {
|
|
841
841
|
const { secretId, secretKey, token, proxy } = this.environment.getAuthConfig();
|
|
842
842
|
const cosProxy = process.env.TCB_COS_PROXY;
|
|
843
|
-
|
|
843
|
+
const cosConfig = {
|
|
844
844
|
FileParallelLimit: parallel,
|
|
845
845
|
SecretId: secretId,
|
|
846
846
|
SecretKey: secretKey,
|
|
847
847
|
Proxy: cosProxy || proxy,
|
|
848
848
|
SecurityToken: token,
|
|
849
849
|
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* PUBLIC */
|
|
850
|
-
}
|
|
850
|
+
};
|
|
851
|
+
if (constant_1.COS_SDK_PROTOCOL in process.env && process.env.COS_SDK_PROTOCOL.toLowerCase().startsWith('http')) {
|
|
852
|
+
cosConfig.Protocol = process.env.COS_SDK_PROTOCOL.toLowerCase() + ":";
|
|
853
|
+
}
|
|
854
|
+
return new cos_nodejs_sdk_v5_1.default(cosConfig);
|
|
851
855
|
}
|
|
852
856
|
/**
|
|
853
857
|
* 将 cloudPath 转换成 cloudPath/ 形式
|
package/package.json
CHANGED
package/types/constant.d.ts
CHANGED