Compare commits
176 Commits
Author | SHA1 | Date | |
---|---|---|---|
82bfc20a6d | |||
b84714b208 | |||
6425e4a93f | |||
55fa1215ae | |||
3769468b01 | |||
6ea919780c | |||
b5afe8e842 | |||
942e444d41 | |||
1ab15c0b72 | |||
f1db9c1c5d | |||
e3974b3bb1 | |||
016b93ea3a | |||
ab870af0bb | |||
8cda69b3c2 | |||
3641d75e2f | |||
fd343c1558 | |||
76650ac199 | |||
d9ba5f20b1 | |||
941923e90f | |||
e38b4c1215 | |||
d405bf63a3 | |||
737f5bf5cc | |||
149cdf67bb | |||
c35ff8d711 | |||
f2bd9b65aa | |||
018a25ba6a | |||
3c052df1e7 | |||
17c85eb8b9 | |||
2bcb31e4d6 | |||
70aef3fe7e | |||
734bde4a98 | |||
c7d9a42feb | |||
f20bc72abb | |||
cd2cfce683 | |||
44ab180474 | |||
15557dfdd6 | |||
488f616d34 | |||
e920406ce9 | |||
e044fd81bd | |||
edaccc357d | |||
67f645ad50 | |||
bfeced5f34 | |||
24b9794a18 | |||
a781329a47 | |||
6b5e0a1207 | |||
2455adfbca | |||
a2cf86b62f | |||
7277906851 | |||
9da9ebb01e | |||
f70684b773 | |||
8b19b206a4 | |||
6be2866ddd | |||
ab55d3c91a | |||
c7ee7eb774 | |||
02daa13a2f | |||
28944b1100 | |||
7ec04d6d3d | |||
595d4d8894 | |||
04ed28f7d1 | |||
6c95cec709 | |||
59173b3ca8 | |||
c2036bba90 | |||
83afea95e6 | |||
ac515f5e80 | |||
6abbf58b83 | |||
9c25ecdc02 | |||
81a15da2d0 | |||
86929251ba | |||
1d8fb2b296 | |||
9d5f0d7a5d | |||
82b1d68576 | |||
e04b23aceb | |||
8e255938b5 | |||
f2eb9666a7 | |||
cbdb0c8b08 | |||
f821f4d9cc | |||
6cfcf21d95 | |||
a33090bb5e | |||
3151829f85 | |||
eca63e588c | |||
9d23e205d8 | |||
5ecdf7c9fd | |||
2817a65e21 | |||
09a8bc5cb5 | |||
a1134cf227 | |||
4ee1c4b08c | |||
08c3eaa65f | |||
2717f08476 | |||
f16dbeea32 | |||
a0c0230419 | |||
0d1ebf2d1a | |||
6edbf3cb46 | |||
b26f7ac3e9 | |||
5129c5d601 | |||
d09b3fd1bc | |||
14fccd40d8 | |||
c0f45a10e0 | |||
f9db3d28fe | |||
c3fd8750b2 | |||
2b3c28c7a1 | |||
d6b1f942b3 | |||
7eff6ea36a | |||
1ef3615a49 | |||
3653cdc797 | |||
c0271648fc | |||
5546fa5f49 | |||
54fe89860e | |||
d1edf75f6f | |||
6f9c644221 | |||
0b26054687 | |||
e3323ed4ef | |||
24f692636c | |||
a9f709ee7b | |||
1b11b637a5 | |||
ad54bf41ea | |||
060ebf1b29 | |||
a87c6acb8a | |||
62d27619f4 | |||
0faebf2a79 | |||
29ea50796c | |||
26d1b7cbf0 | |||
c0c97835ea | |||
d4d50b7dcf | |||
2492fd4de2 | |||
bef54799b6 | |||
dbe09f320a | |||
18045dadaf | |||
ee300c3e12 | |||
ed4ba0cb61 | |||
a8ab27045d | |||
975c3ed190 | |||
a99dea549b | |||
f8b78c433a | |||
6c33111074 | |||
280335f6f6 | |||
b90092c043 | |||
9e1c73febf | |||
dcf1915816 | |||
748c911168 | |||
3a48cb4ea8 | |||
a035c5c0b0 | |||
f9c521b7b3 | |||
19cfe8bdc5 | |||
601d6b30d3 | |||
57ffc82c43 | |||
312d3c01cd | |||
8814c1fc62 | |||
223a47c997 | |||
651ef6d281 | |||
9eda0da9a7 | |||
3e350dfed5 | |||
6fc280e168 | |||
a9efae65d6 | |||
0f09bdaf9f | |||
84177cd575 | |||
7d16ada760 | |||
b4de8cc2be | |||
68e570c32a | |||
20ea599f9d | |||
5fa530456b | |||
2cd1794e7e | |||
1f38e12bd3 | |||
1c777f6f05 | |||
aad113a8ea | |||
fff63839d1 | |||
c8d2cfd4ce | |||
dfd7edd330 | |||
4dadcf227c | |||
fce25c60ed | |||
98cc70dbfb | |||
89d628bd37 | |||
0056c8508c | |||
96e0c4f905 | |||
2f844dd78d | |||
ab82ac0c83 | |||
5b925e3d1b |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @git.zone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
19
.gitignore
vendored
19
.gitignore
vendored
@ -1,4 +1,19 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
#------# custom
|
@ -1,59 +0,0 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- trigger
|
|
||||||
- pages
|
|
||||||
|
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test legacy
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test lts
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test stable
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: trigger
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
pages:
|
|
||||||
image: hosttoday/ht-docker-node:npmpage
|
|
||||||
stage: pages
|
|
||||||
script:
|
|
||||||
- npmci command npmpage --host gitlab
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
4
.npmignore
Normal file
4
.npmignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
Copyright (C) 2016, Lossless GmbH
|
Copyright (C) 2016, Task Venture Capital GmbH
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
24
README.md
24
README.md
@ -1,24 +0,0 @@
|
|||||||
# smartacme
|
|
||||||
acme implementation in TypeScript
|
|
||||||
|
|
||||||
## Availabililty
|
|
||||||
[](https://www.npmjs.com/package/smartacme)
|
|
||||||
[](https://GitLab.com/pushrocks/smartacme)
|
|
||||||
[](https://github.com/pushrocks/smartacme)
|
|
||||||
[](https://pushrocks.gitlab.io/smartacme/)
|
|
||||||
|
|
||||||
## Status for master
|
|
||||||
[](https://GitLab.com/pushrocks/smartacme/commits/master)
|
|
||||||
[](https://GitLab.com/pushrocks/smartacme/commits/master)
|
|
||||||
[](https://www.npmjs.com/package/smartacme)
|
|
||||||
[](https://david-dm.org/pushrocks/smartacme)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartacme/master/dependencies/npm)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartacme)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
Use TypeScript for best in class instellisense.
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
|
@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpQIBAAKCAQEAyocFq3vvbiRNCsEcXtsqimIi6UM1OmxiYVQ0NoLvBtpaWk+E
|
|
||||||
TvNIjmUgh5QQaQfRyRGoWvhskp+E8p6go4GsbRtzx0TvL8uINTcC3SHHo6Qvl599
|
|
||||||
4QUUPUrioHdh+lX1oj+zIPVUOaL4dl0US1Ebs5vrZVbCfNXSm86vBaPIj6IkWEkj
|
|
||||||
4S5xGsYlVaQUI8Tvv2fbPziIivbkxS1v/EEMnfk6i5PWgCsnMupYxz58WaVp9xyu
|
|
||||||
+v/DMPB09mqo4DzchtUNF/b5eOWh3pDJoewYyRVMDDPJoQiTKkJn3kt64EaQuZK2
|
|
||||||
nUXcihlmaKIx5ayxirsgfvIvxidHnkQcluvciQIDAQABAoIBAQCTPUKz/3B8pMuW
|
|
||||||
C/syQyhUXzB+YawrA20q0Wr8Toi0dL7HdZP9SgXv8DmMF+suUM8F3V6GdKGKn4qq
|
|
||||||
UQT8mmPfFtw/fTBfkRs/hPUCC3L214D6PKvpkiW6wdytSN3kf+YKxUDXr0RCeuck
|
|
||||||
NltwvlDjbXHfxQm0dEefms3HzeEb+jwCyyLVLv+cDly7w7Qqq+67A6mduV/hb53p
|
|
||||||
92VFm36r7njr+1CYHq+ixV+oyUrEue7yW7w1SjZRkii3AY8Tbvk1f0lVw+XkyYf7
|
|
||||||
bQvmGSGJh1FmBi7Lytc2hKnqBLTn+iWx3S5pdPhcKTMwC/OD8p+r/DfyqThW/KVa
|
|
||||||
aaXdoY/5AoGBAO4uAcmHOhR+M/Jnue4srZJ82EkNOQy+zaFlg9KCU9R4qZ59/klH
|
|
||||||
fp0PkOw3bDFT4/1i12nm4XXqhI9Z7nsKdAoajOYpnifJVEAwQh9MlRBM7Lw+ZS0q
|
|
||||||
IcH7dvvP1XQ7E2U4C0cWUMcpWNpnmwV67gtqy0KZwk5i+WlFuugQzmhbAoGBANmu
|
|
||||||
JX6bPKUx0kBJLWhJeAxsk0OoHJ4uGihs1zxT6gl6s+AKQG4db9vU2w99lJ0nR3Aw
|
|
||||||
MLA4evSMFa5Od96W4KnoiMNHS4c5QiiVKsRSU1losWfwq0jyg406oyTh8rd0eOQn
|
|
||||||
LDOKP7nDTij8A6l0/t5a2MCu4bLQQXTedPrX+wPrAoGBAM/XO94Fb+xUGLaOR1SM
|
|
||||||
jkaHRSGyNTdnBP+zGy5GZirBxJo2rgB6MAWUgM1wq6v73bbOWtXiEJqaNGT3gEDE
|
|
||||||
ZXAvrQZoCMgFSszcj8bKSEW6Ktc1x4p6+oxRCIpC2aycpJcuKcE1uvWgohWsVT2a
|
|
||||||
AUHbRlXu4P0QJz7zB1/c0pGDAoGAbIvSVpfCXf3CAhx7cA1yt39Mz+f8nUQP9yiP
|
|
||||||
C54sjh2JpKZ4CnDTXqN9uPO+L79ueBsPrE/9wAQ6q3ilfXFvBkrWJ8pdd0iuHN6F
|
|
||||||
PPBwb50tGc+BGhcUUlBzGekxxxllTx/ZgrnlnRQu3XENwmp8zRQwEaUjFq+SdFyZ
|
|
||||||
qJwap5ECgYEA7UGxxRXAjfStTLnsrnr9svvr3QhwnZBg5JAjeR6FKC0cGFzdBrJ5
|
|
||||||
rV/Zy4mGbTBBVh5oU3MplB3AUHejuFv+8eCik2mJug8k3G8KQAk9mB8oV97k0cp+
|
|
||||||
bdlu9vlutIoCG9RXxCHdgRVLiLK+OkLv6p7hQOIY7fsIRaAuI+vPKSk=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
@ -1,9 +0,0 @@
|
|||||||
-----BEGIN PUBLIC KEY-----
|
|
||||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyocFq3vvbiRNCsEcXtsq
|
|
||||||
imIi6UM1OmxiYVQ0NoLvBtpaWk+ETvNIjmUgh5QQaQfRyRGoWvhskp+E8p6go4Gs
|
|
||||||
bRtzx0TvL8uINTcC3SHHo6Qvl5994QUUPUrioHdh+lX1oj+zIPVUOaL4dl0US1Eb
|
|
||||||
s5vrZVbCfNXSm86vBaPIj6IkWEkj4S5xGsYlVaQUI8Tvv2fbPziIivbkxS1v/EEM
|
|
||||||
nfk6i5PWgCsnMupYxz58WaVp9xyu+v/DMPB09mqo4DzchtUNF/b5eOWh3pDJoewY
|
|
||||||
yRVMDDPJoQiTKkJn3kt64EaQuZK2nUXcihlmaKIx5ayxirsgfvIvxidHnkQcluvc
|
|
||||||
iQIDAQAB
|
|
||||||
-----END PUBLIC KEY-----
|
|
116
changelog.md
Normal file
116
changelog.md
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-04-26 - 5.0.1 - fix(build)
|
||||||
|
Update CI workflows, bump dependency versions, and refine import and TypeScript configuration
|
||||||
|
|
||||||
|
- Changed CI workflow image and npmci package from '@shipzone/npmci' to '@ship.zone/npmci', and updated repository URLs
|
||||||
|
- Bumped several dependency versions in package.json (e.g. @api.global/typedserver, @push.rocks/lik, @push.rocks/smartdata, @push.rocks/smartdns, @tsclass/tsclass) to newer releases
|
||||||
|
- Adjusted smartdns import to use the smartdnsClient module for proper module resolution
|
||||||
|
- Updated tsconfig.json to add emitDecoratorMetadata and baseUrl settings
|
||||||
|
- Minor markdown and formatting tweaks in readme and gitignore files, and slight improvements in test async handling
|
||||||
|
|
||||||
|
## 2024-06-16 - 5.0.0 - No significant changes
|
||||||
|
This release contains no user‑facing changes.
|
||||||
|
|
||||||
|
## 2024-06-16 - 4.0.8 - Structure and configuration updates
|
||||||
|
- BREAKING CHANGE(structure): renamed classes to avoid confusion
|
||||||
|
- update description
|
||||||
|
- update tsconfig
|
||||||
|
- update npmextra.json: githost
|
||||||
|
|
||||||
|
## 2024-01-28 - 4.0.7–4.0.6 - Internal fixes and updates
|
||||||
|
- A series of releases with routine bug fixes and maintenance updates.
|
||||||
|
|
||||||
|
## 2023-07-21 - 4.0.5–4.0.4 - Internal fixes and updates
|
||||||
|
- Multiple releases addressing internal issues and maintenance improvements.
|
||||||
|
|
||||||
|
## 2023-07-10 - 4.0.3 - Organizational changes
|
||||||
|
- switch to new org scheme
|
||||||
|
|
||||||
|
## 2022-09-27 - 4.0.0–4.0.2 - Internal fixes and updates
|
||||||
|
- Routine maintenance and internal bug fixes.
|
||||||
|
|
||||||
|
## 2022-09-27 - 3.0.15 - Breaking changes
|
||||||
|
- BREAKING CHANGE(core): update
|
||||||
|
|
||||||
|
## 2021-01-22 - 3.0.9–3.0.14 - Internal fixes and updates
|
||||||
|
- A range of releases focused on routine internal updates.
|
||||||
|
|
||||||
|
## 2020-11-18 - 3.0.0–3.0.8 - Internal fixes and updates
|
||||||
|
- Routine maintenance and internal bug fixes.
|
||||||
|
|
||||||
|
## 2020-02-10 - 2.1.2 - Breaking changes
|
||||||
|
- BREAKING CHANGE(core): streamline scope to certificate retrieval using dns challenge
|
||||||
|
|
||||||
|
## 2020-02-10 - 2.1.0–2.1.1 - Internal fixes and updates
|
||||||
|
- Routine fixes and updates.
|
||||||
|
|
||||||
|
## 2019-02-06 - 2.0.36 - New feature
|
||||||
|
- feat(Cert): now has validity check
|
||||||
|
|
||||||
|
## 2019-01-18 - 2.0.2–2.0.35 - Internal fixes and updates
|
||||||
|
- Routine internal updates and maintenance.
|
||||||
|
|
||||||
|
## 2018-10-07 - 2.0.0–2.0.1 - Internal fixes and updates
|
||||||
|
- Routine internal updates and maintenance.
|
||||||
|
|
||||||
|
## 2018-10-07 - 1.1.4 - Breaking changes
|
||||||
|
- BREAKING CHANGE(scope): change to @pushrocks
|
||||||
|
|
||||||
|
## 2018-08-12 - 1.1.1 - NPM publishing fix
|
||||||
|
- fix(npm publishing): update
|
||||||
|
|
||||||
|
## 2018-08-11 - 1.1.0 - Certificate issuance update
|
||||||
|
- fix(core): now creating certs all right
|
||||||
|
|
||||||
|
## 2018-08-11 - 1.0.11 - Feature update
|
||||||
|
- feat(swaitch to acme-v2): switch to letsencrypt v2
|
||||||
|
|
||||||
|
## 2017-04-28 - 1.0.10 - CI improvements
|
||||||
|
- add updated ci config
|
||||||
|
|
||||||
|
## 2017-04-28 - 1.0.9 - Standards update
|
||||||
|
- update to latest standards
|
||||||
|
|
||||||
|
## 2017-01-27 - 1.0.8 - Basic functionality
|
||||||
|
- basic functionality
|
||||||
|
|
||||||
|
## 2017-01-25 - 1.0.7 - Response and validation improvements
|
||||||
|
- now getting a valid response
|
||||||
|
- update validation
|
||||||
|
- improve README
|
||||||
|
|
||||||
|
## 2017-01-15 - 1.0.6 - Async and documentation improvements
|
||||||
|
- improve README
|
||||||
|
- add async checkDNS
|
||||||
|
|
||||||
|
## 2017-01-15 - 1.0.5 - Standards and process updates
|
||||||
|
- update to new standards
|
||||||
|
- now has working requestValidation method
|
||||||
|
- fix som things
|
||||||
|
- start better segregation of concerns
|
||||||
|
- start with certificate signing process
|
||||||
|
|
||||||
|
## 2017-01-01 - 1.0.4 - Certificate acquisition improvements
|
||||||
|
- now getting certificates
|
||||||
|
- can now agree to TOS
|
||||||
|
- remove test keys
|
||||||
|
|
||||||
|
## 2017-01-01 - 1.0.3 - NPM extra configuration
|
||||||
|
- add npmextra.json
|
||||||
|
|
||||||
|
## 2017-01-01 - 1.0.2 - README and integration update
|
||||||
|
- add better readme
|
||||||
|
- switch to rawacme for more basic letsencrypt access
|
||||||
|
|
||||||
|
## 2016-11-17 - 1.0.1 - Promise fix
|
||||||
|
- fix promise
|
||||||
|
|
||||||
|
## 2016-11-17 - 1.0.0 - Major initial release changes
|
||||||
|
- remove superflouous key creation
|
||||||
|
- switch to acme core
|
||||||
|
- prepare switch to le‑acme‑core
|
||||||
|
- improve upon keyCreation
|
||||||
|
- update to use more promises
|
||||||
|
- add README
|
||||||
|
- first version
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export * from './smartacme.classes.smartacme';
|
|
6
dist/index.js
vendored
6
dist/index.js
vendored
@ -1,6 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
function __export(m) {
|
|
||||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
||||||
}
|
|
||||||
__export(require("./smartacme.classes.smartacme"));
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsbURBQTZDIn0=
|
|
8
dist/smartacme.classes.helper.d.ts
vendored
8
dist/smartacme.classes.helper.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
import 'typings-global';
|
|
||||||
export interface IRsaKeypair {
|
|
||||||
publicKey: string;
|
|
||||||
privateKey: string;
|
|
||||||
}
|
|
||||||
export declare class SmartacmeHelper {
|
|
||||||
createKeypair(bit?: number): IRsaKeypair;
|
|
||||||
}
|
|
14
dist/smartacme.classes.helper.js
vendored
14
dist/smartacme.classes.helper.js
vendored
@ -1,14 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
let rsaKeygen = require('rsa-keygen');
|
|
||||||
class SmartacmeHelper {
|
|
||||||
createKeypair(bit = 2048) {
|
|
||||||
let result = rsaKeygen.generate(bit);
|
|
||||||
return {
|
|
||||||
publicKey: result.public_key,
|
|
||||||
privateKey: result.private_key
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.SmartacmeHelper = SmartacmeHelper;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmNsYXNzZXMuaGVscGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhY21lLmNsYXNzZXMuaGVscGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFDdkIsSUFBSSxTQUFTLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFBO0FBT3JDO0lBQ0ksYUFBYSxDQUFDLEdBQUcsR0FBRyxJQUFJO1FBQ3BCLElBQUksTUFBTSxHQUFHLFNBQVMsQ0FBQyxRQUFRLENBQUMsR0FBRyxDQUFDLENBQUE7UUFDbkMsTUFBTSxDQUFDO1lBQ0osU0FBUyxFQUFHLE1BQU0sQ0FBQyxVQUFVO1lBQzdCLFVBQVUsRUFBRSxNQUFNLENBQUMsV0FBVztTQUNoQyxDQUFBO0lBQ04sQ0FBQztDQUNKO0FBUkQsMENBUUMifQ==
|
|
23
dist/smartacme.classes.smartacme.d.ts
vendored
23
dist/smartacme.classes.smartacme.d.ts
vendored
@ -1,23 +0,0 @@
|
|||||||
/// <reference types="q" />
|
|
||||||
import 'typings-global';
|
|
||||||
import * as q from 'q';
|
|
||||||
import { SmartacmeHelper, IRsaKeypair } from './smartacme.classes.helper';
|
|
||||||
/**
|
|
||||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
|
||||||
*/
|
|
||||||
export declare class SmartAcme {
|
|
||||||
helper: SmartacmeHelper;
|
|
||||||
acmeUrl: string;
|
|
||||||
productionBool: boolean;
|
|
||||||
keyPair: IRsaKeypair;
|
|
||||||
JWK: any;
|
|
||||||
/**
|
|
||||||
* the constructor for class SmartAcme
|
|
||||||
*/
|
|
||||||
constructor(productionArg?: boolean);
|
|
||||||
/**
|
|
||||||
* creates an account if not currently present in module
|
|
||||||
* @executes ASYNC
|
|
||||||
*/
|
|
||||||
createAccount(): q.Promise<{}>;
|
|
||||||
}
|
|
60
dist/smartacme.classes.smartacme.js
vendored
60
dist/smartacme.classes.smartacme.js
vendored
@ -1,60 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
const q = require("q");
|
|
||||||
let rsaKeygen = require('rsa-keygen');
|
|
||||||
let rawacme = require('rawacme');
|
|
||||||
const smartacme_classes_helper_1 = require("./smartacme.classes.helper");
|
|
||||||
/**
|
|
||||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
|
||||||
*/
|
|
||||||
class SmartAcme {
|
|
||||||
/**
|
|
||||||
* the constructor for class SmartAcme
|
|
||||||
*/
|
|
||||||
constructor(productionArg = false) {
|
|
||||||
this.productionBool = productionArg;
|
|
||||||
this.helper = new smartacme_classes_helper_1.SmartacmeHelper();
|
|
||||||
this.keyPair = this.helper.createKeypair();
|
|
||||||
if (this.productionBool) {
|
|
||||||
this.acmeUrl = rawacme.LETSENCRYPT_STAGING_URL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.acmeUrl = rawacme.LETSENCRYPT_URL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* creates an account if not currently present in module
|
|
||||||
* @executes ASYNC
|
|
||||||
*/
|
|
||||||
createAccount() {
|
|
||||||
let done = q.defer();
|
|
||||||
rawacme.createClient({
|
|
||||||
url: this.acmeUrl,
|
|
||||||
publicKey: this.keyPair.publicKey,
|
|
||||||
privateKey: this.keyPair.privateKey
|
|
||||||
}, (err, client) => {
|
|
||||||
if (err) {
|
|
||||||
console.error('smartacme: something went wrong:');
|
|
||||||
console.log(err);
|
|
||||||
done.reject(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
client.newReg({
|
|
||||||
contact: ['mailto:domains@lossless.org']
|
|
||||||
}, (err, res) => {
|
|
||||||
if (err) {
|
|
||||||
console.error('smartacme: something went wrong:');
|
|
||||||
console.log(err);
|
|
||||||
done.reject(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.JWK = res.body.key;
|
|
||||||
console.log(this.JWK);
|
|
||||||
done.resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.SmartAcme = SmartAcme;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFDdkIsdUJBQXNCO0FBRXRCLElBQUksU0FBUyxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQTtBQUdyQyxJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUE7QUFHaEMseUVBQXlFO0FBRXpFOztHQUVHO0FBQ0g7SUFPSTs7T0FFRztJQUNILFlBQVksZ0JBQXlCLEtBQUs7UUFDdEMsSUFBSSxDQUFDLGNBQWMsR0FBRyxhQUFhLENBQUE7UUFDbkMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLDBDQUFlLEVBQUUsQ0FBQTtRQUNuQyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsYUFBYSxFQUFFLENBQUE7UUFDMUMsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDLENBQUM7WUFDdEIsSUFBSSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUMsdUJBQXVCLENBQUE7UUFDbEQsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osSUFBSSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUMsZUFBZSxDQUFBO1FBQzFDLENBQUM7SUFDTCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsYUFBYTtRQUNULElBQUksSUFBSSxHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUNwQixPQUFPLENBQUMsWUFBWSxDQUNoQjtZQUNJLEdBQUcsRUFBRSxJQUFJLENBQUMsT0FBTztZQUNqQixTQUFTLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxTQUFTO1lBQ2pDLFVBQVUsRUFBRSxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVU7U0FDdEMsRUFDRCxDQUFDLEdBQUcsRUFBRSxNQUFNO1lBQ1IsRUFBRSxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQztnQkFDTixPQUFPLENBQUMsS0FBSyxDQUFDLGtDQUFrQyxDQUFDLENBQUE7Z0JBQ2pELE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7Z0JBQ2hCLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUE7Z0JBQ2hCLE1BQU0sQ0FBQTtZQUNWLENBQUM7WUFFRCxNQUFNLENBQUMsTUFBTSxDQUNUO2dCQUNJLE9BQU8sRUFBRSxDQUFDLDZCQUE2QixDQUFDO2FBQzNDLEVBQ0QsQ0FBQyxHQUFHLEVBQUUsR0FBRztnQkFDTCxFQUFFLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO29CQUNOLE9BQU8sQ0FBQyxLQUFLLENBQUMsa0NBQWtDLENBQUMsQ0FBQTtvQkFDakQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQTtvQkFDaEIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQTtvQkFDaEIsTUFBTSxDQUFBO2dCQUNWLENBQUM7Z0JBQ0QsSUFBSSxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQTtnQkFDdkIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUE7Z0JBQ3JCLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtZQUNsQixDQUFDLENBQUMsQ0FBQTtRQUVWLENBQUMsQ0FDSixDQUFBO1FBQ0QsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDdkIsQ0FBQztDQUNKO0FBN0RELDhCQTZEQyJ9
|
|
2
dist/smartacme.paths.d.ts
vendored
2
dist/smartacme.paths.d.ts
vendored
@ -1,2 +0,0 @@
|
|||||||
export declare let packageDir: string;
|
|
||||||
export declare let assetDir: string;
|
|
7
dist/smartacme.paths.js
vendored
7
dist/smartacme.paths.js
vendored
@ -1,7 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const path = require("path");
|
|
||||||
const smartfile = require("smartfile");
|
|
||||||
exports.packageDir = path.join(__dirname, '../');
|
|
||||||
exports.assetDir = path.join(exports.packageDir, 'assets/');
|
|
||||||
smartfile.fs.ensureDirSync(exports.assetDir);
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhY21lLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw2QkFBNEI7QUFDNUIsdUNBQXNDO0FBRTNCLFFBQUEsVUFBVSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLEtBQUssQ0FBQyxDQUFBO0FBQ3ZDLFFBQUEsUUFBUSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsa0JBQVUsRUFBQyxTQUFTLENBQUMsQ0FBQTtBQUNyRCxTQUFTLENBQUMsRUFBRSxDQUFDLGFBQWEsQ0FBQyxnQkFBUSxDQUFDLENBQUEifQ==
|
|
38
npmextra.json
Normal file
38
npmextra.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartacme",
|
||||||
|
"description": "A TypeScript-based ACME client for LetsEncrypt certificate management with a focus on simplicity and power.",
|
||||||
|
"npmPackagename": "@push.rocks/smartacme",
|
||||||
|
"license": "MIT",
|
||||||
|
"projectDomain": "push.rocks",
|
||||||
|
"keywords": [
|
||||||
|
"ACME",
|
||||||
|
"LetsEncrypt",
|
||||||
|
"TypeScript",
|
||||||
|
"certificate management",
|
||||||
|
"DNS challenges",
|
||||||
|
"SSL/TLS",
|
||||||
|
"secure communication",
|
||||||
|
"domain validation",
|
||||||
|
"automation",
|
||||||
|
"crypto",
|
||||||
|
"MongoDB",
|
||||||
|
"dns-01 challenge",
|
||||||
|
"token-based challenges",
|
||||||
|
"certificate renewal",
|
||||||
|
"wildcard certificates"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
|
}
|
||||||
|
}
|
89
package.json
89
package.json
@ -1,39 +1,84 @@
|
|||||||
{
|
{
|
||||||
"name": "smartacme",
|
"name": "@push.rocks/smartacme",
|
||||||
"version": "1.0.3",
|
"version": "5.0.1",
|
||||||
"description": "acme implementation in TypeScript",
|
"private": false,
|
||||||
"main": "dist/index.js",
|
"description": "A TypeScript-based ACME client for LetsEncrypt certificate management with a focus on simplicity and power.",
|
||||||
"typings": "dist/index.d.ts",
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts --nodocs)"
|
"test": "(tstest test/)",
|
||||||
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartacme.git"
|
"url": "https://code.foss.global/push.rocks/smartacme.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
"ACME",
|
||||||
|
"LetsEncrypt",
|
||||||
"TypeScript",
|
"TypeScript",
|
||||||
"acme",
|
"certificate management",
|
||||||
"letsencrypt"
|
"DNS challenges",
|
||||||
|
"SSL/TLS",
|
||||||
|
"secure communication",
|
||||||
|
"domain validation",
|
||||||
|
"automation",
|
||||||
|
"crypto",
|
||||||
|
"MongoDB",
|
||||||
|
"dns-01 challenge",
|
||||||
|
"token-based challenges",
|
||||||
|
"certificate renewal",
|
||||||
|
"wildcard certificates"
|
||||||
],
|
],
|
||||||
"author": "Lossless GmbH",
|
"author": "Task Venture Capital GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartacme/issues"
|
"url": "https://code.foss.global/push.rocks/smartacme/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartacme#README",
|
"homepage": "https://code.foss.global/push.rocks/smartacme#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/q": "0.x.x",
|
"@api.global/typedserver": "^3.0.74",
|
||||||
"q": "^1.4.1",
|
"@push.rocks/lik": "^6.2.2",
|
||||||
"rawacme": "^0.2.1",
|
"@push.rocks/smartdata": "^5.15.1",
|
||||||
"rsa-keygen": "^1.0.6",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"smartfile": "^4.1.0",
|
"@push.rocks/smartdns": "^6.2.2",
|
||||||
"smartstring": "^2.0.20",
|
"@push.rocks/smartlog": "^3.0.7",
|
||||||
"typings-global": "^1.0.14"
|
"@push.rocks/smartpromise": "^4.2.3",
|
||||||
|
"@push.rocks/smartrequest": "^2.1.0",
|
||||||
|
"@push.rocks/smartstring": "^4.0.15",
|
||||||
|
"@push.rocks/smarttime": "^4.1.1",
|
||||||
|
"@push.rocks/smartunique": "^3.0.9",
|
||||||
|
"@tsclass/tsclass": "^9.0.0",
|
||||||
|
"acme-client": "^4.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.30",
|
"@apiclient.xyz/cloudflare": "^6.3.2",
|
||||||
"should": "^11.1.1",
|
"@git.zone/tsbuild": "^2.3.2",
|
||||||
"typings-test": "^1.0.3"
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
|
"@git.zone/tstest": "^1.0.96",
|
||||||
|
"@push.rocks/qenv": "^6.1.0",
|
||||||
|
"@push.rocks/tapbundle": "^5.6.3",
|
||||||
|
"@types/node": "^22.15.2"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
],
|
||||||
|
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
|
||||||
|
"pnpm": {
|
||||||
|
"overrides": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10451
pnpm-lock.yaml
generated
Normal file
10451
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
5
qenv.yml
Normal file
5
qenv.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
required:
|
||||||
|
- CF_TOKEN
|
||||||
|
- MONGODB_URL
|
||||||
|
- MONGODB_PASSWORD
|
||||||
|
- MONGODB_DATABASE
|
2
readme.hints.md
Normal file
2
readme.hints.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
- this repo is dependent on letsencrypt and its limits
|
||||||
|
- to simpify the outside API, smartacme is stateful, meaning it works with a mongodb and a collection called 'SmartacmeCert'.
|
290
readme.md
Normal file
290
readme.md
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
````markdown
|
||||||
|
# @push.rocks/smartacme
|
||||||
|
|
||||||
|
A TypeScript-based ACME client with an easy yet powerful interface for LetsEncrypt certificate management.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
To install `@push.rocks/smartacme`, you can use npm or yarn. Run one of the following commands in your project directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @push.rocks/smartacme --save
|
||||||
|
```
|
||||||
|
````
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn add @push.rocks/smartacme
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure your project is set up to use TypeScript and supports ECMAScript Modules (ESM).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
This guide will walk you through using `@push.rocks/smartacme` to set up and manage ACME (Automated Certificate Management Environment) certificates with a focus on the Let's Encrypt service, which provides free SSL certificates. The library provides an easy yet powerful TypeScript interface to automate the process of obtaining, renewing, and installing your SSL certificates.
|
||||||
|
|
||||||
|
### Table of Contents
|
||||||
|
|
||||||
|
1. [Setting Up Your Project](#setting-up-your-project)
|
||||||
|
2. [Creating a SmartAcme Instance](#creating-a-smartacme-instance)
|
||||||
|
3. [Initializing SmartAcme](#initializing-smartacme)
|
||||||
|
4. [Obtaining a Certificate for a Domain](#obtaining-a-certificate-for-a-domain)
|
||||||
|
5. [Automating DNS Challenges](#automating-dns-challenges)
|
||||||
|
6. [Managing Certificates](#managing-certificates)
|
||||||
|
7. [Environmental Considerations](#environmental-considerations)
|
||||||
|
8. [Complete Example](#complete-example)
|
||||||
|
|
||||||
|
### Setting Up Your Project
|
||||||
|
|
||||||
|
Ensure your project includes the necessary TypeScript configuration and dependencies. You'll need to have TypeScript installed and configured for ECMAScript Modules. If you are new to TypeScript, review its [documentation](https://www.typescriptlang.org/docs/) to get started.
|
||||||
|
|
||||||
|
### Creating a SmartAcme Instance
|
||||||
|
|
||||||
|
Start by importing the `SmartAcme` class from the `@push.rocks/smartacme` package. You'll also need to import or define interfaces for your setup options:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartAcme } from '@push.rocks/smartacme';
|
||||||
|
|
||||||
|
const smartAcmeInstance = new SmartAcme({
|
||||||
|
accountEmail: 'youremail@example.com', // Email used for Let's Encrypt registration and recovery
|
||||||
|
accountPrivateKey: null, // Private key for the account (optional, if not provided it will be generated)
|
||||||
|
mongoDescriptor: {
|
||||||
|
mongoDbUrl: 'mongodb://yourmongoURL',
|
||||||
|
mongoDbName: 'yourDbName',
|
||||||
|
mongoDbPass: 'yourDbPassword',
|
||||||
|
},
|
||||||
|
removeChallenge: async (dnsChallenge) => {
|
||||||
|
// Implement logic here to remove DNS challenge records
|
||||||
|
},
|
||||||
|
setChallenge: async (dnsChallenge) => {
|
||||||
|
// Implement logic here to create DNS challenge records
|
||||||
|
},
|
||||||
|
environment: 'integration', // Use 'production' for actual certificates
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Initializing SmartAcme
|
||||||
|
|
||||||
|
Before proceeding to request certificates, initialize your SmartAcme instance:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
await smartAcmeInstance.init();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Obtaining a Certificate for a Domain
|
||||||
|
|
||||||
|
To obtain a certificate for a specific domain, use the `getCertificateForDomain` method. This function ensures that if a valid certificate is already present, it will be reused; otherwise, a new certificate is obtained:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const myDomain = 'example.com';
|
||||||
|
const myCert = await smartAcmeInstance.getCertificateForDomain(myDomain);
|
||||||
|
console.log('Certificate:', myCert);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Automating DNS Challenges
|
||||||
|
|
||||||
|
Part of the ACME protocol involves responding to DNS challenges issued by the certificate authority to prove control over a domain. Implement the `setChallenge` and `removeChallenge` functions in your SmartAcme configuration to automate this process. These functions receive a `dnsChallenge` argument containing details needed to create or remove the necessary DNS records.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import * as cloudflare from '@apiclient.xyz/cloudflare';
|
||||||
|
import { Qenv } from '@push.rocks/qenv';
|
||||||
|
|
||||||
|
const testQenv = new Qenv('./', './.nogit/');
|
||||||
|
const testCloudflare = new cloudflare.CloudflareAccount(testQenv.getEnvVarOnDemand('CF_TOKEN'));
|
||||||
|
|
||||||
|
const smartAcmeInstance = new SmartAcme({
|
||||||
|
accountEmail: 'domains@example.com',
|
||||||
|
accountPrivateKey: null,
|
||||||
|
mongoDescriptor: {
|
||||||
|
mongoDbName: testQenv.getEnvVarRequired('MONGODB_DATABASE'),
|
||||||
|
mongoDbPass: testQenv.getEnvVarRequired('MONGODB_PASSWORD'),
|
||||||
|
mongoDbUrl: testQenv.getEnvVarRequired('MONGODB_URL'),
|
||||||
|
},
|
||||||
|
removeChallenge: async (dnsChallenge) => {
|
||||||
|
testCloudflare.convenience.acmeRemoveDnsChallenge(dnsChallenge);
|
||||||
|
},
|
||||||
|
setChallenge: async (dnsChallenge) => {
|
||||||
|
testCloudflare.convenience.acmeSetDnsChallenge(dnsChallenge);
|
||||||
|
},
|
||||||
|
environment: 'integration',
|
||||||
|
});
|
||||||
|
|
||||||
|
await smartAcmeInstance.init();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Managing Certificates
|
||||||
|
|
||||||
|
The library automatically handles fetching, renewing, and storing your certificates in a MongoDB database specified in your configuration. Ensure your MongoDB instance is accessible and properly configured for use with SmartAcme.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const mongoDescriptor = {
|
||||||
|
mongoDbUrl: 'mongodb://yourmongoURL',
|
||||||
|
mongoDbName: 'yourDbName',
|
||||||
|
mongoDbPass: 'yourDbPassword',
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Environmental Considerations
|
||||||
|
|
||||||
|
When creating an instance of `SmartAcme`, you can specify an `environment` option. This is particularly useful for testing, as you can use the `integration` environment to avoid hitting rate limits and for testing your setup without issuing real certificates. Switch to `production` when you are ready to obtain actual certificates.
|
||||||
|
|
||||||
|
### Complete Example
|
||||||
|
|
||||||
|
Below is a complete example demonstrating how to use `@push.rocks/smartacme` to obtain and manage an ACME certificate with Let's Encrypt:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartAcme } from '@push.rocks/smartacme';
|
||||||
|
import * as cloudflare from '@apiclient.xyz/cloudflare';
|
||||||
|
import { Qenv } from '@push.rocks/qenv';
|
||||||
|
|
||||||
|
const qenv = new Qenv('./', './.nogit/');
|
||||||
|
const cloudflareAccount = new cloudflare.CloudflareAccount(qenv.getEnvVarOnDemand('CF_TOKEN'));
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const smartAcmeInstance = new SmartAcme({
|
||||||
|
accountEmail: 'youremail@example.com',
|
||||||
|
accountPrivateKey: null,
|
||||||
|
mongoDescriptor: {
|
||||||
|
mongoDbUrl: qenv.getEnvVarRequired('MONGODB_URL'),
|
||||||
|
mongoDbName: qenv.getEnvVarRequired('MONGODB_DATABASE'),
|
||||||
|
mongoDbPass: qenv.getEnvVarRequired('MONGODB_PASSWORD'),
|
||||||
|
},
|
||||||
|
setChallenge: async (dnsChallenge) => {
|
||||||
|
await cloudflareAccount.convenience.acmeSetDnsChallenge(dnsChallenge);
|
||||||
|
},
|
||||||
|
removeChallenge: async (dnsChallenge) => {
|
||||||
|
await cloudflareAccount.convenience.acmeRemoveDnsChallenge(dnsChallenge);
|
||||||
|
},
|
||||||
|
environment: 'integration',
|
||||||
|
});
|
||||||
|
|
||||||
|
await smartAcmeInstance.init();
|
||||||
|
|
||||||
|
const myDomain = 'example.com';
|
||||||
|
const myCert = await smartAcmeInstance.getCertificateForDomain(myDomain);
|
||||||
|
console.log('Certificate:', myCert);
|
||||||
|
|
||||||
|
await smartAcmeInstance.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(console.error);
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, `Qenv` is used to manage environment variables, and `cloudflare` library is used to handle DNS challenges required by Let's Encrypt ACME protocol. The `setChallenge` and `removeChallenge` methods are essential for automating the DNS challenge process, which is a key part of domain validation.
|
||||||
|
|
||||||
|
## Additional Details
|
||||||
|
|
||||||
|
### Certificate Object
|
||||||
|
|
||||||
|
The certificate object obtained from the `getCertificateForDomain` method has the following properties:
|
||||||
|
|
||||||
|
- `id`: Unique identifier for the certificate.
|
||||||
|
- `domainName`: The domain name for which the certificate is issued.
|
||||||
|
- `created`: Timestamp of when the certificate was created.
|
||||||
|
- `privateKey`: The private key associated with the certificate.
|
||||||
|
- `publicKey`: The public key or certificate itself.
|
||||||
|
- `csr`: Certificate Signing Request (CSR) used to obtain the certificate.
|
||||||
|
- `validUntil`: Timestamp indicating the expiration date of the certificate.
|
||||||
|
|
||||||
|
### Methods Summary
|
||||||
|
|
||||||
|
- **start()**: Initializes the SmartAcme instance, sets up the ACME client, and registers the account with Let's Encrypt.
|
||||||
|
- **stop()**: Closes the MongoDB connection and performs any necessary cleanup.
|
||||||
|
- **getCertificateForDomain(domainArg: string)**: Retrieves or obtains a certificate for the specified domain name. If a valid certificate exists in the database, it is returned. Otherwise, a new certificate is requested and stored.
|
||||||
|
- **setChallenge(dnsChallenge: any)**: Automates the process of setting DNS challenge records.
|
||||||
|
- **removeChallenge(dnsChallenge: any)**: Automates the process of removing DNS challenge records.
|
||||||
|
|
||||||
|
### Handling Domain Matching
|
||||||
|
|
||||||
|
The `SmartacmeCertMatcher` class is responsible for matching certificates with the broadest scope for wildcard certificates. The `getCertificateDomainNameByDomainName` method ensures that domains at various levels are correctly matched.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SmartacmeCertMatcher } from '@push.rocks/smartacme';
|
||||||
|
|
||||||
|
const certMatcher = new SmartacmeCertMatcher();
|
||||||
|
const certDomainName = certMatcher.getCertificateDomainNameByDomainName('subdomain.example.com');
|
||||||
|
console.log('Certificate Domain Name:', certDomainName); // Output: example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
Automated tests can be added to ensure that the setup and functions work as expected. Using a testing framework such as `tap` and mock services for DNS providers (e.g., Cloudflare), you can simulate the process of obtaining and managing certificates without the need for actual domain ownership.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
import { Qenv } from '@push.rocks/qenv';
|
||||||
|
import * as cloudflare from '@apiclient.xyz/cloudflare';
|
||||||
|
import * as smartacme from '@push.rocks/smartacme';
|
||||||
|
|
||||||
|
const testQenv = new Qenv('./', './.nogit/');
|
||||||
|
const testCloudflare = new cloudflare.CloudflareAccount(testQenv.getEnvVarOnDemand('CF_TOKEN'));
|
||||||
|
|
||||||
|
let smartAcmeInstance: smartacme.SmartAcme;
|
||||||
|
|
||||||
|
tap.test('should create a valid instance of SmartAcme', async () => {
|
||||||
|
smartAcmeInstance = new smartacme.SmartAcme({
|
||||||
|
accountEmail: 'domains@lossless.org',
|
||||||
|
accountPrivateKey: null,
|
||||||
|
mongoDescriptor: {
|
||||||
|
mongoDbName: testQenv.getEnvVarRequired('MONGODB_DATABASE'),
|
||||||
|
mongoDbPass: testQenv.getEnvVarRequired('MONGODB_PASSWORD'),
|
||||||
|
mongoDbUrl: testQenv.getEnvVarRequired('MONGODB_URL'),
|
||||||
|
},
|
||||||
|
setChallenge: async (dnsChallenge) => {
|
||||||
|
await testCloudflare.convenience.acmeSetDnsChallenge(dnsChallenge);
|
||||||
|
},
|
||||||
|
removeChallenge: async (dnsChallenge) => {
|
||||||
|
await testCloudflare.convenience.acmeRemoveDnsChallenge(dnsChallenge);
|
||||||
|
},
|
||||||
|
environment: 'integration',
|
||||||
|
});
|
||||||
|
await smartAcmeInstance.init();
|
||||||
|
expect(smartAcmeInstance).toBeInstanceOf(smartacme.SmartAcme);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should get a domain certificate', async () => {
|
||||||
|
const certificate = await smartAcmeInstance.getCertificateForDomain('example.com');
|
||||||
|
console.log('Certificate:', certificate);
|
||||||
|
expect(certificate).toHaveProperty('domainName', 'example.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('certmatcher should correctly match domains', async () => {
|
||||||
|
const certMatcher = new smartacme.SmartacmeCertMatcher();
|
||||||
|
const matchedCert = certMatcher.getCertificateDomainNameByDomainName('subdomain.example.com');
|
||||||
|
expect(matchedCert).toBe('example.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should stop correctly', async () => {
|
||||||
|
await smartAcmeInstance.stop();
|
||||||
|
expect(smartAcmeInstance).toHaveProperty('client', null);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
||||||
|
```
|
||||||
|
|
||||||
|
This comprehensive guide ensures you can set up, manage, and test ACME certificates efficiently and effectively using `@push.rocks/smartacme`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
```
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
26
test/test.js
26
test/test.js
@ -1,26 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
const should = require("should");
|
|
||||||
// import the module to test
|
|
||||||
const smartacme = require("../dist/index");
|
|
||||||
describe('smartacme', function () {
|
|
||||||
let testAcme;
|
|
||||||
it('should create a valid instance', function () {
|
|
||||||
this.timeout(10000);
|
|
||||||
testAcme = new smartacme.SmartAcme();
|
|
||||||
should(testAcme).be.instanceOf(smartacme.SmartAcme);
|
|
||||||
});
|
|
||||||
it('should have created keyPair', function () {
|
|
||||||
should(testAcme.acmeUrl).be.of.type('string');
|
|
||||||
});
|
|
||||||
it('should register a new account', function (done) {
|
|
||||||
this.timeout(40000);
|
|
||||||
testAcme.createAccount().then(x => {
|
|
||||||
done();
|
|
||||||
}).catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
done(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFFaEMsNEJBQTRCO0FBQzVCLDJDQUEwQztBQUUxQyxRQUFRLENBQUMsV0FBVyxFQUFFO0lBQ2xCLElBQUksUUFBNkIsQ0FBQTtJQUNqQyxFQUFFLENBQUMsZ0NBQWdDLEVBQUU7UUFDakMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQTtRQUNuQixRQUFRLEdBQUcsSUFBSSxTQUFTLENBQUMsU0FBUyxFQUFFLENBQUE7UUFDcEMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQ3ZELENBQUMsQ0FBQyxDQUFBO0lBQ0YsRUFBRSxDQUFDLDZCQUE2QixFQUFFO1FBQzlCLE1BQU0sQ0FBQyxRQUFRLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUE7SUFDakQsQ0FBQyxDQUFDLENBQUE7SUFDRixFQUFFLENBQUMsK0JBQStCLEVBQUUsVUFBVSxJQUFJO1FBQzlDLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUE7UUFDbkIsUUFBUSxDQUFDLGFBQWEsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQzNCLElBQUksRUFBRSxDQUFBO1FBQ1YsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLEdBQUc7WUFDUixPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFBO1lBQ2hCLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQTtRQUNiLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9
|
|
70
test/test.ts
70
test/test.ts
@ -1,26 +1,48 @@
|
|||||||
import 'typings-test'
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
import * as should from 'should'
|
import { Qenv } from '@push.rocks/qenv';
|
||||||
|
import * as cloudflare from '@apiclient.xyz/cloudflare';
|
||||||
|
|
||||||
// import the module to test
|
const testQenv = new Qenv('./', './.nogit/');
|
||||||
import * as smartacme from '../dist/index'
|
const testCloudflare = new cloudflare.CloudflareAccount(await testQenv.getEnvVarOnDemand('CF_TOKEN'));
|
||||||
|
|
||||||
describe('smartacme', function () {
|
import * as smartacme from '../ts/index.js';
|
||||||
let testAcme: smartacme.SmartAcme
|
|
||||||
it('should create a valid instance', function () {
|
let smartAcmeInstance: smartacme.SmartAcme;
|
||||||
this.timeout(10000)
|
|
||||||
testAcme = new smartacme.SmartAcme()
|
tap.test('should create a valid instance of SmartAcme', async () => {
|
||||||
should(testAcme).be.instanceOf(smartacme.SmartAcme)
|
smartAcmeInstance = new smartacme.SmartAcme({
|
||||||
})
|
accountEmail: 'domains@lossless.org',
|
||||||
it('should have created keyPair', function () {
|
accountPrivateKey: null,
|
||||||
should(testAcme.acmeUrl).be.of.type('string')
|
mongoDescriptor: {
|
||||||
})
|
mongoDbName: await testQenv.getEnvVarOnDemand('MONGODB_DATABASE'),
|
||||||
it('should register a new account', function (done) {
|
mongoDbPass: await testQenv.getEnvVarOnDemand('MONGODB_PASSWORD'),
|
||||||
this.timeout(40000)
|
mongoDbUrl: await testQenv.getEnvVarOnDemand('MONGODB_URL'),
|
||||||
testAcme.createAccount().then(x => {
|
},
|
||||||
done()
|
removeChallenge: async (dnsChallenge) => {
|
||||||
}).catch(err => {
|
testCloudflare.convenience.acmeRemoveDnsChallenge(dnsChallenge);
|
||||||
console.log(err)
|
},
|
||||||
done(err)
|
setChallenge: async (dnsChallenge) => {
|
||||||
})
|
testCloudflare.convenience.acmeSetDnsChallenge(dnsChallenge);
|
||||||
})
|
},
|
||||||
})
|
environment: 'integration',
|
||||||
|
});
|
||||||
|
await smartAcmeInstance.start();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should get a domain certificate', async () => {
|
||||||
|
const certificate = await smartAcmeInstance.getCertificateForDomain('bleu.de');
|
||||||
|
console.log(certificate);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('certmatcher should correctly match domains', async () => {
|
||||||
|
const certMatcherMod = await import('../ts/smartacme.classes.certmatcher.js');
|
||||||
|
const certMatcher = new certMatcherMod.SmartacmeCertMatcher();
|
||||||
|
const matchedCert = certMatcher.getCertificateDomainNameByDomainName('level3.level2.level1');
|
||||||
|
expect(matchedCert).toEqual('level2.level1');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should stop correctly', async () => {
|
||||||
|
await smartAcmeInstance.stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartacme',
|
||||||
|
version: '5.0.1',
|
||||||
|
description: 'A TypeScript-based ACME client for LetsEncrypt certificate management with a focus on simplicity and power.'
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
export * from './smartacme.classes.smartacme'
|
export * from './smartacme.classes.smartacme.js';
|
||||||
|
export { SmartacmeCert as Cert } from './smartacme.classes.cert.js';
|
||||||
|
8
ts/interfaces/accountdata.ts
Normal file
8
ts/interfaces/accountdata.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export interface IAccountData {
|
||||||
|
id: number;
|
||||||
|
key: { kty: 'RSA'; n: string; e: string; kid: string };
|
||||||
|
contact: string[];
|
||||||
|
initialIp: string;
|
||||||
|
createdAt: string;
|
||||||
|
status: string;
|
||||||
|
}
|
1
ts/interfaces/index.ts
Normal file
1
ts/interfaces/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './accountdata.js';
|
64
ts/smartacme.classes.cert.ts
Normal file
64
ts/smartacme.classes.cert.ts
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import * as plugins from './smartacme.plugins.js';
|
||||||
|
|
||||||
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
|
import { SmartacmeCertManager } from './smartacme.classes.certmanager.js';
|
||||||
|
|
||||||
|
import { Collection, svDb, unI } from '@push.rocks/smartdata';
|
||||||
|
|
||||||
|
@plugins.smartdata.Collection(() => {
|
||||||
|
return SmartacmeCertManager.activeDB;
|
||||||
|
})
|
||||||
|
export class SmartacmeCert
|
||||||
|
extends plugins.smartdata.SmartDataDbDoc<SmartacmeCert, plugins.tsclass.network.ICert>
|
||||||
|
implements plugins.tsclass.network.ICert
|
||||||
|
{
|
||||||
|
@unI()
|
||||||
|
public id: string;
|
||||||
|
|
||||||
|
@svDb()
|
||||||
|
public domainName: string;
|
||||||
|
|
||||||
|
@svDb()
|
||||||
|
public created: number;
|
||||||
|
|
||||||
|
@svDb()
|
||||||
|
public privateKey: string;
|
||||||
|
|
||||||
|
@svDb()
|
||||||
|
public publicKey: string;
|
||||||
|
|
||||||
|
@svDb()
|
||||||
|
public csr: string;
|
||||||
|
|
||||||
|
@svDb()
|
||||||
|
public validUntil: number;
|
||||||
|
|
||||||
|
public isStillValid(): boolean {
|
||||||
|
return this.validUntil >= Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
public shouldBeRenewed(): boolean {
|
||||||
|
const shouldBeValidAtLeastUntil =
|
||||||
|
Date.now() +
|
||||||
|
plugins.smarttime.getMilliSecondsFromUnits({
|
||||||
|
days: 10,
|
||||||
|
});
|
||||||
|
return !(this.validUntil >= shouldBeValidAtLeastUntil);
|
||||||
|
}
|
||||||
|
|
||||||
|
public update(certDataArg: plugins.tsclass.network.ICert) {
|
||||||
|
Object.keys(certDataArg).forEach((key) => {
|
||||||
|
this[key] = certDataArg[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(optionsArg: plugins.tsclass.network.ICert) {
|
||||||
|
super();
|
||||||
|
if (optionsArg) {
|
||||||
|
Object.keys(optionsArg).forEach((key) => {
|
||||||
|
this[key] = optionsArg[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
77
ts/smartacme.classes.certmanager.ts
Normal file
77
ts/smartacme.classes.certmanager.ts
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import * as plugins from './smartacme.plugins.js';
|
||||||
|
import { SmartacmeCert } from './smartacme.classes.cert.js';
|
||||||
|
import { SmartAcme } from './smartacme.classes.smartacme.js';
|
||||||
|
|
||||||
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
|
export class SmartacmeCertManager {
|
||||||
|
// =========
|
||||||
|
// STATIC
|
||||||
|
// =========
|
||||||
|
public static activeDB: plugins.smartdata.SmartdataDb;
|
||||||
|
|
||||||
|
// =========
|
||||||
|
// INSTANCE
|
||||||
|
// =========
|
||||||
|
private mongoDescriptor: plugins.smartdata.IMongoDescriptor;
|
||||||
|
public smartdataDb: plugins.smartdata.SmartdataDb;
|
||||||
|
|
||||||
|
public interestMap: plugins.lik.InterestMap<string, SmartacmeCert>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
smartAcmeArg: SmartAcme,
|
||||||
|
optionsArg: {
|
||||||
|
mongoDescriptor: plugins.smartdata.IMongoDescriptor;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
this.mongoDescriptor = optionsArg.mongoDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async init() {
|
||||||
|
// Smartdata DB
|
||||||
|
this.smartdataDb = new plugins.smartdata.SmartdataDb(this.mongoDescriptor);
|
||||||
|
await this.smartdataDb.init();
|
||||||
|
SmartacmeCertManager.activeDB = this.smartdataDb;
|
||||||
|
|
||||||
|
// Pending Map
|
||||||
|
this.interestMap = new plugins.lik.InterestMap((certName) => certName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retrieves a certificate
|
||||||
|
* @returns the Cert class or null
|
||||||
|
* @param certDomainNameArg the domain Name to retrieve the vcertificate for
|
||||||
|
*/
|
||||||
|
public async retrieveCertificate(certDomainNameArg: string): Promise<SmartacmeCert> {
|
||||||
|
const existingCertificate: SmartacmeCert = await SmartacmeCert.getInstance<SmartacmeCert>({
|
||||||
|
domainName: certDomainNameArg,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (existingCertificate) {
|
||||||
|
return existingCertificate;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stores the certificate
|
||||||
|
* @param optionsArg
|
||||||
|
*/
|
||||||
|
public async storeCertificate(optionsArg: plugins.tsclass.network.ICert) {
|
||||||
|
const cert = new SmartacmeCert(optionsArg);
|
||||||
|
await cert.save();
|
||||||
|
const interest = this.interestMap.findInterest(cert.domainName);
|
||||||
|
if (interest) {
|
||||||
|
interest.fullfillInterest(cert);
|
||||||
|
interest.markLost();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async deleteCertificate(certDomainNameArg: string) {
|
||||||
|
const cert: SmartacmeCert = await SmartacmeCert.getInstance<SmartacmeCert>({
|
||||||
|
domainName: certDomainNameArg,
|
||||||
|
});
|
||||||
|
await cert.delete();
|
||||||
|
}
|
||||||
|
}
|
19
ts/smartacme.classes.certmatcher.ts
Normal file
19
ts/smartacme.classes.certmatcher.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import * as plugins from './smartacme.plugins.js';
|
||||||
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* certmatcher is responsible for matching certificates
|
||||||
|
*/
|
||||||
|
export class SmartacmeCertMatcher {
|
||||||
|
/**
|
||||||
|
* creates a domainName for the certificate that will include the broadest scope
|
||||||
|
* for wild card certificates
|
||||||
|
* @param domainNameArg the domainNameArg to create the scope from
|
||||||
|
*/
|
||||||
|
public getCertificateDomainNameByDomainName(domainNameArg: string): string {
|
||||||
|
const originalDomain = new plugins.smartstring.Domain(domainNameArg);
|
||||||
|
if (!originalDomain.level4) {
|
||||||
|
return `${originalDomain.level2}.${originalDomain.level1}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
import 'typings-global'
|
|
||||||
let rsaKeygen = require('rsa-keygen')
|
|
||||||
|
|
||||||
export interface IRsaKeypair {
|
|
||||||
publicKey: string
|
|
||||||
privateKey: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export class SmartacmeHelper {
|
|
||||||
createKeypair(bit = 2048): IRsaKeypair {
|
|
||||||
let result = rsaKeygen.generate(bit)
|
|
||||||
return {
|
|
||||||
publicKey: result.public_key,
|
|
||||||
privateKey: result.private_key
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,76 +1,217 @@
|
|||||||
import 'typings-global'
|
import * as plugins from './smartacme.plugins.js';
|
||||||
import * as q from 'q'
|
import { SmartacmeCert } from './smartacme.classes.cert.js';
|
||||||
import * as path from 'path'
|
import { SmartacmeCertManager } from './smartacme.classes.certmanager.js';
|
||||||
let rsaKeygen = require('rsa-keygen')
|
import { SmartacmeCertMatcher } from './smartacme.classes.certmatcher.js';
|
||||||
import * as smartfile from 'smartfile'
|
import { commitinfo } from './00_commitinfo_data.js';
|
||||||
import * as smartstring from 'smartstring'
|
|
||||||
let rawacme = require('rawacme')
|
|
||||||
import * as paths from './smartacme.paths'
|
|
||||||
|
|
||||||
import { SmartacmeHelper, IRsaKeypair } from './smartacme.classes.helper'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
* the options for the class @see SmartAcme
|
||||||
|
*/
|
||||||
|
export interface ISmartAcmeOptions {
|
||||||
|
accountPrivateKey?: string;
|
||||||
|
accountEmail: string;
|
||||||
|
mongoDescriptor: plugins.smartdata.IMongoDescriptor;
|
||||||
|
setChallenge: (dnsChallengeArg: plugins.tsclass.network.IDnsChallenge) => Promise<any>;
|
||||||
|
removeChallenge: (dnsChallengeArg: plugins.tsclass.network.IDnsChallenge) => Promise<any>;
|
||||||
|
environment: 'production' | 'integration';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class SmartAcme
|
||||||
|
* can be used for setting up communication with an ACME authority
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* const mySmartAcmeInstance = new SmartAcme({
|
||||||
|
* // see ISmartAcmeOptions for options
|
||||||
|
* })
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
export class SmartAcme {
|
export class SmartAcme {
|
||||||
helper: SmartacmeHelper // bundles helper methods that would clutter the main SmartAcme class
|
private options: ISmartAcmeOptions;
|
||||||
acmeUrl: string // the acme url to use
|
|
||||||
productionBool: boolean // a boolean to quickly know wether we are in production or not
|
|
||||||
keyPair: IRsaKeypair // the keyPair needed for account creation
|
|
||||||
JWK
|
|
||||||
|
|
||||||
/**
|
// the acme client
|
||||||
* the constructor for class SmartAcme
|
private client: any;
|
||||||
*/
|
private smartdns = new plugins.smartdnsClient.Smartdns({});
|
||||||
constructor(productionArg: boolean = false) {
|
public logger: plugins.smartlog.Smartlog;
|
||||||
this.productionBool = productionArg
|
|
||||||
this.helper = new SmartacmeHelper()
|
// the account private key
|
||||||
this.keyPair = this.helper.createKeypair()
|
private privateKey: string;
|
||||||
if (this.productionBool) {
|
|
||||||
this.acmeUrl = rawacme.LETSENCRYPT_STAGING_URL
|
// challenge fullfillment
|
||||||
|
private setChallenge: (dnsChallengeArg: plugins.tsclass.network.IDnsChallenge) => Promise<any>;
|
||||||
|
private removeChallenge: (dnsChallengeArg: plugins.tsclass.network.IDnsChallenge) => Promise<any>;
|
||||||
|
|
||||||
|
// certmanager
|
||||||
|
private certmanager: SmartacmeCertManager;
|
||||||
|
private certmatcher: SmartacmeCertMatcher;
|
||||||
|
|
||||||
|
constructor(optionsArg: ISmartAcmeOptions) {
|
||||||
|
this.options = optionsArg;
|
||||||
|
this.logger = plugins.smartlog.Smartlog.createForCommitinfo(commitinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* starts the instance
|
||||||
|
* ```ts
|
||||||
|
* await myCloudlyInstance.start() // does not support options
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
public async start() {
|
||||||
|
this.privateKey =
|
||||||
|
this.options.accountPrivateKey || (await plugins.acme.forge.createPrivateKey()).toString();
|
||||||
|
this.setChallenge = this.options.setChallenge;
|
||||||
|
this.removeChallenge = this.options.removeChallenge;
|
||||||
|
|
||||||
|
// CertMangaer
|
||||||
|
this.certmanager = new SmartacmeCertManager(this, {
|
||||||
|
mongoDescriptor: this.options.mongoDescriptor,
|
||||||
|
});
|
||||||
|
await this.certmanager.init();
|
||||||
|
|
||||||
|
// CertMatcher
|
||||||
|
this.certmatcher = new SmartacmeCertMatcher();
|
||||||
|
|
||||||
|
// ACME Client
|
||||||
|
this.client = new plugins.acme.Client({
|
||||||
|
directoryUrl: (() => {
|
||||||
|
if (this.options.environment === 'production') {
|
||||||
|
return plugins.acme.directory.letsencrypt.production;
|
||||||
} else {
|
} else {
|
||||||
this.acmeUrl = rawacme.LETSENCRYPT_URL
|
return plugins.acme.directory.letsencrypt.staging;
|
||||||
}
|
}
|
||||||
|
})(),
|
||||||
|
accountKey: this.privateKey,
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Register account */
|
||||||
|
await this.client.createAccount({
|
||||||
|
termsOfServiceAgreed: true,
|
||||||
|
contact: [`mailto:${this.options.accountEmail}`],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async stop() {
|
||||||
|
await this.certmanager.smartdataDb.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets a certificate
|
||||||
|
* it runs through the following steps
|
||||||
|
*
|
||||||
|
* * look in the database
|
||||||
|
* * if in the database and still valid return it
|
||||||
|
* * if not in the database announce it
|
||||||
|
* * then get it from letsencrypt
|
||||||
|
* * store it
|
||||||
|
* * remove it from the pending map (which it go onto by announcing it)
|
||||||
|
* * retrieve it from the databse and return it
|
||||||
|
*
|
||||||
|
* @param domainArg
|
||||||
|
*/
|
||||||
|
public async getCertificateForDomain(domainArg: string): Promise<SmartacmeCert> {
|
||||||
|
const certDomainName = this.certmatcher.getCertificateDomainNameByDomainName(domainArg);
|
||||||
|
const retrievedCertificate = await this.certmanager.retrieveCertificate(certDomainName);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!retrievedCertificate &&
|
||||||
|
(await this.certmanager.interestMap.checkInterest(certDomainName))
|
||||||
|
) {
|
||||||
|
const existingCertificateInterest = this.certmanager.interestMap.findInterest(certDomainName);
|
||||||
|
const certificate = existingCertificateInterest.interestFullfilled;
|
||||||
|
return certificate;
|
||||||
|
} else if (retrievedCertificate && !retrievedCertificate.shouldBeRenewed()) {
|
||||||
|
return retrievedCertificate;
|
||||||
|
} else if (retrievedCertificate && retrievedCertificate.shouldBeRenewed()) {
|
||||||
|
await retrievedCertificate.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// lets make sure others get the same interest
|
||||||
* creates an account if not currently present in module
|
const currentDomainInterst = await this.certmanager.interestMap.addInterest(certDomainName);
|
||||||
* @executes ASYNC
|
|
||||||
*/
|
|
||||||
createAccount() {
|
|
||||||
let done = q.defer()
|
|
||||||
rawacme.createClient(
|
|
||||||
{
|
|
||||||
url: this.acmeUrl,
|
|
||||||
publicKey: this.keyPair.publicKey,
|
|
||||||
privateKey: this.keyPair.privateKey
|
|
||||||
},
|
|
||||||
(err, client) => {
|
|
||||||
if (err) {
|
|
||||||
console.error('smartacme: something went wrong:')
|
|
||||||
console.log(err)
|
|
||||||
done.reject(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client.newReg(
|
/* Place new order */
|
||||||
{
|
const order = await this.client.createOrder({
|
||||||
contact: ['mailto:domains@lossless.org']
|
identifiers: [
|
||||||
},
|
{ type: 'dns', value: certDomainName },
|
||||||
(err, res) => {
|
{ type: 'dns', value: `*.${certDomainName}` },
|
||||||
if (err) {
|
],
|
||||||
console.error('smartacme: something went wrong:')
|
});
|
||||||
console.log(err)
|
|
||||||
done.reject(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.JWK = res.body.key
|
|
||||||
console.log(this.JWK)
|
|
||||||
done.resolve()
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
/* Get authorizations and select challenges */
|
||||||
)
|
const authorizations = await this.client.getAuthorizations(order);
|
||||||
return done.promise
|
|
||||||
|
for (const authz of authorizations) {
|
||||||
|
console.log(authz);
|
||||||
|
const fullHostName: string = `_acme-challenge.${authz.identifier.value}`;
|
||||||
|
const dnsChallenge: string = authz.challenges.find((challengeArg) => {
|
||||||
|
return challengeArg.type === 'dns-01';
|
||||||
|
});
|
||||||
|
// process.exit(1);
|
||||||
|
const keyAuthorization: string = await this.client.getChallengeKeyAuthorization(dnsChallenge);
|
||||||
|
|
||||||
|
try {
|
||||||
|
/* Satisfy challenge */
|
||||||
|
await this.setChallenge({
|
||||||
|
hostName: fullHostName,
|
||||||
|
challenge: keyAuthorization,
|
||||||
|
});
|
||||||
|
await plugins.smartdelay.delayFor(30000);
|
||||||
|
await this.smartdns.checkUntilAvailable(fullHostName, 'TXT', keyAuthorization, 100, 5000);
|
||||||
|
console.log('Cool down an extra 60 second for region availability');
|
||||||
|
await plugins.smartdelay.delayFor(60000);
|
||||||
|
|
||||||
|
/* Verify that challenge is satisfied */
|
||||||
|
await this.client.verifyChallenge(authz, dnsChallenge);
|
||||||
|
|
||||||
|
/* Notify ACME provider that challenge is satisfied */
|
||||||
|
await this.client.completeChallenge(dnsChallenge);
|
||||||
|
|
||||||
|
/* Wait for ACME provider to respond with valid status */
|
||||||
|
await this.client.waitForValidStatus(dnsChallenge);
|
||||||
|
} finally {
|
||||||
|
/* Clean up challenge response */
|
||||||
|
try {
|
||||||
|
await this.removeChallenge({
|
||||||
|
hostName: fullHostName,
|
||||||
|
challenge: keyAuthorization,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Finalize order */
|
||||||
|
const [key, csr] = await plugins.acme.forge.createCsr({
|
||||||
|
commonName: `*.${certDomainName}`,
|
||||||
|
altNames: [certDomainName],
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.client.finalizeOrder(order, csr);
|
||||||
|
const cert = await this.client.getCertificate(order);
|
||||||
|
|
||||||
|
/* Done */
|
||||||
|
|
||||||
|
await this.certmanager.storeCertificate({
|
||||||
|
id: plugins.smartunique.shortId(),
|
||||||
|
domainName: certDomainName,
|
||||||
|
privateKey: key.toString(),
|
||||||
|
publicKey: cert.toString(),
|
||||||
|
csr: csr.toString(),
|
||||||
|
created: Date.now(),
|
||||||
|
validUntil:
|
||||||
|
Date.now() +
|
||||||
|
plugins.smarttime.getMilliSecondsFromUnits({
|
||||||
|
days: 90,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const newCertificate = await this.certmanager.retrieveCertificate(certDomainName);
|
||||||
|
currentDomainInterst.fullfillInterest(newCertificate);
|
||||||
|
currentDomainInterst.destroy();
|
||||||
|
return newCertificate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getAllCertificates(): Promise<SmartacmeCert[]> {
|
||||||
|
return SmartacmeCert.getInstances({});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
import * as path from 'path'
|
|
||||||
import * as smartfile from 'smartfile'
|
|
||||||
|
|
||||||
export let packageDir = path.join(__dirname,'../')
|
|
||||||
export let assetDir = path.join(packageDir,'assets/')
|
|
||||||
smartfile.fs.ensureDirSync(assetDir)
|
|
39
ts/smartacme.plugins.ts
Normal file
39
ts/smartacme.plugins.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// @apiglobal scope
|
||||||
|
import * as typedserver from '@api.global/typedserver';
|
||||||
|
|
||||||
|
export { typedserver };
|
||||||
|
|
||||||
|
// @pushrocks scope
|
||||||
|
import * as lik from '@push.rocks/lik';
|
||||||
|
import * as smartdata from '@push.rocks/smartdata';
|
||||||
|
import * as smartdelay from '@push.rocks/smartdelay';
|
||||||
|
import * as smartdnsClient from '@push.rocks/smartdns/client';
|
||||||
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
import * as smartrequest from '@push.rocks/smartrequest';
|
||||||
|
import * as smartunique from '@push.rocks/smartunique';
|
||||||
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
|
import * as smarttime from '@push.rocks/smarttime';
|
||||||
|
|
||||||
|
export {
|
||||||
|
lik,
|
||||||
|
smartdata,
|
||||||
|
smartdelay,
|
||||||
|
smartdnsClient,
|
||||||
|
smartlog,
|
||||||
|
smartpromise,
|
||||||
|
smartrequest,
|
||||||
|
smartunique,
|
||||||
|
smartstring,
|
||||||
|
smarttime,
|
||||||
|
};
|
||||||
|
|
||||||
|
// @tsclass scope
|
||||||
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
|
export { tsclass };
|
||||||
|
|
||||||
|
// third party scope
|
||||||
|
import * as acme from 'acme-client';
|
||||||
|
|
||||||
|
export { acme };
|
17
tsconfig.json
Normal file
17
tsconfig.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {}
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "tslint-config-standard"
|
|
||||||
}
|
|
Reference in New Issue
Block a user