@geek-fun/serverlessinsight 0.6.10 → 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/README.md CHANGED
@@ -333,10 +333,13 @@ When binding a custom domain that requires ownership verification:
333
333
 
334
334
  For OSS static website hosting, ServerlessInsight supports:
335
335
 
336
- | Domain Type | CNAME Target | Use Case |
337
- | ----------------- | -------------------------------- | ---------------------------------------------- |
338
- | Root domain (`@`) | `bucket.region.taihangcda.cn` | Bypasses DNS CNAME restriction on root domains |
339
- | Subdomain (`www`) | `bucket.oss-region.aliyuncs.com` | Standard OSS endpoint |
336
+ | Domain Type | CNAME Target | Use Case |
337
+ | ----------------- | ----------------------------- | ---------------------------------------------- |
338
+ | Root domain (`@`) | `bucket.region.taihangcda.cn` | Bypasses DNS CNAME restriction on root domains |
339
+ | Subdomain (`www`) | `bucket.region.taihangcda.cn` | Standard CNAME for all subdomains |
340
+ | Any subdomain | `bucket.region.taihangcda.cn` | Unified CNAME endpoint for all domain types |
341
+
342
+ > 💡 **Note**: All domain types now use the recommended `taihangcda.cn` CNAME endpoint, which is derived automatically from your bucket's actual extranet endpoint via the `GetBucketInfo` API.
340
343
 
341
344
  For detailed configuration, see [OSS Custom Domain Binding Guide](./docs/oss-custom-domain-binding.md).
342
345
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.6.10",
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,8 +40,19 @@ const createOssOperations = (ossClient, region, dnsOps) => {
40
40
  const useBucket = (bucketName) => {
41
41
  ossClient.useBucket(bucketName);
42
42
  };
43
- const getOssEndpoint = (bucketName) => {
44
- return `${bucketName}.oss-${region}.aliyuncs.com`;
43
+ const getBucketCnameEndpoint = async (bucketName) => {
44
+ const infoResult = await ossClient.getBucketInfo(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 }));
50
+ }
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`;
45
56
  };
46
57
  const buildCertificateXml = (cert) => {
47
58
  if (!cert)
@@ -222,26 +233,27 @@ const createOssOperations = (ossClient, region, dnsOps) => {
222
233
  }
223
234
  };
224
235
  const bindCustomDomain = async (bucketName, domain, certificate) => {
225
- const mainDomain = (0, domainUtils_1.extractMainDomain)(domain);
226
- const hostRecord = (0, domainUtils_1.extractHostRecord)(domain, mainDomain);
227
- const ossEndpoint = getOssEndpoint(bucketName);
228
- let cnameResult = await putBucketCname(bucketName, domain, certificate);
236
+ const normalizedDomain = (0, domainUtils_1.normalizeDomain)(domain);
237
+ const mainDomain = (0, domainUtils_1.extractMainDomain)(normalizedDomain);
238
+ const hostRecord = (0, domainUtils_1.extractHostRecord)(normalizedDomain, mainDomain);
239
+ const ossEndpoint = await getBucketCnameEndpoint(bucketName);
240
+ let cnameResult = await putBucketCname(bucketName, normalizedDomain, certificate);
229
241
  let txtRecordId;
230
242
  if (cnameResult.needVerification) {
231
- const verificationResult = await handleDomainOwnershipVerification(bucketName, domain, certificate);
243
+ const verificationResult = await handleDomainOwnershipVerification(bucketName, normalizedDomain, certificate);
232
244
  cnameResult = verificationResult;
233
245
  txtRecordId = verificationResult.txtRecordId;
234
246
  }
235
247
  const bucketCnameBound = cnameResult.success;
236
248
  if (certificate && bucketCnameBound) {
237
- logger_1.logger.info(lang_1.lang.__('OSS_BUCKET_CERT_BOUND', { domain }));
249
+ logger_1.logger.info(lang_1.lang.__('OSS_BUCKET_CERT_BOUND', { domain: normalizedDomain }));
238
250
  }
239
- await addCorsRuleForDomain(bucketName, domain);
251
+ await addCorsRuleForDomain(bucketName, normalizedDomain);
240
252
  if (!dnsOps) {
241
- logger_1.logger.warn(lang_1.lang.__('OSS_DNS_MANUAL_CONFIG_REQUIRED', { domain, cname: ossEndpoint }));
242
- return { domain, cname: ossEndpoint, bucketCnameBound, txtRecordId };
253
+ logger_1.logger.warn(lang_1.lang.__('OSS_DNS_MANUAL_CONFIG_REQUIRED', { domain: normalizedDomain, cname: ossEndpoint }));
254
+ return { domain: normalizedDomain, cname: ossEndpoint, bucketCnameBound, txtRecordId };
243
255
  }
244
- const result = await createOrFindDnsCnameRecord(domain, mainDomain, hostRecord, ossEndpoint, bucketCnameBound);
256
+ const result = await createOrFindDnsCnameRecord(normalizedDomain, mainDomain, hostRecord, ossEndpoint, bucketCnameBound);
245
257
  return { ...result, txtRecordId };
246
258
  };
247
259
  const logOssVerificationInstructions = (domain, fullTxtRecord, token) => {
@@ -255,7 +267,7 @@ const createOssOperations = (ossClient, region, dnsOps) => {
255
267
  const tokenInfo = await createCnameToken(bucketName, domain);
256
268
  const txtRecordName = '_dnsauth';
257
269
  const hostRecord = (0, domainUtils_1.extractHostRecord)(domain, (0, domainUtils_1.extractMainDomain)(domain));
258
- const fullTxtRecord = hostRecord ? `${txtRecordName}.${hostRecord}` : txtRecordName;
270
+ const fullTxtRecord = hostRecord && hostRecord !== '@' ? `${txtRecordName}.${hostRecord}` : txtRecordName;
259
271
  logger_1.logger.info(lang_1.lang.__('OSS_CNAME_VERIFICATION_TOKEN_CREATED', {
260
272
  domain,
261
273
  txtRecord: fullTxtRecord,
@@ -377,7 +389,7 @@ const createOssOperations = (ossClient, region, dnsOps) => {
377
389
  }
378
390
  const hostRecord = (0, domainUtils_1.extractHostRecord)(domain, (0, domainUtils_1.extractMainDomain)(domain));
379
391
  const txtRecordName = '_dnsauth';
380
- const fullTxtRecord = hostRecord ? `${txtRecordName}.${hostRecord}` : txtRecordName;
392
+ const fullTxtRecord = hostRecord && hostRecord !== '@' ? `${txtRecordName}.${hostRecord}` : txtRecordName;
381
393
  logger_1.logger.warn(lang_1.lang.__('OSS_CNAME_VERIFICATION_RETRY_FAILED', {
382
394
  domain,
383
395
  txtRecord: `${fullTxtRecord}.${(0, domainUtils_1.extractMainDomain)(domain)}`,
@@ -699,7 +711,6 @@ const createOssOperations = (ossClient, region, dnsOps) => {
699
711
  },
700
712
  bindCustomDomain,
701
713
  unbindCustomDomain,
702
- getOssEndpoint,
703
714
  createCnameToken,
704
715
  };
705
716
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deriveWwwDomain = exports.extractHostRecord = exports.extractMainDomain = void 0;
3
+ exports.deriveWwwDomain = exports.extractHostRecord = exports.extractMainDomain = exports.normalizeDomain = void 0;
4
4
  const MULTI_LEVEL_TLDS = new Set([
5
5
  // United Kingdom
6
6
  'co.uk',
@@ -93,6 +93,13 @@ const MULTI_LEVEL_TLDS = new Set([
93
93
  'gov.sg',
94
94
  'edu.sg',
95
95
  ]);
96
+ const normalizeDomain = (domain) => {
97
+ if (domain.startsWith('@.')) {
98
+ return domain.slice(2);
99
+ }
100
+ return domain;
101
+ };
102
+ exports.normalizeDomain = normalizeDomain;
96
103
  const extractMainDomain = (domainName) => {
97
104
  const parts = domainName.split('.');
98
105
  if (parts.length <= 2) {
@@ -329,6 +329,8 @@ exports.en = {
329
329
  OSS_BUCKET_PUBLIC_ACCESS_BLOCK_DISABLED: 'Disabled Block Public Access for bucket: {{bucketName}}',
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
+ OSS_BUCKET_EXTRANET_ENDPOINT_NOT_FOUND: 'ExtranetEndpoint not found for bucket: {{bucketName}}. The bucket may not have public access enabled.',
333
+ OSS_BUCKET_LOCATION_NOT_FOUND: 'Location not found for bucket: {{bucketName}}',
332
334
  // Tencent COS DNS messages
333
335
  COS_DNS_CNAME_CREATED: 'Created DNS CNAME record: {{domain}} -> {{cname}}',
334
336
  COS_DNS_CNAME_EXISTS: 'DNS CNAME record already exists: {{domain}} -> {{cname}}',
@@ -326,7 +326,9 @@ exports.zhCN = {
326
326
  OSS_CORS_RULE_REMOVED: '已移除自定义域名的 CORS 规则: {{domain}}',
327
327
  OSS_CORS_RULE_REMOVE_FAILED: '移除 {{domain}} 的 CORS 规则失败: {{error}}',
328
328
  OSS_BUCKET_PUBLIC_ACCESS_BLOCK_DISABLED: '已为存储桶禁用公共访问阻止: {{bucketName}}',
329
- OSS_BUCKET_PUBLIC_ACCESS_BLOCK_DISABLE_FAILED: '禁用存储桶 {{bucketName}} 的公共访问阻止失败: {{error}}。您可能需要在阿里云 OSS 控制台手动禁用公共访问阻止。',
329
+ OSS_BUCKET_PUBLIC_ACCESS_BLOCK_DISABLE_FAILED: '禁用存储桶 {{bucketName}} 的公共访问阻止失败:{{error}}。您可能需要在阿里云 OSS 控制台手动禁用公共访问阻止。',
330
+ OSS_BUCKET_EXTRANET_ENDPOINT_NOT_FOUND: '存储桶 {{bucketName}} 未找到外网访问端点。该存储桶可能未启用公共访问。',
331
+ OSS_BUCKET_LOCATION_NOT_FOUND: '存储桶 {{bucketName}} 未找到地域信息',
330
332
  // Tencent COS DNS messages
331
333
  COS_DNS_CNAME_CREATED: '已创建 DNS CNAME 记录: {{domain}} -> {{cname}}',
332
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.10",
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",