diff --git a/CHANGELOG.md b/CHANGELOG.md index 22ee3c61..8f38e7e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +### Bug Fixes + +* 申请证书没有使用到系统设置的http代理的bug ([3db216f](https://github.com/certd/certd/commit/3db216f515ba404cb4330fdab452971b22a50f08)) +* 修复移动任务后出现空阶段的bug ([4ea3edd](https://github.com/certd/certd/commit/4ea3edd59e93ca4f5b2e43b20dd4ef33909caddb)) +* 修复google证书*.xx.com与xx.com同时申请时报错的bug ([f8b99b8](https://github.com/certd/certd/commit/f8b99b81a23e7e9fd5e05ebd5caf355c41d67a90)) +* 允许七牛云cdn插件输入.号开头的通配符域名 ([18ee87d](https://github.com/certd/certd/commit/18ee87daff6eafc2201b58e28d85aafd3cb7a5b9)) + +### Performance Improvements + +* 申请证书启用新的反代地址 ([a705182](https://github.com/certd/certd/commit/a705182b85e51157883e48f23463263793bf3c12)) +* 优化日志颜色 ([1291e98](https://github.com/certd/certd/commit/1291e98e821c5b1810aab7f0aebe3f5f5cd44a20)) +* 优化证书申请速度和成功率,反代地址优化,google基本可以稳定请求。增加请求重试。 ([41d9c3a](https://github.com/certd/certd/commit/41d9c3ac8398def541e65351cbe920d4a927182d)) +* 优化pfx密码密码输入框,让浏览器不自动填写密码 ([ffeede3](https://github.com/certd/certd/commit/ffeede38afa70c5ff6f2015516bead23d2c4df87)) + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) ### Bug Fixes diff --git a/build.trigger b/build.trigger index 97224975..d99d4ded 100644 --- a/build.trigger +++ b/build.trigger @@ -1 +1 @@ -12:34 +10:38 diff --git a/docs/guide/use/rerun/images/rerun.png b/docs/guide/use/rerun/images/rerun.png new file mode 100644 index 00000000..41f85302 Binary files /dev/null and b/docs/guide/use/rerun/images/rerun.png differ diff --git a/docs/guide/use/rerun/index.md b/docs/guide/use/rerun/index.md new file mode 100644 index 00000000..29ad53b6 --- /dev/null +++ b/docs/guide/use/rerun/index.md @@ -0,0 +1,5 @@ +# 如何强制重新执行任务 + +## 强制重新执行任务 + +![](./images/rerun.png) \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 8710a89b..e941e6ad 100644 --- a/docs/index.md +++ b/docs/index.md @@ -28,7 +28,7 @@ features: - title: 多域名、泛域名打到一个证书上 details: 支持通配符域名/泛域名,支持多个域名打到一个证书上 - title: 多证书格式支持 - details: 支持pem、pfx、der等多种证书格式 + details: 支持pem、pfx、der等多种证书格式,支持Google、Letsencrypt、ZeroSSL证书颁发机构 - title: 支持私有化部署 details: 保障数据安全 - title: 多数据库支持 diff --git a/lerna.json b/lerna.json index 3c538bf8..1ea738c5 100644 --- a/lerna.json +++ b/lerna.json @@ -9,5 +9,5 @@ } }, "npmClient": "pnpm", - "version": "1.26.10" + "version": "1.26.11" } diff --git a/packages/core/acme-client/CHANGELOG.md b/packages/core/acme-client/CHANGELOG.md index 1e1f76f7..8bf97d09 100644 --- a/packages/core/acme-client/CHANGELOG.md +++ b/packages/core/acme-client/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/publishlab/node-acme-client/compare/v1.26.10...v1.26.11) (2024-10-23) + +### Bug Fixes + +* 申请证书没有使用到系统设置的http代理的bug ([3db216f](https://github.com/publishlab/node-acme-client/commit/3db216f515ba404cb4330fdab452971b22a50f08)) +* 修复google证书*.xx.com与xx.com同时申请时报错的bug ([f8b99b8](https://github.com/publishlab/node-acme-client/commit/f8b99b81a23e7e9fd5e05ebd5caf355c41d67a90)) + +### Performance Improvements + +* 优化证书申请速度和成功率,反代地址优化,google基本可以稳定请求。增加请求重试。 ([41d9c3a](https://github.com/publishlab/node-acme-client/commit/41d9c3ac8398def541e65351cbe920d4a927182d)) + ## [1.26.10](https://github.com/publishlab/node-acme-client/compare/v1.26.9...v1.26.10) (2024-10-20) **Note:** Version bump only for package @certd/acme-client diff --git a/packages/core/acme-client/package.json b/packages/core/acme-client/package.json index d9dd69ce..d98e01d2 100644 --- a/packages/core/acme-client/package.json +++ b/packages/core/acme-client/package.json @@ -3,7 +3,7 @@ "description": "Simple and unopinionated ACME client", "private": false, "author": "nmorsman", - "version": "1.26.10", + "version": "1.26.11", "main": "src/index.js", "types": "types/index.d.ts", "license": "MIT", @@ -20,6 +20,7 @@ "asn1js": "^3.0.5", "axios": "^1.7.2", "debug": "^4.3.5", + "http-proxy-agent": "^7.0.2", "https-proxy-agent": "^7.0.5", "node-forge": "^1.3.1" }, @@ -59,5 +60,5 @@ "bugs": { "url": "https://github.com/publishlab/node-acme-client/issues" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/core/acme-client/src/agents.js b/packages/core/acme-client/src/agents.js new file mode 100644 index 00000000..ca182059 --- /dev/null +++ b/packages/core/acme-client/src/agents.js @@ -0,0 +1,101 @@ +const nodeHttp = require('node:http'); +const https = require('node:https'); +const { HttpProxyAgent } = require('http-proxy-agent'); +const { HttpsProxyAgent } = require('https-proxy-agent'); +const { log } = require('./logger'); + +function createAgent(opts = {}) { + let httpAgent; + let + httpsAgent; + const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy; + if (httpProxy) { + log(`acme use httpProxy:${httpProxy}`); + httpAgent = new HttpProxyAgent(httpProxy, opts); + } + else { + httpAgent = new nodeHttp.Agent(opts); + } + const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy; + if (httpsProxy) { + log(`acme use httpsProxy:${httpsProxy}`); + httpsAgent = new HttpsProxyAgent(httpsProxy, opts); + } + else { + httpsAgent = new https.Agent(opts); + } + return { + httpAgent, + httpsAgent, + }; +} + +let defaultAgents = createAgent(); + +function getGlobalAgents() { + return defaultAgents; +} + +function setGlobalProxy(opts) { + log('acme setGlobalProxy:', opts); + if (opts.httpProxy) { + process.env.HTTP_PROXY = opts.httpProxy; + } + if (opts.httpsProxy) { + process.env.HTTPS_PROXY = opts.httpsProxy; + } + + defaultAgents = createAgent(); +} + +class HttpError extends Error { + constructor(error) { + super(error || error.message); + if (!error) { + return; + } + + if (error.message.indexOf('ssl3_get_record:wrong version number') >= 0) { + this.message = 'http协议错误,服务端要求http协议,请检查是否使用了https请求'; + } + + this.name = error.name; + this.code = error.code; + this.cause = error.cause; + + if (error.response) { + this.status = error.response.status; + this.statusText = error.response.statusText; + this.response = { + data: error.response.data, + }; + } + + let url = ''; + if (error.config) { + this.request = { + baseURL: error.config.baseURL, + url: error.config.url, + method: error.config.method, + params: error.config.params, + data: error.config.data, + }; + url = error.config.baseURL + error.config.url; + } + if (url) { + this.message = `${this.message}:${url}`; + } + + delete error.response; + delete error.config; + delete error.request; + // logger.error(error); + } +} + +module.exports = { + setGlobalProxy, + createAgent, + getGlobalAgents, + HttpError, +}; diff --git a/packages/core/acme-client/src/api.js b/packages/core/acme-client/src/api.js index 9c251ca5..70e21b5b 100644 --- a/packages/core/acme-client/src/api.js +++ b/packages/core/acme-client/src/api.js @@ -30,6 +30,7 @@ class AcmeApi { } } } + console.log(locationUrl, mapping); return locationUrl; } diff --git a/packages/core/acme-client/src/auto.js b/packages/core/acme-client/src/auto.js index d8ee534e..dcb47ac4 100644 --- a/packages/core/acme-client/src/auto.js +++ b/packages/core/acme-client/src/auto.js @@ -182,12 +182,19 @@ module.exports = async (client, userOpts) => { authorizations.forEach((authz) => { const d = authz.identifier.value; + log(`authorization:domain = ${d}, value = ${JSON.stringify(authz)}`); + + if (authz.status === 'valid') { + log(`[auto] [${d}] Authorization already has valid status, no need to complete challenges`); + return; + } let setd = false; // eslint-disable-next-line no-restricted-syntax for (const group of domainSets) { if (!group[d]) { group[d] = authz; setd = true; + break; } } if (!setd) { @@ -197,6 +204,8 @@ module.exports = async (client, userOpts) => { } }); + // log(`domainSets:${JSON.stringify(domainSets)}`); + const allChallengePromises = []; // eslint-disable-next-line no-restricted-syntax for (const domainSet of domainSets) { @@ -233,28 +242,52 @@ module.exports = async (client, userOpts) => { return Promise.all(results); } - log(`开始challenge,共${allChallengePromises.length}组`); - let i = 0; - // eslint-disable-next-line no-restricted-syntax - for (const challengePromises of allChallengePromises) { - i += 1; - log(`开始第${i}组`); - if (opts.signal && opts.signal.aborted) { - throw new Error('用户取消'); - } + try { + log(`开始challenge,共${allChallengePromises.length}组`); + let i = 0; + // eslint-disable-next-line no-restricted-syntax + for (const challengePromises of allChallengePromises) { + i += 1; + log(`开始第${i}组`); + if (opts.signal && opts.signal.aborted) { + throw new Error('用户取消'); + } - try { - // eslint-disable-next-line no-await-in-loop - await runPromisePa(challengePromises); - } - catch (e) { - log(`证书申请失败${e.message}`); - throw e; - } - finally { - log(`清理challenge痕迹,length:${clearTasks.length}`); try { // eslint-disable-next-line no-await-in-loop + await runPromisePa(challengePromises); + } + catch (e) { + log(`证书申请失败${e.message}`); + throw e; + } + finally { + if (client.opts.sslProvider !== 'google') { + // letsencrypt 如果同时检出两个TXT记录,会以第一个为准,就会校验失败,所以需要提前删除 + // zerossl 此方式测试无问题 + log(`清理challenge痕迹,length:${clearTasks.length}`); + try { + // eslint-disable-next-line no-await-in-loop + await runAllPromise(clearTasks); + } + catch (e) { + log('清理challenge失败'); + log(e); + } + } + } + } + } + finally { + if (client.opts.sslProvider === 'google') { + // google 相同的域名txt记录是一样的,不能提前删除,否则校验失败,报错如下 + // Error: The TXT record retrieved from _acme-challenge.bbc.handsfree.work. + // at the time the challenge was validated did not contain JshHVu7dt_DT6uYILWhokHefFVad2Q6Mw1L-fNZFcq8 + // (the base64url-encoded SHA-256 digest of RlJZNBR0LWnxNK_xd2zqtYVvCiNJOKJ3J1NmCjU_9BjaUJgL3k-qSpIhQ-uF4FBS.NRyqT8fRiq6THzzrvkgzgR5Xai2LsA2SyGLAq_wT3qc). + // See https://tools.ietf.org/html/rfc8555#section-8.4 for more information. + log(`清理challenge痕迹,length:${clearTasks.length}`); + try { + // eslint-disable-next-line no-await-in-loop await runAllPromise(clearTasks); } catch (e) { @@ -263,6 +296,7 @@ module.exports = async (client, userOpts) => { } } } + log('challenge结束'); // log('[auto] Waiting for challenge valid status'); diff --git a/packages/core/acme-client/src/axios.js b/packages/core/acme-client/src/axios.js index 84b0cc55..2c54c0f5 100644 --- a/packages/core/acme-client/src/axios.js +++ b/packages/core/acme-client/src/axios.js @@ -1,11 +1,11 @@ /** * Axios instance */ - const axios = require('axios'); const { parseRetryAfterHeader } = require('./util'); const { log } = require('./logger'); const pkg = require('./../package.json'); +const Agents = require('./agents'); const { AxiosError } = axios; @@ -24,8 +24,8 @@ instance.defaults.acmeSettings = { httpsChallengePort: 443, tlsAlpnChallengePort: 443, - retryMaxAttempts: 5, - retryDefaultDelay: 5, + retryMaxAttempts: 3, + retryDefaultDelay: 3, }; // instance.defaults.proxy = { // host: '192.168.34.139', @@ -56,19 +56,26 @@ function isRetryableError(error) { /* https://github.com/axios/axios/blob/main/lib/core/settle.js */ function validateStatus(response) { - const validator = response.config.retryValidateStatus; - + if (!response) { + return new Error('Response is undefined'); + } + let validator = null; + if (response.config) { + validator = response.config.retryValidateStatus; + } if (!response.status || !validator || validator(response.status)) { return response; } - throw new AxiosError( + const err = new AxiosError( `Request failed with status code ${response.status}`, (Math.floor(response.status / 100) === 4) ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE, response.config, response.request, response, ); + + throw new Agents.HttpError(err); } /* Pass all responses through the error interceptor */ @@ -76,8 +83,17 @@ instance.interceptors.request.use((config) => { if (!('retryValidateStatus' in config)) { config.retryValidateStatus = config.validateStatus; } - config.validateStatus = () => false; + + const agents = Agents.getGlobalAgents(); + // if (config.skipSslVerify) { + // logger.info('跳过SSL验证'); + // agents = createAgent({ rejectUnauthorized: false } as any); + // } + // delete config.skipSslVerify; + config.httpsAgent = agents.httpsAgent; + config.httpAgent = agents.httpAgent; + config.proxy = false; // 必须 否则还会走一层代理, return config; }); @@ -86,7 +102,7 @@ instance.interceptors.response.use(null, async (error) => { const { config, response } = error; if (!config) { - return Promise.reject(error); + return Promise.reject(new Agents.HttpError(error)); } /* Pick up errors we want to retry */ @@ -115,6 +131,9 @@ instance.interceptors.response.use(null, async (error) => { } } + if (!response) { + return Promise.reject(new Agents.HttpError(error)); + } /* Validate and return response */ return validateStatus(response); }); diff --git a/packages/core/acme-client/src/client.js b/packages/core/acme-client/src/client.js index f32cd17c..f96adc37 100644 --- a/packages/core/acme-client/src/client.js +++ b/packages/core/acme-client/src/client.js @@ -558,6 +558,7 @@ class AcmeClient { const verifyFn = async (abort) => { if (this.opts.signal && this.opts.signal.aborted) { + abort(); throw new Error('用户取消'); } diff --git a/packages/core/acme-client/src/http.js b/packages/core/acme-client/src/http.js index d2afec33..2e2915f6 100644 --- a/packages/core/acme-client/src/http.js +++ b/packages/core/acme-client/src/http.js @@ -3,21 +3,9 @@ */ const { createHmac, createSign, constants: { RSA_PKCS1_PADDING } } = require('crypto'); -const { HttpsProxyAgent } = require('https-proxy-agent'); const { getJwk } = require('./crypto'); const { log } = require('./logger'); -const axios1 = require('./axios'); - -const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy; -let httpsAgent = null; -if (httpsProxy) { - httpsAgent = new HttpsProxyAgent(httpsProxy); - log(`use https_proxy:${httpsProxy}`); -} -const axios = axios1.create({ - proxy: false, - httpsAgent, -}); +const axios = require('./axios'); /** * ACME HTTP client diff --git a/packages/core/acme-client/src/index.js b/packages/core/acme-client/src/index.js index 65276df4..b0a58842 100644 --- a/packages/core/acme-client/src/index.js +++ b/packages/core/acme-client/src/index.js @@ -39,6 +39,7 @@ exports.forge = require('./crypto/forge'); */ exports.axios = require('./axios'); +exports.agents = require('./agents'); /** * Logger diff --git a/packages/core/acme-client/src/logger.js b/packages/core/acme-client/src/logger.js index 3659c517..166a7a9c 100644 --- a/packages/core/acme-client/src/logger.js +++ b/packages/core/acme-client/src/logger.js @@ -22,7 +22,7 @@ exports.setLogger = (fn) => { * @param {string} msg Message */ -exports.log = (msg) => { - debug(msg); - logger(msg); +exports.log = (...msg) => { + debug(...msg); + logger(...msg); }; diff --git a/packages/core/acme-client/types/index.d.ts b/packages/core/acme-client/types/index.d.ts index 9178c840..56e4cf11 100644 --- a/packages/core/acme-client/types/index.d.ts +++ b/packages/core/acme-client/types/index.d.ts @@ -37,6 +37,7 @@ export type UrlMapping={ */ export interface ClientOptions { + sslProvider:string; directoryUrl: string; accountKey: PrivateKeyBuffer | PrivateKeyString; accountUrl?: string; @@ -192,6 +193,7 @@ export const forge: CryptoLegacyInterface; export const axios: AxiosInstance; +export const agents: any; /** * Logger */ diff --git a/packages/core/basic/CHANGELOG.md b/packages/core/basic/CHANGELOG.md index 868f3f36..54a65068 100644 --- a/packages/core/basic/CHANGELOG.md +++ b/packages/core/basic/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +### Bug Fixes + +* 申请证书没有使用到系统设置的http代理的bug ([3db216f](https://github.com/certd/certd/commit/3db216f515ba404cb4330fdab452971b22a50f08)) + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) **Note:** Version bump only for package @certd/basic diff --git a/packages/core/basic/build.md b/packages/core/basic/build.md index b4497168..c8455156 100644 --- a/packages/core/basic/build.md +++ b/packages/core/basic/build.md @@ -1 +1 @@ -12:31 +10:35 diff --git a/packages/core/basic/package.json b/packages/core/basic/package.json index bcf0a262..0b0a7c35 100644 --- a/packages/core/basic/package.json +++ b/packages/core/basic/package.json @@ -1,7 +1,7 @@ { "name": "@certd/basic", "private": false, - "version": "1.26.10", + "version": "1.26.11", "type": "module", "main": "./dist/index.js", "module": "./dist/index.js", @@ -64,5 +64,5 @@ "vite": "^4.3.8", "vue-tsc": "^1.6.5" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/core/basic/src/utils/util.request.ts b/packages/core/basic/src/utils/util.request.ts index 2bf994d4..1167f885 100644 --- a/packages/core/basic/src/utils/util.request.ts +++ b/packages/core/basic/src/utils/util.request.ts @@ -5,6 +5,7 @@ import { HttpProxyAgent } from 'http-proxy-agent'; import { HttpsProxyAgent } from 'https-proxy-agent'; import nodeHttp from 'http'; import * as https from 'node:https'; +import { merge } from 'lodash-es'; export class HttpError extends Error { status?: number; statusText?: string; @@ -35,6 +36,14 @@ export class HttpError extends Error { params: error.config?.params, data: error.config?.data, }; + let url = error.config?.url; + if (error.config?.baseURL) { + url = error.config?.baseURL + url; + } + if (url) { + this.message = `${this.message} : url=${url}`; + } + this.response = { data: error.response?.data, }; @@ -62,6 +71,10 @@ export function setGlobalProxy(opts: { httpProxy?: string; httpsProxy?: string } defaultAgents = createAgent(); } +export function getGlobalAgents() { + return defaultAgents; +} + /** * @description 创建请求实例 */ @@ -72,7 +85,10 @@ export function createAxiosService({ logger }: { logger: Logger }) { // 请求拦截 service.interceptors.request.use( (config: any) => { - logger.info(`http request:${config.url},method:${config.method},params:${JSON.stringify(config.params)}`); + logger.info(`http request:${config.url},method:${config.method}`); + if (config.logParams !== false) { + logger.info(`params:${JSON.stringify(config.params)}`); + } if (config.timeout == null) { config.timeout = 15000; } @@ -84,6 +100,11 @@ export function createAxiosService({ logger }: { logger: Logger }) { delete config.skipSslVerify; config.httpsAgent = agents.httpsAgent; config.httpAgent = agents.httpAgent; + + // const agent = new https.Agent({ + // rejectUnauthorized: false // 允许自签名证书 + // }); + // config.httpsAgent = agent; config.proxy = false; //必须 否则还会走一层代理, return config; }, @@ -96,7 +117,11 @@ export function createAxiosService({ logger }: { logger: Logger }) { // 响应拦截 service.interceptors.response.use( (response: any) => { - logger.info('http response:', JSON.stringify(response?.data)); + if (response?.config?.logRes !== false) { + logger.info(`http response : status=${response?.status},data=${JSON.stringify(response?.data)}`); + } else { + logger.info('http response status:', response?.status); + } return response.data; }, (error: any) => { @@ -160,6 +185,8 @@ export type HttpClientResponse = any; export type HttpRequestConfig = { skipSslVerify?: boolean; skipCheckRes?: boolean; + logParams?: boolean; + logRes?: boolean; } & AxiosRequestConfig; export type HttpClient = { request(config: HttpRequestConfig): Promise>; @@ -171,6 +198,7 @@ export function createAgent(opts: nodeHttp.AgentOptions = {}) { if (httpProxy) { logger.info('use httpProxy:', httpProxy); httpAgent = new HttpProxyAgent(httpProxy, opts as any); + merge(httpAgent.options, opts); } else { httpAgent = new nodeHttp.Agent(opts); } @@ -178,6 +206,7 @@ export function createAgent(opts: nodeHttp.AgentOptions = {}) { if (httpsProxy) { logger.info('use httpsProxy:', httpsProxy); httpsAgent = new HttpsProxyAgent(httpsProxy, opts as any); + merge(httpsAgent.options, opts); } else { httpsAgent = new https.Agent(opts); } diff --git a/packages/core/pipeline/CHANGELOG.md b/packages/core/pipeline/CHANGELOG.md index bde43c93..1d8b2a7e 100644 --- a/packages/core/pipeline/CHANGELOG.md +++ b/packages/core/pipeline/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +### Performance Improvements + +* 申请证书启用新的反代地址 ([a705182](https://github.com/certd/certd/commit/a705182b85e51157883e48f23463263793bf3c12)) + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) ### Bug Fixes diff --git a/packages/core/pipeline/package.json b/packages/core/pipeline/package.json index dc023929..5f0313fe 100644 --- a/packages/core/pipeline/package.json +++ b/packages/core/pipeline/package.json @@ -1,7 +1,7 @@ { "name": "@certd/pipeline", "private": false, - "version": "1.26.10", + "version": "1.26.11", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -15,8 +15,8 @@ "test": "mocha --loader=ts-node/esm" }, "dependencies": { - "@certd/basic": "^1.26.10", - "@certd/plus-core": "^1.26.10", + "@certd/basic": "^1.26.11", + "@certd/plus-core": "^1.26.11", "axios": "^1.7.2", "dayjs": "^1.11.7", "fix-path": "^4.0.0", @@ -66,5 +66,5 @@ "vite": "^4.3.8", "vue-tsc": "^1.6.5" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts index 7b2256fc..7f332de8 100644 --- a/packages/core/pipeline/src/core/executor.ts +++ b/packages/core/pipeline/src/core/executor.ts @@ -128,6 +128,10 @@ export class Executor { this.runtime.skip(runnable); return resultType; } + if (resultType == ResultType.disabled) { + this.runtime.disabled(runnable); + return resultType; + } this.runtime.success(runnable); return ResultType.success; } catch (e: any) { @@ -164,12 +168,14 @@ export class Executor { let resList: ResultType[] = []; if (stage.concurrency === ConcurrencyStrategy.Parallel) { + //并行 const pList = []; for (const item of runnerList) { pList.push(item()); } resList = await Promise.all(pList); } else { + //串行 for (let i = 0; i < runnerList.length; i++) { const runner = runnerList[i]; resList[i] = await runner(); @@ -181,6 +187,7 @@ export class Executor { compositionResultType(resList: ResultType[]): ResultType { let hasSuccess = false; let hasSkip = false; + let hasDisabled = false; for (const type of resList) { if (type === ResultType.error) { return ResultType.error; @@ -188,8 +195,14 @@ export class Executor { hasSuccess = true; } else if (type === ResultType.skip) { hasSkip = true; + } else if (type === ResultType.disabled) { + hasDisabled = true; } } + if (!hasSuccess && !hasSkip && hasDisabled) { + //全是disabled + return ResultType.disabled; + } if (!hasSuccess && hasSkip) { //全是跳过 return ResultType.skip; diff --git a/packages/libs/lib-huawei/CHANGELOG.md b/packages/libs/lib-huawei/CHANGELOG.md index ea882211..0c9ae20e 100644 --- a/packages/libs/lib-huawei/CHANGELOG.md +++ b/packages/libs/lib-huawei/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +**Note:** Version bump only for package @certd/lib-huawei + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) **Note:** Version bump only for package @certd/lib-huawei diff --git a/packages/libs/lib-huawei/package.json b/packages/libs/lib-huawei/package.json index ae946901..5a4b08f2 100644 --- a/packages/libs/lib-huawei/package.json +++ b/packages/libs/lib-huawei/package.json @@ -1,7 +1,7 @@ { "name": "@certd/lib-huawei", "private": false, - "version": "1.26.10", + "version": "1.26.11", "main": "./dist/bundle.js", "module": "./dist/bundle.js", "types": "./dist/d/index.d.ts", @@ -17,5 +17,5 @@ "rimraf": "^5.0.5", "rollup": "^3.7.4" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/libs/lib-iframe/CHANGELOG.md b/packages/libs/lib-iframe/CHANGELOG.md index 5b236842..db9b1507 100644 --- a/packages/libs/lib-iframe/CHANGELOG.md +++ b/packages/libs/lib-iframe/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +**Note:** Version bump only for package @certd/lib-iframe + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) **Note:** Version bump only for package @certd/lib-iframe diff --git a/packages/libs/lib-iframe/package.json b/packages/libs/lib-iframe/package.json index c5d30be4..bf9c0e3a 100644 --- a/packages/libs/lib-iframe/package.json +++ b/packages/libs/lib-iframe/package.json @@ -1,7 +1,7 @@ { "name": "@certd/lib-iframe", "private": false, - "version": "1.26.10", + "version": "1.26.11", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -39,5 +39,5 @@ "tslib": "^2.5.2", "typescript": "^5.4.2" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/libs/lib-jdcloud/CHANGELOG.md b/packages/libs/lib-jdcloud/CHANGELOG.md index 0ed408fc..969547d0 100644 --- a/packages/libs/lib-jdcloud/CHANGELOG.md +++ b/packages/libs/lib-jdcloud/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +**Note:** Version bump only for package @certd/lib-jdcloud + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) **Note:** Version bump only for package @certd/lib-jdcloud diff --git a/packages/libs/lib-jdcloud/package.json b/packages/libs/lib-jdcloud/package.json index 90684236..6785e150 100644 --- a/packages/libs/lib-jdcloud/package.json +++ b/packages/libs/lib-jdcloud/package.json @@ -1,7 +1,7 @@ { "name": "@certd/lib-jdcloud", "private": false, - "version": "1.26.10", + "version": "1.26.11", "main": "./dist/bundle.mjs", "module": "./dist/bundle.mjs", "types": "./dist/d/index.d.ts", @@ -27,5 +27,5 @@ "rimraf": "^5.0.5", "rollup": "^3.7.4" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/libs/lib-k8s/CHANGELOG.md b/packages/libs/lib-k8s/CHANGELOG.md index e7549dd9..6c3eccfd 100644 --- a/packages/libs/lib-k8s/CHANGELOG.md +++ b/packages/libs/lib-k8s/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +**Note:** Version bump only for package @certd/lib-k8s + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) **Note:** Version bump only for package @certd/lib-k8s diff --git a/packages/libs/lib-k8s/package.json b/packages/libs/lib-k8s/package.json index 7b79a13f..819760b1 100644 --- a/packages/libs/lib-k8s/package.json +++ b/packages/libs/lib-k8s/package.json @@ -1,7 +1,7 @@ { "name": "@certd/lib-k8s", "private": false, - "version": "1.26.10", + "version": "1.26.11", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -18,7 +18,7 @@ "@kubernetes/client-node": "0.21.0" }, "devDependencies": { - "@certd/pipeline": "^1.26.10", + "@certd/pipeline": "^1.26.11", "@rollup/plugin-commonjs": "^23.0.4", "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-node-resolve": "^15.0.1", @@ -40,5 +40,5 @@ "tslib": "^2.5.2", "typescript": "^5.4.2" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/libs/lib-server/CHANGELOG.md b/packages/libs/lib-server/CHANGELOG.md index 4dd8f9b3..c77d1129 100644 --- a/packages/libs/lib-server/CHANGELOG.md +++ b/packages/libs/lib-server/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +### Bug Fixes + +* 申请证书没有使用到系统设置的http代理的bug ([3db216f](https://github.com/certd/certd/commit/3db216f515ba404cb4330fdab452971b22a50f08)) + +### Performance Improvements + +* 申请证书启用新的反代地址 ([a705182](https://github.com/certd/certd/commit/a705182b85e51157883e48f23463263793bf3c12)) + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) **Note:** Version bump only for package @certd/lib-server diff --git a/packages/libs/lib-server/package.json b/packages/libs/lib-server/package.json index a2194076..0bdf9719 100644 --- a/packages/libs/lib-server/package.json +++ b/packages/libs/lib-server/package.json @@ -1,6 +1,6 @@ { "name": "@certd/lib-server", - "version": "1.26.10", + "version": "1.26.11", "description": "midway with flyway, sql upgrade way ", "private": false, "type": "module", @@ -26,8 +26,9 @@ ], "license": "AGPL", "dependencies": { - "@certd/basic": "^1.26.10", - "@certd/pipeline": "^1.26.10", + "@certd/acme-client": "^1.26.11", + "@certd/basic": "^1.26.11", + "@certd/pipeline": "^1.26.11", "@midwayjs/cache": "~3.14.0", "@midwayjs/core": "~3.17.1", "@midwayjs/i18n": "~3.17.3", @@ -68,5 +69,5 @@ "typeorm": "^0.3.11", "typescript": "^5.4.2" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/libs/lib-server/src/system/settings/service/sys-settings-service.ts b/packages/libs/lib-server/src/system/settings/service/sys-settings-service.ts index 5d3f2a8f..6d89ffbb 100644 --- a/packages/libs/lib-server/src/system/settings/service/sys-settings-service.ts +++ b/packages/libs/lib-server/src/system/settings/service/sys-settings-service.ts @@ -7,7 +7,7 @@ import { BaseSettings, SysInstallInfo, SysPrivateSettings, SysPublicSettings, Sy import * as _ from 'lodash-es'; import { BaseService } from '../../../basic/index.js'; import { logger, setGlobalProxy } from '@certd/basic'; - +import { agents } from '@certd/acme-client'; /** * 设置 */ @@ -23,7 +23,6 @@ export class SysSettingsService extends BaseService { getRepository() { return this.repository; } - async getById(id: any): Promise { const entity = await this.info(id); if (!entity) { @@ -129,10 +128,12 @@ export class SysSettingsService extends BaseService { async reloadPrivateSettings() { const bean = await this.getPrivateSettings(); if (bean.httpProxy || bean.httpsProxy) { - setGlobalProxy({ + const opts = { httpProxy: bean.httpProxy, httpsProxy: bean.httpsProxy, - }); + }; + setGlobalProxy(opts); + agents.setGlobalProxy(opts); } } @@ -149,10 +150,10 @@ export class SysSettingsService extends BaseService { async backupSecret() { const settings = await this.getSettingByKey(SysSecretBackup.__key__); + const privateSettings = await this.getPrivateSettings(); + const installInfo = await this.getSetting(SysInstallInfo); if (settings == null) { const backup = new SysSecretBackup(); - const privateSettings = await this.getPrivateSettings(); - const installInfo = await this.getSetting(SysInstallInfo); if (installInfo.siteId == null || privateSettings.encryptSecret == null) { logger.error('备份密钥失败,siteId或encryptSecret为空'); return; @@ -161,6 +162,14 @@ export class SysSettingsService extends BaseService { backup.encryptSecret = privateSettings.encryptSecret; await this.saveSetting(backup); logger.info('备份密钥成功'); + } else { + //校验是否有变化 + if (settings.siteId !== installInfo.siteId) { + throw new Error(`siteId与备份不一致,可能是数据异常,请检查:backup=${settings.siteId}, current=${installInfo.siteId}`); + } + if (settings.encryptSecret !== privateSettings.encryptSecret) { + throw new Error('encryptSecret与备份不一致,可能是数据异常,请检查'); + } } } } diff --git a/packages/libs/midway-flyway-js/CHANGELOG.md b/packages/libs/midway-flyway-js/CHANGELOG.md index e8c84792..c36258d9 100644 --- a/packages/libs/midway-flyway-js/CHANGELOG.md +++ b/packages/libs/midway-flyway-js/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +**Note:** Version bump only for package @certd/midway-flyway-js + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) **Note:** Version bump only for package @certd/midway-flyway-js diff --git a/packages/libs/midway-flyway-js/package.json b/packages/libs/midway-flyway-js/package.json index 7d44f0e9..bb87f713 100644 --- a/packages/libs/midway-flyway-js/package.json +++ b/packages/libs/midway-flyway-js/package.json @@ -1,6 +1,6 @@ { "name": "@certd/midway-flyway-js", - "version": "1.26.10", + "version": "1.26.11", "description": "midway with flyway, sql upgrade way ", "private": false, "type": "module", @@ -56,5 +56,5 @@ "typeorm": "^0.3.11", "typescript": "^5.4.2" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/plugins/plugin-cert/CHANGELOG.md b/packages/plugins/plugin-cert/CHANGELOG.md index ecba6cf2..6f65bf40 100644 --- a/packages/plugins/plugin-cert/CHANGELOG.md +++ b/packages/plugins/plugin-cert/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +### Performance Improvements + +* 申请证书启用新的反代地址 ([a705182](https://github.com/certd/certd/commit/a705182b85e51157883e48f23463263793bf3c12)) +* 优化证书申请速度和成功率,反代地址优化,google基本可以稳定请求。增加请求重试。 ([41d9c3a](https://github.com/certd/certd/commit/41d9c3ac8398def541e65351cbe920d4a927182d)) +* 优化pfx密码密码输入框,让浏览器不自动填写密码 ([ffeede3](https://github.com/certd/certd/commit/ffeede38afa70c5ff6f2015516bead23d2c4df87)) + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) ### Bug Fixes diff --git a/packages/plugins/plugin-cert/package.json b/packages/plugins/plugin-cert/package.json index 9dfd7baa..5c189d11 100644 --- a/packages/plugins/plugin-cert/package.json +++ b/packages/plugins/plugin-cert/package.json @@ -1,7 +1,7 @@ { "name": "@certd/plugin-cert", "private": false, - "version": "1.26.10", + "version": "1.26.11", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -15,9 +15,9 @@ "preview": "vite preview" }, "dependencies": { - "@certd/acme-client": "^1.26.10", - "@certd/basic": "^1.26.10", - "@certd/pipeline": "^1.26.10", + "@certd/acme-client": "^1.26.11", + "@certd/basic": "^1.26.11", + "@certd/pipeline": "^1.26.11", "@google-cloud/publicca": "^1.3.0", "dayjs": "^1.11.7", "jszip": "^3.10.1", @@ -57,5 +57,5 @@ "vite": "^3.1.0", "vue-tsc": "^0.38.9" }, - "gitHead": "617cc13e29e6a325ac6fc0202499398390d25997" + "gitHead": "3a78cb9929fd63bb72f0e00f4389e775c926c789" } diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts index 14402024..cb00d9d7 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts @@ -89,12 +89,15 @@ export class AcmeService { } async getAcmeClient(email: string, isTest = false): Promise { + const mappings = {}; + if (this.sslProvider === "letsencrypt") { + mappings["acme-v02.api.letsencrypt.org"] = this.options.reverseProxy || "le.px.certd.handfree.work"; + } else if (this.sslProvider === "google") { + mappings["dv.acme-v02.api.pki.goog"] = this.options.reverseProxy || "gg.px.certd.handfree.work"; + } const urlMapping: UrlMapping = { enabled: false, - mappings: { - "acme-v02.api.letsencrypt.org": this.options.reverseProxy || "letsencrypt.proxy.handsfree.work", - "dv.acme-v02.api.pki.goog": this.options.reverseProxy || "google.proxy.handsfree.work", - }, + mappings, }; const conf = await this.getAccountConfig(email, urlMapping); if (conf.key == null) { @@ -119,6 +122,7 @@ export class AcmeService { } } const client = new acme.Client({ + sslProvider: this.sslProvider, directoryUrl: directoryUrl, accountKey: conf.key, accountUrl: conf.accountUrl, @@ -172,7 +176,7 @@ export class AcmeService { this.logger.info(`Would create TXT record "${fullRecord}" with value "${recordValue}"`); let domain = parseDomain(fullDomain); - this.logger.info("解析到域名domain=", domain); + this.logger.info("解析到域名domain=" + domain); if (domainsVerifyPlan) { //按照计划执行 diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts index 36cfd19e..e42b235b 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts @@ -50,7 +50,7 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin { @TaskInput({ title: "PFX证书密码", component: { - name: "a-input-password", + name: "input-password", vModel: "value", }, required: false, @@ -227,7 +227,7 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin { * "successNotify": true, * "pfxPassword": "123456" */ - const checkInputChanges = ["domains", "sslProvider", "privateKeyType", "dnsProviderType", "dnsProviderAccess", "pfxPassword"]; + const checkInputChanges = ["domains", "sslProvider", "privateKeyType", "dnsProviderType", "pfxPassword"]; const oldInput = JSON.stringify(pick(this.lastStatus?.input, checkInputChanges)); const thisInput = JSON.stringify(pick(this, checkInputChanges)); inputChanged = oldInput !== thisInput; diff --git a/packages/ui/certd-client/CHANGELOG.md b/packages/ui/certd-client/CHANGELOG.md index 500e092f..573ebf7d 100644 --- a/packages/ui/certd-client/CHANGELOG.md +++ b/packages/ui/certd-client/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +### Bug Fixes + +* 修复移动任务后出现空阶段的bug ([4ea3edd](https://github.com/certd/certd/commit/4ea3edd59e93ca4f5b2e43b20dd4ef33909caddb)) +* 允许七牛云cdn插件输入.号开头的通配符域名 ([18ee87d](https://github.com/certd/certd/commit/18ee87daff6eafc2201b58e28d85aafd3cb7a5b9)) + +### Performance Improvements + +* 优化日志颜色 ([1291e98](https://github.com/certd/certd/commit/1291e98e821c5b1810aab7f0aebe3f5f5cd44a20)) +* 优化证书申请速度和成功率,反代地址优化,google基本可以稳定请求。增加请求重试。 ([41d9c3a](https://github.com/certd/certd/commit/41d9c3ac8398def541e65351cbe920d4a927182d)) +* 优化pfx密码密码输入框,让浏览器不自动填写密码 ([ffeede3](https://github.com/certd/certd/commit/ffeede38afa70c5ff6f2015516bead23d2c4df87)) + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) ### Bug Fixes diff --git a/packages/ui/certd-client/package.json b/packages/ui/certd-client/package.json index 815afe0e..5eaf7f5f 100644 --- a/packages/ui/certd-client/package.json +++ b/packages/ui/certd-client/package.json @@ -1,6 +1,6 @@ { "name": "@certd/ui-client", - "version": "1.26.10", + "version": "1.26.11", "private": true, "scripts": { "dev": "vite --open", @@ -11,6 +11,7 @@ "debug:force": "vite --force --mode debug", "build": " vite build ", "dev-build": "echo 1", + "test:unit": "vitest", "serve": "vite preview", "preview": "vite preview", "pretty-quick": "pretty-quick", @@ -61,8 +62,8 @@ "vuedraggable": "^4.1.0" }, "devDependencies": { - "@certd/lib-iframe": "^1.26.10", - "@certd/pipeline": "^1.26.10", + "@certd/lib-iframe": "^1.26.11", + "@certd/pipeline": "^1.26.11", "@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-node-resolve": "^15.2.3", "@types/chai": "^4.3.12", @@ -77,7 +78,7 @@ "@vitejs/plugin-vue-jsx": "^3.1.0", "@vue/compiler-sfc": "^3.4.21", "@vue/eslint-config-typescript": "^13.0.0", - "@vue/test-utils": "^2.4.5", + "@vue/test-utils": "^2.4.6", "autoprefixer": "^10.4.18", "caller-path": "^4.0.0", "chai": "^5.1.0", @@ -113,6 +114,7 @@ "vite-plugin-compression": "^0.5.1", "vite-plugin-html": "^3.2.2", "vite-plugin-windicss": "^1.9.3", + "vitest": "^2.1.2", "vue-eslint-parser": "^9.4.2", "vue-tsc": "^1.8.8" }, diff --git a/packages/ui/certd-client/src/api/service.ts b/packages/ui/certd-client/src/api/service.ts index b5285cf2..0a7c91b2 100644 --- a/packages/ui/certd-client/src/api/service.ts +++ b/packages/ui/certd-client/src/api/service.ts @@ -53,7 +53,9 @@ function createService() { // @ts-ignore response.config.onError(new Error(errorMessage)); } - errorCreate(`${errorMessage}: ${response.config.url}`); + //@ts-ignore + const showErrorNotify = response?.config?.showErrorNotify; + errorCreate(`${errorMessage}: ${response.config.url}`, showErrorNotify); return dataAxios; } } @@ -97,7 +99,7 @@ function createService() { default: break; } - errorLog(error); + errorLog(error, error?.response?.config?.showErrorNotify); if (status === 401) { const userStore = useUserStore(); userStore.logout(); diff --git a/packages/ui/certd-client/src/api/tools.ts b/packages/ui/certd-client/src/api/tools.ts index f389e203..08d80890 100644 --- a/packages/ui/certd-client/src/api/tools.ts +++ b/packages/ui/certd-client/src/api/tools.ts @@ -48,7 +48,7 @@ export function responseError(data = {}, msg = "请求失败", code = 500) { * @description 记录和显示错误 * @param {Error} error 错误对象 */ -export function errorLog(error: any) { +export function errorLog(error: any, notify = true) { // 打印到控制台 console.error("errorLog", error); let message = error.message; @@ -58,17 +58,22 @@ export function errorLog(error: any) { if (message.indexOf("ssl3_get_record:wrong version number") >= 0) { message = "http协议错误,服务端要求http协议,请检查是否使用了https请求"; } - // 显示提示 - uiContext.get().notification.error({ message }); + if (notify) { + // 显示提示 + uiContext.get().notification.error({ message }); + } } /** * @description 创建一个错误 * @param {String} msg 错误信息 */ -export function errorCreate(msg: string) { +export function errorCreate(msg: string, notify = true) { const err = new Error(msg); console.error("errorCreate", err); - uiContext.get().notification.error({ message: err.message }); + if (notify) { + uiContext.get().notification.error({ message: err.message }); + } + throw err; } diff --git a/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/api.ts b/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/api.ts index 85394285..baeaee01 100644 --- a/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/api.ts +++ b/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/api.ts @@ -3,8 +3,10 @@ import { request } from "/src/api/service"; const apiPrefix = "/cname/record"; export type CnameRecord = { - id: number; - status: string; + id?: number; + status?: string; + hostRecord?: string; + recordValue?: string; }; export async function GetList() { diff --git a/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/cname-record-info.vue b/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/cname-record-info.vue index 50e16f69..5050c142 100644 --- a/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/cname-record-info.vue +++ b/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/cname-record-info.vue @@ -7,6 +7,7 @@ + CNAME @@ -44,10 +45,12 @@ const props = defineProps<{ }>(); const emit = defineEmits<{ - change: { - id: number | null; - status: string | null; - }; + change: [ + { + id: number | null; + status: string | null; + } + ]; }>(); const cnameRecord = ref(null); diff --git a/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/cname-verify-plan.vue b/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/cname-verify-plan.vue index 41259ad4..ce4d571e 100644 --- a/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/cname-verify-plan.vue +++ b/packages/ui/certd-client/src/components/plugins/cert/domains-verify-plan-editor/cname-verify-plan.vue @@ -3,6 +3,7 @@ 主机记录 + 记录类型 请设置CNAME记录(验证成功以后不要删除) 状态 操作 diff --git a/packages/ui/certd-client/src/components/plugins/common/input-password.vue b/packages/ui/certd-client/src/components/plugins/common/input-password.vue new file mode 100644 index 00000000..6dc42141 --- /dev/null +++ b/packages/ui/certd-client/src/components/plugins/common/input-password.vue @@ -0,0 +1,28 @@ + + + diff --git a/packages/ui/certd-client/src/components/plugins/common/remote-select.vue b/packages/ui/certd-client/src/components/plugins/common/remote-select.vue index 3ea47918..360ec6ea 100644 --- a/packages/ui/certd-client/src/components/plugins/common/remote-select.vue +++ b/packages/ui/certd-client/src/components/plugins/common/remote-select.vue @@ -43,6 +43,7 @@ const attrs = useAttrs(); const optionsRef = ref([]); const message = ref(""); const getOptions = async () => { + message.value = ""; const res = await doRequest( { type: props.type, @@ -53,10 +54,10 @@ const getOptions = async () => { { onError(err: any) { message.value = `获取选项出错:${err.message}`; - } + }, + showErrorNotify: false } ); - message.value = ""; return res; }; diff --git a/packages/ui/certd-client/src/components/plugins/index.ts b/packages/ui/certd-client/src/components/plugins/index.ts index 6f1f7713..f9d811fe 100644 --- a/packages/ui/certd-client/src/components/plugins/index.ts +++ b/packages/ui/certd-client/src/components/plugins/index.ts @@ -5,6 +5,7 @@ import OutputSelector from "/@/components/plugins/common/output-selector/index.v import DnsProviderSelector from "/@/components/plugins/cert/dns-provider-selector/index.vue"; import DomainsVerifyPlanEditor from "/@/components/plugins/cert/domains-verify-plan-editor/index.vue"; import AccessSelector from "/@/views/certd/access/access-selector/index.vue"; +import InputPassword from "./common/input-password.vue"; export * from "./cert/index.js"; export default { install(app: any) { @@ -16,5 +17,6 @@ export default { app.component("SynologyDeviceIdGetter", SynologyIdDeviceGetter); app.component("RemoteSelect", RemoteSelect); app.component("CertDomainsGetter", CertDomainsGetter); + app.component("InputPassword", InputPassword); } }; diff --git a/packages/ui/certd-client/src/plugin/validator/__tests__/validator.spec.ts b/packages/ui/certd-client/src/plugin/validator/__tests__/validator.spec.ts new file mode 100644 index 00000000..133030c1 --- /dev/null +++ b/packages/ui/certd-client/src/plugin/validator/__tests__/validator.spec.ts @@ -0,0 +1,44 @@ +import { describe, expect, it } from "vitest"; +import { isDomain } from "/@/plugin/validator"; + +describe("domain_validator", () => { + it("ok", () => { + const value = ["a.cc.com", "*.zz.com", "a.cc.com"]; + const v = isDomain({}, value); + expect(v).to.be.true; + }); + + it("allowDotStart", () => { + let value = ["&.cc.com"]; + function test() { + return isDomain({ allowDotStart: true }, value); + } + expect(test).to.throw(Error, "域名有误:&.cc.com,请输入正确的域名"); + + value = ["a,cc.com"]; + expect(test).to.throw(Error, "域名有误:a,cc.com,请输入正确的域名"); + + value = ["&cc.com"]; + expect(test).to.throw(Error, "域名有误:&cc.com,请输入正确的域名"); + + value = [".cc.com"]; + expect(test()).to.be.true; + }); + + it("default", () => { + let value = ["&.cc.com"]; + function test() { + return isDomain({ allowDotStart: false }, value); + } + expect(test).to.throw(Error, "域名有误:&.cc.com,请输入正确的域名"); + + value = ["&cc.com"]; + expect(test).to.throw(Error, "域名有误:&cc.com,请输入正确的域名"); + + value = ["a,cc.com"]; + expect(test).to.throw(Error, "域名有误:a,cc.com,请输入正确的域名"); + + value = [".cc.com"]; + expect(test).to.throw(Error, "域名有误:.cc.com,请输入正确的域名"); + }); +}); diff --git a/packages/ui/certd-client/src/plugin/validator/index.ts b/packages/ui/certd-client/src/plugin/validator/index.ts index b0f0a156..b61d7cf1 100644 --- a/packages/ui/certd-client/src/plugin/validator/index.ts +++ b/packages/ui/certd-client/src/plugin/validator/index.ts @@ -1,6 +1,6 @@ import Validator from "async-validator"; // 自定义验证器函数 -function isDomain(rule, value) { +export function isDomain(rule: any, value: any) { if (value == null) { return true; } @@ -8,9 +8,14 @@ function isDomain(rule, value) { if (typeof value === "string") { domains = value.split(","); } + + const allowDotStart = rule.allowDotStart ? "\\.|" : ""; + const exp = `^(?:${allowDotStart}\\*\\.|[0-9a-zA-Z\u4e00-\u9fa5-]+\\.)+[0-9a-zA-Z\u4e00-\u9fa5-]+$`; + const compiled = new RegExp(exp); for (const domain of domains) { //域名可以是泛域名,中文域名,数字域名,英文域名,域名中可以包含-和. ,可以_开头 - if (!/^(?:\*\.|[0-9a-zA-Z\u4e00-\u9fa5-]+\.)+[0-9a-zA-Z\u4e00-\u9fa5-]+$/.test(domain)) { + + if (!compiled.test(domain)) { throw new Error(`域名有误:${domain},请输入正确的域名`); } } diff --git a/packages/ui/certd-client/src/router/source/header.ts b/packages/ui/certd-client/src/router/source/header.ts index 7467caef..5a074857 100644 --- a/packages/ui/certd-client/src/router/source/header.ts +++ b/packages/ui/certd-client/src/router/source/header.ts @@ -1,7 +1,10 @@ export const headerResource = [ { title: "文档", - path: "https://certd.docmirror.cn" + path: "https://certd.docmirror.cn", + meta: { + icon: "ion:document-text-outline" + }, }, { title: "源码", diff --git a/packages/ui/certd-client/src/style/common.less b/packages/ui/certd-client/src/style/common.less index 13d8b97c..361011c2 100644 --- a/packages/ui/certd-client/src/style/common.less +++ b/packages/ui/certd-client/src/style/common.less @@ -170,6 +170,9 @@ h1, h2, h3, h4, h5, h6 { color: #1890ff; } +.iconify{ + //font-size: 16px; +} .icon-box { display: inline-flex; diff --git a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx index 7b006f4c..7b83032d 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx @@ -13,7 +13,8 @@ import { useSettingStore } from "/@/store/modules/settings"; import _ from "lodash-es"; import { useModal } from "/@/use/use-modal"; import CertView from "./cert-view.vue"; -import { eachRunnable, eachStages } from "./utils"; +import { eachStages } from "./utils"; + export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOptionsProps): CreateCrudOptionsRet { const router = useRouter(); const { t } = useI18n(); diff --git a/packages/ui/certd-client/src/views/certd/pipeline/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/index.vue index fe1e642d..341ddf6a 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/index.vue @@ -20,7 +20,7 @@ import createCrudOptions from "./crud"; import { useExpose } from "@fast-crud/fast-crud"; import PiCertdForm from "./certd-form/index.vue"; export default defineComponent({ - name: "PipelineManager", + name: "PipelineManager1", components: { PiCertdForm }, setup() { const certdFormRef = ref(); diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue index d4900313..54b13b17 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue @@ -8,7 +8,11 @@ -
+
+ +
@@ -57,7 +61,20 @@ export default { if (currentHistory?.value?.logs != null) { node.logs = computed(() => { if (currentHistory?.value?.logs && currentHistory.value?.logs[node.node.id] != null) { - return currentHistory.value?.logs[node.node.id]; + const logs = currentHistory.value?.logs[node.node.id]; + const list = []; + for (let log of logs) { + const index = log.indexOf("]", 27) + 1; + const time = log.substring(0, index); + const content = log.substring(index); + const color = time.includes("ERROR") ? "red" : time.includes("WARN") ? "yellow" : "green"; + list.push({ + time, + content, + color + }); + } + return list; } return []; }); @@ -92,6 +109,7 @@ export default { .pi-task-view { .tab-title { display: flex; + .tab-title-text { display: inline-block; width: 180px; @@ -104,11 +122,26 @@ export default { .pi-task-view-logs { background-color: #000c17; - color: #fafafa; + color: #e9e9e9; + font-family: monospace; + padding: 5px; min-height: 300px; max-height: 580px; white-space: pre-wrap; word-wrap: break-word; + > div { + padding: 0; + margin: 0; + } + .green { + color: rgba(0, 255, 0, 0.8); + } + .yellow { + color: yellow; + } + .red { + color: red; + } } } diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue index 3f5ec18c..6066f745 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue @@ -101,8 +101,9 @@ @@ -263,7 +264,7 @@ import _ from "lodash-es"; import { message, Modal, notification } from "ant-design-vue"; import { nanoid } from "nanoid"; import { PipelineDetail, PipelineOptions, PluginGroups, RunHistory } from "./type"; -import type { Runnable } from "@certd/pipeline"; +import type { Runnable, Stage } from "@certd/pipeline"; import PiHistoryTimelineItem from "/@/views/certd/pipeline/pipeline/component/history-timeline-item.vue"; import { FsIcon } from "@fast-crud/fast-crud"; import { useSettingStore } from "/@/store/modules/settings"; @@ -632,6 +633,12 @@ export default defineComponent({ } pipeline.value.version++; currentPipeline.value = pipeline.value; + + //移除空阶段 + _.remove(pipeline.value.stages, (item: Stage) => { + return item.tasks.length === 0; + }); + await props.options.doSave(pipeline.value); } toggleEditMode(false); diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/utils/util.status.ts b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/utils/util.status.ts index 54c8c1ed..a655b5fd 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/utils/util.status.ts +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/utils/util.status.ts @@ -4,6 +4,7 @@ export type StatusEnumItem = { color: string; icon: string; spin?: boolean; + iconSpin?: boolean; }; export type StatusEnumType = { [key: string]: StatusEnumItem; @@ -34,13 +35,13 @@ const StatusEnum: StatusEnumType = { label: "运行中", color: "blue", spin: true, + iconSpin: true, icon: "ant-design:sync-outlined" }, canceled: { value: "canceled", label: "已取消", color: "yellow", - spin: true, icon: "ant-design:minus-circle-twotone" }, none: { diff --git a/packages/ui/certd-server/CHANGELOG.md b/packages/ui/certd-server/CHANGELOG.md index 63e84bb4..5f9e0787 100644 --- a/packages/ui/certd-server/CHANGELOG.md +++ b/packages/ui/certd-server/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.26.11](https://github.com/certd/certd/compare/v1.26.10...v1.26.11) (2024-10-23) + +### Bug Fixes + +* 允许七牛云cdn插件输入.号开头的通配符域名 ([18ee87d](https://github.com/certd/certd/commit/18ee87daff6eafc2201b58e28d85aafd3cb7a5b9)) + +### Performance Improvements + +* 优化证书申请速度和成功率,反代地址优化,google基本可以稳定请求。增加请求重试。 ([41d9c3a](https://github.com/certd/certd/commit/41d9c3ac8398def541e65351cbe920d4a927182d)) + ## [1.26.10](https://github.com/certd/certd/compare/v1.26.9...v1.26.10) (2024-10-20) ### Bug Fixes diff --git a/packages/ui/certd-server/package.json b/packages/ui/certd-server/package.json index b3da1474..b11b8e3d 100644 --- a/packages/ui/certd-server/package.json +++ b/packages/ui/certd-server/package.json @@ -1,6 +1,6 @@ { "name": "@certd/ui-server", - "version": "1.26.10", + "version": "1.26.11", "description": "fast-server base midway", "private": true, "type": "module", @@ -27,17 +27,17 @@ }, "dependencies": { "@alicloud/pop-core": "^1.7.10", - "@certd/acme-client": "^1.26.10", - "@certd/commercial-core": "^1.26.10", - "@certd/lib-huawei": "^1.26.10", - "@certd/lib-jdcloud": "^1.26.10", - "@certd/lib-k8s": "^1.26.10", - "@certd/lib-server": "^1.26.10", - "@certd/midway-flyway-js": "^1.26.10", - "@certd/pipeline": "^1.26.10", - "@certd/plugin-cert": "^1.26.10", - "@certd/plugin-plus": "^1.26.10", - "@certd/plus-core": "^1.26.10", + "@certd/acme-client": "^1.26.11", + "@certd/commercial-core": "^1.26.11", + "@certd/lib-huawei": "^1.26.11", + "@certd/lib-jdcloud": "^1.26.11", + "@certd/lib-k8s": "^1.26.11", + "@certd/lib-server": "^1.26.11", + "@certd/midway-flyway-js": "^1.26.11", + "@certd/pipeline": "^1.26.11", + "@certd/plugin-cert": "^1.26.11", + "@certd/plugin-plus": "^1.26.11", + "@certd/plus-core": "^1.26.11", "@koa/cors": "^5.0.0", "@midwayjs/bootstrap": "~3.17.1", "@midwayjs/cache": "~3.14.0", diff --git a/packages/ui/certd-server/src/plugins/plugin-cloudflare/dns-provider.ts b/packages/ui/certd-server/src/plugins/plugin-cloudflare/dns-provider.ts index f4b1ce1f..fe67282a 100644 --- a/packages/ui/certd-server/src/plugins/plugin-cloudflare/dns-provider.ts +++ b/packages/ui/certd-server/src/plugins/plugin-cloudflare/dns-provider.ts @@ -37,8 +37,12 @@ export class CloudflareDnsProvider extends AbstractDnsProvider } async getZoneId(domain: string) { + this.logger.info('获取zoneId:', domain); const url = `https://api.cloudflare.com/client/v4/zones?name=${domain}`; const res = await this.doRequestApi(url, null, 'get'); + if (res.result.length === 0) { + throw new Error(`未找到域名${domain}的zoneId`); + } return res.result[0].id; } diff --git a/packages/ui/certd-server/src/plugins/plugin-qiniu/plugin/deploy-to-cdn/index.ts b/packages/ui/certd-server/src/plugins/plugin-qiniu/plugin/deploy-to-cdn/index.ts index 338486cf..97f655aa 100644 --- a/packages/ui/certd-server/src/plugins/plugin-qiniu/plugin/deploy-to-cdn/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-qiniu/plugin/deploy-to-cdn/index.ts @@ -7,7 +7,7 @@ import { CertInfo } from '@certd/plugin-cert'; title: '部署证书至七牛CDN', icon: 'svg:icon-qiniuyun', group: pluginGroups.cdn.key, - desc: '自动部署域名证书至七牛云CDN,七牛云OSS', + desc: '自动部署域名证书至七牛云CDN', default: { strategy: { runStrategy: RunStrategy.SkipWhenSucceed, @@ -25,7 +25,7 @@ export class QiniuDeployCertToCDN extends AbstractTaskPlugin { open: false, tokenSeparators: [',', ' ', ',', '、', '|'], }, - rules: [{ type: 'domains' }], + rules: [{ type: 'domains', allowDotStart: true }], required: true, }) domainName!: string | string[];