Compare commits
348 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e96a83a528 | ||
|
|
fbddd7ead8 | ||
|
|
762a2058d3 | ||
|
|
2bc0a4bd14 | ||
|
|
e052e304bd | ||
|
|
50c56d134e | ||
|
|
4caa2fad9d | ||
|
|
07043aff0c | ||
|
|
e8b617b80c | ||
|
|
417971d15d | ||
|
|
ccfe72a0d9 | ||
|
|
6f8fe62087 | ||
|
|
5601bc4ab2 | ||
|
|
67ba17286c | ||
|
|
a10b8aa042 | ||
|
|
273ab6139f | ||
|
|
9b68009eb3 | ||
|
|
aec2448406 | ||
|
|
4343fb1b30 | ||
|
|
64e6c74bb6 | ||
|
|
73962536d5 | ||
|
|
38be8d84b2 | ||
|
|
8ab632c97c | ||
|
|
903edf12df | ||
|
|
66f9b08fcf | ||
|
|
fcaf891a90 | ||
|
|
3b1f3e8a3f | ||
|
|
d8d9f9b99c | ||
|
|
126e548510 | ||
|
|
91fc1cd735 | ||
|
|
4244569211 | ||
|
|
f23c4af2ad | ||
|
|
809bde9d20 | ||
|
|
52bf8a1bb6 | ||
|
|
614ce97898 | ||
|
|
5aacd18320 | ||
|
|
daf575e7c3 | ||
|
|
70ce2b96e3 | ||
|
|
0b5b3b7444 | ||
|
|
46b8108229 | ||
|
|
cc38f3eb29 | ||
|
|
cfd4bc740a | ||
|
|
443f3e7f10 | ||
|
|
49395e8cb6 | ||
|
|
480ce2d812 | ||
|
|
ecf9a52573 | ||
|
|
b5e1179a39 | ||
|
|
8176469e3e | ||
|
|
a6fb15f81b | ||
|
|
50173aa265 | ||
|
|
79f8e5bf47 | ||
|
|
e9a285bd29 | ||
|
|
6754d5a3d6 | ||
|
|
68e5ea1cad | ||
|
|
0e4b72c65d | ||
|
|
81fac736f9 | ||
|
|
a954ab7ede | ||
|
|
99387ee32b | ||
|
|
e85c47744c | ||
|
|
56711c6040 | ||
|
|
7ad5bcffb5 | ||
|
|
88d745e290 | ||
|
|
2a3ca9f552 | ||
|
|
5649f708e3 | ||
|
|
cbd6abb29d | ||
|
|
0a9ec06fe7 | ||
|
|
2ba94d03aa | ||
|
|
5d15d71da8 | ||
|
|
592791d135 | ||
|
|
c5e58770d1 | ||
|
|
77cc3c4a5c | ||
|
|
8f79107d2b | ||
|
|
1b4ba04a23 | ||
|
|
722557fd14 | ||
|
|
1d48dcc004 | ||
|
|
f0b2a61246 | ||
|
|
afd278e609 | ||
|
|
42bde235d3 | ||
|
|
b5d8935159 | ||
|
|
9498d189e4 | ||
|
|
01b79bbeaf | ||
|
|
f3d35084ed | ||
|
|
0c8e83e125 | ||
|
|
67adddd23e | ||
|
|
4b400bbfde | ||
|
|
854053e961 | ||
|
|
11a9fe9014 | ||
|
|
ce9a9862f1 | ||
|
|
0584b3672b | ||
|
|
a21889080d | ||
|
|
4e502a171c | ||
|
|
f66e6412af | ||
|
|
a4e2cc54e6 | ||
|
|
a13203fb3f | ||
|
|
4053e72782 | ||
|
|
c9d18f6d8a | ||
|
|
aeed24e87d | ||
|
|
ff9b7a5e80 | ||
|
|
afa8155fda | ||
|
|
388cb60cbb | ||
|
|
4d9fb9f69f | ||
|
|
3ef0541cc8 | ||
|
|
93fc8dc665 | ||
|
|
2ecf1cce5b | ||
|
|
551311d3a0 | ||
|
|
b09acfb4dc | ||
|
|
f8f3e8b43f | ||
|
|
f2f56adfd7 | ||
|
|
19a2d74eed | ||
|
|
af582a489d | ||
|
|
f548fe7011 | ||
|
|
17a9beb514 | ||
|
|
8d42273665 | ||
|
|
251e450fab | ||
|
|
d3ba3254f1 | ||
|
|
196f9c5fa8 | ||
|
|
d00f7ee010 | ||
|
|
345571cdff | ||
|
|
1bdf7cf439 | ||
|
|
9c253e8c49 | ||
|
|
1c0b040eb0 | ||
|
|
939b8d4aa9 | ||
|
|
eec9e2e742 | ||
|
|
62f5b18022 | ||
|
|
a7ecda9b36 | ||
|
|
aec753a3f8 | ||
|
|
9225eeee44 | ||
|
|
d5608c6dab | ||
|
|
d668032310 | ||
|
|
f46db508c7 | ||
|
|
bf024bdda8 | ||
|
|
7532a96085 | ||
|
|
8e32156aa0 | ||
|
|
75ccae3f6b | ||
|
|
8d493b7a89 | ||
|
|
c6412674fa | ||
|
|
feb3fc6eb5 | ||
|
|
0874c03882 | ||
|
|
15f44e64f7 | ||
|
|
51f29d6093 | ||
|
|
7ee9d915fb | ||
|
|
d91026dc4f | ||
|
|
df88a936a5 | ||
|
|
1939c214cf | ||
|
|
5668a3e222 | ||
|
|
47fa419803 | ||
|
|
4fcaab5feb | ||
|
|
5aa06f5b07 | ||
|
|
9d9c021819 | ||
|
|
21c09c93b3 | ||
|
|
3dc2750d64 | ||
|
|
76e86ea283 | ||
|
|
a00e96b63b | ||
|
|
d047234d98 | ||
|
|
3f21a49988 | ||
|
|
6a02de35ce | ||
|
|
65363b2713 | ||
|
|
ec8c06da9b | ||
|
|
d0cb0e324e | ||
|
|
be13390b3a | ||
|
|
e9fda44bf0 | ||
|
|
27f6cf24dd | ||
|
|
6ab627ed5a | ||
|
|
a350b51cf8 | ||
|
|
bbb032344b | ||
|
|
3220b87457 | ||
|
|
ec1015295e | ||
|
|
a943a41d2e | ||
|
|
2d86fa254c | ||
|
|
03ce69dbfb | ||
|
|
653d8d43a8 | ||
|
|
ae816e614c | ||
|
|
3460d3ddca | ||
|
|
f5b423c351 | ||
|
|
a4652ce7ba | ||
|
|
7417188d36 | ||
|
|
c2650d308c | ||
|
|
a616101ad0 | ||
|
|
9fdb560528 | ||
|
|
0f0ddb9c59 | ||
|
|
50e027ca80 | ||
|
|
37aa7f5dfc | ||
|
|
9c3709106b | ||
|
|
66fb689ac5 | ||
|
|
8e01360a22 | ||
|
|
3bbf8f4a03 | ||
|
|
c7f7910fa9 | ||
|
|
211548fd53 | ||
|
|
4d4c77129f | ||
|
|
7500fb3b1c | ||
|
|
1906c310f5 | ||
|
|
59695cee88 | ||
|
|
36975b37e3 | ||
|
|
5724c04bc3 | ||
|
|
2e22f69bde | ||
|
|
298c2c8bc7 | ||
|
|
86e291c5a3 | ||
|
|
f9a3ac2cb1 | ||
|
|
8ecc2f9446 | ||
|
|
8de56feeb7 | ||
|
|
10ff783982 | ||
|
|
c46b2c3cb7 | ||
|
|
9a3ff8ad1a | ||
|
|
92aa4a6d63 | ||
|
|
154f627f2a | ||
|
|
a624a3f065 | ||
|
|
361e8fe7ae | ||
|
|
3d9c3ecb3e | ||
|
|
f9ff9191a1 | ||
|
|
e85b4da2e3 | ||
|
|
ab53c601bf | ||
|
|
8e03e8463f | ||
|
|
81d6c0ebdf | ||
|
|
e0466409d0 | ||
|
|
e86756e4c6 | ||
|
|
bdc0227c08 | ||
|
|
0451fa7573 | ||
|
|
8b8039f42b | ||
|
|
df55299e6f | ||
|
|
9c773aaa05 | ||
|
|
4e4bbee8c2 | ||
|
|
d331fea477 | ||
|
|
9de77b327d | ||
|
|
ab41eea7a9 | ||
|
|
22ef28f633 | ||
|
|
a8da658a97 | ||
|
|
e5a5d0a607 | ||
|
|
60ea9106f1 | ||
|
|
7549b9443f | ||
|
|
5021a2081e | ||
|
|
ce3426368b | ||
|
|
7aa3d8e5d9 | ||
|
|
4c37ec3222 | ||
|
|
830de90317 | ||
|
|
d5956072f0 | ||
|
|
2309b07d85 | ||
|
|
3a6e067ea3 | ||
|
|
bb8f0bed6d | ||
|
|
6fee28c9e9 | ||
|
|
b6e3b96d56 | ||
|
|
ecd83ee136 | ||
|
|
8ed16b3ea2 | ||
|
|
5b0f5f75d0 | ||
|
|
a89fe4702d | ||
|
|
664bd863e5 | ||
|
|
e0241686dc | ||
|
|
9092f05985 | ||
|
|
eb1ab0992f | ||
|
|
f22ff2296c | ||
|
|
6fe2d2c328 | ||
|
|
20f5865bb9 | ||
|
|
2b224c712f | ||
|
|
c446e24f1a | ||
|
|
2623f45a3b | ||
|
|
52e7208e8f | ||
|
|
d1498a7160 | ||
|
|
5c270b6b9d | ||
|
|
18718f6a25 | ||
|
|
653f409d91 | ||
|
|
0f0af2f309 | ||
|
|
7908ab79da | ||
|
|
ae3daa9bcf | ||
|
|
48238d929e | ||
|
|
01df4d0f1d | ||
|
|
25ff6906c6 | ||
|
|
695548eade | ||
|
|
6221a4e464 | ||
|
|
115b819c66 | ||
|
|
bceb8cce0d | ||
|
|
8d2cf2095c | ||
|
|
1b1a1a5bc2 | ||
|
|
935ebe022a | ||
|
|
ff356571c8 | ||
|
|
76fb2141e4 | ||
|
|
b220500f40 | ||
|
|
1cbf70fb6a | ||
|
|
52ec48656d | ||
|
|
fddf3a0f68 | ||
|
|
98520a1213 | ||
|
|
d65d94b784 | ||
|
|
00f1e0da59 | ||
|
|
65ef685729 | ||
|
|
6e344140c6 | ||
|
|
97a01b6f6d | ||
|
|
c49ccbde93 | ||
|
|
fc73d9d615 | ||
|
|
1133d6b0f7 | ||
|
|
b80210f24b | ||
|
|
3bad0b2685 | ||
|
|
af388ec39f | ||
|
|
8d7c2c8e29 | ||
|
|
8088cd6d58 | ||
|
|
590ce9642e | ||
|
|
99302b8ff2 | ||
|
|
14b108f09e | ||
|
|
0669835d4e | ||
|
|
fbeaed2035 | ||
|
|
ecad7f58c1 | ||
|
|
1dd9a8d4d3 | ||
|
|
bd73a163cd | ||
|
|
1e9b5638aa | ||
|
|
71ac8aae4a | ||
|
|
d5bfcdb6de | ||
|
|
1480efb43d | ||
|
|
1c17b41e16 | ||
|
|
192d9dc7e3 | ||
|
|
d0d3c2b588 | ||
|
|
b8a8f20448 | ||
|
|
28a32aed7d | ||
|
|
ff46771d8d | ||
|
|
87a2673e8c | ||
|
|
c59cab1aae | ||
|
|
6314e8d7eb | ||
|
|
5ade12d700 | ||
|
|
ceb210b1b7 | ||
|
|
5e084db038 | ||
|
|
bef6b981e2 | ||
|
|
a77cd65789 | ||
|
|
415b731d9a | ||
|
|
6c0099d600 | ||
|
|
98b77f8084 | ||
|
|
2f47ffb76b | ||
|
|
35a3603c41 | ||
|
|
ea775adae1 | ||
|
|
724a85028b | ||
|
|
b2d595e85c | ||
|
|
d9b1ff8c5c | ||
|
|
1c17970b98 | ||
|
|
b9bddbfabb | ||
|
|
ee617095ef | ||
|
|
bee20c7f51 | ||
|
|
b8e05e9b44 | ||
|
|
869e14bad9 | ||
|
|
952e01ab7d | ||
|
|
db61033633 | ||
|
|
42a56b581d | ||
|
|
d6bb9f6af4 | ||
|
|
a430b27034 | ||
|
|
0f6679425f | ||
|
|
4b9d1eb4b5 | ||
|
|
ca4a1b8d92 | ||
|
|
08a702a758 | ||
|
|
589191244f | ||
|
|
f3ddcd3054 | ||
|
|
f923655d91 | ||
|
|
879e2609ca | ||
|
|
d227dd64e3 | ||
|
|
d2997624b0 |
38
.github/workflows/build-image.yml
vendored
@@ -40,7 +40,7 @@ jobs:
|
||||
# cache: 'npm'
|
||||
# working-directory: ./packages/ui/certd-client
|
||||
- run: |
|
||||
npm install -g pnpm
|
||||
npm install -g pnpm@8.15.7
|
||||
pnpm install
|
||||
npm run build
|
||||
working-directory: ./packages/ui/certd-client
|
||||
@@ -58,8 +58,14 @@ jobs:
|
||||
username: ${{ secrets.aliyun_cs_username }}
|
||||
password: ${{ secrets.aliyun_cs_password }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6.5.0
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.dockerhub_username }}
|
||||
password: ${{ secrets.dockerhub_password }}
|
||||
|
||||
- name: Build default platforms
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
@@ -67,3 +73,29 @@ jobs:
|
||||
tags: |
|
||||
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:latest
|
||||
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${{steps.get_certd_version.outputs.result}}
|
||||
greper/certd:latest
|
||||
greper/certd:${{steps.get_certd_version.outputs.result}}
|
||||
|
||||
- name: Build armv7
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/arm/v7
|
||||
push: true
|
||||
context: ./packages/ui/
|
||||
tags: |
|
||||
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:armv7
|
||||
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${{steps.get_certd_version.outputs.result}}-armv7
|
||||
greper/certd:armv7
|
||||
greper/certd:${{steps.get_certd_version.outputs.result}}-armv7
|
||||
|
||||
- name: Build agent
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
context: ./packages/ui/agent/
|
||||
tags: |
|
||||
registry.cn-shenzhen.aliyuncs.com/handsfree/certd-agent:latest
|
||||
registry.cn-shenzhen.aliyuncs.com/handsfree/certd-agent:${{steps.get_certd_version.outputs.result}}
|
||||
greper/certd-agent:latest
|
||||
greper/certd-agent:${{steps.get_certd_version.outputs.result}}
|
||||
|
||||
12
.gitignore
vendored
@@ -19,23 +19,13 @@ gen
|
||||
/*.log
|
||||
|
||||
/packages/ui/*/.idea
|
||||
|
||||
/packages/ui/*/node_modules
|
||||
|
||||
/packages/*/node_modules
|
||||
/packages/ui/certd-server/tmp/
|
||||
/packages/ui/certd-ui/dist/
|
||||
/other
|
||||
/dev-sidecar-test
|
||||
/packages/core/certd/yarn.lock
|
||||
/packages/test
|
||||
/test/own
|
||||
/pnpm-lock.yaml
|
||||
|
||||
docker/image/workspace
|
||||
/packages/core/lego
|
||||
|
||||
tsconfig.tsbuildinfo
|
||||
test/**/*.js
|
||||
/packages/ui/certd-server/data/db.sqlite
|
||||
/packages/ui/certd-server/data/keys.yaml
|
||||
/packages/pro/
|
||||
|
||||
204
CHANGELOG.md
@@ -3,6 +3,210 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.26.4](https://github.com/certd/certd/compare/v1.26.3...v1.26.4) (2024-10-14)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* [comm] 支持插件管理 ([e8b617b](https://github.com/certd/certd/commit/e8b617b80ce882dd63006f0cfc719a80a1cc6acc))
|
||||
* 新增代理设置功能 ([273ab61](https://github.com/certd/certd/commit/273ab6139f5807f4d7fe865cc353b97f51b9a668))
|
||||
* EAB授权支持绑定邮箱,支持公共EAB设置 ([07043af](https://github.com/certd/certd/commit/07043aff0ca7fd29c56dd3c363002cb15d78b464))
|
||||
|
||||
## [1.26.3](https://github.com/certd/certd/compare/v1.26.2...v1.26.3) (2024-10-12)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 优化系统设置加载时机 ([7396253](https://github.com/certd/certd/commit/73962536d5a4769902d760d005f3f879465addcc))
|
||||
|
||||
## [1.26.2](https://github.com/certd/certd/compare/v1.26.1...v1.26.2) (2024-10-11)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复某些情况下bindUrl失败的bug ([91fc1cd](https://github.com/certd/certd/commit/91fc1cd7353be4a22be951239ed70b38baebc74e))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 邮箱设置改为系统设置,普通用户无需配置发件邮箱 ([4244569](https://github.com/certd/certd/commit/42445692117184a3293e63bef84a74cbb5984b0e))
|
||||
|
||||
## [1.26.1](https://github.com/certd/certd/compare/v1.26.0...v1.26.1) (2024-10-10)
|
||||
|
||||
**Note:** Version bump only for package root
|
||||
|
||||
# [1.26.0](https://github.com/certd/certd/compare/v1.25.9...v1.26.0) (2024-10-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复管理员编辑其他用户流水线任务时归属userid也被修改的bug ([e85c477](https://github.com/certd/certd/commit/e85c47744cf740b4af3b93dca7c2f0ccc818ec2f))
|
||||
* 修复历史记录根据流水线名称查询报错的bug ([ce9a986](https://github.com/certd/certd/commit/ce9a9862f122fce2186e7727eaa4b251b59e6032))
|
||||
* 修复某些代理情况下 报 400 The plain HTTP request was sent to HTTPS port use proxy 的bug ([a13203f](https://github.com/certd/certd/commit/a13203fb3f48c427d0d81a504912248dcc07df1a))
|
||||
|
||||
### Features
|
||||
|
||||
* 域名验证方法支持CNAME间接方式,此方式支持所有域名注册商,且无需提供Access授权,但是需要手动添加cname解析 ([f3d3508](https://github.com/certd/certd/commit/f3d35084ed44f9f33845f7045e520be5c27eed93))
|
||||
* 站点个性化设置 ([11a9fe9](https://github.com/certd/certd/commit/11a9fe9014d96cba929e5a066e78f2af7ae59d14))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 并行任务名称改成添加任务,取消并行,可以在同一个阶段获取上一个task的输出 ([c5e5877](https://github.com/certd/certd/commit/c5e58770d1c5edc19c6f9ea1618f44b68e091f35))
|
||||
* 调整静态资源到static目录 ([0584b36](https://github.com/certd/certd/commit/0584b3672b40f9042a2ed87e5627022606d046cd))
|
||||
* 调整全部静态资源到static目录 ([a218890](https://github.com/certd/certd/commit/a21889080d6c7ffdf0af526a3a21f0b2d1c77288))
|
||||
* 检查cname是否正确配置 ([b5d8935](https://github.com/certd/certd/commit/b5d8935159374fbe7fc7d4c48ae0ed9396861bdd))
|
||||
* 七牛云cdn支持配置多个域名 ([88d745e](https://github.com/certd/certd/commit/88d745e29063a089864fb9c6705be7b8d4c2669a))
|
||||
* 上传到主机插件支持注入环境变量 ([81fac73](https://github.com/certd/certd/commit/81fac736f9ccc8d1cda7ef4178752239cec20849))
|
||||
* 优化宝塔网站部署插件远程获取数据的提示 ([2a3ca9f](https://github.com/certd/certd/commit/2a3ca9f552d96594ec6690a1c4c91f598451b9a1))
|
||||
* 优化缩短首页缓存时间 ([49395e8](https://github.com/certd/certd/commit/49395e8cb65f4b30c0145329ed5de48be4ef3842))
|
||||
* 域名输入增加校验提示,避免输入错误的域名 ([0c8e83e](https://github.com/certd/certd/commit/0c8e83e1254a9ce4d5a4e7888eb1710394a4b77c))
|
||||
* cname校验配置增加未校验通过提示 ([77cc3c4](https://github.com/certd/certd/commit/77cc3c4a5cbd81f8233a8e0bb33fab0621c0905f))
|
||||
* google eab授权支持自动获取,不过要配置代理 ([592791d](https://github.com/certd/certd/commit/592791d1356fc252fbb70d7f168567aee9585507))
|
||||
|
||||
## [1.25.9](https://github.com/certd/certd/compare/v1.25.8...v1.25.9) (2024-10-01)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复西部数码账户级别apikey不可用的bug ([f8f3e8b](https://github.com/certd/certd/commit/f8f3e8b43fd5d815887bcb53b95f46dc96424b79))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 增加等待插件 ([3ef0541](https://github.com/certd/certd/commit/3ef0541cc85ab6abf698ead3b258ae1ac156ef98))
|
||||
|
||||
## [1.25.8](https://github.com/certd/certd/compare/v1.25.7...v1.25.8) (2024-09-30)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复pfxPassword无效的bug ([251e450](https://github.com/certd/certd/commit/251e450fabfe62405bac13e39f2153736c081ef0))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 群晖获取deviceid优化 ([8d42273](https://github.com/certd/certd/commit/8d4227366548eb70f6bc04303829e6933168f906))
|
||||
|
||||
## [1.25.7](https://github.com/certd/certd/compare/v1.25.6...v1.25.7) (2024-09-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复某些地区被屏蔽无法激活专业版的bug ([7532a96](https://github.com/certd/certd/commit/7532a960851b84d4f2cc3dba02353c5235e1a364))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 上传到主机,支持socks代理 ([d91026d](https://github.com/certd/certd/commit/d91026dc4fbfe5fedc4ee8e43dc0d08f1cf88356))
|
||||
* 支持上传到七牛云oss ([bf024bd](https://github.com/certd/certd/commit/bf024bdda8bc2a463475be5761acf0da7317a08a))
|
||||
|
||||
## [1.25.6](https://github.com/certd/certd/compare/v1.25.5...v1.25.6) (2024-09-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复中间证书复制错误的bug ([76e86ea](https://github.com/certd/certd/commit/76e86ea283ecbe4ec76cdc92b98457d0fef544ac))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 部署支持1Panel ([d047234](https://github.com/certd/certd/commit/d047234d98d31504f2e5a472b66e1b75806af26e))
|
||||
* 增加使用教程 ([9d9c021](https://github.com/certd/certd/commit/9d9c0218195af5b9896cce7109b26a433480571d))
|
||||
|
||||
## [1.25.5](https://github.com/certd/certd/compare/v1.25.4...v1.25.5) (2024-09-26)
|
||||
|
||||
**Note:** Version bump only for package root
|
||||
|
||||
## [1.25.4](https://github.com/certd/certd/compare/v1.25.3...v1.25.4) (2024-09-25)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复启动报授权验证失败的bug ([3460d3d](https://github.com/certd/certd/commit/3460d3ddca222ea702816ab805909d489eff957f))
|
||||
|
||||
## [1.25.3](https://github.com/certd/certd/compare/v1.25.2...v1.25.3) (2024-09-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复upload to host trim错误 ([0f0ddb9](https://github.com/certd/certd/commit/0f0ddb9c5963fd643d6d203334efac471c43ec3b))
|
||||
|
||||
## [1.25.2](https://github.com/certd/certd/compare/v1.25.1...v1.25.2) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package root
|
||||
|
||||
## [1.25.1](https://github.com/certd/certd/compare/v1.25.0...v1.25.1) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package root
|
||||
|
||||
# [1.25.0](https://github.com/certd/certd/compare/v1.24.4...v1.25.0) (2024-09-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复首次创建任务运行时不自动设置当前运行情况的bug ([ecd83ee](https://github.com/certd/certd/commit/ecd83ee136abdd3df9ed2f21ec2ff0f24c0ed9d9))
|
||||
|
||||
### Features
|
||||
|
||||
* 账号绑定 ([e046640](https://github.com/certd/certd/commit/e0466409d0c021bb415abd94df448c8a0d4799e9))
|
||||
* 支持中间证书 ([e86756e](https://github.com/certd/certd/commit/e86756e4c65a53dd23106d7ecbfe2fa987cc13f3))
|
||||
* 支持vip转移 ([361e8fe](https://github.com/certd/certd/commit/361e8fe7ae5877e23fd5de31bc919bedd09c57f5))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 群晖支持OTP双重验证登录 ([8b8039f](https://github.com/certd/certd/commit/8b8039f42bbce10a4d0e737cdeeeef9bb17bee5a))
|
||||
* 任务支持禁用 ([8ed16b3](https://github.com/certd/certd/commit/8ed16b3ea2dfe847357863a0bfa614e4fa5fc041))
|
||||
* 优化收件邮箱输入 ([22ef28f](https://github.com/certd/certd/commit/22ef28f6338a78465bd52ccbad13e66e80263b2f))
|
||||
* 优化主机登录失败提示 ([9de77b3](https://github.com/certd/certd/commit/9de77b327d39cff5ed6660ec53b58ba0eea18e5a))
|
||||
* 增加重启certd插件 ([48238d9](https://github.com/certd/certd/commit/48238d929e6c4afa1d428e4d35b9159d37a47ae0))
|
||||
* 证书支持旧版RSA,pkcs1 ([3d9c3ec](https://github.com/certd/certd/commit/3d9c3ecb3eb604b2458154f608bde0f01915d116))
|
||||
* 支持阿里云ACK证书部署 ([d331fea](https://github.com/certd/certd/commit/d331fea47789122650e057ec7c9e85ee8e66f09b))
|
||||
* 支持七牛云 ([8ecc2f9](https://github.com/certd/certd/commit/8ecc2f9446a9ebd11b9bfbffbb6cf7812a043495))
|
||||
* 支持k8s ingress secret ([e5a5d0a](https://github.com/certd/certd/commit/e5a5d0a607bb6b4e1a1f7a1a419bada5f2dee59f))
|
||||
* http请求增加默认超时时间 ([664bd86](https://github.com/certd/certd/commit/664bd863e5b4895aabe2384277c0c65f5902fdb2))
|
||||
* plugins增加图标 ([a8da658](https://github.com/certd/certd/commit/a8da658a9723342b4f43a579f7805bfef0648efb))
|
||||
|
||||
## [1.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复腾讯云cdn证书部署后会自动关闭hsts,http2.0等配置的bug ([7908ab7](https://github.com/certd/certd/commit/7908ab79da624c94fa05849925b15e480e3317c4))
|
||||
* 修复腾讯云tke证书部署报错的bug ([653f409](https://github.com/certd/certd/commit/653f409d91a441850d6381f89a8dd390831f0d5e))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 插件选择支持搜索 ([d1498a7](https://github.com/certd/certd/commit/d1498a71601b74d38343b1d070eadd03705dd9d5))
|
||||
* 前置任务步骤增加错误提示 ([ae3daa9](https://github.com/certd/certd/commit/ae3daa9bcf4fc363825aad9b77f5d3879aeeff70))
|
||||
* 群晖部署教程 ([0f0af2f](https://github.com/certd/certd/commit/0f0af2f309390f388e7a272cea3a1dd30c01977d))
|
||||
* 支持群晖 ([5c270b6](https://github.com/certd/certd/commit/5c270b6b9d45a2152f9fdb3c07bd98b7c803cb8e))
|
||||
|
||||
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 支持多吉云cdn证书部署 ([65ef685](https://github.com/certd/certd/commit/65ef6857296784ca765926e09eafcb6fc8b6ecde))
|
||||
|
||||
## [1.24.2](https://github.com/certd/certd/compare/v1.24.1...v1.24.2) (2024-09-06)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复复制流水线出现的各种问题 ([6314e8d](https://github.com/certd/certd/commit/6314e8d7eb58cd52e2a7bd3b5ffb9112b0b69577))
|
||||
* 修复windows下无法执行第二条命令的bug ([71ac8aa](https://github.com/certd/certd/commit/71ac8aae4aa694e1a23761e9761c9fba30b43a21))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 阶段、任务、步骤全面支持拖动排序 ([bd73a16](https://github.com/certd/certd/commit/bd73a163cd0497f062bd424ddc6bc9bbc95f81ea))
|
||||
* 任务配置不需要的字段可以自动隐藏 ([192d9dc](https://github.com/certd/certd/commit/192d9dc7e36737d684c769f255f407c28b1152ac))
|
||||
* 任务支持拖动排序 ([1e9b563](https://github.com/certd/certd/commit/1e9b5638aa36a8ce70019a9c750230ba41938327))
|
||||
* 西部数据支持用户级的apikey ([1c17b41](https://github.com/certd/certd/commit/1c17b41e160944b073e1849e6f9467c3659a4bfc))
|
||||
* 修复windows下无法执行第二条命令的bug ([d5bfcdb](https://github.com/certd/certd/commit/d5bfcdb6de1dcc1702155442e2e00237d0bbb6e5))
|
||||
* 优化跳过处理逻辑 ([b80210f](https://github.com/certd/certd/commit/b80210f24bf5db1c958d06ab27c9e5d3db452eda))
|
||||
* 支持阿里云oss ([87a2673](https://github.com/certd/certd/commit/87a2673e8c33dff6eda1b836d92ecc121564ed78))
|
||||
* 支持西部数码DNS ([c59cab1](https://github.com/certd/certd/commit/c59cab1aaeb19f86df8e3e0d8127cbd0a9ef77f3))
|
||||
* 支持pfx、der ([fbeaed2](https://github.com/certd/certd/commit/fbeaed203519f59b6d9396c4e8953353ccb5e723))
|
||||
* client 请求超时时间延长为10s ([ff46771](https://github.com/certd/certd/commit/ff46771d8dd43e71c1ca70e3ba783945750342cc))
|
||||
|
||||
## [1.24.1](https://github.com/certd/certd/compare/v1.24.0...v1.24.1) (2024-09-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 激活仅限管理员 ([1c17970](https://github.com/certd/certd/commit/1c17970b981f0987c506744ee6b2283fd5e40493))
|
||||
* 修复在没有勾选使用代理的情况下,仍然会使用代理的bug ([0f66794](https://github.com/certd/certd/commit/0f6679425f6a736bb0128527dd99c085fac17d84))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 部署插件支持宝塔、易盾云等 ([ee61709](https://github.com/certd/certd/commit/ee617095efa1171548cf52fd45f0f98a368555a3))
|
||||
* 授权配置支持加密 ([42a56b5](https://github.com/certd/certd/commit/42a56b581d754c3e5f9838179d19ab0d004ef2eb))
|
||||
* 优化内存占用 ([db61033](https://github.com/certd/certd/commit/db6103363364440b650bc10bb334834e4a9470c7))
|
||||
* 支持阿里云 DCDN ([98b77f8](https://github.com/certd/certd/commit/98b77f80843834616fb26f83b4c42245326abd06))
|
||||
* 支持已跳过的步骤重新运行 ([ea775ad](https://github.com/certd/certd/commit/ea775adae18d57a04470cfba6b9460d761d74035))
|
||||
* 支持cdnfly ([724a850](https://github.com/certd/certd/commit/724a85028b4a7146c9e3b4df4497dcf2a7bf7c67))
|
||||
* 支持ftp上传 ([b9bddbf](https://github.com/certd/certd/commit/b9bddbfabb5664365f1232e9432532187c98006c))
|
||||
|
||||
# [1.24.0](https://github.com/certd/certd/compare/v1.23.1...v1.24.0) (2024-08-25)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# Certd Open Source License
|
||||
|
||||
Certd Open Source License
|
||||
|
||||
|
||||
- This project is licensed under the **GNU Affero General Public License (AGPL)** with the following additional terms.
|
||||
- 本项目遵循 GNU Affero General Public License(AGPL),并附加以下条款。
|
||||
|
||||
113
README.md
@@ -5,25 +5,15 @@ Certd 是一个免费全自动申请和自动部署更新SSL证书的工具。
|
||||
|
||||
关键字:证书自动申请、证书自动更新、证书自动续期、证书自动续签
|
||||
|
||||
************************
|
||||
支持开源,为爱发电,我已入驻爱发电
|
||||
https://afdian.com/a/greper
|
||||
|
||||
发电权益:
|
||||
1. 可加入发电专属群(先加我好友,发送发电截图,我拉你进群)
|
||||
2. 你的需求优先实现
|
||||
3. 可以获得作者一对一技术支持
|
||||
4. 更多权益陆续增加中...
|
||||
************************
|
||||
|
||||
## 一、特性
|
||||
本项目不仅支持证书申请过程自动化,还可以自动化部署更新证书,让你的证书永不过期。
|
||||
|
||||
* 全自动申请证书(支持阿里云、腾讯云、华为云、Cloudflare等各种途径注册的域名)
|
||||
* 全自动部署更新证书(目前支持部署到主机、部署到阿里云、腾讯云等)
|
||||
* 全自动申请证书(支持所有注册商注册的域名)
|
||||
* 全自动部署更新证书(目前支持部署到主机、部署到阿里云、腾讯云等,目前已支持30+部署插件)
|
||||
* 支持通配符域名/泛域名,支持多个域名打到一个证书上
|
||||
* 邮件通知
|
||||
* 私有化部署,保障安全
|
||||
* 私有化部署,保障数据安全
|
||||
* 免费、免费、免费([阿里云单个通配符域名证书最便宜也要1800/年](https://yundun.console.aliyun.com/?p=cas#/certExtend/buy/cn-hangzhou))
|
||||
|
||||
|
||||
@@ -39,33 +29,48 @@ https://certd.handsfree.work/
|
||||
## 三、使用教程
|
||||
本案例演示,如何配置自动申请证书,并部署到阿里云CDN,然后快要到期前自动更新证书并重新部署
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||
-------> [点我查看详细使用步骤演示](./step.md) <--------
|
||||
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
||||
|
||||
当前支持的部署插件列表
|
||||

|
||||
|
||||
## 四、私有化部署
|
||||
|
||||
由于证书、授权信息等属于高度敏感数据,请务必私有化部署,保障数据安全
|
||||
|
||||
### 1. 安装docker、docker-compose
|
||||
### 4.1 宝塔面板一键部署
|
||||
|
||||
1. 安装宝塔面板,前往 [宝塔面板](https://www.bt.cn/u/CL3JHS) 官网,选择9.2.0以上正式版的脚本下载安装
|
||||
|
||||
2. 安装后登录宝塔面板,在菜单栏中点击 Docker,首次进入会提示安装Docker服务,点击立即安装,按提示完成安装
|
||||
|
||||
3. 安装完成后在应用商店中找到`certd`(要先点右上角更新应用),点击安装,配置域名等基本信息即可完成安装
|
||||
|
||||
### 4.2 宝塔面板容器编排部署
|
||||
|
||||
[宝塔面板容器编排部署教程](./doc/deploy/baota/baota.md)
|
||||
|
||||
### 4.3 Docker部署
|
||||
#### 1. 安装docker、docker-compose
|
||||
|
||||
1.1 准备一台云服务器
|
||||
* 【阿里云】云服务器2核2G,新老用户同享,99元/年,续费同价!【 [立即购买](https://www.aliyun.com/benefit?scm=20140722.M_10244282._.V_1&source=5176.11533457&userCode=qya11txb )】
|
||||
* 【腾讯云】云服务器2核2G,新老用户同享,99元/年,续费同价!【 [立即购买](https://cloud.tencent.com/act/cps/redirect?redirect=6094&cps_key=b3ef73330335d7a6efa4a4bbeeb6b2c9&from=console)】
|
||||
|
||||
|
||||
1.2 安装docker
|
||||
|
||||
https://docs.docker.com/engine/install/
|
||||
选择对应的操作系统,按照官方文档执行命令即可
|
||||
|
||||
### 2. 运行certd
|
||||
#### 2. 运行certd
|
||||
|
||||
[docker-compose.yaml 下载](https://gitee.com/certd/certd/raw/v2/docker/run/docker-compose.yaml)
|
||||
|
||||
@@ -92,31 +97,51 @@ docker compose up -d
|
||||
> 如果提示 没有compose命令,请安装docker-compose
|
||||
> https://docs.docker.com/compose/install/linux/
|
||||
|
||||
#### 镜像说明:
|
||||
* certd镜像地址:
|
||||
#### 3. 镜像说明:
|
||||
* 国内镜像地址:
|
||||
* `registry.cn-shenzhen.aliyuncs.com/handsfree/certd:latest`
|
||||
* `registry.cn-shenzhen.aliyuncs.com/handsfree/certd:armv7`、`[version]-armv7`
|
||||
* DockerHub地址:
|
||||
* `https://hub.docker.com/r/greper/certd`
|
||||
* `greper/certd:latest`
|
||||
* `greper/certd:armv7`、`greper/certd:[version]-armv7`
|
||||
|
||||
* 镜像构建通过`Actions`自动执行,过程公开透明,请放心使用
|
||||
* [点我查看镜像构建日志](https://github.com/certd/certd/actions/workflows/build-image.yml)
|
||||
|
||||

|
||||
|
||||
|
||||
### 3. 访问
|
||||
#### 4. 访问测试
|
||||
|
||||
http://your_server_ip:7001
|
||||
默认账号密码:admin/123456
|
||||
记得修改密码
|
||||
|
||||
### 4.4 源码部署
|
||||
```shell
|
||||
# 克隆代码
|
||||
git clone https://github.com/certd/certd
|
||||
cd certd
|
||||
# 启动服务
|
||||
./start.sh
|
||||
# 数据默认保存在 ./packages/ui/certd-server/data 目录下,注意数据备份
|
||||
```
|
||||
如果是windows,请先安装`git for windows` ,然后右键,选择`open git bash here`打开终端,再执行`./start.sh`命令
|
||||
|
||||
|
||||
## 五、 升级
|
||||
如果使用固定版本号
|
||||
1. 修改`docker-compose.yaml`中的镜像版本号
|
||||
2. 运行 `docker compose up -d` 即可
|
||||
2. 运行`docker compose up -d` 即可
|
||||
|
||||
如果使用`latest`版本
|
||||
1. 重新拉取镜像 `docker pull registry.cn-shenzhen.aliyuncs.com/handsfree/certd:latest`
|
||||
2. 重新启动容器 `docker compose restart`
|
||||
```shell
|
||||
#重新拉取镜像
|
||||
docker pull registry.cn-shenzhen.aliyuncs.com/handsfree/certd:latest
|
||||
# 重新启动容器
|
||||
docker compose down
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
> 数据默认存在`/data/certd`目录下,不用担心数据丢失
|
||||
|
||||
@@ -143,17 +168,19 @@ http://your_server_ip:7001
|
||||
* [腾讯云](./doc/tencent/tencent.md)
|
||||
* [windows主机](./doc/host/host.md)
|
||||
* [google证书](./doc/google/google.md)
|
||||
* [群晖部署certd及证书更新教程](./doc/synology/index.md)
|
||||
|
||||
* [CNAME证书校验方式说明](./doc/cname/index.md)
|
||||
|
||||
## 八、问题处理
|
||||
### 7.1 忘记管理员密码
|
||||
解决方法如下:
|
||||
1. 修改docker-compose.yaml文件,将环境变量`certd_system_resetAdminPassword`改为`true`
|
||||
1. 修改docker-compose.yaml文件,将环境变量`certd_system_resetAdminPasswd`改为`true`
|
||||
```yaml
|
||||
services:
|
||||
certd:
|
||||
environment: # 环境变量
|
||||
- certd_system_resetAdminPassword=false
|
||||
- certd_system_resetAdminPasswd=false
|
||||
```
|
||||
2. 重启容器
|
||||
```shell
|
||||
@@ -161,7 +188,7 @@ docker compose up -d
|
||||
docker logs -f --tail 500 certd
|
||||
# 观察日志,当日志中输出“重置1号管理员用户的密码完成”,即可操作下一步
|
||||
```
|
||||
3. 修改docker-compose.yaml,将`certd_system_resetAdminPassword`改回`false`
|
||||
3. 修改docker-compose.yaml,将`certd_system_resetAdminPasswd`改回`false`
|
||||
4. 再次重启容器
|
||||
```shell
|
||||
docker compose up -d
|
||||
@@ -181,23 +208,37 @@ docker compose up -d
|
||||
</p>
|
||||
|
||||
## 十、捐赠
|
||||
************************
|
||||
支持开源,为爱发电,我已入驻爱发电
|
||||
https://afdian.com/a/greper
|
||||
|
||||
发电权益:
|
||||
1. 可加入发电专属群(先加我好友,发送发电截图,我拉你进群)
|
||||
2. 你的需求优先实现
|
||||
3. 可以获得作者一对一技术支持
|
||||
4. 更多权益陆续增加中...
|
||||
1. 可加入发电专属群,可以获得作者一对一技术支持
|
||||
2. 您的需求我们将优先实现,并且将作为专业版功能提供
|
||||
3. 一年期专业版激活码
|
||||
4. 赠送国外免费服务器部署方案(0成本使用Certd,可能需要翻墙,不过现在性能越来越差了)
|
||||
|
||||
|
||||
专业版特权对比
|
||||
|
||||
| 功能 | 免费版 | 专业版 |
|
||||
|---------|------------------------|-----------------------|
|
||||
| 免费证书申请 | 免费无限制 | 免费无限制 |
|
||||
| 自动部署插件 | 阿里云CDN、腾讯云、七牛CDN、主机部署等 | 支持群晖、宝塔、1Panel等,持续开发中 |
|
||||
| 发邮件功能 | 需要配置 | 免配置 |
|
||||
| 证书流水线条数 | 10条 | 无限制 |
|
||||
|
||||
************************
|
||||
|
||||
## 十一、贡献代码
|
||||
|
||||
1. [贡献插件教程](./plugin.md)
|
||||
1. 本地开发 [贡献插件教程](./doc/dev/development.md)
|
||||
2. 作为贡献者,代表您同意您贡献的代码如下许可:
|
||||
1. 可以调整开源协议以使其更严格或更宽松。
|
||||
2. 可以用于商业用途。
|
||||
|
||||
|
||||
|
||||
## 十二、 开源许可
|
||||
* 本项目遵循 GNU Affero General Public License(AGPL)开源协议。
|
||||
* 允许个人和公司使用、复制、修改和分发本项目,禁止任何形式的商业用途
|
||||
|
||||
@@ -1 +1 @@
|
||||
11:39
|
||||
15:06
|
||||
|
||||
BIN
doc/cname/images/cname1.png
Normal file
|
After Width: | Height: | Size: 172 KiB |
BIN
doc/cname/images/cname2.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
doc/cname/images/cname3.png
Normal file
|
After Width: | Height: | Size: 200 KiB |
BIN
doc/cname/images/cname4.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
27
doc/cname/index.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# CNAME代理校验方式说明
|
||||
|
||||
## 1. 前言
|
||||
申请域名证书是需要校验域名所有权的。
|
||||
目前有两种校验方式:
|
||||
1. http-01: 在网站根目录下放置一份txt文件(Certd不支持)
|
||||
2. dns-01: 需要给域名添加txt解析记录,通配符域名只能用这种方式(Certd采用这种方式)
|
||||
|
||||
DNS-01方式需要开发适配DNS服务商的接口,目前已实现主流域名注册商的接口(阿里云、腾讯云、华为云、Cloudflare、西数)
|
||||
|
||||
如果域名不在这几家,那么就只能通过CNAME代理校验方式来实现
|
||||
|
||||
|
||||
## 2. 使用步骤
|
||||
|
||||
1. 假设你要申请证书的域名叫:need.cert.com ,它是在其他服务商注册的
|
||||
2. 现在你需要另外一个域名:cname.foo.com,这个域名属于是在阿里云、腾讯云、华为云、Cloudflare、西数,或者你把这个域名的DNS服务器转到这几家。
|
||||
3. 到Certd的 CNAME服务管理界面,用`cname.foo.com`创建一条默认的CNAME服务,需要提供DNS提供商授权。
|
||||

|
||||
4. 申请证书时,Certd会生成一个随机的CNAME记录,例如:`_acme-challenge.need`->`xxxxxx.cname.foo.com`
|
||||

|
||||
5. 您需要手动添加这条CNAME记录到你要申请证书的域名解析中,点击校验,校验成功后就可以开始申请证书了 (此操作每个域名只需要做一次,后续可以重复使用,注意不要删除添加的CNAME记录)
|
||||

|
||||
6. 
|
||||
6. 申请过程中,Certd会在`xxxxxx.cname.foo.com`下自动添加验证TXT记录。
|
||||
7. 由于您配置了`_acme-challenge.need`的CNAME,所以这个TXT记录会被解析到`_acme-challenge.need.cert.com`下,从而完成域名校验。
|
||||
|
||||
32
doc/deploy/baota/baota.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# 宝塔部署教程
|
||||
|
||||
## 编排模版部署
|
||||
|
||||
### 创建docker模版
|
||||
打开docker-compose.yaml,
|
||||
https://gitee.com/certd/certd/raw/v2/docker/run/docker-compose.yaml
|
||||
|
||||
整个内容复制下来
|
||||
|
||||
然后到宝塔里面进到docker的编排模版,新建模版
|
||||

|
||||
|
||||
### 启动应用
|
||||
|
||||

|
||||
|
||||
等待启动完成
|
||||
|
||||
### 打开应用
|
||||
|
||||
http://ip:7001
|
||||
|
||||
|
||||
## 二、一键应用部署
|
||||
需要宝塔9.2.0版本
|
||||
|
||||
### 应用商店
|
||||
进入应用商店,更新应用列表
|
||||
|
||||
### 搜索certd
|
||||
点击安装
|
||||
BIN
doc/deploy/baota/images/1.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
doc/deploy/baota/images/2.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
0
doc/deploy/koyeb.md
Normal file
@@ -1,8 +1,9 @@
|
||||
# 贡献插件
|
||||
# 本地开发
|
||||
欢迎贡献插件
|
||||
|
||||
## 1.本地调试运行
|
||||
|
||||
安装依赖包:
|
||||
### 克隆代码
|
||||
```shell
|
||||
|
||||
# 克隆代码
|
||||
@@ -10,22 +11,38 @@ git clone https://github.com/certd/certd
|
||||
|
||||
#进入项目目录
|
||||
cd certd
|
||||
```
|
||||
|
||||
### 修改pnpm-workspace.yaml文件
|
||||
重要:否则无法正确加载专业版的access和plugin
|
||||
```yaml
|
||||
# pnpm-workspace.yaml
|
||||
packages:
|
||||
- 'packages/**' # <--------------注释掉这一行,PR时不要提交此修改
|
||||
- 'packages/ui/**'
|
||||
```
|
||||
|
||||
### 安装依赖和初始化:
|
||||
```shell
|
||||
# 安装pnpm,如果提示npm命令不存在,就需要先安装nodejs
|
||||
npm install -g pnpm@8.15.7 --registry=https://registry.npmmirror.com
|
||||
|
||||
# 使用国内镜像源,如果有代理,就不需要
|
||||
pnpm config set registry https://registry.npmmirror.com
|
||||
# 安装依赖
|
||||
npm install -g pnpm@8.15.7
|
||||
pnpm install
|
||||
|
||||
# 初始化构建
|
||||
lerna run build
|
||||
npm run init
|
||||
```
|
||||
|
||||
启动 server:
|
||||
### 启动 server:
|
||||
```shell
|
||||
cd packages/ui/certd-server
|
||||
npm run dev
|
||||
```
|
||||
|
||||
启动 client:
|
||||
### 启动 client:
|
||||
```shell
|
||||
cd packages/ui/certd-client
|
||||
npm run dev
|
||||
@@ -47,7 +64,7 @@ npm run dev
|
||||
这样用户就可以在`certd`后台中创建这种授权凭证了
|
||||
|
||||
### 3. dns-provider
|
||||
如果域名是这个平台进行解析的,那么你需要实现dns-provider
|
||||
如果域名是这个平台进行解析的,那么你需要实现dns-provider,(申请证书需要)
|
||||
参考`plugin-cloudflare/dns-provider.ts` 修改为你要做的平台的`dns-provider`
|
||||
|
||||
### 4. plugin-deploy
|
||||
@@ -65,7 +82,7 @@ export * from './plugins/plugin-deploy-to-xx'
|
||||
在`./src/plugins/index.ts`中增加`import`
|
||||
|
||||
```ts
|
||||
export * from "./plugin-cloudflare"
|
||||
export * from "./plugin-cloudflare.js"
|
||||
```
|
||||
|
||||
## 重启服务进行调试
|
||||
@@ -7,31 +7,50 @@ https://console.cloud.google.com/apis/library/publicca.googleapis.com
|
||||
|
||||
打开该链接后点击“启用”,随后等待右侧出现“API已启用”则可以关闭该页。
|
||||
|
||||
## 2、 申请Key
|
||||
随后打开“Google Cloud Shell”(在右上角点击激活CloudShell图标)。
|
||||
## 2、 获取授权
|
||||
以下两种方式任选其一
|
||||
### 2.1 直接获取EAB 【推荐】
|
||||
|
||||
|
||||
1. 打开“Google Cloud Shell”(在右上角点击激活CloudShell图标)。
|
||||
等待分配完成后在 Shell 窗口内输入如下命令:
|
||||
|
||||
```shell
|
||||
gcloud beta publicca external-account-keys create
|
||||
```
|
||||
此时会弹出“为 Cloud Shell 提供授权”,点击授权即可。
|
||||
|
||||
2. 此时会弹出“为 Cloud Shell 提供授权”,点击授权即可。
|
||||
执行完成后会返回类似如下输出;注意不要在没有收到 Google 的邮件时执行该命令,会返回命令不存在。
|
||||
|
||||
```shell
|
||||
Created an external account key
|
||||
[b64MacKey: xxxxxxxxxxxxx
|
||||
keyId: xxxxxxxxx]
|
||||
[b64MacKey: xxxxxxxxxxxxxxxx
|
||||
keyId: xxxxxxxxxxxxx]
|
||||
```
|
||||
记录以上信息备用
|
||||
|
||||
3. 到Certd中,创建一条EAB授权记录,填写keyId(=kid) 和 b64MacKey 信息
|
||||
注意:keyId没有`]`结尾,不要把`]`也复制了
|
||||
|
||||
注意:EAB授权使用过一次之后,会绑定邮箱,后续再次使用时,要使用相同的邮箱
|
||||
否则会报错 `Unknown external account binding (EAB) key. This may be due to the EAB key expiring which occurs 7 days after creation`
|
||||
|
||||
### 2.2 通过服务账号获取EAB
|
||||
|
||||
此方式可以自动EAB,需要配置代理
|
||||
|
||||
1. 创建服务账号
|
||||
https://console.cloud.google.com/projectselector2/iam-admin/serviceaccounts/create?walkthrough_id=iam--create-service-account&hl=zh-cn#step_index=1
|
||||
|
||||
2. 选择一个项目,进入创建服务账号页面
|
||||
3. 给服务账号起一个名字,点击`创建并继续`
|
||||
4. 向此服务账号授予对项目的访问权限: `选择角色`->`基本`->`Owner`
|
||||
5. 点击完成
|
||||
6. 点击服务账号,进入服务账号详情页面
|
||||
7. 点击`添加密钥`->`创建新密钥`->`JSON`,下载密钥文件
|
||||
8. 将json文件内容粘贴到 certd中 Google服务授权输入框中
|
||||
|
||||
|
||||
## 3、 创建证书流水线
|
||||
选择证书提供商为google, 开启使用代理
|
||||
选择证书提供商为google, 选择EAB授权 或 服务账号授权
|
||||
|
||||
## 4、 将key信息作为EAB授权信息
|
||||
google证书需要EAB授权, 使用第二步中的 keyId 和 b64MacKey 信息创建一条EAB授权记录
|
||||
|
||||
## 5、 其他就跟正常申请证书一样了
|
||||
## 4、 其他就跟正常申请证书一样了
|
||||
|
||||
|
||||
BIN
doc/images/plugins.png
Normal file
|
After Width: | Height: | Size: 327 KiB |
BIN
doc/synology/images/1.png
Normal file
|
After Width: | Height: | Size: 205 KiB |
BIN
doc/synology/images/2.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
doc/synology/images/3.png
Normal file
|
After Width: | Height: | Size: 53 KiB |
BIN
doc/synology/images/4.png
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
doc/synology/images/5.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
doc/synology/images/6.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
doc/synology/images/deploy.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
41
doc/synology/index.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# 群晖部署和证书更新
|
||||
|
||||
|
||||
## 一、群晖系统上部署Certd教程
|
||||
|
||||
### 1. 打开Container Manager
|
||||
|
||||

|
||||
|
||||
### 2. 新增项目
|
||||
|
||||

|
||||
|
||||
### 3. 配置Certd项目
|
||||
|
||||

|
||||
|
||||
### 4. 外网访问设置
|
||||
|
||||

|
||||
|
||||
### 5. 确认项目信息
|
||||
|
||||

|
||||
|
||||
点击完成安装,等待certd启动完成即可
|
||||
|
||||
### 6. 门户配置向导【可选】
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
## 二、更新群晖证书
|
||||
|
||||
## 1. 前提条件
|
||||
* 已经部署了certd
|
||||
* 群晖上已经设置好了证书(证书建议设置好描述,插件需要根据描述查找证书)
|
||||
|
||||
## 2. 在certd上配置自动更新群晖证书插件
|
||||

|
||||
@@ -1,8 +1,7 @@
|
||||
# 腾讯云
|
||||
|
||||
|
||||
## DNSPOD 授权设置
|
||||
目前腾讯云管理的域名的dns暂时只支持从DNSPOD进行设置
|
||||
## DNSPOD 授权设置【已废弃,请使用腾讯云API】
|
||||
打开 https://console.dnspod.cn/account/token/apikey
|
||||
然后按如下方式获取DNSPOD的授权
|
||||

|
||||
@@ -13,4 +12,4 @@
|
||||
腾讯云其他部署需要API密钥,需要在腾讯云控制台进行设置
|
||||
打开 https://console.cloud.tencent.com/cam/capi
|
||||
然后按如下方式获取腾讯云的API密钥
|
||||

|
||||

|
||||
|
||||
@@ -1,34 +1,50 @@
|
||||
version: '3.3'
|
||||
version: '3.3' # 兼容旧版docker-compose
|
||||
services:
|
||||
certd:
|
||||
# 镜像 # ↓↓↓↓↓ --- 1、 镜像版本号,建议改成固定版本号【可选】
|
||||
# 镜像 # ↓↓↓↓↓ ---- 镜像版本号,建议改成固定版本号
|
||||
image: registry.cn-shenzhen.aliyuncs.com/handsfree/certd:latest
|
||||
container_name: certd # 容器名
|
||||
restart: unless-stopped # 自动重启
|
||||
volumes:
|
||||
# ↓↓↓↓↓ ------------------------------------------------------- 2、 数据库以及证书存储路径,默认存在宿主机的/data/certd/目录下【可选】
|
||||
# ↓↓↓↓↓ -------------------------------------------------------- 数据库以及证书存储路径,默认存在宿主机的/data/certd/目录下,【您需要定时备份此目录,以保障数据容灾】
|
||||
- /data/certd:/app/data
|
||||
ports: # 端口映射
|
||||
# ↓↓↓↓ ----------------------------------------------------------3、如果端口有冲突,可以修改第一个7001为其他不冲突的端口号【可选】
|
||||
# ↓↓↓↓ ---------------------------------------------------------- 如果端口有冲突,可以修改第一个7001为其他不冲突的端口号
|
||||
- "7001:7001"
|
||||
dns:
|
||||
# 如果出现getaddrinfo ENOTFOUND等错误,可以尝试修改或注释dns配置
|
||||
# ↓↓↓↓ ---------------------------------------------------------- 如果出现getaddrinfo ENOTFOUND等错误,可以尝试修改或注释dns配置
|
||||
- 223.5.5.5
|
||||
- 223.6.6.6
|
||||
# ↓↓↓↓ ----------------------------------------------------------如果你服务器部署在国外,可以用8.8.8.8替换上面的dns【可选】
|
||||
# ↓↓↓↓ ---------------------------------------------------------- 如果你服务器部署在国外,可以用8.8.8.8替换上面的dns
|
||||
# - 8.8.8.8
|
||||
# - 8.8.4.4
|
||||
# extra_hosts:
|
||||
# ↓↓↓↓ ---------------------------------------------------------- 这里可以配置自定义hosts,外网域名可以指向本地局域网ip地址
|
||||
# - "localdomain.comm:192.168.1.3"
|
||||
environment: # 环境变量
|
||||
- TZ=Asia/Shanghai
|
||||
- certd_system_resetAdminPasswd=false
|
||||
# ↑↑↑↑↑---------------------------4、如果忘记管理员密码,可以设置为true,重启之后,管理员密码将改成123456,然后请及时修改回false【可选】
|
||||
- certd_cron_immediateTriggerOnce=false
|
||||
# ↑↑↑↑↑---------------------------5、如果设置为true,启动后所有配置了cron的流水线任务都将被立即触发一次【可选】
|
||||
- VITE_APP_ICP_NO=
|
||||
# ↑↑↑↑↑ -----------------------------------------6、这里可以设置备案号【可选】
|
||||
# 设置环境变量即可自定义certd配置
|
||||
# 服务端配置项见: packages/ui/certd-server/src/config/config.default.ts
|
||||
# 服务端配置规则: certd_ + 配置项, 点号用_代替
|
||||
# 配置项见: packages/ui/certd-server/src/config/config.default.ts
|
||||
# 配置规则: certd_ + 配置项, 点号用_代替
|
||||
|
||||
# ↓↓↓↓ ------------------------------------ 这里可以设置http代理
|
||||
#- HTTPS_PROXY=http://xxxxxx:xx
|
||||
#- HTTP_PROXY=http://xxxxxx:xx
|
||||
# ↓↓↓↓ ----------------------------- 如果忘记管理员密码,可以设置为true,重启之后,管理员密码将改成123456,然后请及时修改回false
|
||||
- certd_system_resetAdminPasswd=false
|
||||
# ↓↓↓↓ -------------------------- 如果设置为true,启动后所有配置了cron的流水线任务都将被立即触发一次
|
||||
- certd_cron_immediateTriggerOnce=false
|
||||
# ↓↓↓↓ -------------------------------- 配置证书和key,则表示https方式启动,使用https协议访问,https://your.domain:7001
|
||||
#- certd_koa_key=./data/ssl/cert.key
|
||||
#- certd_koa_cert=./data/ssl/cert.crt
|
||||
|
||||
# ↓↓↓↓ ------------------------------- 使用postgresql数据库
|
||||
# - certd_flyway_scriptDir=./db/migration-pg # 升级脚本目录
|
||||
# - certd_typeorm_dataSource_default_type=postgres # 数据库类型
|
||||
# - certd_typeorm_dataSource_default_host=localhost # 数据库地址
|
||||
# - certd_typeorm_dataSource_default_port=5433 # 数据库端口
|
||||
# - certd_typeorm_dataSource_default_username=postgres # 用户名
|
||||
# - certd_typeorm_dataSource_default_password=yourpasswd # 密码
|
||||
# - certd_typeorm_dataSource_default_database=certd # 数据库名
|
||||
|
||||
|
||||
# 客户端配置项见: packages/ui/certd-client/.env
|
||||
# 按实际名称配置环境变量即可,如: VITE_APP_API=http://localhost:7001
|
||||
|
||||
21
init.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
current_pwd=$(pwd)
|
||||
|
||||
echo "开始设置git配置"
|
||||
|
||||
read -p "请输入username:" username
|
||||
git config user.name $username
|
||||
|
||||
read -p "请输入email:" email
|
||||
git config user.email $email
|
||||
|
||||
git config credential.helper "store --file=$current_pwd/.git/credential.store"
|
||||
echo "已设置记住git账号密码"
|
||||
|
||||
git config core.autocrlf input
|
||||
echo "已设置auto crlf = input"
|
||||
|
||||
git config core.filemode false
|
||||
echo "已设置忽略文件模式变化"
|
||||
|
||||
echo "git配置完成"
|
||||
@@ -9,5 +9,5 @@
|
||||
}
|
||||
},
|
||||
"npmClient": "pnpm",
|
||||
"version": "1.24.0"
|
||||
"version": "1.26.4"
|
||||
}
|
||||
|
||||
19
package.json
@@ -4,27 +4,30 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@lerna-lite/cli": "^3.2.1",
|
||||
"@lerna-lite/publish": "^3.2.1",
|
||||
"@lerna-lite/run": "^3.2.1",
|
||||
"@lerna-lite/version": "^3.2.1"
|
||||
"@lerna-lite/cli": "^3.9.3",
|
||||
"@lerna-lite/publish": "^3.9.3",
|
||||
"@lerna-lite/run": "^3.9.3",
|
||||
"@lerna-lite/version": "^3.9.3"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "lerna bootstrap --hoist",
|
||||
"i-all": "lerna link && lerna exec npm install ",
|
||||
"publish": "npm run prepublishOnly2 && lerna publish --conventional-commits --create-release github && npm run afterpublishOnly",
|
||||
"publish": "npm run prepublishOnly2 && lerna publish --force-publish=pro/plus-core --conventional-commits --create-release github && npm run afterpublishOnly && npm run commitAll",
|
||||
"afterpublishOnly": "time /t >build.trigger && git add ./build.trigger && git commit -m \"build: trigger build image\" && TIMEOUT /T 10 && git push",
|
||||
"transform-sql":"cd ./packages/ui/certd-server/db/ && node --experimental-json-modules transform.js",
|
||||
"commitAll": "git add . && git commit -m \"build: publish\" && git push && npm run commitPro",
|
||||
"commitPro": "cd ./packages/core/ && git add . && git commit -m \"build: publish\" && git push",
|
||||
"prepublishOnly1": "npm run check && lerna run build ",
|
||||
"prepublishOnly2": "npm run check && npm run before-build && lerna run build ",
|
||||
"before-build": "cd ./packages/core/pipeline && time /t >build.md && git add ./build.md && git commit -m \"build: prepare to build\"",
|
||||
"before-build": "npm run transform-sql && cd ./packages/core/basic && time /t >build.md && git add ./build.md && git commit -m \"build: prepare to build\"",
|
||||
"deploy1": "node --experimental-json-modules deploy.js ",
|
||||
"check": "node --experimental-json-modules publish-check.js",
|
||||
"init": "lerna run build"
|
||||
},
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"axios": "^1.7.2",
|
||||
"lodash": "^4.17.21"
|
||||
"axios": "^1.7.7",
|
||||
"lodash-es": "^4.17.21"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/**"
|
||||
|
||||
@@ -3,6 +3,98 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.26.4](https://github.com/publishlab/node-acme-client/compare/v1.26.3...v1.26.4) (2024-10-14)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.26.3](https://github.com/publishlab/node-acme-client/compare/v1.26.2...v1.26.3) (2024-10-12)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.26.2](https://github.com/publishlab/node-acme-client/compare/v1.26.1...v1.26.2) (2024-10-11)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.26.1](https://github.com/publishlab/node-acme-client/compare/v1.26.0...v1.26.1) (2024-10-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
# [1.26.0](https://github.com/publishlab/node-acme-client/compare/v1.25.9...v1.26.0) (2024-10-10)
|
||||
|
||||
### Features
|
||||
|
||||
* 域名验证方法支持CNAME间接方式,此方式支持所有域名注册商,且无需提供Access授权,但是需要手动添加cname解析 ([f3d3508](https://github.com/publishlab/node-acme-client/commit/f3d35084ed44f9f33845f7045e520be5c27eed93))
|
||||
|
||||
## [1.25.9](https://github.com/publishlab/node-acme-client/compare/v1.25.8...v1.25.9) (2024-10-01)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.25.8](https://github.com/publishlab/node-acme-client/compare/v1.25.7...v1.25.8) (2024-09-30)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.25.7](https://github.com/publishlab/node-acme-client/compare/v1.25.6...v1.25.7) (2024-09-29)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.25.6](https://github.com/publishlab/node-acme-client/compare/v1.25.5...v1.25.6) (2024-09-29)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 部署支持1Panel ([d047234](https://github.com/publishlab/node-acme-client/commit/d047234d98d31504f2e5a472b66e1b75806af26e))
|
||||
|
||||
## [1.25.5](https://github.com/publishlab/node-acme-client/compare/v1.25.4...v1.25.5) (2024-09-26)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.25.4](https://github.com/publishlab/node-acme-client/compare/v1.25.3...v1.25.4) (2024-09-25)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.25.3](https://github.com/publishlab/node-acme-client/compare/v1.25.2...v1.25.3) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.25.2](https://github.com/publishlab/node-acme-client/compare/v1.25.1...v1.25.2) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.25.1](https://github.com/publishlab/node-acme-client/compare/v1.25.0...v1.25.1) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
# [1.25.0](https://github.com/publishlab/node-acme-client/compare/v1.24.4...v1.25.0) (2024-09-24)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 证书支持旧版RSA,pkcs1 ([3d9c3ec](https://github.com/publishlab/node-acme-client/commit/3d9c3ecb3eb604b2458154f608bde0f01915d116))
|
||||
* 支持七牛云 ([8ecc2f9](https://github.com/publishlab/node-acme-client/commit/8ecc2f9446a9ebd11b9bfbffbb6cf7812a043495))
|
||||
|
||||
## [1.24.4](https://github.com/publishlab/node-acme-client/compare/v1.24.3...v1.24.4) (2024-09-09)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.24.3](https://github.com/publishlab/node-acme-client/compare/v1.24.2...v1.24.3) (2024-09-06)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.24.2](https://github.com/publishlab/node-acme-client/compare/v1.24.1...v1.24.2) (2024-09-06)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 修复windows下无法执行第二条命令的bug ([d5bfcdb](https://github.com/publishlab/node-acme-client/commit/d5bfcdb6de1dcc1702155442e2e00237d0bbb6e5))
|
||||
|
||||
## [1.24.1](https://github.com/publishlab/node-acme-client/compare/v1.24.0...v1.24.1) (2024-09-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复在没有勾选使用代理的情况下,仍然会使用代理的bug ([0f66794](https://github.com/publishlab/node-acme-client/commit/0f6679425f6a736bb0128527dd99c085fac17d84))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 部署插件支持宝塔、易盾云等 ([ee61709](https://github.com/publishlab/node-acme-client/commit/ee617095efa1171548cf52fd45f0f98a368555a3))
|
||||
* 授权配置支持加密 ([42a56b5](https://github.com/publishlab/node-acme-client/commit/42a56b581d754c3e5f9838179d19ab0d004ef2eb))
|
||||
|
||||
# [1.24.0](https://github.com/publishlab/node-acme-client/compare/v1.23.1...v1.24.0) (2024-08-25)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Simple and unopinionated ACME client",
|
||||
"private": false,
|
||||
"author": "nmorsman",
|
||||
"version": "1.24.0",
|
||||
"version": "1.26.4",
|
||||
"main": "src/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/publishlab/node-acme-client",
|
||||
"engines": {
|
||||
"node": ">= 16"
|
||||
"node": ">= 18"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
@@ -20,7 +20,7 @@
|
||||
"asn1js": "^3.0.5",
|
||||
"axios": "^1.7.2",
|
||||
"debug": "^4.3.5",
|
||||
"https-proxy-agent": "^7.0.4",
|
||||
"https-proxy-agent": "^7.0.5",
|
||||
"node-forge": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -34,7 +34,7 @@
|
||||
"mocha": "^10.6.0",
|
||||
"nock": "^13.5.4",
|
||||
"tsd": "^0.31.1",
|
||||
"typescript": "^4.8.4",
|
||||
"typescript": "^5.4.2",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"scripts": {
|
||||
@@ -59,5 +59,5 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/publishlab/node-acme-client/issues"
|
||||
},
|
||||
"gitHead": "e5da46cfc31b2e30a4903bcb2251b1851265ef41"
|
||||
"gitHead": "4343fb1b3072b03e2444398cafdb405f230a3779"
|
||||
}
|
||||
|
||||
@@ -13,8 +13,12 @@ const defaultOpts = {
|
||||
termsOfServiceAgreed: false,
|
||||
skipChallengeVerification: false,
|
||||
challengePriority: ['http-01', 'dns-01'],
|
||||
challengeCreateFn: async () => { throw new Error('Missing challengeCreateFn()'); },
|
||||
challengeRemoveFn: async () => { throw new Error('Missing challengeRemoveFn()'); },
|
||||
challengeCreateFn: async () => {
|
||||
throw new Error('Missing challengeCreateFn()');
|
||||
},
|
||||
challengeRemoveFn: async () => {
|
||||
throw new Error('Missing challengeRemoveFn()');
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -114,16 +118,16 @@ module.exports = async (client, userOpts) => {
|
||||
/* Trigger challengeCreateFn() */
|
||||
log(`[auto] [${d}] Trigger challengeCreateFn()`);
|
||||
const keyAuthorization = await client.getChallengeKeyAuthorization(challenge);
|
||||
let recordItem = null;
|
||||
|
||||
try {
|
||||
recordItem = await opts.challengeCreateFn(authz, challenge, keyAuthorization);
|
||||
const { recordReq, recordRes, dnsProvider } = await opts.challengeCreateFn(authz, challenge, keyAuthorization);
|
||||
log(`[auto] [${d}] challengeCreateFn success`);
|
||||
log(`[auto] [${d}] add challengeRemoveFn()`);
|
||||
clearTasks.push(async () => {
|
||||
/* Trigger challengeRemoveFn(), suppress errors */
|
||||
log(`[auto] [${d}] Trigger challengeRemoveFn()`);
|
||||
try {
|
||||
await opts.challengeRemoveFn(authz, challenge, keyAuthorization, recordItem);
|
||||
await opts.challengeRemoveFn(authz, challenge, keyAuthorization, recordReq, recordRes, dnsProvider);
|
||||
}
|
||||
catch (e) {
|
||||
log(`[auto] [${d}] challengeRemoveFn threw error: ${e.message}`);
|
||||
@@ -209,6 +213,7 @@ module.exports = async (client, userOpts) => {
|
||||
}
|
||||
|
||||
log(`[auto] challengeGroups:${allChallengePromises.length}`);
|
||||
|
||||
function runAllPromise(tasks) {
|
||||
let promise = Promise.resolve();
|
||||
tasks.forEach((task) => {
|
||||
@@ -228,48 +233,48 @@ module.exports = async (client, userOpts) => {
|
||||
return Promise.all(results);
|
||||
}
|
||||
|
||||
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('用户取消');
|
||||
}
|
||||
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);
|
||||
}
|
||||
log('challenge结束');
|
||||
|
||||
// log('[auto] Waiting for challenge valid status');
|
||||
// await Promise.all(challengePromises);
|
||||
|
||||
/**
|
||||
* Finalize order and download certificate
|
||||
*/
|
||||
|
||||
log('[auto] Finalizing order and downloading certificate');
|
||||
const finalized = await client.finalizeOrder(order, opts.csr);
|
||||
return await client.getCertificate(finalized, opts.preferredChain);
|
||||
}
|
||||
catch (e) {
|
||||
log('证书申请失败');
|
||||
log(e);
|
||||
throw new Error(`证书申请失败:${e.message}`);
|
||||
}
|
||||
finally {
|
||||
log(`清理challenge痕迹,length:${clearTasks.length}`);
|
||||
try {
|
||||
await runAllPromise(clearTasks);
|
||||
}
|
||||
catch (e) {
|
||||
log('清理challenge失败');
|
||||
log(e);
|
||||
log(`证书申请失败${e.message}`);
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
log(`清理challenge痕迹,length:${clearTasks.length}`);
|
||||
try {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await runAllPromise(clearTasks);
|
||||
}
|
||||
catch (e) {
|
||||
log('清理challenge失败');
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
log('challenge结束');
|
||||
|
||||
// log('[auto] Waiting for challenge valid status');
|
||||
// await Promise.all(challengePromises);
|
||||
/**
|
||||
* Finalize order and download certificate
|
||||
*/
|
||||
|
||||
log('[auto] Finalizing order and downloading certificate');
|
||||
const finalized = await client.finalizeOrder(order, opts.csr);
|
||||
const res = await client.getCertificate(finalized, opts.preferredChain);
|
||||
return res;
|
||||
// try {
|
||||
// await Promise.allSettled(challengePromises);
|
||||
// }
|
||||
|
||||
@@ -67,11 +67,11 @@ function getKeyInfo(keyPem) {
|
||||
* ```
|
||||
*/
|
||||
|
||||
async function createPrivateRsaKey(modulusLength = 2048) {
|
||||
async function createPrivateRsaKey(modulusLength = 2048, encodingType = 'pkcs8') {
|
||||
const pair = await generateKeyPair('rsa', {
|
||||
modulusLength,
|
||||
privateKeyEncoding: {
|
||||
type: 'pkcs8',
|
||||
type: encodingType,
|
||||
format: 'pem',
|
||||
},
|
||||
});
|
||||
@@ -106,11 +106,11 @@ exports.createPrivateKey = createPrivateRsaKey;
|
||||
* ```
|
||||
*/
|
||||
|
||||
exports.createPrivateEcdsaKey = async (namedCurve = 'P-256') => {
|
||||
exports.createPrivateEcdsaKey = async (namedCurve = 'P-256', encodingType = 'pkcs8') => {
|
||||
const pair = await generateKeyPair('ec', {
|
||||
namedCurve,
|
||||
privateKeyEncoding: {
|
||||
type: 'pkcs8',
|
||||
type: encodingType,
|
||||
format: 'pem',
|
||||
},
|
||||
});
|
||||
@@ -290,7 +290,6 @@ exports.readCsrDomains = (csrPem) => {
|
||||
if (Buffer.isBuffer(csrPem)) {
|
||||
csrPem = csrPem.toString();
|
||||
}
|
||||
|
||||
const dec = x509.PemConverter.decodeFirst(csrPem);
|
||||
const csr = new x509.Pkcs10CertificateRequest(dec);
|
||||
return parseDomains(csr);
|
||||
|
||||
@@ -55,7 +55,7 @@ class HttpClient {
|
||||
*/
|
||||
|
||||
async request(url, method, opts = {}) {
|
||||
if (this.urlMapping && this.urlMapping.mappings) {
|
||||
if (this.urlMapping && this.urlMapping.enabled && this.urlMapping.mappings) {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const key in this.urlMapping.mappings) {
|
||||
if (url.includes(key)) {
|
||||
|
||||
@@ -45,3 +45,5 @@ exports.axios = require('./axios');
|
||||
*/
|
||||
|
||||
exports.setLogger = require('./logger').setLogger;
|
||||
|
||||
exports.walkTxtRecord = require('./verify').walkTxtRecord;
|
||||
|
||||
@@ -66,17 +66,35 @@ async function walkDnsChallengeRecord(recordName, resolver = dns) {
|
||||
log(`Checking name for TXT records: ${recordName}`);
|
||||
const txtRecords = await resolver.resolveTxt(recordName);
|
||||
|
||||
if (txtRecords.length) {
|
||||
if (txtRecords && txtRecords.length) {
|
||||
log(`Found ${txtRecords.length} TXT records at ${recordName}`);
|
||||
log(`TXT records: ${JSON.stringify(txtRecords)}`);
|
||||
return [].concat(...txtRecords);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
catch (e) {
|
||||
log(`No TXT records found for name: ${recordName}`);
|
||||
log(`Resolve TXT records error, ${recordName} :${e.message}`);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/* Found nothing */
|
||||
throw new Error(`No TXT records found for name: ${recordName}`);
|
||||
async function walkTxtRecord(recordName) {
|
||||
try {
|
||||
/* Default DNS resolver first */
|
||||
log('Attempting to resolve TXT with default DNS resolver first');
|
||||
const res = await walkDnsChallengeRecord(recordName);
|
||||
if (res && res.length > 0) {
|
||||
return res;
|
||||
}
|
||||
throw new Error('No TXT records found');
|
||||
}
|
||||
catch (e) {
|
||||
/* Authoritative DNS resolver */
|
||||
log(`Error using default resolver, attempting to resolve TXT with authoritative NS: ${e.message}`);
|
||||
const authoritativeResolver = await util.getAuthoritativeDnsResolver(recordName);
|
||||
return await walkDnsChallengeRecord(recordName, authoritativeResolver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,26 +110,12 @@ async function walkDnsChallengeRecord(recordName, resolver = dns) {
|
||||
*/
|
||||
|
||||
async function verifyDnsChallenge(authz, challenge, keyAuthorization, prefix = '_acme-challenge.') {
|
||||
let recordValues = [];
|
||||
const recordName = `${prefix}${authz.identifier.value}`;
|
||||
log(`Resolving DNS TXT from record: ${recordName}`);
|
||||
|
||||
try {
|
||||
/* Default DNS resolver first */
|
||||
log('Attempting to resolve TXT with default DNS resolver first');
|
||||
recordValues = await walkDnsChallengeRecord(recordName);
|
||||
}
|
||||
catch (e) {
|
||||
/* Authoritative DNS resolver */
|
||||
log(`Error using default resolver, attempting to resolve TXT with authoritative NS: ${e.message}`);
|
||||
const authoritativeResolver = await util.getAuthoritativeDnsResolver(recordName);
|
||||
recordValues = await walkDnsChallengeRecord(recordName, authoritativeResolver);
|
||||
}
|
||||
|
||||
const recordValues = await walkTxtRecord(recordName);
|
||||
log(`DNS query finished successfully, found ${recordValues.length} TXT records`);
|
||||
|
||||
if (!recordValues.length || !recordValues.includes(keyAuthorization)) {
|
||||
throw new Error(`Authorization not found in DNS TXT record: ${recordName}`);
|
||||
throw new Error(`Authorization not found in DNS TXT record: ${recordName},need:${keyAuthorization},found:${recordValues}`);
|
||||
}
|
||||
|
||||
log(`Key authorization match for ${challenge.type}/${recordName}, ACME challenge verified`);
|
||||
@@ -153,4 +157,5 @@ module.exports = {
|
||||
'http-01': verifyHttpChallenge,
|
||||
'dns-01': verifyDnsChallenge,
|
||||
'tls-alpn-01': verifyTlsAlpnChallenge,
|
||||
walkTxtRecord,
|
||||
};
|
||||
|
||||
14
packages/core/acme-client/types/index.d.ts
vendored
@@ -55,8 +55,8 @@ export interface ClientExternalAccountBindingOptions {
|
||||
|
||||
export interface ClientAutoOptions {
|
||||
csr: CsrBuffer | CsrString;
|
||||
challengeCreateFn: (authz: Authorization, challenge: rfc8555.Challenge, keyAuthorization: string) => Promise<any>;
|
||||
challengeRemoveFn: (authz: Authorization, challenge: rfc8555.Challenge, keyAuthorization: string, recordRes:any) => Promise<any>;
|
||||
challengeCreateFn: (authz: Authorization, challenge: rfc8555.Challenge, keyAuthorization: string) => Promise<{recordReq:any,recordRes:any,dnsProvider:any}>;
|
||||
challengeRemoveFn: (authz: Authorization, challenge: rfc8555.Challenge, keyAuthorization: string,recordReq:any, recordRes:any,dnsProvider:any) => Promise<any>;
|
||||
email?: string;
|
||||
termsOfServiceAgreed?: boolean;
|
||||
skipChallengeVerification?: boolean;
|
||||
@@ -155,16 +155,16 @@ export interface EcdsaPublicJwk {
|
||||
}
|
||||
|
||||
export interface CryptoInterface {
|
||||
createPrivateKey(keySize?: number): Promise<PrivateKeyBuffer>;
|
||||
createPrivateRsaKey(keySize?: number): Promise<PrivateKeyBuffer>;
|
||||
createPrivateEcdsaKey(namedCurve?: 'P-256' | 'P-384' | 'P-521'): Promise<PrivateKeyBuffer>;
|
||||
createPrivateKey(keySize?: number,encodingType?:string): Promise<PrivateKeyBuffer>;
|
||||
createPrivateRsaKey(keySize?: number,encodingType?:string): Promise<PrivateKeyBuffer>;
|
||||
createPrivateEcdsaKey(namedCurve?: 'P-256' | 'P-384' | 'P-521',encodingType?:string): Promise<PrivateKeyBuffer>;
|
||||
getPublicKey(keyPem: PrivateKeyBuffer | PrivateKeyString | PublicKeyBuffer | PublicKeyString): PublicKeyBuffer;
|
||||
getJwk(keyPem: PrivateKeyBuffer | PrivateKeyString | PublicKeyBuffer | PublicKeyString): RsaPublicJwk | EcdsaPublicJwk;
|
||||
splitPemChain(chainPem: CertificateBuffer | CertificateString): string[];
|
||||
getPemBodyAsB64u(pem: CertificateBuffer | CertificateString): string;
|
||||
readCsrDomains(csrPem: CsrBuffer | CsrString): CertificateDomains;
|
||||
readCertificateInfo(certPem: CertificateBuffer | CertificateString): CertificateInfo;
|
||||
createCsr(data: CsrOptions, keyPem?: PrivateKeyBuffer | PrivateKeyString): Promise<[PrivateKeyBuffer, CsrBuffer]>;
|
||||
createCsr(data: CsrOptions, keyPem?: PrivateKeyBuffer | PrivateKeyString,encodingType?:string): Promise<[PrivateKeyBuffer, CsrBuffer]>;
|
||||
createAlpnCertificate(authz: Authorization, keyAuthorization: string, keyPem?: PrivateKeyBuffer | PrivateKeyString): Promise<[PrivateKeyBuffer, CertificateBuffer]>;
|
||||
isAlpnCertificateAuthorizationValid(certPem: CertificateBuffer | CertificateString, keyAuthorization: string): boolean;
|
||||
}
|
||||
@@ -197,3 +197,5 @@ export const axios: AxiosInstance;
|
||||
*/
|
||||
|
||||
export function setLogger(fn: (msg: string) => void): void;
|
||||
|
||||
export function walkTxtRecord(record: any): Promise<string[]>;
|
||||
|
||||
22
packages/core/basic/.eslintrc
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"env": {
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"@typescript-eslint/ban-ts-ignore": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
// "no-unused-expressions": "off",
|
||||
"max-len": [0, 160, 2, { "ignoreUrls": true }]
|
||||
}
|
||||
}
|
||||
28
packages/core/basic/.gitignore
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
test/user.secret.*
|
||||
test/**/*.js
|
||||
src/**/*.spec.ts
|
||||
3
packages/core/basic/.npmignore
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
src
|
||||
dist/**/*.spec.*
|
||||
2
packages/core/basic/.npmrc
Normal file
@@ -0,0 +1,2 @@
|
||||
link-workspace-packages=true
|
||||
prefer-workspace-packages=true
|
||||
28
packages/core/basic/CHANGELOG.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.26.4](https://github.com/certd/certd/compare/v1.26.3...v1.26.4) (2024-10-14)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 新增代理设置功能 ([273ab61](https://github.com/certd/certd/commit/273ab6139f5807f4d7fe865cc353b97f51b9a668))
|
||||
|
||||
## [1.26.3](https://github.com/certd/certd/compare/v1.26.2...v1.26.3) (2024-10-12)
|
||||
|
||||
**Note:** Version bump only for package @certd/basic
|
||||
|
||||
## [1.26.2](https://github.com/certd/certd/compare/v1.26.1...v1.26.2) (2024-10-11)
|
||||
|
||||
**Note:** Version bump only for package @certd/basic
|
||||
|
||||
## [1.26.1](https://github.com/certd/certd/compare/v1.26.0...v1.26.1) (2024-10-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/basic
|
||||
|
||||
# [1.26.0](https://github.com/certd/certd/compare/v1.25.9...v1.26.0) (2024-10-10)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 检查cname是否正确配置 ([b5d8935](https://github.com/certd/certd/commit/b5d8935159374fbe7fc7d4c48ae0ed9396861bdd))
|
||||
1
packages/core/basic/build.md
Normal file
@@ -0,0 +1 @@
|
||||
12:33
|
||||
68
packages/core/basic/package.json
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"name": "@certd/basic",
|
||||
"private": false,
|
||||
"version": "1.26.4",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"before-build": "rimraf dist && rimraf tsconfig.tsbuildinfo && rimraf .rollup.cache",
|
||||
"build": "npm run before-build && tsc --skipLibCheck",
|
||||
"dev-build": "npm run build",
|
||||
"preview": "vite preview",
|
||||
"test": "mocha --loader=ts-node/esm"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.7.2",
|
||||
"dayjs": "^1.11.7",
|
||||
"fix-path": "^4.0.0",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.5",
|
||||
"lodash-es": "^4.17.21",
|
||||
"lru-cache": "^10.0.0",
|
||||
"nanoid": "^5.0.7",
|
||||
"node-forge": "^1.3.1",
|
||||
"nodemailer": "^6.9.3",
|
||||
"proxy-agent": "^6.4.0",
|
||||
"qs": "^6.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^23.0.4",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@rollup/plugin-terser": "^0.4.3",
|
||||
"@rollup/plugin-typescript": "^11.0.0",
|
||||
"@types/chai": "^4.3.10",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node-forge": "^1.3.2",
|
||||
"@types/uuid": "^9.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||
"@typescript-eslint/parser": "^5.59.7",
|
||||
"chai": "4.3.10",
|
||||
"dayjs": "^1.11.7",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"log4js": "^6.9.1",
|
||||
"mocha": "^10.2.0",
|
||||
"prettier": "^2.8.8",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^5.0.5",
|
||||
"rollup": "^3.7.4",
|
||||
"rollup-plugin-typescript2": "^0.34.1",
|
||||
"rollup-plugin-visualizer": "^5.8.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsc-esm-fix": "^3.0.0",
|
||||
"tslib": "^2.5.2",
|
||||
"typescript": "^5.4.2",
|
||||
"vite": "^4.3.8",
|
||||
"vue-tsc": "^1.6.5"
|
||||
},
|
||||
"gitHead": "4343fb1b3072b03e2444398cafdb405f230a3779"
|
||||
}
|
||||
0
packages/core/basic/readme.md
Normal file
1
packages/core/basic/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './utils/index.js';
|
||||
33
packages/core/basic/src/utils/index.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
export * from './util.request.js';
|
||||
export * from './util.log.js';
|
||||
export * from './util.file.js';
|
||||
export * from './util.sp.js';
|
||||
export * from './util.promise.js';
|
||||
export * from './util.hash.js';
|
||||
export * from './util.merge.js';
|
||||
export * from './util.cache.js';
|
||||
import sleep from './util.sleep.js';
|
||||
import { http } from './util.request.js';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { mergeUtils } from './util.merge.js';
|
||||
import { sp } from './util.sp.js';
|
||||
import { hashUtils } from './util.hash.js';
|
||||
import { promises } from './util.promise.js';
|
||||
import { fileUtils } from './util.file.js';
|
||||
import * as _ from 'lodash-es';
|
||||
import { cache } from './util.cache.js';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export const utils = {
|
||||
sleep,
|
||||
http,
|
||||
sp,
|
||||
hash: hashUtils,
|
||||
promises,
|
||||
file: fileUtils,
|
||||
_,
|
||||
mergeUtils,
|
||||
cache,
|
||||
nanoid,
|
||||
dayjs,
|
||||
};
|
||||
8
packages/core/basic/src/utils/util.cache.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// LRUCache
|
||||
|
||||
import { LRUCache } from "lru-cache";
|
||||
|
||||
export const cache = new LRUCache<string, any>({
|
||||
max: 1000,
|
||||
ttl: 1000 * 60 * 10,
|
||||
});
|
||||
9
packages/core/basic/src/utils/util.hash.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import crypto from "crypto";
|
||||
|
||||
function md5(data: string) {
|
||||
return crypto.createHash("md5").update(data).digest("hex");
|
||||
}
|
||||
|
||||
export const hashUtils = {
|
||||
md5,
|
||||
};
|
||||
64
packages/core/basic/src/utils/util.merge.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import _ from "lodash-es";
|
||||
function isUnMergeable(srcValue: any) {
|
||||
return srcValue != null && srcValue instanceof UnMergeable;
|
||||
}
|
||||
function isUnCloneable(value: any) {
|
||||
return isUnMergeable(value) && !value.cloneable;
|
||||
}
|
||||
function merge(target: any, ...sources: any) {
|
||||
/**
|
||||
* 如果目标为不可合并对象,比如array、unMergeable、ref,则直接覆盖不合并
|
||||
* @param objValue 被合并对象
|
||||
* @param srcValue 来源对象
|
||||
*/
|
||||
function customizer(objValue: any, srcValue: any) {
|
||||
if (srcValue == null) {
|
||||
return;
|
||||
}
|
||||
// 如果被合并对象为数组,则直接被覆盖对象覆盖,只要覆盖对象不为空
|
||||
if (_.isArray(objValue)) {
|
||||
//原对象如果是数组
|
||||
return srcValue; //来源对象
|
||||
}
|
||||
|
||||
if (isUnMergeable(srcValue)) {
|
||||
return srcValue;
|
||||
}
|
||||
}
|
||||
|
||||
let found: any = null;
|
||||
for (const item of sources) {
|
||||
if (isUnMergeable(item)) {
|
||||
found = item;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
return _.mergeWith(target, ...sources, customizer);
|
||||
}
|
||||
|
||||
function cloneDeep(target: any) {
|
||||
if (isUnCloneable(target)) {
|
||||
return target;
|
||||
}
|
||||
function customizer(value: any) {
|
||||
if (isUnCloneable(value)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return _.cloneDeepWith(target, customizer);
|
||||
}
|
||||
export class UnMergeable {
|
||||
cloneable = false;
|
||||
|
||||
setCloneable(cloneable: any) {
|
||||
this.cloneable = cloneable;
|
||||
}
|
||||
}
|
||||
|
||||
export const mergeUtils = {
|
||||
merge,
|
||||
cloneDeep,
|
||||
};
|
||||
@@ -24,3 +24,27 @@ export function safePromise<T>(callback: (resolve: (ret: T) => void, reject: (re
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function promisify(func: any) {
|
||||
return function (...args: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
func(...args, (err: any, data: any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const promises = {
|
||||
TimeoutPromise,
|
||||
safePromise,
|
||||
promisify,
|
||||
};
|
||||
188
packages/core/basic/src/utils/util.request.ts
Normal file
@@ -0,0 +1,188 @@
|
||||
import axios, { AxiosRequestConfig } from 'axios';
|
||||
import { logger } from './util.log.js';
|
||||
import { Logger } from 'log4js';
|
||||
import { HttpProxyAgent } from 'http-proxy-agent';
|
||||
import { HttpsProxyAgent } from 'https-proxy-agent';
|
||||
import nodeHttp from 'http';
|
||||
import * as https from 'node:https';
|
||||
export class HttpError extends Error {
|
||||
status?: number;
|
||||
statusText?: string;
|
||||
code?: string;
|
||||
request?: { baseURL: string; url: string; method: string; params?: any; data?: any };
|
||||
response?: { data: any };
|
||||
cause?: any;
|
||||
constructor(error: any) {
|
||||
if (!error) {
|
||||
return;
|
||||
}
|
||||
super(error.message);
|
||||
|
||||
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;
|
||||
|
||||
this.status = error.response?.status;
|
||||
this.statusText = error.response?.statusText;
|
||||
this.request = {
|
||||
baseURL: error.config?.baseURL,
|
||||
url: error.config?.url,
|
||||
method: error.config?.method,
|
||||
params: error.config?.params,
|
||||
data: error.config?.data,
|
||||
};
|
||||
this.response = {
|
||||
data: error.response?.data,
|
||||
};
|
||||
|
||||
delete error.response;
|
||||
delete error.config;
|
||||
delete error.request;
|
||||
// logger.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
export const HttpCommonError = HttpError;
|
||||
|
||||
let defaultAgents = createAgent();
|
||||
|
||||
export function setGlobalProxy(opts: { httpProxy?: string; httpsProxy?: string }) {
|
||||
logger.info('setGlobalProxy:', opts);
|
||||
if (opts.httpProxy) {
|
||||
process.env.HTTP_PROXY = opts.httpProxy;
|
||||
}
|
||||
if (opts.httpsProxy) {
|
||||
process.env.HTTPS_PROXY = opts.httpsProxy;
|
||||
}
|
||||
|
||||
defaultAgents = createAgent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建请求实例
|
||||
*/
|
||||
export function createAxiosService({ logger }: { logger: Logger }) {
|
||||
// 创建一个 axios 实例
|
||||
const service = axios.create();
|
||||
|
||||
// 请求拦截
|
||||
service.interceptors.request.use(
|
||||
(config: any) => {
|
||||
logger.info(`http request:${config.url},method:${config.method},params:${JSON.stringify(config.params)}`);
|
||||
if (config.timeout == null) {
|
||||
config.timeout = 15000;
|
||||
}
|
||||
let agents = defaultAgents;
|
||||
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;
|
||||
},
|
||||
(error: Error) => {
|
||||
// 发送失败
|
||||
logger.error('接口请求失败:', error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
// 响应拦截
|
||||
service.interceptors.response.use(
|
||||
(response: any) => {
|
||||
logger.info('http response:', JSON.stringify(response?.data));
|
||||
return response.data;
|
||||
},
|
||||
(error: any) => {
|
||||
const status = error.response?.status;
|
||||
switch (status) {
|
||||
case 400:
|
||||
error.message = '请求错误';
|
||||
break;
|
||||
case 401:
|
||||
error.message = '未授权,请登录';
|
||||
break;
|
||||
case 403:
|
||||
error.message = '拒绝访问';
|
||||
break;
|
||||
case 404:
|
||||
error.message = `请求地址出错: ${error.response.config.url}`;
|
||||
break;
|
||||
case 408:
|
||||
error.message = '请求超时';
|
||||
break;
|
||||
case 500:
|
||||
error.message = '服务器内部错误';
|
||||
break;
|
||||
case 501:
|
||||
error.message = '服务未实现';
|
||||
break;
|
||||
case 502:
|
||||
error.message = '网关错误';
|
||||
break;
|
||||
case 503:
|
||||
error.message = '服务不可用';
|
||||
break;
|
||||
case 504:
|
||||
error.message = '网关超时';
|
||||
break;
|
||||
case 505:
|
||||
error.message = 'HTTP版本不受支持';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
logger.error(
|
||||
`请求出错:status:${error.response?.status},statusText:${error.response?.statusText},url:${error.config?.url},method:${error.config?.method}。`
|
||||
);
|
||||
logger.error('返回数据:', JSON.stringify(error.response?.data));
|
||||
if (error.response?.data) {
|
||||
error.message = error.response.data.message || error.response.data.msg || error.response.data.error || error.response.data;
|
||||
}
|
||||
if (error instanceof AggregateError) {
|
||||
logger.error('AggregateError', error);
|
||||
}
|
||||
const err = new HttpError(error);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
);
|
||||
return service;
|
||||
}
|
||||
|
||||
export const http = createAxiosService({ logger }) as HttpClient;
|
||||
export type HttpClientResponse<R> = any;
|
||||
export type HttpRequestConfig<D> = {
|
||||
skipSslVerify?: boolean;
|
||||
skipCheckRes?: boolean;
|
||||
} & AxiosRequestConfig<D>;
|
||||
export type HttpClient = {
|
||||
request<D = any, R = any>(config: HttpRequestConfig<D>): Promise<HttpClientResponse<R>>;
|
||||
};
|
||||
|
||||
export function createAgent(opts: nodeHttp.AgentOptions = {}) {
|
||||
let httpAgent, httpsAgent;
|
||||
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
|
||||
if (httpProxy) {
|
||||
logger.info('use httpProxy:', httpProxy);
|
||||
httpAgent = new HttpProxyAgent(httpProxy, opts as any);
|
||||
} else {
|
||||
httpAgent = new nodeHttp.Agent(opts);
|
||||
}
|
||||
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
|
||||
if (httpsProxy) {
|
||||
logger.info('use httpsProxy:', httpsProxy);
|
||||
httpsAgent = new HttpsProxyAgent(httpsProxy, opts as any);
|
||||
} else {
|
||||
httpsAgent = new https.Agent(opts);
|
||||
}
|
||||
return {
|
||||
httpAgent,
|
||||
httpsAgent,
|
||||
};
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export type SpawnOption = {
|
||||
cmd: string | string[];
|
||||
onStdout?: (data: string) => void;
|
||||
onStderr?: (data: string) => void;
|
||||
env: any;
|
||||
env?: any;
|
||||
logger?: ILogger;
|
||||
options?: any;
|
||||
};
|
||||
@@ -66,6 +66,8 @@ async function spawn(opts: SpawnOption): Promise<string> {
|
||||
cmd = item;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cmd = opts.cmd;
|
||||
}
|
||||
log.info(`执行命令: ${cmd}`);
|
||||
let stdout = "";
|
||||
42
packages/core/basic/tsconfig.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"inlineSourceMap":true,
|
||||
"noImplicitThis": true,
|
||||
"noUnusedLocals": true,
|
||||
"stripInternal": true,
|
||||
"skipLibCheck": true,
|
||||
"pretty": true,
|
||||
"declaration": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"typeRoots": [ "./typings", "./node_modules/@types"],
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"composite": true,
|
||||
"useDefineForClassFields": true,
|
||||
"strict": true,
|
||||
// "sourceMap": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": false,
|
||||
"lib": ["ESNext", "DOM"],
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.d.ts",
|
||||
"src/**/*.json"
|
||||
],
|
||||
"exclude": [
|
||||
"*.js",
|
||||
"*.ts",
|
||||
"*.spec.ts",
|
||||
"dist",
|
||||
"node_modules",
|
||||
"test"
|
||||
],
|
||||
}
|
||||
@@ -3,6 +3,128 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.26.4](https://github.com/certd/certd/compare/v1.26.3...v1.26.4) (2024-10-14)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* [comm] 支持插件管理 ([e8b617b](https://github.com/certd/certd/commit/e8b617b80ce882dd63006f0cfc719a80a1cc6acc))
|
||||
* EAB授权支持绑定邮箱,支持公共EAB设置 ([07043af](https://github.com/certd/certd/commit/07043aff0ca7fd29c56dd3c363002cb15d78b464))
|
||||
|
||||
## [1.26.3](https://github.com/certd/certd/compare/v1.26.2...v1.26.3) (2024-10-12)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.26.2](https://github.com/certd/certd/compare/v1.26.1...v1.26.2) (2024-10-11)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.26.1](https://github.com/certd/certd/compare/v1.26.0...v1.26.1) (2024-10-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
# [1.26.0](https://github.com/certd/certd/compare/v1.25.9...v1.26.0) (2024-10-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复某些代理情况下 报 400 The plain HTTP request was sent to HTTPS port use proxy 的bug ([a13203f](https://github.com/certd/certd/commit/a13203fb3f48c427d0d81a504912248dcc07df1a))
|
||||
|
||||
### Features
|
||||
|
||||
* 域名验证方法支持CNAME间接方式,此方式支持所有域名注册商,且无需提供Access授权,但是需要手动添加cname解析 ([f3d3508](https://github.com/certd/certd/commit/f3d35084ed44f9f33845f7045e520be5c27eed93))
|
||||
* 站点个性化设置 ([11a9fe9](https://github.com/certd/certd/commit/11a9fe9014d96cba929e5a066e78f2af7ae59d14))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 调整全部静态资源到static目录 ([a218890](https://github.com/certd/certd/commit/a21889080d6c7ffdf0af526a3a21f0b2d1c77288))
|
||||
* 检查cname是否正确配置 ([b5d8935](https://github.com/certd/certd/commit/b5d8935159374fbe7fc7d4c48ae0ed9396861bdd))
|
||||
* cname校验配置增加未校验通过提示 ([77cc3c4](https://github.com/certd/certd/commit/77cc3c4a5cbd81f8233a8e0bb33fab0621c0905f))
|
||||
|
||||
## [1.25.9](https://github.com/certd/certd/compare/v1.25.8...v1.25.9) (2024-10-01)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.25.8](https://github.com/certd/certd/compare/v1.25.7...v1.25.8) (2024-09-30)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.25.7](https://github.com/certd/certd/compare/v1.25.6...v1.25.7) (2024-09-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复某些地区被屏蔽无法激活专业版的bug ([7532a96](https://github.com/certd/certd/commit/7532a960851b84d4f2cc3dba02353c5235e1a364))
|
||||
|
||||
## [1.25.6](https://github.com/certd/certd/compare/v1.25.5...v1.25.6) (2024-09-29)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 部署支持1Panel ([d047234](https://github.com/certd/certd/commit/d047234d98d31504f2e5a472b66e1b75806af26e))
|
||||
|
||||
## [1.25.5](https://github.com/certd/certd/compare/v1.25.4...v1.25.5) (2024-09-26)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.25.4](https://github.com/certd/certd/compare/v1.25.3...v1.25.4) (2024-09-25)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.25.3](https://github.com/certd/certd/compare/v1.25.2...v1.25.3) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.25.2](https://github.com/certd/certd/compare/v1.25.1...v1.25.2) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.25.1](https://github.com/certd/certd/compare/v1.25.0...v1.25.1) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
# [1.25.0](https://github.com/certd/certd/compare/v1.24.4...v1.25.0) (2024-09-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复首次创建任务运行时不自动设置当前运行情况的bug ([ecd83ee](https://github.com/certd/certd/commit/ecd83ee136abdd3df9ed2f21ec2ff0f24c0ed9d9))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 群晖支持OTP双重验证登录 ([8b8039f](https://github.com/certd/certd/commit/8b8039f42bbce10a4d0e737cdeeeef9bb17bee5a))
|
||||
* 任务支持禁用 ([8ed16b3](https://github.com/certd/certd/commit/8ed16b3ea2dfe847357863a0bfa614e4fa5fc041))
|
||||
* 支持阿里云ACK证书部署 ([d331fea](https://github.com/certd/certd/commit/d331fea47789122650e057ec7c9e85ee8e66f09b))
|
||||
* 支持七牛云 ([8ecc2f9](https://github.com/certd/certd/commit/8ecc2f9446a9ebd11b9bfbffbb6cf7812a043495))
|
||||
* 支持k8s ingress secret ([e5a5d0a](https://github.com/certd/certd/commit/e5a5d0a607bb6b4e1a1f7a1a419bada5f2dee59f))
|
||||
* http请求增加默认超时时间 ([664bd86](https://github.com/certd/certd/commit/664bd863e5b4895aabe2384277c0c65f5902fdb2))
|
||||
* plugins增加图标 ([a8da658](https://github.com/certd/certd/commit/a8da658a9723342b4f43a579f7805bfef0648efb))
|
||||
|
||||
## [1.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 前置任务步骤增加错误提示 ([ae3daa9](https://github.com/certd/certd/commit/ae3daa9bcf4fc363825aad9b77f5d3879aeeff70))
|
||||
* 群晖部署教程 ([0f0af2f](https://github.com/certd/certd/commit/0f0af2f309390f388e7a272cea3a1dd30c01977d))
|
||||
* 支持群晖 ([5c270b6](https://github.com/certd/certd/commit/5c270b6b9d45a2152f9fdb3c07bd98b7c803cb8e))
|
||||
|
||||
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 支持多吉云cdn证书部署 ([65ef685](https://github.com/certd/certd/commit/65ef6857296784ca765926e09eafcb6fc8b6ecde))
|
||||
|
||||
## [1.24.2](https://github.com/certd/certd/compare/v1.24.1...v1.24.2) (2024-09-06)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 优化跳过处理逻辑 ([b80210f](https://github.com/certd/certd/commit/b80210f24bf5db1c958d06ab27c9e5d3db452eda))
|
||||
* 支持pfx、der ([fbeaed2](https://github.com/certd/certd/commit/fbeaed203519f59b6d9396c4e8953353ccb5e723))
|
||||
|
||||
## [1.24.1](https://github.com/certd/certd/compare/v1.24.0...v1.24.1) (2024-09-02)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 部署插件支持宝塔、易盾云等 ([ee61709](https://github.com/certd/certd/commit/ee617095efa1171548cf52fd45f0f98a368555a3))
|
||||
* 授权配置支持加密 ([42a56b5](https://github.com/certd/certd/commit/42a56b581d754c3e5f9838179d19ab0d004ef2eb))
|
||||
* 支持阿里云 DCDN ([98b77f8](https://github.com/certd/certd/commit/98b77f80843834616fb26f83b4c42245326abd06))
|
||||
* 支持已跳过的步骤重新运行 ([ea775ad](https://github.com/certd/certd/commit/ea775adae18d57a04470cfba6b9460d761d74035))
|
||||
|
||||
# [1.24.0](https://github.com/certd/certd/compare/v1.23.1...v1.24.0) (2024-08-25)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -1 +1 @@
|
||||
14:26
|
||||
02:40
|
||||
|
||||
@@ -1,24 +1,33 @@
|
||||
{
|
||||
"name": "@certd/pipeline",
|
||||
"private": false,
|
||||
"version": "1.24.0",
|
||||
"version": "1.26.4",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc --skipLibCheck",
|
||||
"before-build": "rimraf dist && rimraf tsconfig.tsbuildinfo && rimraf .rollup.cache",
|
||||
"build": "npm run before-build && tsc --skipLibCheck",
|
||||
"dev-build": "npm run build",
|
||||
"build3": "rollup -c",
|
||||
"build2": "vue-tsc --noEmit && vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "mocha --loader=ts-node/esm"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/basic": "^1.26.4",
|
||||
"@certd/plus-core": "^1.26.4",
|
||||
"axios": "^1.7.2",
|
||||
"dayjs": "^1.11.7",
|
||||
"fix-path": "^4.0.0",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.5",
|
||||
"lodash-es": "^4.17.21",
|
||||
"lru-cache": "^10.0.0",
|
||||
"nanoid": "^5.0.7",
|
||||
"node-forge": "^1.3.1",
|
||||
"nodemailer": "^6.9.3",
|
||||
"proxy-agent": "^6.4.0",
|
||||
"qs": "^6.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -46,15 +55,16 @@
|
||||
"mocha": "^10.2.0",
|
||||
"prettier": "^2.8.8",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^5.0.5",
|
||||
"rollup": "^3.7.4",
|
||||
"rollup-plugin-typescript2": "^0.34.1",
|
||||
"rollup-plugin-visualizer": "^5.8.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsc-esm-fix": "^3.0.0",
|
||||
"tslib": "^2.5.2",
|
||||
"typescript": "^5.0.4",
|
||||
"typescript": "^5.4.2",
|
||||
"vite": "^4.3.8",
|
||||
"vue-tsc": "^1.6.5"
|
||||
},
|
||||
"gitHead": "e5da46cfc31b2e30a4903bcb2251b1851265ef41"
|
||||
"gitHead": "4343fb1b3072b03e2444398cafdb405f230a3779"
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { Registrable } from "../registry/index.js";
|
||||
import { FormItemProps } from "../dt/index.js";
|
||||
import { HttpClient, ILogger, utils } from "../utils/index.js";
|
||||
import _ from "lodash-es";
|
||||
import { AccessRequestHandleReq } from "../core";
|
||||
|
||||
export type AccessInputDefine = FormItemProps & {
|
||||
title: string;
|
||||
required?: boolean;
|
||||
encrypt?: boolean;
|
||||
};
|
||||
export type AccessDefine = Registrable & {
|
||||
input?: {
|
||||
@@ -11,8 +15,39 @@ export type AccessDefine = Registrable & {
|
||||
};
|
||||
};
|
||||
export interface IAccessService {
|
||||
getById(id: any): Promise<any>;
|
||||
getById<T = any>(id: any): Promise<T>;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface IAccess {}
|
||||
export interface IAccess {
|
||||
ctx: AccessContext;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export type AccessContext = {
|
||||
http: HttpClient;
|
||||
logger: ILogger;
|
||||
utils: typeof utils;
|
||||
};
|
||||
|
||||
export abstract class BaseAccess implements IAccess {
|
||||
ctx!: AccessContext;
|
||||
|
||||
async onRequest(req: AccessRequestHandleReq) {
|
||||
if (!req.action) {
|
||||
throw new Error("action is required");
|
||||
}
|
||||
|
||||
let methodName = req.action;
|
||||
if (!req.action.startsWith("on")) {
|
||||
methodName = `on${_.upperFirst(req.action)}`;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const method = this[methodName];
|
||||
if (method) {
|
||||
// @ts-ignore
|
||||
return await this[methodName](req.data);
|
||||
}
|
||||
throw new Error(`action ${req.action} not found`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// src/decorator/memoryCache.decorator.ts
|
||||
import { AccessDefine, AccessInputDefine } from "./api.js";
|
||||
import { AccessContext, AccessDefine, AccessInputDefine } from "./api.js";
|
||||
import { Decorator } from "../decorator/index.js";
|
||||
import _ from "lodash-es";
|
||||
import { accessRegistry } from "./registry.js";
|
||||
import { http, logger, utils } from "../utils/index.js";
|
||||
|
||||
// 提供一个唯一 key
|
||||
export const ACCESS_CLASS_KEY = "pipeline:access";
|
||||
@@ -37,3 +38,24 @@ export function AccessInput(input?: AccessInputDefine): PropertyDecorator {
|
||||
Reflect.defineMetadata(ACCESS_INPUT_KEY, input, target, propertyKey);
|
||||
};
|
||||
}
|
||||
|
||||
export function newAccess(type: string, input: any, ctx?: AccessContext) {
|
||||
const register = accessRegistry.get(type);
|
||||
if (register == null) {
|
||||
throw new Error(`access ${type} not found`);
|
||||
}
|
||||
// @ts-ignore
|
||||
const access = new register.target();
|
||||
for (const key in input) {
|
||||
access[key] = input[key];
|
||||
}
|
||||
if (!ctx) {
|
||||
ctx = {
|
||||
http,
|
||||
logger,
|
||||
utils,
|
||||
};
|
||||
}
|
||||
access.ctx = ctx;
|
||||
return access;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { AxiosInstance } from "axios";
|
||||
import { IContext } from "../core/index.js";
|
||||
|
||||
export type HttpClient = AxiosInstance;
|
||||
export type UserContext = IContext;
|
||||
export type PipelineContext = IContext;
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import { ConcurrencyStrategy, NotificationWhen, Pipeline, ResultType, Runnable, RunStrategy, Stage, Step, Task } from "../dt/index.js";
|
||||
import _ from "lodash-es";
|
||||
import { RunHistory, RunnableCollection } from "./run-history.js";
|
||||
import { AbstractTaskPlugin, PluginDefine, pluginRegistry, TaskInstanceContext } from "../plugin/index.js";
|
||||
import { AbstractTaskPlugin, PluginDefine, pluginRegistry, TaskInstanceContext, UserInfo } from "../plugin/index.js";
|
||||
import { ContextFactory, IContext } from "./context.js";
|
||||
import { IStorage } from "./storage.js";
|
||||
import { logger } from "../utils/util.log.js";
|
||||
import { createAxiosService, hashUtils, logger, utils } from "../utils/index.js";
|
||||
import { Logger } from "log4js";
|
||||
import { createAxiosService } from "../utils/util.request.js";
|
||||
import { IAccessService } from "../access/index.js";
|
||||
import { RegistryItem } from "../registry/index.js";
|
||||
import { Decorator } from "../decorator/index.js";
|
||||
import { IEmailService } from "../service/index.js";
|
||||
import { ICnameProxyService, IEmailService, IPluginConfigService } from "../service/index.js";
|
||||
import { FileStore } from "./file-store.js";
|
||||
// import { TimeoutPromise } from "../utils/util.promise.js";
|
||||
import { cloneDeep, forEach, merge } from "lodash-es";
|
||||
|
||||
export type ExecutorOptions = {
|
||||
userId: any;
|
||||
pipeline: Pipeline;
|
||||
storage: IStorage;
|
||||
onChanged: (history: RunHistory) => Promise<void>;
|
||||
accessService: IAccessService;
|
||||
emailService: IEmailService;
|
||||
cnameProxyService: ICnameProxyService;
|
||||
pluginConfigService: IPluginConfigService;
|
||||
fileRootDir?: string;
|
||||
user: UserInfo;
|
||||
};
|
||||
|
||||
export class Executor {
|
||||
@@ -36,20 +36,26 @@ export class Executor {
|
||||
options: ExecutorOptions;
|
||||
abort: AbortController = new AbortController();
|
||||
|
||||
_inited = false;
|
||||
|
||||
onChanged: (history: RunHistory) => Promise<void>;
|
||||
constructor(options: ExecutorOptions) {
|
||||
this.options = options;
|
||||
this.pipeline = _.cloneDeep(options.pipeline);
|
||||
this.pipeline = cloneDeep(options.pipeline);
|
||||
this.onChanged = async (history: RunHistory) => {
|
||||
await options.onChanged(history);
|
||||
};
|
||||
this.pipeline.userId = options.userId;
|
||||
this.pipeline.userId = options.user.id;
|
||||
this.contextFactory = new ContextFactory(options.storage);
|
||||
this.logger = logger;
|
||||
this.pipelineContext = this.contextFactory.getContext("pipeline", this.pipeline.id);
|
||||
}
|
||||
|
||||
async init() {
|
||||
if (this._inited) {
|
||||
return;
|
||||
}
|
||||
this._inited = true;
|
||||
const lastRuntime = await this.pipelineContext.getObj(`lastRuntime`);
|
||||
this.lastRuntime = lastRuntime;
|
||||
this.lastStatusMap = new RunnableCollection(lastRuntime?.pipeline);
|
||||
@@ -63,6 +69,7 @@ export class Executor {
|
||||
}
|
||||
|
||||
async run(runtimeId: any = 0, triggerType: string) {
|
||||
let intervalFlushLogId: any = undefined;
|
||||
try {
|
||||
await this.init();
|
||||
const trigger = { type: triggerType };
|
||||
@@ -70,64 +77,57 @@ export class Executor {
|
||||
this.runtime = new RunHistory(runtimeId, trigger, this.pipeline);
|
||||
this.logger.info(`pipeline.${this.pipeline.id} start`);
|
||||
await this.notification("start");
|
||||
|
||||
this.runtime.start(this.pipeline);
|
||||
intervalFlushLogId = setInterval(async () => {
|
||||
await this.onChanged(this.runtime);
|
||||
}, 5000);
|
||||
|
||||
await this.runWithHistory(this.pipeline, "pipeline", async () => {
|
||||
await this.runStages(this.pipeline);
|
||||
return await this.runStages(this.pipeline);
|
||||
});
|
||||
if (this.lastRuntime && this.lastRuntime.pipeline.status?.status === ResultType.error) {
|
||||
await this.notification("turnToSuccess");
|
||||
}
|
||||
await this.notification("success");
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
await this.notification("error", e);
|
||||
this.logger.error("pipeline 执行失败", e);
|
||||
} finally {
|
||||
clearInterval(intervalFlushLogId);
|
||||
await this.onChanged(this.runtime);
|
||||
await this.pipelineContext.setObj("lastRuntime", this.runtime);
|
||||
this.logger.info(`pipeline.${this.pipeline.id} end`);
|
||||
}
|
||||
}
|
||||
|
||||
async runWithHistory(runnable: Runnable, runnableType: string, run: () => Promise<void>) {
|
||||
async runWithHistory(runnable: Runnable, runnableType: string, run: () => Promise<ResultType | void>) {
|
||||
runnable.runnableType = runnableType;
|
||||
|
||||
this.runtime.start(runnable);
|
||||
await this.onChanged(this.runtime);
|
||||
|
||||
if (runnable.strategy?.runStrategy === RunStrategy.SkipWhenSucceed) {
|
||||
//如果是成功后跳过策略
|
||||
const lastNode = this.lastStatusMap.get(runnable.id);
|
||||
const lastResult = lastNode?.status?.status;
|
||||
const lastInput = JSON.stringify(lastNode?.status?.input);
|
||||
let inputChanged = false;
|
||||
if (runnableType === "step") {
|
||||
const step = runnable as Step;
|
||||
const input = JSON.stringify(step.input);
|
||||
if (input != null && lastInput !== input) {
|
||||
//参数有变化
|
||||
inputChanged = true;
|
||||
}
|
||||
}
|
||||
if (lastResult != null && lastResult === ResultType.success && !inputChanged) {
|
||||
runnable.status!.output = lastNode?.status?.output;
|
||||
runnable.status!.files = lastNode?.status?.files;
|
||||
this.runtime.skip(runnable);
|
||||
await this.onChanged(this.runtime);
|
||||
return ResultType.skip;
|
||||
}
|
||||
}
|
||||
const intervalFlushLogId = setInterval(async () => {
|
||||
await this.onChanged(this.runtime);
|
||||
}, 5000);
|
||||
|
||||
// const timeout = runnable.timeout ?? 20 * 60 * 1000;
|
||||
try {
|
||||
if (runnable.disabled) {
|
||||
//该任务被禁用
|
||||
this.runtime.disabled(runnable);
|
||||
return ResultType.disabled;
|
||||
}
|
||||
|
||||
await this.onChanged(this.runtime);
|
||||
|
||||
if (this.abort.signal.aborted) {
|
||||
this.runtime.cancel(runnable);
|
||||
return ResultType.canceled;
|
||||
}
|
||||
await run();
|
||||
const resultType = await run();
|
||||
if (this.abort.signal.aborted) {
|
||||
this.runtime.cancel(runnable);
|
||||
return ResultType.canceled;
|
||||
}
|
||||
if (resultType == ResultType.skip) {
|
||||
this.runtime.skip(runnable);
|
||||
return resultType;
|
||||
}
|
||||
this.runtime.success(runnable);
|
||||
return ResultType.success;
|
||||
} catch (e: any) {
|
||||
@@ -135,7 +135,6 @@ export class Executor {
|
||||
throw e;
|
||||
} finally {
|
||||
this.runtime.finally(runnable);
|
||||
clearInterval(intervalFlushLogId);
|
||||
await this.onChanged(this.runtime);
|
||||
}
|
||||
}
|
||||
@@ -144,7 +143,7 @@ export class Executor {
|
||||
const resList: ResultType[] = [];
|
||||
for (const stage of pipeline.stages) {
|
||||
const res: ResultType = await this.runWithHistory(stage, "stage", async () => {
|
||||
await this.runStage(stage);
|
||||
return await this.runStage(stage);
|
||||
});
|
||||
resList.push(res);
|
||||
}
|
||||
@@ -157,6 +156,7 @@ export class Executor {
|
||||
const runner = async () => {
|
||||
return this.runWithHistory(task, "task", async () => {
|
||||
await this.runTask(task);
|
||||
return ResultType.success;
|
||||
});
|
||||
};
|
||||
runnerList.push(runner);
|
||||
@@ -199,7 +199,7 @@ export class Executor {
|
||||
for (const step of task.steps) {
|
||||
step.runnableType = "step";
|
||||
const res: ResultType = await this.runWithHistory(step, "step", async () => {
|
||||
await this.runStep(step);
|
||||
return await this.runStep(step);
|
||||
});
|
||||
resList.push(res);
|
||||
}
|
||||
@@ -217,20 +217,54 @@ export class Executor {
|
||||
const instance: ITaskPlugin = new plugin.target();
|
||||
// @ts-ignore
|
||||
const define: PluginDefine = plugin.define;
|
||||
const pluginName = define.name;
|
||||
const pluginConfig = await this.options.pluginConfigService.getPluginConfig(pluginName);
|
||||
//从outputContext读取输入参数
|
||||
Decorator.inject(define.input, instance, step.input, (item, key) => {
|
||||
if (item.component?.name === "pi-output-selector") {
|
||||
const contextKey = step.input[key];
|
||||
const input = cloneDeep(step.input);
|
||||
Decorator.inject(define.input, instance, input, (item, key) => {
|
||||
if (item.component?.name === "output-selector") {
|
||||
const contextKey = input[key];
|
||||
if (contextKey != null) {
|
||||
if (typeof contextKey !== "string") {
|
||||
throw new Error(`步骤${step.title}的${item.title}属性必须为String类型,请重新配置该属性`);
|
||||
}
|
||||
// "cert": "step.-BNFVPMKPu2O-i9NiOQxP.cert",
|
||||
const arr = contextKey.split(".");
|
||||
const id = arr[1];
|
||||
const outputKey = arr[2];
|
||||
step.input[key] = this.currentStatusMap.get(id)?.status?.output[outputKey] ?? this.lastStatusMap.get(id)?.status?.output[outputKey];
|
||||
input[key] = this.currentStatusMap.get(id)?.status?.output[outputKey] ?? this.lastStatusMap.get(id)?.status?.output[outputKey];
|
||||
if (input[key] == null) {
|
||||
this.logger.warn(`${item.title}的配置未找到对应的输出值,请确认对应的前置任务是否存在或者是否执行正确`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const sysInput = pluginConfig.sysSetting?.input || {};
|
||||
//注入系统设置参数
|
||||
for (const sysInputKey in sysInput) {
|
||||
input[sysInputKey] = sysInput[sysInputKey];
|
||||
}
|
||||
|
||||
const newInputHash = hashUtils.md5(JSON.stringify(input));
|
||||
step.status!.inputHash = newInputHash;
|
||||
//判断是否需要跳过
|
||||
const lastNode = this.lastStatusMap.get(step.id);
|
||||
const lastResult = lastNode?.status?.status;
|
||||
let inputChanged = true;
|
||||
const lastInputHash = lastNode?.status?.inputHash;
|
||||
if (lastInputHash && newInputHash && lastInputHash === newInputHash) {
|
||||
//参数有变化
|
||||
inputChanged = false;
|
||||
}
|
||||
if (step.strategy?.runStrategy === RunStrategy.SkipWhenSucceed) {
|
||||
if (lastResult != null && lastResult === ResultType.success && !inputChanged) {
|
||||
step.status!.output = lastNode?.status?.output;
|
||||
step.status!.files = lastNode?.status?.files;
|
||||
return ResultType.skip;
|
||||
}
|
||||
}
|
||||
|
||||
const http = createAxiosService({ logger: currentLogger });
|
||||
const taskCtx: TaskInstanceContext = {
|
||||
pipeline: this.pipeline,
|
||||
@@ -238,16 +272,21 @@ export class Executor {
|
||||
lastStatus,
|
||||
http,
|
||||
logger: currentLogger,
|
||||
inputChanged,
|
||||
accessService: this.options.accessService,
|
||||
emailService: this.options.emailService,
|
||||
cnameProxyService: this.options.cnameProxyService,
|
||||
pluginConfigService: this.options.pluginConfigService,
|
||||
pipelineContext: this.pipelineContext,
|
||||
userContext: this.contextFactory.getContext("user", this.options.userId),
|
||||
userContext: this.contextFactory.getContext("user", this.options.user.id),
|
||||
fileStore: new FileStore({
|
||||
scope: this.pipeline.id,
|
||||
parent: this.runtime.id,
|
||||
rootDir: this.options.fileRootDir,
|
||||
}),
|
||||
signal: this.abort.signal,
|
||||
utils,
|
||||
user: this.options.user,
|
||||
};
|
||||
instance.setCtx(taskCtx);
|
||||
|
||||
@@ -259,18 +298,17 @@ export class Executor {
|
||||
this.lastStatusMap.clear();
|
||||
}
|
||||
//输出上下文变量到output context
|
||||
_.forEach(define.output, (item: any, key: any) => {
|
||||
forEach(define.output, (item: any, key: any) => {
|
||||
step.status!.output[key] = instance[key];
|
||||
// const stepOutputKey = `step.${step.id}.${key}`;
|
||||
// this.runtime.context[stepOutputKey] = instance[key];
|
||||
});
|
||||
step.status!.files = instance.getFiles();
|
||||
|
||||
//更新pipeline vars
|
||||
if (Object.keys(instance._result.pipelineVars).length > 0) {
|
||||
// 判断 pipelineVars 有值时更新
|
||||
const vars = this.pipelineContext.getObj("vars");
|
||||
_.merge(vars, instance._result.pipelineVars);
|
||||
merge(vars, instance._result.pipelineVars);
|
||||
await this.pipelineContext.setObj("vars", vars);
|
||||
}
|
||||
}
|
||||
@@ -282,17 +320,17 @@ export class Executor {
|
||||
let subject = "";
|
||||
let content = "";
|
||||
if (when === "start") {
|
||||
subject = `【CertD】开始执行,${this.pipeline.title}, buildId:${this.runtime.id}`;
|
||||
content = subject;
|
||||
subject = `【CertD】开始执行,【${this.pipeline.id}】${this.pipeline.title}`;
|
||||
content = `buildId:${this.runtime.id}`;
|
||||
} else if (when === "success") {
|
||||
subject = `【CertD】执行成功,${this.pipeline.title}, buildId:${this.runtime.id}`;
|
||||
content = subject;
|
||||
subject = `【CertD】执行成功,【${this.pipeline.id}】${this.pipeline.title}`;
|
||||
content = `buildId:${this.runtime.id}`;
|
||||
} else if (when === "turnToSuccess") {
|
||||
subject = `【CertD】执行成功(错误转成功),${this.pipeline.title}, buildId:${this.runtime.id}`;
|
||||
content = subject;
|
||||
subject = `【CertD】执行成功(错误转成功),【${this.pipeline.id}】${this.pipeline.title}`;
|
||||
content = `buildId:${this.runtime.id}`;
|
||||
} else if (when === "error") {
|
||||
subject = `【CertD】执行失败,${this.pipeline.title}, buildId:${this.runtime.id}`;
|
||||
content = `<pre>${error.message}</pre>`;
|
||||
subject = `【CertD】执行失败,【${this.pipeline.id}】${this.pipeline.title}`;
|
||||
content = `buildId:${this.runtime.id}\nerror:${error.message}`;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -315,4 +353,8 @@ export class Executor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clearLastStatus(stepId: string) {
|
||||
this.lastStatusMap.clearById(stepId);
|
||||
}
|
||||
}
|
||||
|
||||
21
packages/core/pipeline/src/core/handler.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { HttpClient, ILogger, utils } from "../utils/index.js";
|
||||
|
||||
export type PluginRequestHandleReq<T = any> = {
|
||||
typeName: string;
|
||||
action: string;
|
||||
input: T;
|
||||
data: any;
|
||||
};
|
||||
|
||||
export type AccessRequestHandleReqInput<T = any> = {
|
||||
id?: number;
|
||||
title?: string;
|
||||
access: T;
|
||||
};
|
||||
export type AccessRequestHandleContext = {
|
||||
http: HttpClient;
|
||||
logger: ILogger;
|
||||
utils: typeof utils;
|
||||
};
|
||||
|
||||
export type AccessRequestHandleReq<T = any> = PluginRequestHandleReq<AccessRequestHandleReqInput<T>>;
|
||||
@@ -4,3 +4,4 @@ export * from "./context.js";
|
||||
export * from "./storage.js";
|
||||
export * from "./file-store.js";
|
||||
export * from "./license.js";
|
||||
export * from "./handler.js";
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { isPlus, verify } from "./license.js";
|
||||
import { equal } from "assert";
|
||||
describe("license", function () {
|
||||
it("#license", async function () {
|
||||
const req = {
|
||||
subjectId: "999",
|
||||
license: "",
|
||||
};
|
||||
const plus = isPlus();
|
||||
equal(plus, false);
|
||||
const res = await verify(req);
|
||||
equal(res, true);
|
||||
});
|
||||
});
|
||||
@@ -1,138 +1,16 @@
|
||||
import { createVerify } from "node:crypto";
|
||||
import { logger } from "../utils/index.js";
|
||||
import dayjs from "dayjs";
|
||||
import { setLogger, isPlus, isComm } from "@certd/plus-core";
|
||||
setLogger(logger);
|
||||
export * from "@certd/plus-core";
|
||||
|
||||
let SecreteKey =
|
||||
"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1JSUJDZ0tDQVFFQW9VWE1EWUhjdi82WFROWEZFSUI2RlpuR2FER0cwZnR5bTV1dVhPck9NaVl0UkxSb1lvSGMKNVZxenE0N00rdEFqRFBhaTBlOFhWS1c3aytUQUw3MUs0N2JCQVEyWTBxNU5Ya3lYcE5PTVdueVFMYXBwb0tWNgpPMkFJMnpFVURWMVJVa0ZtMFZTVjU0VXNzMDcrdjI2aW5aQU1CWitDMU42eWFDc2tZL3grNnVlNkVRNVcyZXdFCjZOWEhJcUU1bHdEUmU2SXJtdEpnU2doSnlHTS91azIyejN6NGEraFVPVUlWMy9DbEhYV0VhRHBBRFFsakt3NSsKeHR0dURiTHZyUmdzdWp6czB0dEI2OE1SbXE0R0FJL0JtNWVPWkhlNGxFQjBFVVhFUXdVWE1jV1N1VFZSMUE2cApUM21LRGo5MGcwVDFZUlNOdE5TMm9aRzgvRWIwOVlxK3Z3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0K";
|
||||
let appKey = "kQth6FHM71IPV3qdWc";
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
SecreteKey =
|
||||
"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1JSUJDZ0tDQVFFQXY3TGtMaUp1dGM0NzhTU3RaTExjajVGZXh1YjJwR2NLMGxwa0hwVnlZWjhMY29rRFhuUlAKUGQ5UlJSTVRTaGJsbFl2Mzd4QUhOV1ZIQ0ZsWHkrQklVU001bUlBU1NDQTV0azlJNmpZZ2F4bEFDQm1BY0lGMwozKzBjeGZIYVkrVW9YdVluMkZ6YUt2Ym5GdFZIZ0lkMDg4a3d4clZTZzlCT3BDRVZIR1pxR2I5TWN5MXVHVXhUClFTVENCbmpoTWZlZ0p6cXVPYWVOY0ZPSE5tbmtWRWpLTythbTBPeEhNS1lyS3ZnQnVEbzdoVnFENlBFMUd6V3AKZHdwZUV4QXZDSVJxL2pWTkdRK3FtMkRWOVNJZ3U5bmF4MktmSUtFeU50dUFFS1VpekdqL0VmRFhDM1cxMExhegpKaGNYNGw1SUFZU1o3L3JWVmpGbExWSVl0WDU1T054L1Z3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0K";
|
||||
appKey = "z4nXOeTeSnnpUpnmsV1";
|
||||
}
|
||||
|
||||
export const AppKey = appKey;
|
||||
|
||||
export type LicenseVerifyReq = {
|
||||
subjectId: string;
|
||||
license: string;
|
||||
};
|
||||
|
||||
type License = {
|
||||
appKey: string;
|
||||
code: string;
|
||||
subjectId: string;
|
||||
expireTime: number;
|
||||
activeTime: number;
|
||||
duration: number;
|
||||
version: number;
|
||||
secret: string;
|
||||
vipType: string;
|
||||
signature: string;
|
||||
};
|
||||
|
||||
class LicenseHolder {
|
||||
isPlus = false;
|
||||
expireTime = 0;
|
||||
vipType = "";
|
||||
message?: string = undefined;
|
||||
secret?: string = undefined;
|
||||
}
|
||||
const holder = new LicenseHolder();
|
||||
holder.isPlus = false;
|
||||
|
||||
class LicenseVerifier {
|
||||
checked = false;
|
||||
licenseReq?: LicenseVerifyReq = undefined;
|
||||
async reVerify(req: LicenseVerifyReq) {
|
||||
this.checked = false;
|
||||
return await this.verify(req);
|
||||
}
|
||||
|
||||
setPlus(value: boolean, info: any = {}) {
|
||||
if (value && info) {
|
||||
holder.isPlus = true;
|
||||
holder.expireTime = info.expireTime;
|
||||
holder.secret = info.secret;
|
||||
holder.vipType = info.vipType;
|
||||
} else {
|
||||
holder.isPlus = false;
|
||||
holder.expireTime = 0;
|
||||
holder.vipType = "";
|
||||
holder.message = info.message;
|
||||
holder.secret = undefined;
|
||||
}
|
||||
return {
|
||||
...holder,
|
||||
};
|
||||
}
|
||||
async verify(req: LicenseVerifyReq) {
|
||||
this.licenseReq = req;
|
||||
if (this.checked) {
|
||||
return this.setPlus(false);
|
||||
}
|
||||
const license = req?.license;
|
||||
if (!license) {
|
||||
this.checked = true;
|
||||
return this.setPlus(false);
|
||||
}
|
||||
|
||||
const licenseJson = Buffer.from(license, "base64").toString();
|
||||
const json: License = JSON.parse(licenseJson);
|
||||
if (json.expireTime < Date.now()) {
|
||||
logger.warn("授权已过期");
|
||||
return this.setPlus(false, { message: "授权已过期" });
|
||||
}
|
||||
const content = `${appKey},${this.licenseReq.subjectId},${json.code},${json.secret},${json.vipType},${json.activeTime},${json.duration},${json.expireTime},${json.version}`;
|
||||
// content := fmt.Sprintf("%s,%s,%s,%s,%d,%d,%d,%d,%d", entity.AppKey, entity.SubjectId, entity.Code, entity.Secret, entity.Level, entity.ActiveTime, entity.Duration, entity.ExpireTime, entity.Version)
|
||||
//z4nXOeTeSnnpUpnmsV,_m9jFTdNHktdaEN4xBDw_,HZz7rAAR3h3zGlDMhScO1wGBYPjXpZ9S_1,uUpr9I8p6K3jWSzu2Wh5NECvgG2FNynU,0,1724199847470,365,1787271324416,1
|
||||
logger.debug("content:", content);
|
||||
const publicKey = Buffer.from(SecreteKey, "base64").toString();
|
||||
const res = this.verifySignature(content, json.signature, publicKey);
|
||||
this.checked = true;
|
||||
if (!res) {
|
||||
logger.warn("授权校验失败");
|
||||
return this.setPlus(false, { message: "授权校验失败" });
|
||||
}
|
||||
logger.info(`授权校验成功,到期时间:${dayjs(json.expireTime).format("YYYY-MM-DD HH:mm:ss")}`);
|
||||
return this.setPlus(true, {
|
||||
expireTime: json.expireTime,
|
||||
vipType: json.vipType || "plus",
|
||||
secret: json.secret,
|
||||
});
|
||||
}
|
||||
|
||||
verifySignature(content: string, signature: any, publicKey: string) {
|
||||
const verify = createVerify("RSA-SHA256");
|
||||
verify.update(content);
|
||||
return verify.verify(publicKey, signature, "base64");
|
||||
export function checkPlus() {
|
||||
if (!isPlus()) {
|
||||
throw new Error("此为专业版功能,请升级到专业版");
|
||||
}
|
||||
}
|
||||
|
||||
const verifier = new LicenseVerifier();
|
||||
|
||||
export function isPlus() {
|
||||
return holder.isPlus && holder.expireTime > Date.now();
|
||||
}
|
||||
|
||||
export function isCommercial() {
|
||||
return holder.isPlus && holder.vipType === "comm" && holder.expireTime > Date.now();
|
||||
}
|
||||
|
||||
export function getPlusInfo() {
|
||||
return {
|
||||
isPlus: holder.isPlus,
|
||||
vipType: holder.vipType,
|
||||
expireTime: holder.expireTime,
|
||||
secret: holder.secret,
|
||||
};
|
||||
}
|
||||
|
||||
export async function verify(req: LicenseVerifyReq) {
|
||||
try {
|
||||
return await verifier.reVerify(req);
|
||||
} catch (e) {
|
||||
logger.error(e);
|
||||
return verifier.setPlus(false, { message: "授权校验失败" });
|
||||
export function checkComm() {
|
||||
if (!isComm()) {
|
||||
throw new Error("此为商业版功能,请升级到商业版");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HistoryResult, Pipeline, ResultType, Runnable, RunnableMap, Stage, Step, Task } from "../dt/index.js";
|
||||
import _ from "lodash-es";
|
||||
import { buildLogger } from "../utils/util.log.js";
|
||||
import { buildLogger } from "../utils/index.js";
|
||||
import { Logger } from "log4js";
|
||||
|
||||
export type HistoryStatus = {
|
||||
@@ -41,10 +41,8 @@ export class RunHistory {
|
||||
this._loggers[runnable.id] = buildLogger((text) => {
|
||||
this.logs[runnable.id].push(text);
|
||||
});
|
||||
const input = (runnable as Step).input;
|
||||
const status: HistoryResult = {
|
||||
output: {},
|
||||
input: _.cloneDeep(input),
|
||||
status: ResultType.start,
|
||||
startTime: now,
|
||||
result: ResultType.start,
|
||||
@@ -76,6 +74,17 @@ export class RunHistory {
|
||||
this.log(runnable, `跳过`);
|
||||
}
|
||||
|
||||
disabled(runnable: Runnable) {
|
||||
const now = new Date().getTime();
|
||||
const status = runnable.status;
|
||||
_.merge(status, {
|
||||
status: "canceled",
|
||||
endTime: now,
|
||||
result: "disabled",
|
||||
});
|
||||
this.log(runnable, `禁用`);
|
||||
}
|
||||
|
||||
error(runnable: Runnable, e: Error) {
|
||||
const now = new Date().getTime();
|
||||
const status = runnable.status;
|
||||
@@ -104,12 +113,13 @@ export class RunHistory {
|
||||
|
||||
log(runnable: Runnable, text: string) {
|
||||
// @ts-ignore
|
||||
this._loggers[runnable.id].info(`[${runnable.title}]<id:${runnable.id}> [${runnable.runnableType}]`, text);
|
||||
this._loggers[runnable.id].info(`[${runnable.runnableType}] [${runnable.title}]<id:${runnable.id}> :`, text);
|
||||
}
|
||||
|
||||
logError(runnable: Runnable, e: Error) {
|
||||
// @ts-ignore
|
||||
this._loggers[runnable.id].error(`[${runnable.title}]<id:${runnable.id}> [${runnable.runnableType}]`, e);
|
||||
const errorInfo = runnable.runnableType === "step" ? e : e.message;
|
||||
this._loggers[runnable.id].error(`[${runnable.runnableType}] [${runnable.title}]<id:${runnable.id}> :`, errorInfo);
|
||||
}
|
||||
|
||||
finally(runnable: Runnable) {
|
||||
@@ -166,6 +176,14 @@ export class RunnableCollection {
|
||||
});
|
||||
}
|
||||
|
||||
clearById(id: string) {
|
||||
const runnable = this.collection[id];
|
||||
if (runnable?.status) {
|
||||
runnable.status.status = ResultType.none;
|
||||
runnable.status.result = ResultType.none;
|
||||
}
|
||||
}
|
||||
|
||||
add(runnable: Runnable) {
|
||||
this.collection[runnable.id] = runnable;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { fileUtils } from "../utils/util.file.js";
|
||||
import { fileUtils } from "../utils/index.js";
|
||||
|
||||
export interface IStorage {
|
||||
get(scope: string, namespace: string, version: string, key: string): Promise<string | null>;
|
||||
|
||||
@@ -46,6 +46,7 @@ export type Stage = Runnable & {
|
||||
tasks: Task[];
|
||||
concurrency: ConcurrencyStrategy;
|
||||
next: NextStrategy;
|
||||
maxTaskCount?: number;
|
||||
};
|
||||
|
||||
export type Trigger = {
|
||||
@@ -70,6 +71,7 @@ export type Runnable = {
|
||||
default?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export type EmailOptions = {
|
||||
@@ -108,6 +110,7 @@ export enum ResultType {
|
||||
error = "error",
|
||||
canceled = "canceled",
|
||||
skip = "skip",
|
||||
disabled = "disabled",
|
||||
none = "none",
|
||||
}
|
||||
|
||||
@@ -118,7 +121,8 @@ export type HistoryResultGroup = {
|
||||
};
|
||||
};
|
||||
export type HistoryResult = {
|
||||
input: any;
|
||||
// input: any;
|
||||
inputHash?: string;
|
||||
output: any;
|
||||
files?: FileItem[];
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import "util";
|
||||
export * from "./core/index.js";
|
||||
export * from "./dt/index.js";
|
||||
export * from "./access/index.js";
|
||||
|
||||
@@ -3,11 +3,17 @@ import { FileItem, FormItemProps, Pipeline, Runnable, Step } from "../dt/index.j
|
||||
import { FileStore } from "../core/file-store.js";
|
||||
import { Logger } from "log4js";
|
||||
import { IAccessService } from "../access/index.js";
|
||||
import { IEmailService } from "../service/index.js";
|
||||
import { IContext } from "../core/index.js";
|
||||
import { AxiosInstance } from "axios";
|
||||
import { ILogger, logger } from "../utils/index.js";
|
||||
|
||||
import { ICnameProxyService, IEmailService } from "../service/index.js";
|
||||
import { IContext, PluginRequestHandleReq, RunnableCollection } from "../core/index.js";
|
||||
import { ILogger, logger, utils } from "../utils/index.js";
|
||||
import { HttpClient } from "../utils/index.js";
|
||||
import dayjs from "dayjs";
|
||||
import { IPluginConfigService } from "../service/config";
|
||||
import { upperFirst } from "lodash-es";
|
||||
export type UserInfo = {
|
||||
role: "admin" | "user";
|
||||
id: any;
|
||||
};
|
||||
export enum ContextScope {
|
||||
global,
|
||||
pipeline,
|
||||
@@ -17,13 +23,18 @@ export enum ContextScope {
|
||||
export type TaskOutputDefine = {
|
||||
title: string;
|
||||
value?: any;
|
||||
type?: string;
|
||||
};
|
||||
|
||||
export type TaskInputDefine = FormItemProps;
|
||||
export type TaskInputDefine = {
|
||||
required?: boolean;
|
||||
isSys?: boolean;
|
||||
} & FormItemProps;
|
||||
|
||||
export type PluginDefine = Registrable & {
|
||||
default?: any;
|
||||
group?: string;
|
||||
icon?: string;
|
||||
input?: {
|
||||
[key: string]: TaskInputDefine;
|
||||
};
|
||||
@@ -35,16 +46,13 @@ export type PluginDefine = Registrable & {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
reference?: {
|
||||
src: string;
|
||||
dest: string;
|
||||
type: "computed";
|
||||
}[];
|
||||
needPlus?: boolean;
|
||||
};
|
||||
|
||||
export type ITaskPlugin = {
|
||||
onInstance(): Promise<void>;
|
||||
execute(): Promise<void>;
|
||||
onRequest(req: PluginRequestHandleReq<any>): Promise<any>;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
@@ -54,17 +62,38 @@ export type TaskResult = {
|
||||
pipelineVars: Record<string, any>;
|
||||
};
|
||||
export type TaskInstanceContext = {
|
||||
//流水线定义
|
||||
pipeline: Pipeline;
|
||||
//步骤定义
|
||||
step: Step;
|
||||
//日志
|
||||
logger: Logger;
|
||||
//当前步骤输入参数跟上一次执行比较是否有变化
|
||||
inputChanged: boolean;
|
||||
//授权获取服务
|
||||
accessService: IAccessService;
|
||||
//邮件服务
|
||||
emailService: IEmailService;
|
||||
//cname记录服务
|
||||
cnameProxyService: ICnameProxyService;
|
||||
//插件配置服务
|
||||
pluginConfigService: IPluginConfigService;
|
||||
//流水线上下文
|
||||
pipelineContext: IContext;
|
||||
//用户上下文
|
||||
userContext: IContext;
|
||||
http: AxiosInstance;
|
||||
//http请求客户端
|
||||
http: HttpClient;
|
||||
//文件存储
|
||||
fileStore: FileStore;
|
||||
//上一次执行结果状态
|
||||
lastStatus?: Runnable;
|
||||
//用户取消信号
|
||||
signal: AbortSignal;
|
||||
//工具类
|
||||
utils: typeof utils;
|
||||
//用户信息
|
||||
user: UserInfo;
|
||||
};
|
||||
|
||||
export abstract class AbstractTaskPlugin implements ITaskPlugin {
|
||||
@@ -87,6 +116,17 @@ export abstract class AbstractTaskPlugin implements ITaskPlugin {
|
||||
this.accessService = ctx.accessService;
|
||||
}
|
||||
|
||||
async getAccess(accessId: string) {
|
||||
if (accessId == null) {
|
||||
throw new Error("您还没有配置授权");
|
||||
}
|
||||
const res = await this.ctx.accessService.getById(accessId);
|
||||
if (res == null) {
|
||||
throw new Error("授权不存在,可能已被删除,请前往任务配置里面重新选择授权");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
randomFileId() {
|
||||
return Math.random().toString(36).substring(2, 9);
|
||||
}
|
||||
@@ -120,6 +160,51 @@ export abstract class AbstractTaskPlugin implements ITaskPlugin {
|
||||
}
|
||||
|
||||
abstract execute(): Promise<void>;
|
||||
|
||||
appendTimeSuffix(name?: string) {
|
||||
if (name == null) {
|
||||
name = "certd";
|
||||
}
|
||||
return name + "_" + dayjs().format("YYYYMMDDHHmmss");
|
||||
}
|
||||
|
||||
async onRequest(req: PluginRequestHandleReq<any>) {
|
||||
if (!req.action) {
|
||||
throw new Error("action is required");
|
||||
}
|
||||
|
||||
let methodName = req.action;
|
||||
if (!req.action.startsWith("on")) {
|
||||
methodName = `on${upperFirst(req.action)}`;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const method = this[methodName];
|
||||
if (method) {
|
||||
// @ts-ignore
|
||||
return await this[methodName](req.data);
|
||||
}
|
||||
throw new Error(`action ${req.action} not found`);
|
||||
}
|
||||
|
||||
isAdmin() {
|
||||
return this.ctx.user.role === "admin";
|
||||
}
|
||||
|
||||
getStepFromPipeline(stepId: string) {
|
||||
let found: any = null;
|
||||
RunnableCollection.each(this.ctx.pipeline.stages, (step) => {
|
||||
if (step.id === stepId) {
|
||||
found = step;
|
||||
return;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
getStepIdFromRefInput(ref = ".") {
|
||||
return ref.split(".")[1];
|
||||
}
|
||||
}
|
||||
|
||||
export type OutputVO = {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import _ from "lodash-es";
|
||||
import { pluginRegistry } from "./registry.js";
|
||||
import { PluginDefine, TaskInputDefine, TaskOutputDefine } from "./api.js";
|
||||
import { Decorator } from "../decorator/index.js";
|
||||
import { AUTOWIRE_KEY } from "../decorator/index.js";
|
||||
import "reflect-metadata";
|
||||
import { merge, sortBy } from "lodash-es";
|
||||
// 提供一个唯一 key
|
||||
export const PLUGIN_CLASS_KEY = "pipeline:plugin";
|
||||
|
||||
@@ -42,13 +42,13 @@ export function IsTaskPlugin(define: PluginDefine): ClassDecorator {
|
||||
}
|
||||
inputArray.push([key, _input]);
|
||||
}
|
||||
inputArray = _.sortBy(inputArray, (item: any) => item[1].order);
|
||||
inputArray = sortBy(inputArray, (item: any) => item[1].order);
|
||||
const inputMap: any = {};
|
||||
inputArray.forEach((item: any) => {
|
||||
inputMap[item[0]] = item[1];
|
||||
});
|
||||
|
||||
_.merge(define, { input: inputMap, autowire: autowires, output: outputs });
|
||||
merge(define, { input: inputMap, autowire: autowires, output: outputs });
|
||||
|
||||
Reflect.defineMetadata(PLUGIN_CLASS_KEY, define, target);
|
||||
|
||||
|
||||
@@ -21,5 +21,7 @@ export const pluginGroups = {
|
||||
huawei: new PluginGroup("huawei", "华为云", 3),
|
||||
tencent: new PluginGroup("tencent", "腾讯云", 4),
|
||||
host: new PluginGroup("host", "主机", 5),
|
||||
other: new PluginGroup("other", "其他", 7),
|
||||
cdn: new PluginGroup("cdn", "CDN", 6),
|
||||
panel: new PluginGroup("panel", "面板", 7),
|
||||
other: new PluginGroup("other", "其他", 8),
|
||||
};
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import { ITaskPlugin } from "../api.js";
|
||||
import { IsTaskPlugin, TaskInput } from "../decorator.js";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: "EchoPlugin",
|
||||
title: "测试插件",
|
||||
desc: "test",
|
||||
})
|
||||
export class EchoPlugin implements ITaskPlugin {
|
||||
@TaskInput({
|
||||
title: "测试属性",
|
||||
component: {
|
||||
name: "text",
|
||||
},
|
||||
})
|
||||
test?: string;
|
||||
|
||||
onInstance(): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
async execute(): Promise<void> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ export type Registrable = {
|
||||
title: string;
|
||||
desc?: string;
|
||||
group?: string;
|
||||
deprecated?: string;
|
||||
};
|
||||
|
||||
export type RegistryItem<T> = {
|
||||
@@ -67,6 +68,9 @@ export class Registry<T> {
|
||||
for (const key in this.storage) {
|
||||
const define = this.getDefine(key);
|
||||
if (define) {
|
||||
if (define?.deprecated) {
|
||||
continue;
|
||||
}
|
||||
list.push({ ...define, key });
|
||||
}
|
||||
}
|
||||
|
||||
17
packages/core/pipeline/src/service/cname.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export type CnameProvider = {
|
||||
id: any;
|
||||
domain: string;
|
||||
dnsProviderType: string;
|
||||
accessId: any;
|
||||
};
|
||||
export type CnameRecord = {
|
||||
id: any;
|
||||
domain: string;
|
||||
hostRecord: string;
|
||||
recordValue: string;
|
||||
cnameProvider: CnameProvider;
|
||||
status: string;
|
||||
};
|
||||
export type ICnameProxyService = {
|
||||
getByDomain: (domain: string) => Promise<CnameRecord>;
|
||||
};
|
||||
12
packages/core/pipeline/src/service/config.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export type PluginConfig = {
|
||||
name: string;
|
||||
disabled: boolean;
|
||||
sysSetting: {
|
||||
input: Record<string, any>;
|
||||
};
|
||||
};
|
||||
|
||||
//插件配置服务
|
||||
export type IPluginConfigService = {
|
||||
getPluginConfig: (pluginName: string) => Promise<PluginConfig>;
|
||||
};
|
||||
@@ -1 +1,3 @@
|
||||
export * from "./email.js";
|
||||
export * from "./cname.js";
|
||||
export * from "./config.js";
|
||||
|
||||
@@ -1,10 +1 @@
|
||||
import sleep from "./util.sleep.js";
|
||||
import { request } from "./util.request.js";
|
||||
export * from "./util.log.js";
|
||||
export * from "./util.file.js";
|
||||
export * from "./util.sp.js";
|
||||
export * as promises from "./util.promise.js";
|
||||
export const utils = {
|
||||
sleep,
|
||||
http: request,
|
||||
};
|
||||
export * from "@certd/basic";
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
import axios from "axios";
|
||||
// @ts-ignore
|
||||
import qs from "qs";
|
||||
import { logger } from "./util.log.js";
|
||||
import { Logger } from "log4js";
|
||||
/**
|
||||
* @description 创建请求实例
|
||||
*/
|
||||
export function createAxiosService({ logger }: { logger: Logger }) {
|
||||
// 创建一个 axios 实例
|
||||
const service = axios.create();
|
||||
// 请求拦截
|
||||
service.interceptors.request.use(
|
||||
(config: any) => {
|
||||
if (config.formData) {
|
||||
config.data = qs.stringify(config.formData, {
|
||||
arrayFormat: "indices",
|
||||
allowDots: true,
|
||||
}); // 序列化请求参数
|
||||
delete config.formData;
|
||||
}
|
||||
logger.info(`http request:${config.url},method:${config.method}`);
|
||||
return config;
|
||||
},
|
||||
(error: Error) => {
|
||||
// 发送失败
|
||||
logger.error("接口请求失败:", error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
// 响应拦截
|
||||
service.interceptors.response.use(
|
||||
(response: any) => {
|
||||
logger.info("http response:", JSON.stringify(response?.data));
|
||||
return response.data;
|
||||
},
|
||||
(error: any) => {
|
||||
// const status = _.get(error, 'response.status')
|
||||
// switch (status) {
|
||||
// case 400: error.message = '请求错误'; break
|
||||
// case 401: error.message = '未授权,请登录'; break
|
||||
// case 403: error.message = '拒绝访问'; break
|
||||
// case 404: error.message = `请求地址出错: ${error.response.config.url}`; break
|
||||
// case 408: error.message = '请求超时'; break
|
||||
// case 500: error.message = '服务器内部错误'; break
|
||||
// case 501: error.message = '服务未实现'; break
|
||||
// case 502: error.message = '网关错误'; break
|
||||
// case 503: error.message = '服务不可用'; break
|
||||
// case 504: error.message = '网关超时'; break
|
||||
// case 505: error.message = 'HTTP版本不受支持'; break
|
||||
// default: break
|
||||
// }
|
||||
logger.error(`请求出错:url:${error?.response?.config.url},method:${error?.response?.config?.method},status:${error?.response?.status}`);
|
||||
logger.info("返回数据:", JSON.stringify(error?.response?.data));
|
||||
delete error.config;
|
||||
const data = error?.response?.data;
|
||||
if (!data) {
|
||||
error.message = data.message || data.msg || data.error || data;
|
||||
}
|
||||
if (error?.response) {
|
||||
return Promise.reject({
|
||||
status: error?.response?.status,
|
||||
statusText: error?.response?.statusText,
|
||||
request: {
|
||||
url: error?.response?.config?.url,
|
||||
method: error?.response?.config?.method,
|
||||
data: error?.response?.data,
|
||||
},
|
||||
data: error?.response?.data,
|
||||
});
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
return service;
|
||||
}
|
||||
|
||||
export const request = createAxiosService({ logger });
|
||||
@@ -1,27 +0,0 @@
|
||||
import { Autowire, IsTaskPlugin, ITaskPlugin, TaskInput, TaskOutput } from "../src";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: "EchoPlugin",
|
||||
title: "测试插件【echo】",
|
||||
})
|
||||
export class EchoPlugin implements ITaskPlugin {
|
||||
@TaskInput({
|
||||
title: "cert",
|
||||
component: {
|
||||
name: "pi-output-selector",
|
||||
},
|
||||
helper: "输出选择",
|
||||
})
|
||||
cert!: any;
|
||||
|
||||
@TaskOutput({
|
||||
title: "cert info",
|
||||
})
|
||||
certInfo!: any;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
async onInstance(): Promise<void> {}
|
||||
async execute(): Promise<void> {
|
||||
console.log("input :cert", this.cert);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,58 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.26.4](https://github.com/certd/certd/compare/v1.26.3...v1.26.4) (2024-10-14)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.26.3](https://github.com/certd/certd/compare/v1.26.2...v1.26.3) (2024-10-12)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.26.2](https://github.com/certd/certd/compare/v1.26.1...v1.26.2) (2024-10-11)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.26.1](https://github.com/certd/certd/compare/v1.26.0...v1.26.1) (2024-10-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
# [1.26.0](https://github.com/certd/certd/compare/v1.25.9...v1.26.0) (2024-10-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.25.9](https://github.com/certd/certd/compare/v1.25.8...v1.25.9) (2024-10-01)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.25.8](https://github.com/certd/certd/compare/v1.25.7...v1.25.8) (2024-09-30)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.25.7](https://github.com/certd/certd/compare/v1.25.6...v1.25.7) (2024-09-29)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.25.6](https://github.com/certd/certd/compare/v1.25.5...v1.25.6) (2024-09-29)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.25.5](https://github.com/certd/certd/compare/v1.25.4...v1.25.5) (2024-09-26)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.24.2](https://github.com/certd/certd/compare/v1.24.1...v1.24.2) (2024-09-06)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.24.1](https://github.com/certd/certd/compare/v1.24.0...v1.24.1) (2024-09-02)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
## [1.22.1](https://github.com/certd/certd/compare/v1.22.0...v1.22.1) (2024-07-20)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-huawei
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
{
|
||||
"name": "@certd/lib-huawei",
|
||||
"private": false,
|
||||
"version": "1.22.1",
|
||||
"version": "1.26.4",
|
||||
"main": "./dist/bundle.js",
|
||||
"module": "./dist/bundle.js",
|
||||
"types": "./dist/d/index.d.ts",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "rollup -c ",
|
||||
"build2": "vue-tsc --noEmit && vite build",
|
||||
"before-build": "rimraf dist && rimraf tsconfig.tsbuildinfo && rimraf .rollup.cache",
|
||||
"build": "npm run before-build && rollup -c ",
|
||||
"dev-build": "npm run build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/pipeline": "1.21.0",
|
||||
"axios": "^1.7.2",
|
||||
"rimraf": "^5.0.5",
|
||||
"rollup": "^3.7.4"
|
||||
},
|
||||
"gitHead": "47fe3d5826661f678d081ab53e67c847a3239d88"
|
||||
"gitHead": "4343fb1b3072b03e2444398cafdb405f230a3779"
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = {
|
||||
rootDir: "src",
|
||||
declaration: true,
|
||||
declarationDir: "dist/d",
|
||||
exclude: ["./node_modules/**", "./src/**/*.vue"],
|
||||
exclude: ["./node_modules/**", "./src/**/*.vue", "./src/**/*.spec.ts"],
|
||||
allowSyntheticDefaultImports: true,
|
||||
}),
|
||||
json(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
|
||||
23
packages/libs/lib-iframe/.eslintrc
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"env": {
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"@typescript-eslint/ban-ts-ignore": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
// "no-unused-expressions": "off",
|
||||
"max-len": [0, 160, 2, { "ignoreUrls": true }]
|
||||
}
|
||||
}
|
||||
28
packages/libs/lib-iframe/.gitignore
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
src/test/user.secret.ts
|
||||
|
||||
src/**/*.js
|
||||
2
packages/libs/lib-iframe/.npmignore
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
src
|
||||
7
packages/libs/lib-iframe/.prettierrc
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"printWidth": 160,
|
||||
"bracketSpacing": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5",
|
||||
"arrowParens": "avoid"
|
||||
}
|
||||
129
packages/libs/lib-iframe/CHANGELOG.md
Normal file
@@ -0,0 +1,129 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.26.4](https://github.com/certd/certd/compare/v1.26.3...v1.26.4) (2024-10-14)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.26.3](https://github.com/certd/certd/compare/v1.26.2...v1.26.3) (2024-10-12)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.26.2](https://github.com/certd/certd/compare/v1.26.1...v1.26.2) (2024-10-11)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.26.1](https://github.com/certd/certd/compare/v1.26.0...v1.26.1) (2024-10-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
# [1.26.0](https://github.com/certd/certd/compare/v1.25.9...v1.26.0) (2024-10-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.25.9](https://github.com/certd/certd/compare/v1.25.8...v1.25.9) (2024-10-01)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.25.8](https://github.com/certd/certd/compare/v1.25.7...v1.25.8) (2024-09-30)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.25.7](https://github.com/certd/certd/compare/v1.25.6...v1.25.7) (2024-09-29)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.25.6](https://github.com/certd/certd/compare/v1.25.5...v1.25.6) (2024-09-29)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 部署支持1Panel ([d047234](https://github.com/certd/certd/commit/d047234d98d31504f2e5a472b66e1b75806af26e))
|
||||
|
||||
## [1.25.5](https://github.com/certd/certd/compare/v1.25.4...v1.25.5) (2024-09-26)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.25.4](https://github.com/certd/certd/compare/v1.25.3...v1.25.4) (2024-09-25)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.25.3](https://github.com/certd/certd/compare/v1.25.2...v1.25.3) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.25.2](https://github.com/certd/certd/compare/v1.25.1...v1.25.2) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
## [1.25.1](https://github.com/certd/certd/compare/v1.25.0...v1.25.1) (2024-09-24)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-iframe
|
||||
|
||||
# [1.25.0](https://github.com/certd/certd/compare/v1.24.4...v1.25.0) (2024-09-24)
|
||||
|
||||
### Features
|
||||
|
||||
* 支持vip转移 ([361e8fe](https://github.com/certd/certd/commit/361e8fe7ae5877e23fd5de31bc919bedd09c57f5))
|
||||
|
||||
## [1.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.24.2](https://github.com/certd/certd/compare/v1.24.1...v1.24.2) (2024-09-06)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.24.1](https://github.com/certd/certd/compare/v1.24.0...v1.24.1) (2024-09-02)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
# [1.24.0](https://github.com/certd/certd/compare/v1.23.1...v1.24.0) (2024-08-25)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 更新k8s底层api库 ([746bb9d](https://github.com/certd/certd/commit/746bb9d385e2f397daef4976eca1d4782a2f5ebd))
|
||||
|
||||
## [1.23.1](https://github.com/certd/certd/compare/v1.23.0...v1.23.1) (2024-08-06)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.22.8](https://github.com/certd/certd/compare/v1.22.7...v1.22.8) (2024-08-05)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.22.7](https://github.com/certd/certd/compare/v1.22.6...v1.22.7) (2024-08-04)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.22.6](https://github.com/certd/certd/compare/v1.22.5...v1.22.6) (2024-08-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.22.5](https://github.com/certd/certd/compare/v1.22.4...v1.22.5) (2024-07-26)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.22.3](https://github.com/certd/certd/compare/v1.22.2...v1.22.3) (2024-07-25)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.22.2](https://github.com/certd/certd/compare/v1.22.1...v1.22.2) (2024-07-23)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [1.22.1](https://github.com/certd/certd/compare/v1.22.0...v1.22.1) (2024-07-20)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
# [1.22.0](https://github.com/certd/certd/compare/v1.21.2...v1.22.0) (2024-07-19)
|
||||
|
||||
### Features
|
||||
|
||||
* 升级midway,支持esm ([485e603](https://github.com/certd/certd/commit/485e603b5165c28bc08694997726eaf2a585ebe7))
|
||||
* 支持postgresql ([3b19bfb](https://github.com/certd/certd/commit/3b19bfb4291e89064b3b407a80dae092d54747d5))
|
||||
16
packages/libs/lib-iframe/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Vue 3 + TypeScript + Vite
|
||||
|
||||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
|
||||
|
||||
## Type Support For `.vue` Imports in TS
|
||||
|
||||
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
|
||||
|
||||
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
|
||||
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
|
||||
|
||||
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
|
||||
96
packages/libs/lib-iframe/fix-esm-import-paths.js
Normal file
@@ -0,0 +1,96 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
// https://gist.github.com/lovasoa/8691344
|
||||
async function* walk(dir) {
|
||||
for await (const d of await fs.promises.opendir(dir)) {
|
||||
const entry = path.join(dir, d.name);
|
||||
if (d.isDirectory()) {
|
||||
yield* walk(entry);
|
||||
} else if (d.isFile()) {
|
||||
yield entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resolveImportPath(sourceFile, importPath, options) {
|
||||
const sourceFileAbs = path.resolve(process.cwd(), sourceFile);
|
||||
const root = path.dirname(sourceFileAbs);
|
||||
const { moduleFilter = defaultModuleFilter } = options;
|
||||
|
||||
if (moduleFilter(importPath)) {
|
||||
const importPathAbs = path.resolve(root, importPath);
|
||||
let possiblePath = [path.resolve(importPathAbs, "./index.ts"), path.resolve(importPathAbs, "./index.js"), importPathAbs + ".ts", importPathAbs + ".js"];
|
||||
|
||||
if (possiblePath.length) {
|
||||
for (let i = 0; i < possiblePath.length; i++) {
|
||||
let entry = possiblePath[i];
|
||||
if (fs.existsSync(entry)) {
|
||||
const resolved = path.relative(root, entry.replace(/\.ts$/, ".js"));
|
||||
|
||||
if (!resolved.startsWith(".")) {
|
||||
return "./" + resolved;
|
||||
}
|
||||
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function replace(filePath, outFilePath, options) {
|
||||
const code = fs.readFileSync(filePath).toString();
|
||||
const newCode = code.replace(/(import|export) (.+?) from ('[^\n']+'|"[^\n"]+");/gs, function (found, action, imported, from) {
|
||||
const importPath = from.slice(1, -1);
|
||||
let resolvedPath = resolveImportPath(filePath, importPath, options);
|
||||
|
||||
if (resolvedPath) {
|
||||
resolvedPath = resolvedPath.replaceAll("\\", "/");
|
||||
console.log("\t", importPath, resolvedPath);
|
||||
return `${action} ${imported} from "${resolvedPath}";`;
|
||||
}
|
||||
|
||||
return found;
|
||||
});
|
||||
|
||||
if (code !== newCode) {
|
||||
fs.writeFileSync(outFilePath, newCode);
|
||||
}
|
||||
}
|
||||
|
||||
// Then, use it with a simple async for loop
|
||||
async function run(srcDir, options = defaultOptions) {
|
||||
const { sourceFileFilter = defaultSourceFileFilter } = options;
|
||||
|
||||
for await (const entry of walk(srcDir)) {
|
||||
if (sourceFileFilter(entry)) {
|
||||
console.log(entry);
|
||||
replace(entry, entry, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const defaultSourceFileFilter = function (sourceFilePath) {
|
||||
return /\.(js|ts)$/.test(sourceFilePath) && !/node_modules/.test(sourceFilePath);
|
||||
};
|
||||
|
||||
const defaultModuleFilter = function (importedModule) {
|
||||
return !path.isAbsolute(importedModule) && !importedModule.startsWith("@") && !importedModule.endsWith(".js");
|
||||
};
|
||||
|
||||
const defaultOptions = {
|
||||
sourceFileFilter: defaultSourceFileFilter,
|
||||
moduleFilter: defaultModuleFilter,
|
||||
};
|
||||
|
||||
// Switch this to test on one file or directly run on a directory.
|
||||
const DEBUG = false;
|
||||
|
||||
if (DEBUG) {
|
||||
replace("./src/index.ts", "./out.ts", defaultOptions);
|
||||
} else {
|
||||
await run("./src/", defaultOptions);
|
||||
}
|
||||
43
packages/libs/lib-iframe/package.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@certd/lib-iframe",
|
||||
"private": false,
|
||||
"version": "1.26.4",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"before-build": "rimraf dist && rimraf tsconfig.tsbuildinfo && rimraf .rollup.cache",
|
||||
"build": "npm run before-build && tsc --skipLibCheck",
|
||||
"dev-build": "npm run build",
|
||||
"build3": "rollup -c",
|
||||
"build2": "vue-tsc --noEmit && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"nanoid": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^23.0.4",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@rollup/plugin-terser": "^0.4.3",
|
||||
"@rollup/plugin-typescript": "^11.0.0",
|
||||
"@types/chai": "^4.3.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
||||
"@typescript-eslint/parser": "^5.38.1",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"prettier": "^2.8.8",
|
||||
"rimraf": "^5.0.5",
|
||||
"rollup": "^3.7.4",
|
||||
"rollup-plugin-visualizer": "^5.8.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"tslib": "^2.5.2",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "4343fb1b3072b03e2444398cafdb405f230a3779"
|
||||
}
|
||||
1
packages/libs/lib-iframe/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './lib/iframe.client.js';
|
||||
122
packages/libs/lib-iframe/src/lib/iframe.client.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
export type IframeMessageData<T> = {
|
||||
action: string;
|
||||
id: string;
|
||||
data?: T;
|
||||
replyId?: string;
|
||||
errorCode?: number; //0为成功
|
||||
message?: string;
|
||||
};
|
||||
|
||||
export type IframeMessageReq<T = any, R = any> = {
|
||||
req: IframeMessageData<T>;
|
||||
onReply: (data: IframeMessageData<R>) => void;
|
||||
};
|
||||
|
||||
export class IframeException extends Error {
|
||||
code?: number = 0;
|
||||
constructor(data: IframeMessageData<any>) {
|
||||
super(data.message);
|
||||
this.code = data.errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
export class IframeClient {
|
||||
requestQueue: Record<string, IframeMessageReq> = {};
|
||||
//当前客户端是否是父级页面
|
||||
iframe?: HTMLIFrameElement;
|
||||
onError?: any;
|
||||
|
||||
handlers: Record<string, (data: IframeMessageData<any>) => Promise<void>> = {};
|
||||
constructor(iframe?: HTMLIFrameElement, onError?: (e: any) => void) {
|
||||
this.iframe = iframe;
|
||||
this.onError = onError;
|
||||
window.addEventListener('message', async (event: MessageEvent<IframeMessageData<any>>) => {
|
||||
const data = event.data;
|
||||
if (data.action) {
|
||||
console.log(`收到消息[isSub:${this.isInFrame()}]`, data);
|
||||
try {
|
||||
const handler = this.handlers[data.action];
|
||||
if (handler) {
|
||||
const res = await handler(data);
|
||||
if (data.id && data.action !== 'reply') {
|
||||
await this.send('reply', res, data.id);
|
||||
}
|
||||
} else {
|
||||
throw new Error(`action:${data.action} 未注册处理器,可能版本过低`);
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
await this.send('reply', {}, data.id, 500, e.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.register('reply', async data => {
|
||||
const req = this.requestQueue[data.replyId!];
|
||||
if (req) {
|
||||
req.onReply(data);
|
||||
delete this.requestQueue[data.replyId!];
|
||||
}
|
||||
});
|
||||
}
|
||||
isInFrame() {
|
||||
return window.self !== window.top;
|
||||
}
|
||||
|
||||
register<T = any>(action: string, handler: (data: IframeMessageData<T>) => Promise<void>) {
|
||||
this.handlers[action] = handler;
|
||||
}
|
||||
|
||||
async send<R = any, T = any>(action: string, data?: T, replyId?: string, errorCode?: number, message?: string): Promise<IframeMessageData<R>> {
|
||||
try {
|
||||
return await this.doSend<R, T>(action, data, replyId, errorCode, message);
|
||||
} catch (e) {
|
||||
if (this.onError) {
|
||||
this.onError(e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
async doSend<R = any, T = any>(action: string, data?: T, replyId?: string, errorCode?: number, message?: string): Promise<IframeMessageData<R>> {
|
||||
const reqMessageData: IframeMessageData<T> = {
|
||||
id: nanoid(),
|
||||
action,
|
||||
data,
|
||||
replyId,
|
||||
errorCode,
|
||||
message,
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const onReply = (reply: IframeMessageData<R>) => {
|
||||
if (reply.errorCode && reply.errorCode > 0) {
|
||||
reject(new IframeException(reply));
|
||||
return;
|
||||
}
|
||||
resolve(reply);
|
||||
};
|
||||
this.requestQueue[reqMessageData.id] = {
|
||||
req: reqMessageData,
|
||||
onReply,
|
||||
};
|
||||
try {
|
||||
console.log(`send message[isSub:${this.isInFrame()}]:`, reqMessageData);
|
||||
if (!this.iframe) {
|
||||
if (!window.parent) {
|
||||
reject('当前页面不在 iframe 中');
|
||||
}
|
||||
window.parent.postMessage(reqMessageData, '*');
|
||||
} else {
|
||||
//子页面
|
||||
this.iframe.contentWindow?.postMessage(reqMessageData, '*');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
41
packages/libs/lib-iframe/tsconfig.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"inlineSourceMap":true,
|
||||
"noImplicitThis": true,
|
||||
"noUnusedLocals": true,
|
||||
"stripInternal": true,
|
||||
"skipLibCheck": true,
|
||||
"pretty": true,
|
||||
"declaration": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"typeRoots": [ "./typings", "./node_modules/@types"],
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"composite": true,
|
||||
"useDefineForClassFields": true,
|
||||
"strict": false,
|
||||
// "sourceMap": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"lib": ["ESNext", "DOM"],
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.d.ts",
|
||||
"src/**/*.json"
|
||||
],
|
||||
"exclude": [
|
||||
"*.js",
|
||||
"*.ts",
|
||||
"dist",
|
||||
"node_modules",
|
||||
"src/test"
|
||||
],
|
||||
}
|
||||