@geek-fun/serverlessinsight 0.6.1 → 0.6.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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
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",
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.warnInlinePem = exports.readPemContent = exports.isFilePath = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const logger_1 = require("./logger");
10
+ const lang_1 = require("../lang");
11
+ const isFilePath = (value) => {
12
+ if (value.startsWith('./') || value.startsWith('../'))
13
+ return true;
14
+ return /\.(pem|crt|key)$/.test(value);
15
+ };
16
+ exports.isFilePath = isFilePath;
17
+ const readPemContent = (value) => {
18
+ if (!(0, exports.isFilePath)(value))
19
+ return value;
20
+ const filePath = node_path_1.default.resolve(process.cwd(), value);
21
+ if (!node_fs_1.default.existsSync(filePath)) {
22
+ throw new Error(lang_1.lang.__('CERT_FILE_NOT_FOUND', { filePath }));
23
+ }
24
+ logger_1.logger.info(lang_1.lang.__('CERT_READING_FILE', { filePath }));
25
+ return node_fs_1.default.readFileSync(filePath, 'utf-8');
26
+ };
27
+ exports.readPemContent = readPemContent;
28
+ const warnInlinePem = (value) => {
29
+ if (typeof value === 'string' && (value.includes('BEGIN') || value.includes('PRIVATE KEY'))) {
30
+ logger_1.logger.warn(lang_1.lang.__('CERT_INLINE_PEM_WARNING'));
31
+ }
32
+ };
33
+ exports.warnInlinePem = warnInlinePem;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getIacDefinition = exports.isCertificateDomain = exports.isFunctionDomain = exports.calcValue = exports.readCodeSize = exports.resolveCode = void 0;
6
+ exports.isFunctionDomain = exports.getIacDefinition = exports.calcValue = exports.readCodeSize = exports.resolveCode = void 0;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  const node_fs_1 = __importDefault(require("node:fs"));
9
9
  const lodash_1 = require("lodash");
@@ -83,19 +83,15 @@ const calcValue = (rawValue, ctx, iacVars) => {
83
83
  return inferType(value, isExactTemplateRef);
84
84
  };
85
85
  exports.calcValue = calcValue;
86
- const isFunctionDomain = (def) => 'name' in def;
87
- exports.isFunctionDomain = isFunctionDomain;
88
- const isCertificateDomain = (def) => !('name' in def);
89
- exports.isCertificateDomain = isCertificateDomain;
90
86
  const getIacDefinition = (iac, rawValue) => {
91
87
  const matchFn = rawValue.match(/^\$\{functions\.(\w+(\.\w+)?)}$/);
92
88
  if (matchFn?.length) {
93
89
  return iac.functions?.find((fc) => fc.key === matchFn[1]);
94
90
  }
95
- const matchCert = rawValue.match(/^\$\{certificates\.(\w+)}$/);
96
- if (matchCert?.length) {
97
- return iac.certificates?.find((cert) => cert.key === matchCert[1]);
98
- }
99
91
  return iac.functions?.find((fc) => fc.key === rawValue);
100
92
  };
101
93
  exports.getIacDefinition = getIacDefinition;
94
+ const isFunctionDomain = (def) => {
95
+ return def != null && typeof def.key === 'string';
96
+ };
97
+ exports.isFunctionDomain = isFunctionDomain;
@@ -31,5 +31,5 @@ __exportStar(require("./runtimeMapper"), exports);
31
31
  __exportStar(require("./hashUtils"), exports);
32
32
  __exportStar(require("./dependencyGraph"), exports);
33
33
  __exportStar(require("./sidUtils"), exports);
34
- __exportStar(require("./certificateResolver"), exports);
34
+ __exportStar(require("./certUtils"), exports);
35
35
  __exportStar(require("./planFormatter"), exports);
@@ -475,10 +475,12 @@ exports.en = {
475
475
  CERT_READING_FILE: 'Reading certificate file: {{filePath}}',
476
476
  CERT_PARSING_CERTIFICATES: 'Parsing certificates configuration',
477
477
  CERT_RESOLVING_REFERENCE: 'Resolving certificate reference "{{reference}}" for domain "{{domain}}"',
478
- CERT_REFERENCE_NOT_FOUND: 'Certificate reference "{{reference}}" could not be resolved. Ensure it is defined in the certificates block.',
478
+ CERT_REFERENCE_NOT_FOUND: 'Certificate reference "{{reference}}" could not be resolved.',
479
479
  CERT_RESOLVED_UPLOAD: 'Certificate "{{name}}" resolved as upload mode (PEM files provided)',
480
480
  CERT_RESOLVED_REFERENCE: 'Certificate "{{name}}" resolved as reference mode (certificate_id: {{certId}})',
481
481
  CERT_READING_PEM_FILES: 'Reading PEM files for certificate "{{name}}"',
482
+ // Certificate inline PEM warning
483
+ CERT_INLINE_PEM_WARNING: 'Security warning: certificate_private_key appears to contain inline PEM content. Consider using a file path (e.g., ./certs/server.key) instead for better security.',
482
484
  // CAS (Certificate Authority Service) messages
483
485
  CAS_UPLOADING_CERT: 'Uploading certificate "{{name}}" to CAS',
484
486
  CAS_CERT_UPLOADED: 'Certificate "{{name}}" uploaded to CAS (certId: {{certId}})',
@@ -503,7 +505,8 @@ exports.en = {
503
505
  SSL_CERT_DEPLOY_FAILED: 'Failed to deploy certificate to {{resourceType}} (certificateId: {{certificateId}}): {{error}}',
504
506
  COS_BUCKET_CERT_DEPLOYING: 'Deploying SSL certificate to COS bucket domain: {{domain}} (bucket: {{bucketName}})',
505
507
  COS_BUCKET_CERT_DEPLOYED: 'SSL certificate deployed to COS bucket domain: {{domain}}',
506
- TENCENT_CERT_REFERENCE_NOT_SUPPORTED: 'Certificate "{{name}}" uses certificate_id reference mode which is not yet supported for Tencent Cloud. Use certificate_body and private_key instead.',
508
+ TENCENT_CERT_REFERENCE_NOT_SUPPORTED: 'Certificate "{{name}}" uses certificate_id reference mode which is not yet supported for Tencent Cloud. Use certificate_body and certificate_private_key instead.',
509
+ BUCKET_DOMAIN_REQUIRED_FOR_CERT: 'Bucket "{{name}}" has certificate configuration but no domain is set. A domain is required when providing certificate information.',
507
510
  // Protocol messages
508
511
  PROTOCOL_INFERRED_REDIRECT: 'Protocol "{{protocol}}" inferred HTTP-to-HTTPS redirect: {{redirect}}',
509
512
  // Retry utility messages
@@ -471,10 +471,11 @@ exports.zhCN = {
471
471
  CERT_READING_FILE: '正在读取证书文件: {{filePath}}',
472
472
  CERT_PARSING_CERTIFICATES: '正在解析证书配置',
473
473
  CERT_RESOLVING_REFERENCE: '正在解析域名 "{{domain}}" 的证书引用 "{{reference}}"',
474
- CERT_REFERENCE_NOT_FOUND: '无法解析证书引用 "{{reference}}"。请确保它已在 certificates 块中定义。',
474
+ CERT_REFERENCE_NOT_FOUND: '无法解析证书引用 "{{reference}}"。',
475
475
  CERT_RESOLVED_UPLOAD: '证书 "{{name}}" 解析为上传模式(提供了 PEM 文件)',
476
476
  CERT_RESOLVED_REFERENCE: '证书 "{{name}}" 解析为引用模式(certificate_id: {{certId}})',
477
477
  CERT_READING_PEM_FILES: '正在读取证书 "{{name}}" 的 PEM 文件',
478
+ CERT_INLINE_PEM_WARNING: '安全警告:certificate_private_key 似乎包含内联 PEM 内容。建议使用文件路径(例如 ./certs/server.key)以提高安全性。',
478
479
  // CAS(证书授权服务)消息
479
480
  CAS_UPLOADING_CERT: '正在上传证书 "{{name}}" 到 CAS',
480
481
  CAS_CERT_UPLOADED: '证书 "{{name}}" 已上传到 CAS(certId: {{certId}})',
@@ -499,7 +500,8 @@ exports.zhCN = {
499
500
  SSL_CERT_DEPLOY_FAILED: '部署证书到 {{resourceType}} 失败(证书ID: {{certificateId}}):{{error}}',
500
501
  COS_BUCKET_CERT_DEPLOYING: '正在为 COS 存储桶域名部署 SSL 证书: {{domain}}(存储桶: {{bucketName}})',
501
502
  COS_BUCKET_CERT_DEPLOYED: 'SSL 证书已部署到 COS 存储桶域名: {{domain}}',
502
- TENCENT_CERT_REFERENCE_NOT_SUPPORTED: '证书 "{{name}}" 使用了 certificate_id 引用模式,腾讯云暂不支持该模式。请改用 certificate_body 和 private_key。',
503
+ TENCENT_CERT_REFERENCE_NOT_SUPPORTED: '证书 "{{name}}" 使用了 certificate_id 引用模式,腾讯云暂不支持该模式。请改用 certificate_body 和 certificate_private_key。',
504
+ BUCKET_DOMAIN_REQUIRED_FOR_CERT: '存储桶 "{{name}}" 已配置证书信息,但未设置域名。提供证书信息时必须设置域名。',
503
505
  // 协议消息
504
506
  PROTOCOL_INFERRED_REDIRECT: '协议 "{{protocol}}" 推断 HTTP 到 HTTPS 重定向:{{redirect}}',
505
507
  // 重试工具消息
@@ -6,14 +6,28 @@ const parseUtils_1 = require("./parseUtils");
6
6
  const isStructuredDomain = (domain) => typeof domain === 'object' && domain !== null && 'domain_name' in domain;
7
7
  const parseWebsiteDomain = (domain) => {
8
8
  if (domain == null) {
9
- return { domain: undefined, domain_certificate: undefined, domain_protocol: undefined };
9
+ return {
10
+ domain: undefined,
11
+ domain_certificate_id: undefined,
12
+ domain_certificate_body: undefined,
13
+ domain_certificate_private_key: undefined,
14
+ domain_protocol: undefined,
15
+ };
10
16
  }
11
17
  if (!isStructuredDomain(domain)) {
12
- return { domain: String(domain), domain_certificate: undefined, domain_protocol: undefined };
18
+ return {
19
+ domain: String(domain),
20
+ domain_certificate_id: undefined,
21
+ domain_certificate_body: undefined,
22
+ domain_certificate_private_key: undefined,
23
+ domain_protocol: undefined,
24
+ };
13
25
  }
14
26
  return {
15
27
  domain: String(domain.domain_name),
16
- domain_certificate: domain.certificate != null ? String(domain.certificate) : undefined,
28
+ domain_certificate_id: domain.certificate_id != null ? String(domain.certificate_id) : undefined,
29
+ domain_certificate_body: domain.certificate_body != null ? String(domain.certificate_body) : undefined,
30
+ domain_certificate_private_key: domain.certificate_private_key != null ? String(domain.certificate_private_key) : undefined,
17
31
  domain_protocol: domain.protocol != null
18
32
  ? Array.isArray(domain.protocol)
19
33
  ? domain.protocol.map(String)
@@ -11,7 +11,6 @@ const yaml_1 = require("yaml");
11
11
  const validator_1 = require("../validator");
12
12
  const bucketParser_1 = require("./bucketParser");
13
13
  const tableParser_1 = require("./tableParser");
14
- const certificateParser_1 = require("./certificateParser");
15
14
  const common_1 = require("../common");
16
15
  const validateExistence = (path) => {
17
16
  if (!(0, node_fs_1.existsSync)(path)) {
@@ -52,7 +51,6 @@ const transformYaml = (iacJson, stage) => {
52
51
  tables: (0, tableParser_1.parseTable)(iacJson.tables),
53
52
  tags: (0, tagParser_1.parseTag)(iacJson.tags, iacJson.app, iacJson.service, stage),
54
53
  buckets: (0, bucketParser_1.parseBucket)(iacJson.buckets),
55
- certificates: iacJson.certificates ? (0, certificateParser_1.parseCertificate)(iacJson.certificates) : undefined,
56
54
  };
57
55
  };
58
56
  const parseYaml = (iacLocation) => {
@@ -43,7 +43,7 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
43
43
  domain: event.domain
44
44
  ? {
45
45
  domainName: event.domain.domain_name,
46
- certificateName: event.domain.certificate_name,
46
+ hasCertificate: !!(event.domain.certificate_body || event.domain.certificate_id),
47
47
  }
48
48
  : null,
49
49
  };
@@ -5,6 +5,7 @@ const aliyunClient_1 = require("../../common/aliyunClient");
5
5
  const apigwTypes_1 = require("./apigwTypes");
6
6
  const stateManager_1 = require("../../common/stateManager");
7
7
  const common_1 = require("../../common");
8
+ const certUtils_1 = require("../../common/certUtils");
8
9
  const logger_1 = require("../../common/logger");
9
10
  const lang_1 = require("../../lang");
10
11
  const buildApigwGroupInstanceFromProvider = (info, stage) => {
@@ -56,35 +57,33 @@ const buildApigwDeploymentInstance = (groupId, apiId, stageName, stage) => {
56
57
  stageName,
57
58
  };
58
59
  };
59
- const resolveDomainCertificate = async (domain, context, client) => {
60
- if (domain.certificate) {
61
- if (!context.iac) {
62
- throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: String(domain.certificate) }));
60
+ const resolveDomainCertificate = async (domain, serviceName, eventKey, stage, client) => {
61
+ if (domain.certificate_id) {
62
+ const certId = domain.certificate_id;
63
+ const detail = await client.cas.getCertificate(certId);
64
+ if (!detail || !detail.cert || !detail.key) {
65
+ throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: certId }));
63
66
  }
64
- const certDef = (0, common_1.getIacDefinition)(context.iac, domain.certificate);
65
- if (!certDef || !(0, common_1.isCertificateDomain)(certDef)) {
66
- throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: String(domain.certificate) }));
67
- }
68
- const resolved = await (0, common_1.resolveCertificateDomain)(certDef, async (certId) => {
69
- const detail = await client.cas.getCertificate(certId);
70
- if (!detail)
71
- return null;
72
- return { cert: detail.cert, key: detail.key };
73
- });
74
67
  return {
75
- certificateName: resolved.certificateName,
76
- certificateBody: resolved.certificateBody,
77
- certificatePrivateKey: resolved.certificatePrivateKey,
68
+ certificateName: `${serviceName}-${stage}-apigw-${eventKey}`,
69
+ certificateBody: detail.cert,
70
+ certificatePrivateKey: detail.key,
78
71
  };
79
72
  }
80
- return {
81
- certificateName: domain.certificate_name,
82
- certificateBody: domain.certificate_body,
83
- certificatePrivateKey: domain.certificate_private_key,
84
- };
73
+ if (domain.certificate_body && domain.certificate_private_key) {
74
+ const body = (0, certUtils_1.readPemContent)(domain.certificate_body);
75
+ const key = (0, certUtils_1.readPemContent)(domain.certificate_private_key);
76
+ (0, certUtils_1.warnInlinePem)(domain.certificate_private_key);
77
+ return {
78
+ certificateName: `${serviceName}-${stage}-apigw-${eventKey}`,
79
+ certificateBody: body,
80
+ certificatePrivateKey: key,
81
+ };
82
+ }
83
+ return {};
85
84
  };
86
- const buildDomainBindingConfig = async (domain, groupId, context, client) => {
87
- const certConfig = await resolveDomainCertificate(domain, context, client);
85
+ const buildDomainBindingConfig = async (domain, groupId, serviceName, eventKey, stage, client) => {
86
+ const certConfig = await resolveDomainCertificate(domain, serviceName, eventKey, stage, client);
88
87
  const protocolConfig = (0, apigwTypes_1.inferProtocolConfig)(domain.protocol);
89
88
  return {
90
89
  groupId,
@@ -134,7 +133,7 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
134
133
  domain: event.domain
135
134
  ? {
136
135
  domainName: event.domain.domain_name,
137
- certificateName: event.domain.certificate_name,
136
+ hasCertificate: !!(event.domain.certificate_body || event.domain.certificate_id),
138
137
  }
139
138
  : null,
140
139
  },
@@ -173,7 +172,7 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
173
172
  domain: event.domain
174
173
  ? {
175
174
  domainName: event.domain.domain_name,
176
- certificateName: event.domain.certificate_name,
175
+ hasCertificate: !!(event.domain.certificate_body || event.domain.certificate_id),
177
176
  }
178
177
  : null,
179
178
  },
@@ -184,7 +183,7 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
184
183
  }
185
184
  if (event.domain) {
186
185
  try {
187
- const domainConfig = await buildDomainBindingConfig(event.domain, groupId, context, client);
186
+ const domainConfig = await buildDomainBindingConfig(event.domain, groupId, serviceName, event.key, context.stage, client);
188
187
  state = await client.apigw.bindCustomDomain(domainConfig, state, logicalId);
189
188
  }
190
189
  catch (error) {
@@ -208,7 +207,7 @@ const createApigwResource = async (context, event, serviceName, roleArn, state)
208
207
  domain: event.domain
209
208
  ? {
210
209
  domainName: event.domain.domain_name,
211
- certificateName: event.domain.certificate_name,
210
+ hasCertificate: !!(event.domain.certificate_body || event.domain.certificate_id),
212
211
  }
213
212
  : null,
214
213
  },
@@ -299,7 +298,7 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
299
298
  }
300
299
  }
301
300
  if (event.domain) {
302
- const domainConfig = await buildDomainBindingConfig(event.domain, groupId, context, client);
301
+ const domainConfig = await buildDomainBindingConfig(event.domain, groupId, serviceName, event.key, context.stage, client);
303
302
  state = await client.apigw.bindCustomDomain(domainConfig, state, logicalId);
304
303
  }
305
304
  const groupDefinition = (0, apigwTypes_1.extractApigwGroupDefinition)(groupConfig);
@@ -316,7 +315,7 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
316
315
  domain: event.domain
317
316
  ? {
318
317
  domainName: event.domain.domain_name,
319
- certificateName: event.domain.certificate_name,
318
+ hasCertificate: !!(event.domain.certificate_body || event.domain.certificate_id),
320
319
  }
321
320
  : null,
322
321
  },
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.deleteBucketResource = exports.updateBucketResource = exports.readBucketResource = exports.createBucketResource = void 0;
7
7
  const aliyunClient_1 = require("../../common/aliyunClient");
8
8
  const common_1 = require("../../common");
9
+ const certUtils_1 = require("../../common/certUtils");
9
10
  const types_1 = require("../../types");
10
11
  const ossTypes_1 = require("./ossTypes");
11
12
  const logger_1 = require("../../common/logger");
@@ -97,24 +98,25 @@ const buildOssInstanceFromProvider = (info, sid) => {
97
98
  })),
98
99
  };
99
100
  };
100
- const resolveBucketDomainCertificate = async (domainCertificate, context, client) => {
101
- if (!context.iac) {
102
- throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: domainCertificate }));
101
+ const resolveBucketDomainCertificate = async (bucket, client) => {
102
+ const website = bucket.website;
103
+ if (!website)
104
+ return undefined;
105
+ if (website.domain_certificate_id) {
106
+ const certId = website.domain_certificate_id;
107
+ const detail = await client.cas.getCertificate(certId);
108
+ if (!detail || !detail.cert || !detail.key) {
109
+ throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: certId }));
110
+ }
111
+ return { certificateBody: detail.cert, certificatePrivateKey: detail.key };
103
112
  }
104
- const certDef = (0, common_1.getIacDefinition)(context.iac, domainCertificate);
105
- if (!certDef || !(0, common_1.isCertificateDomain)(certDef)) {
106
- throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: domainCertificate }));
113
+ if (website.domain_certificate_body && website.domain_certificate_private_key) {
114
+ const body = (0, certUtils_1.readPemContent)(website.domain_certificate_body);
115
+ const key = (0, certUtils_1.readPemContent)(website.domain_certificate_private_key);
116
+ (0, certUtils_1.warnInlinePem)(website.domain_certificate_private_key);
117
+ return { certificateBody: body, certificatePrivateKey: key };
107
118
  }
108
- const resolved = await (0, common_1.resolveCertificateDomain)(certDef, async (certId) => {
109
- const detail = await client.cas.getCertificate(certId);
110
- if (!detail)
111
- return null;
112
- return { cert: detail.cert, key: detail.key };
113
- });
114
- return {
115
- certificateBody: resolved.certificateBody,
116
- certificatePrivateKey: resolved.certificatePrivateKey,
117
- };
119
+ return undefined;
118
120
  };
119
121
  const createBucketResource = async (context, bucket, state) => {
120
122
  const config = (0, ossTypes_1.bucketToOssBucketConfig)(bucket);
@@ -144,9 +146,7 @@ const createBucketResource = async (context, bucket, state) => {
144
146
  state = (0, common_1.setResource)(state, logicalId, partialResourceState);
145
147
  let cnameInfo;
146
148
  if (bucket.website?.domain) {
147
- const certificate = bucket.website.domain_certificate
148
- ? await resolveBucketDomainCertificate(bucket.website.domain_certificate, context, client)
149
- : undefined;
149
+ const certificate = await resolveBucketDomainCertificate(bucket, client);
150
150
  logger_1.logger.info(lang_1.lang.__('BINDING_CUSTOM_DOMAIN_TO_BUCKET', {
151
151
  domain: bucket.website.domain,
152
152
  bucketName: config.bucketName,
@@ -236,9 +236,7 @@ const updateBucketResource = async (context, bucket, state) => {
236
236
  if (domainChanged && existingDnsInstance) {
237
237
  await client.oss.unbindCustomDomain(config.bucketName, existingDnsInstance.domain, existingDnsInstance.dnsRecordId, existingDnsInstance.txtRecordId);
238
238
  }
239
- const certificate = bucket.website.domain_certificate
240
- ? await resolveBucketDomainCertificate(bucket.website.domain_certificate, context, client)
241
- : undefined;
239
+ const certificate = await resolveBucketDomainCertificate(bucket, client);
242
240
  logger_1.logger.info(lang_1.lang.__('BINDING_CUSTOM_DOMAIN_TO_BUCKET', {
243
241
  domain: bucket.website.domain,
244
242
  bucketName: config.bucketName,
@@ -5,21 +5,30 @@ const types_1 = require("../../types");
5
5
  const tencentClient_1 = require("../../common/tencentClient");
6
6
  const cosTypes_1 = require("./cosTypes");
7
7
  const common_1 = require("../../common");
8
- const certificateResolver_1 = require("../../common/certificateResolver");
8
+ const certUtils_1 = require("../../common/certUtils");
9
9
  const logger_1 = require("../../common/logger");
10
10
  const lang_1 = require("../../lang");
11
- const resolveBucketDomainCertificate = (domainCertificate, context) => {
12
- if (!context.iac) {
13
- throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: domainCertificate }));
11
+ const resolveBucketDomainCertificate = (bucket) => {
12
+ const website = bucket.website;
13
+ if (!website)
14
+ return undefined;
15
+ if (website.domain_certificate_id) {
16
+ throw new Error(lang_1.lang.__('TENCENT_CERT_REFERENCE_NOT_SUPPORTED', { name: bucket.key }));
14
17
  }
15
- const certDef = (0, common_1.getIacDefinition)(context.iac, domainCertificate);
16
- if (!certDef || !(0, common_1.isCertificateDomain)(certDef)) {
17
- throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: domainCertificate }));
18
- }
19
- if (certDef.certificate_id) {
20
- throw new Error(lang_1.lang.__('TENCENT_CERT_REFERENCE_NOT_SUPPORTED', { name: certDef.key }));
18
+ if (website.domain_certificate_body && website.domain_certificate_private_key) {
19
+ if (!website.domain) {
20
+ throw new Error(lang_1.lang.__('BUCKET_DOMAIN_REQUIRED_FOR_CERT', { name: bucket.key }));
21
+ }
22
+ const body = (0, certUtils_1.readPemContent)(website.domain_certificate_body);
23
+ const key = (0, certUtils_1.readPemContent)(website.domain_certificate_private_key);
24
+ (0, certUtils_1.warnInlinePem)(website.domain_certificate_private_key);
25
+ return {
26
+ certificateName: website.domain.replace(/\./g, '_'),
27
+ certificateBody: body,
28
+ certificatePrivateKey: key,
29
+ };
21
30
  }
22
- return (0, certificateResolver_1.resolveUploadCertificate)(certDef);
31
+ return undefined;
23
32
  };
24
33
  const deployCertificateToCosDomain = async (client, resolved, bucketName, domain, region) => {
25
34
  logger_1.logger.info(lang_1.lang.__('COS_BUCKET_CERT_DEPLOYING', { domain, bucketName }));
@@ -101,9 +110,7 @@ const createBucketResource = async (context, bucket, state) => {
101
110
  ];
102
111
  let cnameInfo;
103
112
  if (bucket.website?.domain) {
104
- const resolved = bucket.website.domain_certificate
105
- ? resolveBucketDomainCertificate(bucket.website.domain_certificate, context)
106
- : undefined;
113
+ const resolved = resolveBucketDomainCertificate(bucket);
107
114
  logger_1.logger.info(lang_1.lang.__('BINDING_CUSTOM_DOMAIN_TO_BUCKET', {
108
115
  domain: bucket.website.domain,
109
116
  bucketName: bucket.name,
@@ -171,9 +178,7 @@ const updateBucketResource = async (context, bucket, state) => {
171
178
  if (domainChanged && existingDnsInstance) {
172
179
  await client.cos.unbindCustomDomain(bucket.name, existingDnsInstance.domain, existingDnsInstance.dnsRecordId);
173
180
  }
174
- const resolved = bucket.website.domain_certificate
175
- ? resolveBucketDomainCertificate(bucket.website.domain_certificate, context)
176
- : undefined;
181
+ const resolved = resolveBucketDomainCertificate(bucket);
177
182
  logger_1.logger.info(lang_1.lang.__('BINDING_CUSTOM_DOMAIN_TO_BUCKET', {
178
183
  domain: bucket.website.domain,
179
184
  bucketName: bucket.name,
@@ -26,5 +26,4 @@ __exportStar(require("./domains/table"), exports);
26
26
  __exportStar(require("./domains/state"), exports);
27
27
  __exportStar(require("./domains/lock"), exports);
28
28
  __exportStar(require("./domains/backend"), exports);
29
- __exportStar(require("./domains/certificate"), exports);
30
29
  __exportStar(require("./assets"), exports);
@@ -59,7 +59,9 @@ exports.bucketSchema = {
59
59
  type: 'object',
60
60
  properties: {
61
61
  domain_name: { type: 'string' },
62
- certificate: { type: 'string' },
62
+ certificate_id: { type: 'string' },
63
+ certificate_body: { type: 'string' },
64
+ certificate_private_key: { type: 'string' },
63
65
  protocol: {
64
66
  oneOf: [
65
67
  { type: 'string', enum: ['HTTP', 'HTTPS'] },
@@ -74,6 +76,30 @@ exports.bucketSchema = {
74
76
  },
75
77
  required: ['domain_name'],
76
78
  additionalProperties: false,
79
+ oneOf: [
80
+ {
81
+ not: {
82
+ anyOf: [
83
+ { required: ['certificate_id'] },
84
+ { required: ['certificate_body'] },
85
+ { required: ['certificate_private_key'] },
86
+ ],
87
+ },
88
+ },
89
+ {
90
+ required: ['certificate_body', 'certificate_private_key'],
91
+ not: { required: ['certificate_id'] },
92
+ },
93
+ {
94
+ required: ['certificate_id'],
95
+ not: {
96
+ anyOf: [
97
+ { required: ['certificate_body'] },
98
+ { required: ['certificate_private_key'] },
99
+ ],
100
+ },
101
+ },
102
+ ],
77
103
  },
78
104
  ],
79
105
  },
@@ -26,10 +26,9 @@ exports.eventSchema = {
26
26
  required: ['domain_name'],
27
27
  properties: {
28
28
  domain_name: { type: 'string' },
29
- certificate_name: { type: 'string' },
29
+ certificate_id: { type: 'string' },
30
30
  certificate_body: { type: 'string' },
31
31
  certificate_private_key: { type: 'string' },
32
- certificate: { type: 'string' },
33
32
  protocol: {
34
33
  oneOf: [
35
34
  { type: 'string', enum: ['HTTP', 'HTTPS'] },
@@ -42,6 +41,30 @@ exports.eventSchema = {
42
41
  ],
43
42
  },
44
43
  },
44
+ oneOf: [
45
+ {
46
+ not: {
47
+ anyOf: [
48
+ { required: ['certificate_id'] },
49
+ { required: ['certificate_body'] },
50
+ { required: ['certificate_private_key'] },
51
+ ],
52
+ },
53
+ },
54
+ {
55
+ required: ['certificate_body', 'certificate_private_key'],
56
+ not: { required: ['certificate_id'] },
57
+ },
58
+ {
59
+ required: ['certificate_id'],
60
+ not: {
61
+ anyOf: [
62
+ { required: ['certificate_body'] },
63
+ { required: ['certificate_private_key'] },
64
+ ],
65
+ },
66
+ },
67
+ ],
45
68
  },
46
69
  },
47
70
  required: ['name', 'type', 'triggers'],
@@ -12,7 +12,6 @@ const eventSchema_1 = require("./eventSchema");
12
12
  const functionSchema_1 = require("./functionSchema");
13
13
  const bucketSchema_1 = require("./bucketSchema");
14
14
  const tableschema_1 = require("./tableschema");
15
- const certificateSchema_1 = require("./certificateSchema");
16
15
  const lang_1 = require("../lang");
17
16
  class IacSchemaErrors extends Error {
18
17
  constructor(errors) {
@@ -51,7 +50,6 @@ const validate = ajv
51
50
  .addSchema(databaseSchema_1.databaseSchema)
52
51
  .addSchema(tableschema_1.tableSchema)
53
52
  .addSchema(bucketSchema_1.bucketSchema)
54
- .addSchema(certificateSchema_1.certificateSchema)
55
53
  .compile(rootSchema_1.rootSchema);
56
54
  const validateRuntimeCompatibility = (iacJson) => {
57
55
  if (!iacJson.functions) {
@@ -99,9 +99,6 @@ exports.rootSchema = {
99
99
  tables: {
100
100
  $ref: 'https://serverlessinsight.geekfun.club/schemas/tableschema.json',
101
101
  },
102
- certificates: {
103
- $ref: 'https://serverlessinsight.geekfun.club/schemas/certificateschema.json',
104
- },
105
102
  backend: {
106
103
  type: 'object',
107
104
  properties: {
@@ -1 +1 @@
1
- {"root":["../src/index.ts","../src/commands/deploy.ts","../src/commands/destroy.ts","../src/commands/forceUnlock.ts","../src/commands/index.ts","../src/commands/local.ts","../src/commands/plan.ts","../src/commands/show.ts","../src/commands/validate.ts","../src/common/base64.ts","../src/common/certificateResolver.ts","../src/common/constants.ts","../src/common/context.ts","../src/common/credentials.ts","../src/common/domainUtils.ts","../src/common/fileUtils.ts","../src/common/getVersion.ts","../src/common/hashUtils.ts","../src/common/iacHelper.ts","../src/common/imsClient.ts","../src/common/index.ts","../src/common/lockManager.ts","../src/common/logger.ts","../src/common/planFormatter.ts","../src/common/providerEnum.ts","../src/common/requestHelper.ts","../src/common/retryUtils.ts","../src/common/runtimeMapper.ts","../src/common/scfClient.ts","../src/common/sidUtils.ts","../src/common/stateManager.ts","../src/common/aliyunClient/apigwOperations.ts","../src/common/aliyunClient/casOperations.ts","../src/common/aliyunClient/dnsOperations.ts","../src/common/aliyunClient/ecsOperations.ts","../src/common/aliyunClient/esOperations.ts","../src/common/aliyunClient/fc3Operations.ts","../src/common/aliyunClient/index.ts","../src/common/aliyunClient/nasOperations.ts","../src/common/aliyunClient/ossOperations.ts","../src/common/aliyunClient/ramOperations.ts","../src/common/aliyunClient/rdsOperations.ts","../src/common/aliyunClient/slsOperations.ts","../src/common/aliyunClient/tablestoreOperations.ts","../src/common/aliyunClient/types.ts","../src/common/dependencyGraph/graph.ts","../src/common/dependencyGraph/index.ts","../src/common/dependencyGraph/types.ts","../src/common/stateBackend/cosStateBackend.ts","../src/common/stateBackend/index.ts","../src/common/stateBackend/localStateBackend.ts","../src/common/stateBackend/lockUtils.ts","../src/common/stateBackend/ossStateBackend.ts","../src/common/stateBackend/remoteStateBackend.ts","../src/common/stateBackend/types.ts","../src/common/tencentClient/cosOperations.ts","../src/common/tencentClient/dnspodOperations.ts","../src/common/tencentClient/esOperations.ts","../src/common/tencentClient/index.ts","../src/common/tencentClient/scfOperations.ts","../src/common/tencentClient/sslOperations.ts","../src/common/tencentClient/tdsqlcOperations.ts","../src/common/tencentClient/types.ts","../src/lang/en.ts","../src/lang/index.ts","../src/lang/zh-CN.ts","../src/parser/bucketParser.ts","../src/parser/certificateParser.ts","../src/parser/databaseParser.ts","../src/parser/eventParser.ts","../src/parser/functionParser.ts","../src/parser/index.ts","../src/parser/parseUtils.ts","../src/parser/tableParser.ts","../src/parser/tagParser.ts","../src/stack/bucketTypes.ts","../src/stack/deploy.ts","../src/stack/index.ts","../src/stack/aliyunStack/apigwExecutor.ts","../src/stack/aliyunStack/apigwPlanner.ts","../src/stack/aliyunStack/apigwResource.ts","../src/stack/aliyunStack/apigwTypes.ts","../src/stack/aliyunStack/databaseExecutor.ts","../src/stack/aliyunStack/databasePlanner.ts","../src/stack/aliyunStack/databaseResource.ts","../src/stack/aliyunStack/deployer.ts","../src/stack/aliyunStack/destroyer.ts","../src/stack/aliyunStack/esServerlessTypes.ts","../src/stack/aliyunStack/fc3Executor.ts","../src/stack/aliyunStack/fc3Planner.ts","../src/stack/aliyunStack/fc3Resource.ts","../src/stack/aliyunStack/fc3Types.ts","../src/stack/aliyunStack/index.ts","../src/stack/aliyunStack/ossExecutor.ts","../src/stack/aliyunStack/ossPlanner.ts","../src/stack/aliyunStack/ossResource.ts","../src/stack/aliyunStack/ossTypes.ts","../src/stack/aliyunStack/planner.ts","../src/stack/aliyunStack/rdsTypes.ts","../src/stack/aliyunStack/tablestoreExecutor.ts","../src/stack/aliyunStack/tablestorePlanner.ts","../src/stack/aliyunStack/tablestoreResource.ts","../src/stack/aliyunStack/tablestoreTypes.ts","../src/stack/localStack/aliyunFc.ts","../src/stack/localStack/bucket.ts","../src/stack/localStack/event.ts","../src/stack/localStack/function.ts","../src/stack/localStack/functionRunner.ts","../src/stack/localStack/index.ts","../src/stack/localStack/localServer.ts","../src/stack/localStack/utils.ts","../src/stack/rfsStack/function.ts","../src/stack/rfsStack/index.ts","../src/stack/scfStack/cosExecutor.ts","../src/stack/scfStack/cosPlanner.ts","../src/stack/scfStack/cosResource.ts","../src/stack/scfStack/cosTypes.ts","../src/stack/scfStack/deployer.ts","../src/stack/scfStack/destroyer.ts","../src/stack/scfStack/esServerlessExecutor.ts","../src/stack/scfStack/esServerlessPlanner.ts","../src/stack/scfStack/esServerlessResource.ts","../src/stack/scfStack/esServerlessTypes.ts","../src/stack/scfStack/index.ts","../src/stack/scfStack/planner.ts","../src/stack/scfStack/scfExecutor.ts","../src/stack/scfStack/scfPlanner.ts","../src/stack/scfStack/scfResource.ts","../src/stack/scfStack/scfTypes.ts","../src/stack/scfStack/tdsqlcExecutor.ts","../src/stack/scfStack/tdsqlcPlanner.ts","../src/stack/scfStack/tdsqlcResource.ts","../src/stack/scfStack/tdsqlcTypes.ts","../src/types/assets.ts","../src/types/index.ts","../src/types/tablestore.d.ts","../src/types/domains/backend.ts","../src/types/domains/bucket.ts","../src/types/domains/certificate.ts","../src/types/domains/context.ts","../src/types/domains/database.ts","../src/types/domains/event.ts","../src/types/domains/function.ts","../src/types/domains/lock.ts","../src/types/domains/provider.ts","../src/types/domains/resolvable.ts","../src/types/domains/state.ts","../src/types/domains/table.ts","../src/types/domains/tag.ts","../src/types/domains/vars.ts","../src/types/localStack/index.ts","../src/validator/bucketSchema.ts","../src/validator/certificateSchema.ts","../src/validator/databaseSchema.ts","../src/validator/eventSchema.ts","../src/validator/functionSchema.ts","../src/validator/iacSchema.ts","../src/validator/index.ts","../src/validator/rootSchema.ts","../src/validator/tableschema.ts","../src/validator/templateRefSchema.ts"],"version":"5.9.3"}
1
+ {"root":["../src/index.ts","../src/commands/deploy.ts","../src/commands/destroy.ts","../src/commands/forceUnlock.ts","../src/commands/index.ts","../src/commands/local.ts","../src/commands/plan.ts","../src/commands/show.ts","../src/commands/validate.ts","../src/common/base64.ts","../src/common/certUtils.ts","../src/common/constants.ts","../src/common/context.ts","../src/common/credentials.ts","../src/common/domainUtils.ts","../src/common/fileUtils.ts","../src/common/getVersion.ts","../src/common/hashUtils.ts","../src/common/iacHelper.ts","../src/common/imsClient.ts","../src/common/index.ts","../src/common/lockManager.ts","../src/common/logger.ts","../src/common/planFormatter.ts","../src/common/providerEnum.ts","../src/common/requestHelper.ts","../src/common/retryUtils.ts","../src/common/runtimeMapper.ts","../src/common/scfClient.ts","../src/common/sidUtils.ts","../src/common/stateManager.ts","../src/common/aliyunClient/apigwOperations.ts","../src/common/aliyunClient/casOperations.ts","../src/common/aliyunClient/dnsOperations.ts","../src/common/aliyunClient/ecsOperations.ts","../src/common/aliyunClient/esOperations.ts","../src/common/aliyunClient/fc3Operations.ts","../src/common/aliyunClient/index.ts","../src/common/aliyunClient/nasOperations.ts","../src/common/aliyunClient/ossOperations.ts","../src/common/aliyunClient/ramOperations.ts","../src/common/aliyunClient/rdsOperations.ts","../src/common/aliyunClient/slsOperations.ts","../src/common/aliyunClient/tablestoreOperations.ts","../src/common/aliyunClient/types.ts","../src/common/dependencyGraph/graph.ts","../src/common/dependencyGraph/index.ts","../src/common/dependencyGraph/types.ts","../src/common/stateBackend/cosStateBackend.ts","../src/common/stateBackend/index.ts","../src/common/stateBackend/localStateBackend.ts","../src/common/stateBackend/lockUtils.ts","../src/common/stateBackend/ossStateBackend.ts","../src/common/stateBackend/remoteStateBackend.ts","../src/common/stateBackend/types.ts","../src/common/tencentClient/cosOperations.ts","../src/common/tencentClient/dnspodOperations.ts","../src/common/tencentClient/esOperations.ts","../src/common/tencentClient/index.ts","../src/common/tencentClient/scfOperations.ts","../src/common/tencentClient/sslOperations.ts","../src/common/tencentClient/tdsqlcOperations.ts","../src/common/tencentClient/types.ts","../src/lang/en.ts","../src/lang/index.ts","../src/lang/zh-CN.ts","../src/parser/bucketParser.ts","../src/parser/databaseParser.ts","../src/parser/eventParser.ts","../src/parser/functionParser.ts","../src/parser/index.ts","../src/parser/parseUtils.ts","../src/parser/tableParser.ts","../src/parser/tagParser.ts","../src/stack/bucketTypes.ts","../src/stack/deploy.ts","../src/stack/index.ts","../src/stack/aliyunStack/apigwExecutor.ts","../src/stack/aliyunStack/apigwPlanner.ts","../src/stack/aliyunStack/apigwResource.ts","../src/stack/aliyunStack/apigwTypes.ts","../src/stack/aliyunStack/databaseExecutor.ts","../src/stack/aliyunStack/databasePlanner.ts","../src/stack/aliyunStack/databaseResource.ts","../src/stack/aliyunStack/deployer.ts","../src/stack/aliyunStack/destroyer.ts","../src/stack/aliyunStack/esServerlessTypes.ts","../src/stack/aliyunStack/fc3Executor.ts","../src/stack/aliyunStack/fc3Planner.ts","../src/stack/aliyunStack/fc3Resource.ts","../src/stack/aliyunStack/fc3Types.ts","../src/stack/aliyunStack/index.ts","../src/stack/aliyunStack/ossExecutor.ts","../src/stack/aliyunStack/ossPlanner.ts","../src/stack/aliyunStack/ossResource.ts","../src/stack/aliyunStack/ossTypes.ts","../src/stack/aliyunStack/planner.ts","../src/stack/aliyunStack/rdsTypes.ts","../src/stack/aliyunStack/tablestoreExecutor.ts","../src/stack/aliyunStack/tablestorePlanner.ts","../src/stack/aliyunStack/tablestoreResource.ts","../src/stack/aliyunStack/tablestoreTypes.ts","../src/stack/localStack/aliyunFc.ts","../src/stack/localStack/bucket.ts","../src/stack/localStack/event.ts","../src/stack/localStack/function.ts","../src/stack/localStack/functionRunner.ts","../src/stack/localStack/index.ts","../src/stack/localStack/localServer.ts","../src/stack/localStack/utils.ts","../src/stack/rfsStack/function.ts","../src/stack/rfsStack/index.ts","../src/stack/scfStack/cosExecutor.ts","../src/stack/scfStack/cosPlanner.ts","../src/stack/scfStack/cosResource.ts","../src/stack/scfStack/cosTypes.ts","../src/stack/scfStack/deployer.ts","../src/stack/scfStack/destroyer.ts","../src/stack/scfStack/esServerlessExecutor.ts","../src/stack/scfStack/esServerlessPlanner.ts","../src/stack/scfStack/esServerlessResource.ts","../src/stack/scfStack/esServerlessTypes.ts","../src/stack/scfStack/index.ts","../src/stack/scfStack/planner.ts","../src/stack/scfStack/scfExecutor.ts","../src/stack/scfStack/scfPlanner.ts","../src/stack/scfStack/scfResource.ts","../src/stack/scfStack/scfTypes.ts","../src/stack/scfStack/tdsqlcExecutor.ts","../src/stack/scfStack/tdsqlcPlanner.ts","../src/stack/scfStack/tdsqlcResource.ts","../src/stack/scfStack/tdsqlcTypes.ts","../src/types/assets.ts","../src/types/index.ts","../src/types/tablestore.d.ts","../src/types/domains/backend.ts","../src/types/domains/bucket.ts","../src/types/domains/context.ts","../src/types/domains/database.ts","../src/types/domains/event.ts","../src/types/domains/function.ts","../src/types/domains/lock.ts","../src/types/domains/provider.ts","../src/types/domains/resolvable.ts","../src/types/domains/state.ts","../src/types/domains/table.ts","../src/types/domains/tag.ts","../src/types/domains/vars.ts","../src/types/localStack/index.ts","../src/validator/bucketSchema.ts","../src/validator/databaseSchema.ts","../src/validator/eventSchema.ts","../src/validator/functionSchema.ts","../src/validator/iacSchema.ts","../src/validator/index.ts","../src/validator/rootSchema.ts","../src/validator/tableschema.ts","../src/validator/templateRefSchema.ts"],"version":"5.9.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
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",
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveCertificateDomain = exports.resolveReferenceCertificate = exports.resolveUploadCertificate = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const node_fs_1 = __importDefault(require("node:fs"));
9
- const certificateParser_1 = require("../parser/certificateParser");
10
- const logger_1 = require("./logger");
11
- const lang_1 = require("../lang");
12
- const readPemContent = (value) => {
13
- if (!(0, certificateParser_1.isFilePath)(value)) {
14
- return value;
15
- }
16
- const filePath = node_path_1.default.resolve(process.cwd(), value);
17
- if (!node_fs_1.default.existsSync(filePath)) {
18
- throw new Error(lang_1.lang.__('CERT_FILE_NOT_FOUND', { filePath }));
19
- }
20
- logger_1.logger.info(lang_1.lang.__('CERT_READING_FILE', { filePath }));
21
- return node_fs_1.default.readFileSync(filePath, 'utf-8');
22
- };
23
- const resolveUploadCertificate = (cert) => {
24
- if (!cert.certificate_body || !cert.private_key) {
25
- throw new Error(lang_1.lang.__('CERT_INVALID_CONFIGURATION', { name: cert.key }));
26
- }
27
- logger_1.logger.info(lang_1.lang.__('CERT_RESOLVED_UPLOAD', { name: cert.key }));
28
- logger_1.logger.info(lang_1.lang.__('CERT_READING_PEM_FILES', { name: cert.key }));
29
- const body = readPemContent(cert.certificate_body);
30
- const key = readPemContent(cert.private_key);
31
- const chain = cert.chain ? readPemContent(cert.chain) : undefined;
32
- return {
33
- certificateName: cert.key,
34
- certificateBody: chain ? `${body}\n${chain}` : body,
35
- certificatePrivateKey: key,
36
- };
37
- };
38
- exports.resolveUploadCertificate = resolveUploadCertificate;
39
- const resolveReferenceCertificate = async (cert, getCertificateFromProvider) => {
40
- if (!cert.certificate_id) {
41
- throw new Error(lang_1.lang.__('CERT_INVALID_CONFIGURATION', { name: cert.key }));
42
- }
43
- const certId = cert.certificate_id;
44
- logger_1.logger.info(lang_1.lang.__('CERT_RESOLVED_REFERENCE', { name: cert.key, certId }));
45
- logger_1.logger.info(lang_1.lang.__('CAS_FETCHING_CERT', { certId }));
46
- const certDetail = await getCertificateFromProvider(certId);
47
- if (!certDetail || !certDetail.cert || !certDetail.key) {
48
- throw new Error(lang_1.lang.__('CAS_CERT_NOT_FOUND', { certId }));
49
- }
50
- return {
51
- certificateName: cert.key,
52
- certificateBody: certDetail.cert,
53
- certificatePrivateKey: certDetail.key,
54
- };
55
- };
56
- exports.resolveReferenceCertificate = resolveReferenceCertificate;
57
- const resolveCertificateDomain = async (cert, getCertificateFromProvider) => {
58
- if (cert.certificate_id) {
59
- return (0, exports.resolveReferenceCertificate)(cert, getCertificateFromProvider);
60
- }
61
- return (0, exports.resolveUploadCertificate)(cert);
62
- };
63
- exports.resolveCertificateDomain = resolveCertificateDomain;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFilePath = exports.parseCertificate = void 0;
4
- const isFilePath = (value) => {
5
- if (value.startsWith('./') || value.startsWith('../')) {
6
- return true;
7
- }
8
- return /\.(pem|crt|key)$/.test(value);
9
- };
10
- exports.isFilePath = isFilePath;
11
- const parseCertificate = (certificates) => {
12
- if (!certificates) {
13
- return undefined;
14
- }
15
- return Object.entries(certificates).map(([key, cert]) => ({
16
- key,
17
- certificate_body: cert.certificate_body != null ? String(cert.certificate_body) : undefined,
18
- private_key: cert.private_key != null ? String(cert.private_key) : undefined,
19
- chain: cert.chain != null ? String(cert.chain) : undefined,
20
- certificate_id: cert.certificate_id != null ? String(cert.certificate_id) : undefined,
21
- }));
22
- };
23
- exports.parseCertificate = parseCertificate;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.certificateSchema = void 0;
4
- exports.certificateSchema = {
5
- $id: 'https://serverlessinsight.geekfun.club/schemas/certificateschema.json',
6
- type: 'object',
7
- patternProperties: {
8
- '.*': {
9
- type: 'object',
10
- properties: {
11
- certificate_body: { type: 'string' },
12
- private_key: { type: 'string' },
13
- chain: { type: 'string' },
14
- certificate_id: { type: 'string' },
15
- },
16
- oneOf: [
17
- {
18
- required: ['certificate_body', 'private_key'],
19
- not: { required: ['certificate_id'] },
20
- },
21
- {
22
- required: ['certificate_id'],
23
- not: {
24
- anyOf: [{ required: ['certificate_body'] }, { required: ['private_key'] }],
25
- },
26
- },
27
- ],
28
- additionalProperties: false,
29
- },
30
- },
31
- };