@geek-fun/serverlessinsight 0.6.11 → 0.6.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.6.11",
3
+ "version": "0.6.12",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.geekfun.club",
6
6
  "main": "dist/src/index.js",
@@ -40,27 +40,19 @@ const createOssOperations = (ossClient, region, dnsOps) => {
40
40
  const useBucket = (bucketName) => {
41
41
  ossClient.useBucket(bucketName);
42
42
  };
43
- const getBucketExtranetEndpoint = async (bucketName) => {
43
+ const getBucketCnameEndpoint = async (bucketName) => {
44
44
  const infoResult = await ossClient.getBucketInfo(bucketName);
45
- const endpoint = infoResult.bucket.ExtranetEndpoint;
46
- if (!endpoint) {
47
- throw new Error(lang_1.lang.__('OSS_BUCKET_EXTRANET_ENDPOINT_NOT_FOUND', { bucketName }));
45
+ const bucket = infoResult.bucket;
46
+ const actualBucketName = bucket.Name || bucketName;
47
+ const location = bucket.Location;
48
+ if (!location) {
49
+ throw new Error(lang_1.lang.__('OSS_BUCKET_LOCATION_NOT_FOUND', { bucketName }));
48
50
  }
49
- return endpoint;
50
- };
51
- const getCnameEndpointFromExtranet = (extranetEndpoint) => {
52
- const suffix = '.aliyuncs.com';
53
- if (!extranetEndpoint.endsWith(suffix)) {
54
- throw new Error(lang_1.lang.__('OSS_BUCKET_ENDPOINT_INVALID_FORMAT', { extranetEndpoint }));
55
- }
56
- const withoutAliyun = extranetEndpoint.slice(0, -suffix.length);
57
- const lastDotIndex = withoutAliyun.lastIndexOf('.');
58
- if (lastDotIndex <= 0) {
59
- throw new Error(lang_1.lang.__('OSS_BUCKET_ENDPOINT_INVALID_FORMAT', { extranetEndpoint }));
60
- }
61
- const bucketPart = withoutAliyun.slice(0, lastDotIndex);
62
- const regionWithout = withoutAliyun.slice(lastDotIndex + 1).replace(/^oss-/, '');
63
- return `${bucketPart}.${regionWithout}.taihangcda.cn`;
51
+ const derivedRegion = location.replace(/^oss-/, '');
52
+ const isChinaRegion = derivedRegion.startsWith('cn-');
53
+ return isChinaRegion
54
+ ? `${actualBucketName}.${derivedRegion}.taihangcda.cn`
55
+ : `${actualBucketName}.oss-${derivedRegion}.aliyuncs.com`;
64
56
  };
65
57
  const buildCertificateXml = (cert) => {
66
58
  if (!cert)
@@ -244,8 +236,7 @@ const createOssOperations = (ossClient, region, dnsOps) => {
244
236
  const normalizedDomain = (0, domainUtils_1.normalizeDomain)(domain);
245
237
  const mainDomain = (0, domainUtils_1.extractMainDomain)(normalizedDomain);
246
238
  const hostRecord = (0, domainUtils_1.extractHostRecord)(normalizedDomain, mainDomain);
247
- const extranetEndpoint = await getBucketExtranetEndpoint(bucketName);
248
- const ossEndpoint = getCnameEndpointFromExtranet(extranetEndpoint);
239
+ const ossEndpoint = await getBucketCnameEndpoint(bucketName);
249
240
  let cnameResult = await putBucketCname(bucketName, normalizedDomain, certificate);
250
241
  let txtRecordId;
251
242
  if (cnameResult.needVerification) {
@@ -276,7 +267,7 @@ const createOssOperations = (ossClient, region, dnsOps) => {
276
267
  const tokenInfo = await createCnameToken(bucketName, domain);
277
268
  const txtRecordName = '_dnsauth';
278
269
  const hostRecord = (0, domainUtils_1.extractHostRecord)(domain, (0, domainUtils_1.extractMainDomain)(domain));
279
- const fullTxtRecord = hostRecord ? `${txtRecordName}.${hostRecord}` : txtRecordName;
270
+ const fullTxtRecord = hostRecord && hostRecord !== '@' ? `${txtRecordName}.${hostRecord}` : txtRecordName;
280
271
  logger_1.logger.info(lang_1.lang.__('OSS_CNAME_VERIFICATION_TOKEN_CREATED', {
281
272
  domain,
282
273
  txtRecord: fullTxtRecord,
@@ -398,7 +389,7 @@ const createOssOperations = (ossClient, region, dnsOps) => {
398
389
  }
399
390
  const hostRecord = (0, domainUtils_1.extractHostRecord)(domain, (0, domainUtils_1.extractMainDomain)(domain));
400
391
  const txtRecordName = '_dnsauth';
401
- const fullTxtRecord = hostRecord ? `${txtRecordName}.${hostRecord}` : txtRecordName;
392
+ const fullTxtRecord = hostRecord && hostRecord !== '@' ? `${txtRecordName}.${hostRecord}` : txtRecordName;
402
393
  logger_1.logger.warn(lang_1.lang.__('OSS_CNAME_VERIFICATION_RETRY_FAILED', {
403
394
  domain,
404
395
  txtRecord: `${fullTxtRecord}.${(0, domainUtils_1.extractMainDomain)(domain)}`,
@@ -330,7 +330,7 @@ exports.en = {
330
330
  OSS_BUCKET_PUBLIC_ACCESS_BLOCK_DISABLE_FAILED: 'Failed to disable Block Public Access for bucket {{bucketName}}: {{error}}. ' +
331
331
  'You may need to manually disable Block Public Access in the Alibaba Cloud OSS Console.',
332
332
  OSS_BUCKET_EXTRANET_ENDPOINT_NOT_FOUND: 'ExtranetEndpoint not found for bucket: {{bucketName}}. The bucket may not have public access enabled.',
333
- OSS_BUCKET_ENDPOINT_INVALID_FORMAT: 'Invalid OSS endpoint format: {{extranetEndpoint}}. Expected format: {bucket}.oss-{region}.aliyuncs.com',
333
+ OSS_BUCKET_LOCATION_NOT_FOUND: 'Location not found for bucket: {{bucketName}}',
334
334
  // Tencent COS DNS messages
335
335
  COS_DNS_CNAME_CREATED: 'Created DNS CNAME record: {{domain}} -> {{cname}}',
336
336
  COS_DNS_CNAME_EXISTS: 'DNS CNAME record already exists: {{domain}} -> {{cname}}',
@@ -328,7 +328,7 @@ exports.zhCN = {
328
328
  OSS_BUCKET_PUBLIC_ACCESS_BLOCK_DISABLED: '已为存储桶禁用公共访问阻止: {{bucketName}}',
329
329
  OSS_BUCKET_PUBLIC_ACCESS_BLOCK_DISABLE_FAILED: '禁用存储桶 {{bucketName}} 的公共访问阻止失败:{{error}}。您可能需要在阿里云 OSS 控制台手动禁用公共访问阻止。',
330
330
  OSS_BUCKET_EXTRANET_ENDPOINT_NOT_FOUND: '存储桶 {{bucketName}} 未找到外网访问端点。该存储桶可能未启用公共访问。',
331
- OSS_BUCKET_ENDPOINT_INVALID_FORMAT: 'OSS 端点格式无效:{{extranetEndpoint}}。预期格式:{bucket}.oss-{region}.aliyuncs.com',
331
+ OSS_BUCKET_LOCATION_NOT_FOUND: '存储桶 {{bucketName}} 未找到地域信息',
332
332
  // Tencent COS DNS messages
333
333
  COS_DNS_CNAME_CREATED: '已创建 DNS CNAME 记录: {{domain}} -> {{cname}}',
334
334
  COS_DNS_CNAME_EXISTS: 'DNS CNAME 记录已存在: {{domain}} -> {{cname}}',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.6.11",
3
+ "version": "0.6.12",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.geekfun.club",
6
6
  "main": "dist/src/index.js",