Compare commits
80 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
123
.gitlab-ci.yml
123
.gitlab-ci.yml
@ -3,69 +3,148 @@ image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .yarn/
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
- metadata
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci test legacy
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
sast:
|
||||
stage: security
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
|
||||
--volume "$PWD:/code"
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
|
||||
artifacts:
|
||||
reports:
|
||||
sast: gl-sast-report.json
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
- npmci npm prepare
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command yarn global add npmpage
|
||||
- npmci command npmpage
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
12
.snyk
Normal file
12
.snyk
Normal file
@ -0,0 +1,12 @@
|
||||
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||
version: v1.12.0
|
||||
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
|
||||
ignore:
|
||||
'npm:node-forge:20180226':
|
||||
- rsa-compat > node-forge:
|
||||
reason: None given
|
||||
expires: '2018-09-11T19:17:24.148Z'
|
||||
- acme-v2 > rsa-compat > node-forge:
|
||||
reason: None given
|
||||
expires: '2018-09-11T19:17:24.148Z'
|
||||
patch: {}
|
40
README.md
40
README.md
@ -1,13 +1,16 @@
|
||||
# smartacme
|
||||
|
||||
acme implementation in TypeScript
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/smartacme)
|
||||
[](https://GitLab.com/umbrellazone/smartacme)
|
||||
[](https://github.com/umbrellazone/smartacme)
|
||||
[](https://umbrellazone.gitlab.io/smartacme/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
||||
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
||||
[](https://www.npmjs.com/package/smartacme)
|
||||
@ -19,11 +22,42 @@ acme implementation in TypeScript
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
```javascript
|
||||
import { SmartAcme } from 'smartacme';
|
||||
|
||||
let smac = new SmartAcme()(async () => {
|
||||
// learn async/await, it'll make your life easier
|
||||
|
||||
// optionally accepts a filePath Arg with a stored acmeaccount.json
|
||||
// will create an account and
|
||||
let myAccount = await smac.createAcmeAccount();
|
||||
|
||||
// will return a dnsHash to set in your DNS record
|
||||
let myCert = await myAccount.createAcmeCert('example.com');
|
||||
|
||||
// gets and accepts the specified challenge
|
||||
// first argument optional, defaults to dns-01 (which is the cleanest method for production use)
|
||||
let myChallenge = await myCert.getChallenge('dns-01');
|
||||
|
||||
/* ----------
|
||||
Now you need to set the challenge in your DNS
|
||||
myChallenge.domainNamePrefixed is the address for the record
|
||||
myChallenge.dnsKeyHash is the ready to use txt record value expected by letsencrypt
|
||||
-------------*/
|
||||
})();
|
||||
```
|
||||
|
||||
## Other relevant npm modules
|
||||
|
||||
| module name | description |
|
||||
| ----------- | ------------------------------------------------------------------- |
|
||||
| cert | a higlevel production module that uses smartacme to manage certs |
|
||||
| smartnginx | a highlevel production tool for docker environments to manage nginx |
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://umbrella.zone)
|
||||
[](https://umbrella.zone
|
||||
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +0,0 @@
|
||||
export * from './smartacme.classes.smartacme';
|
7
dist/index.js
vendored
7
dist/index.js
vendored
@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./smartacme.classes.smartacme"));
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLG1EQUE2QyJ9
|
21
dist/smartacme.classes.acmeaccount.d.ts
vendored
21
dist/smartacme.classes.acmeaccount.d.ts
vendored
@ -1,21 +0,0 @@
|
||||
import { SmartAcme } from './smartacme.classes.smartacme';
|
||||
import { AcmeCert } from './smartacme.classes.acmecert';
|
||||
/**
|
||||
* class AcmeAccount represents an AcmeAccount
|
||||
*/
|
||||
export declare class AcmeAccount {
|
||||
parentSmartAcme: SmartAcme;
|
||||
location: string;
|
||||
link: string;
|
||||
JWK: any;
|
||||
constructor(smartAcmeParentArg: SmartAcme);
|
||||
/**
|
||||
* register the account with letsencrypt
|
||||
*/
|
||||
register(): Promise<{}>;
|
||||
/**
|
||||
* agree to letsencrypr terms of service
|
||||
*/
|
||||
agreeTos(): Promise<{}>;
|
||||
createAcmeCert(domainNameArg: string, countryArg?: string, countryShortArg?: string, city?: string, companyArg?: string, companyShortArg?: string): Promise<AcmeCert>;
|
||||
}
|
72
dist/smartacme.classes.acmeaccount.js
vendored
72
dist/smartacme.classes.acmeaccount.js
vendored
@ -1,72 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const q = require("smartq");
|
||||
const smartacme_classes_acmecert_1 = require("./smartacme.classes.acmecert");
|
||||
/**
|
||||
* class AcmeAccount represents an AcmeAccount
|
||||
*/
|
||||
class AcmeAccount {
|
||||
constructor(smartAcmeParentArg) {
|
||||
this.parentSmartAcme = smartAcmeParentArg;
|
||||
}
|
||||
/**
|
||||
* register the account with letsencrypt
|
||||
*/
|
||||
register() {
|
||||
let done = q.defer();
|
||||
this.parentSmartAcme.rawacmeClient.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;
|
||||
this.link = res.headers.link;
|
||||
console.log(this.link);
|
||||
this.location = res.headers.location;
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
/**
|
||||
* agree to letsencrypr terms of service
|
||||
*/
|
||||
agreeTos() {
|
||||
let done = q.defer();
|
||||
let tosPart = this.link.split(',')[1];
|
||||
let tosLinkPortion = tosPart.split(';')[0];
|
||||
let url = tosLinkPortion.split(';')[0].trim().replace(/[<>]/g, '');
|
||||
this.parentSmartAcme.rawacmeClient.post(this.location, { Agreement: url, resource: 'reg' }, (err, res) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
done.reject(err);
|
||||
return;
|
||||
}
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
createAcmeCert(domainNameArg, countryArg = 'Germany', countryShortArg = 'DE', city = 'Bremen', companyArg = 'Some Company', companyShortArg = 'SC') {
|
||||
let done = q.defer();
|
||||
let acmeCert = new smartacme_classes_acmecert_1.AcmeCert({
|
||||
bit: 2064,
|
||||
key: null,
|
||||
domain: domainNameArg,
|
||||
country: countryArg,
|
||||
country_short: countryShortArg,
|
||||
locality: city,
|
||||
organization: companyArg,
|
||||
organization_short: companyShortArg,
|
||||
password: null,
|
||||
unstructured: null,
|
||||
subject_alt_names: null
|
||||
}, this);
|
||||
done.resolve(acmeCert);
|
||||
return done.promise;
|
||||
}
|
||||
}
|
||||
exports.AcmeAccount = AcmeAccount;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmNsYXNzZXMuYWNtZWFjY291bnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFjbWUuY2xhc3Nlcy5hY21lYWNjb3VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDRCQUEyQjtBQU0zQiw2RUFBdUQ7QUFFdkQ7O0dBRUc7QUFDSDtJQUtFLFlBQVksa0JBQTZCO1FBQ3ZDLElBQUksQ0FBQyxlQUFlLEdBQUcsa0JBQWtCLENBQUE7SUFDM0MsQ0FBQztJQUVEOztPQUVHO0lBQ0gsUUFBUTtRQUNOLElBQUksSUFBSSxHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUNwQixJQUFJLENBQUMsZUFBZSxDQUFDLGFBQWEsQ0FBQyxNQUFNLENBQ3ZDO1lBQ0UsT0FBTyxFQUFFLENBQUUsNkJBQTZCLENBQUU7U0FDM0MsRUFDRCxDQUFDLEdBQUcsRUFBRSxHQUFHO1lBQ1AsRUFBRSxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQztnQkFDUixPQUFPLENBQUMsS0FBSyxDQUFDLGtDQUFrQyxDQUFDLENBQUE7Z0JBQ2pELE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7Z0JBQ2hCLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUE7Z0JBQ2hCLE1BQU0sQ0FBQTtZQUNSLENBQUM7WUFDRCxJQUFJLENBQUMsR0FBRyxHQUFHLEdBQUcsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFBO1lBQ3ZCLElBQUksQ0FBQyxJQUFJLEdBQUcsR0FBRyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUE7WUFDNUIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7WUFDdEIsSUFBSSxDQUFDLFFBQVEsR0FBRyxHQUFHLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQTtZQUNwQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUE7UUFDaEIsQ0FBQyxDQUFDLENBQUE7UUFDSixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUNyQixDQUFDO0lBRUQ7O09BRUc7SUFDSCxRQUFRO1FBQ04sSUFBSSxJQUFJLEdBQUcsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQ3BCLElBQUksT0FBTyxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFFLENBQUMsQ0FBRSxDQUFBO1FBQ3ZDLElBQUksY0FBYyxHQUFHLE9BQU8sQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLENBQUUsQ0FBQyxDQUFFLENBQUE7UUFDNUMsSUFBSSxHQUFHLEdBQUcsY0FBYyxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBRSxDQUFDLENBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLEVBQUUsQ0FBQyxDQUFBO1FBQ3BFLElBQUksQ0FBQyxlQUFlLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFLEVBQUUsU0FBUyxFQUFFLEdBQUcsRUFBRSxRQUFRLEVBQUUsS0FBSyxFQUFFLEVBQUUsQ0FBQyxHQUFHLEVBQUUsR0FBRztZQUNuRyxFQUFFLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO2dCQUNSLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7Z0JBQ2hCLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUE7Z0JBQ2hCLE1BQU0sQ0FBQTtZQUNSLENBQUM7WUFDRCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUE7UUFDaEIsQ0FBQyxDQUFDLENBQUE7UUFDRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUNyQixDQUFDO0lBRUQsY0FBYyxDQUNaLGFBQXFCLEVBQ3JCLFVBQVUsR0FBRyxTQUFTLEVBQ3RCLGVBQWUsR0FBRyxJQUFJLEVBQ3RCLElBQUksR0FBRyxRQUFRLEVBQ2YsVUFBVSxHQUFHLGNBQWMsRUFDM0IsZUFBZSxHQUFHLElBQUk7UUFHdEIsSUFBSSxJQUFJLEdBQUcsQ0FBQyxDQUFDLEtBQUssRUFBWSxDQUFBO1FBQzlCLElBQUksUUFBUSxHQUFHLElBQUkscUNBQVEsQ0FDekI7WUFDRSxHQUFHLEVBQUUsSUFBSTtZQUNULEdBQUcsRUFBRSxJQUFJO1lBQ1QsTUFBTSxFQUFFLGFBQWE7WUFDckIsT0FBTyxFQUFFLFVBQVU7WUFDbkIsYUFBYSxFQUFFLGVBQWU7WUFDOUIsUUFBUSxFQUFFLElBQUk7WUFDZCxZQUFZLEVBQUUsVUFBVTtZQUN4QixrQkFBa0IsRUFBRSxlQUFlO1lBQ25DLFFBQVEsRUFBRSxJQUFJO1lBQ2QsWUFBWSxFQUFFLElBQUk7WUFDbEIsaUJBQWlCLEVBQUUsSUFBSTtTQUN4QixFQUNELElBQUksQ0FDTCxDQUFBO1FBQ0QsSUFBSSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQTtRQUN0QixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUNyQixDQUFDO0NBQ0Y7QUFsRkQsa0NBa0ZDIn0=
|
78
dist/smartacme.classes.acmecert.d.ts
vendored
78
dist/smartacme.classes.acmecert.d.ts
vendored
@ -1,78 +0,0 @@
|
||||
import { IRsaKeypair } from './smartacme.classes.smartacme';
|
||||
import { AcmeAccount } from './smartacme.classes.acmeaccount';
|
||||
/**
|
||||
* types of challenges supported by letsencrypt and this module
|
||||
*/
|
||||
export declare type TChallengeType = 'dns-01' | 'http-01';
|
||||
/**
|
||||
* values that a challenge's status can have
|
||||
*/
|
||||
export declare type TChallengeStatus = 'pending';
|
||||
export interface ISmartAcmeChallenge {
|
||||
uri: string;
|
||||
status: TChallengeStatus;
|
||||
type: TChallengeType;
|
||||
token: string;
|
||||
keyAuthorization: string;
|
||||
}
|
||||
export interface ISmartAcmeChallengeChosen extends ISmartAcmeChallenge {
|
||||
dnsKeyHash: string;
|
||||
domainName: string;
|
||||
domainNamePrefixed: string;
|
||||
}
|
||||
export interface IAcmeCsrConstructorOptions {
|
||||
bit: number;
|
||||
key: string;
|
||||
domain: string;
|
||||
country: string;
|
||||
country_short: string;
|
||||
locality: string;
|
||||
organization: string;
|
||||
organization_short: string;
|
||||
password: string;
|
||||
unstructured: string;
|
||||
subject_alt_names: string[];
|
||||
}
|
||||
/**
|
||||
* class AcmeCert represents a cert for domain
|
||||
*/
|
||||
export declare class AcmeCert {
|
||||
domainName: string;
|
||||
attributes: any;
|
||||
fullchain: string;
|
||||
parentAcmeAccount: AcmeAccount;
|
||||
csr: any;
|
||||
validFrom: Date;
|
||||
validTo: Date;
|
||||
keypair: IRsaKeypair;
|
||||
keyPairFinal: IRsaKeypair;
|
||||
chosenChallenge: ISmartAcmeChallengeChosen;
|
||||
dnsKeyHash: string;
|
||||
constructor(optionsArg: IAcmeCsrConstructorOptions, parentAcmeAccount: AcmeAccount);
|
||||
/**
|
||||
* requests a challenge for a domain
|
||||
* @param domainNameArg - the domain name to request a challenge for
|
||||
* @param challengeType - the challenge type to request
|
||||
*/
|
||||
requestChallenge(challengeTypeArg?: TChallengeType): Promise<ISmartAcmeChallengeChosen>;
|
||||
/**
|
||||
* checks if DNS records are set, will go through a max of 30 cycles
|
||||
*/
|
||||
checkDns(cycleArg?: number): Promise<void>;
|
||||
/**
|
||||
* validates a challenge, only call after you have set the challenge at the expected location
|
||||
*/
|
||||
requestValidation(): Promise<void>;
|
||||
/**
|
||||
* requests a certificate
|
||||
*/
|
||||
requestCert(): Promise<{}>;
|
||||
/**
|
||||
* getCertificate - takes care of cooldown, validation polling and certificate retrieval
|
||||
*/
|
||||
getCertificate(): void;
|
||||
/**
|
||||
* accept a challenge - for private use only
|
||||
*/
|
||||
acceptChallenge(): Promise<{}>;
|
||||
}
|
183
dist/smartacme.classes.acmecert.js
vendored
183
dist/smartacme.classes.acmecert.js
vendored
File diff suppressed because one or more lines are too long
32
dist/smartacme.classes.smartacme.d.ts
vendored
32
dist/smartacme.classes.smartacme.d.ts
vendored
@ -1,32 +0,0 @@
|
||||
import { AcmeAccount } from './smartacme.classes.acmeaccount';
|
||||
/**
|
||||
* a rsa keypair needed for account creation and subsequent requests
|
||||
*/
|
||||
export interface IRsaKeypair {
|
||||
publicKey: string;
|
||||
privateKey: string;
|
||||
}
|
||||
export { AcmeAccount } from './smartacme.classes.acmeaccount';
|
||||
export { AcmeCert, ISmartAcmeChallenge, ISmartAcmeChallengeChosen } from './smartacme.classes.acmecert';
|
||||
/**
|
||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
||||
*/
|
||||
export declare class SmartAcme {
|
||||
acmeUrl: string;
|
||||
productionBool: boolean;
|
||||
keyPair: IRsaKeypair;
|
||||
rawacmeClient: any;
|
||||
/**
|
||||
* the constructor for class SmartAcme
|
||||
*/
|
||||
constructor(productionArg?: boolean);
|
||||
/**
|
||||
* init the smartacme instance
|
||||
*/
|
||||
init(): Promise<{}>;
|
||||
/**
|
||||
* creates an account if not currently present in module
|
||||
* @executes ASYNC
|
||||
*/
|
||||
createAcmeAccount(): Promise<AcmeAccount>;
|
||||
}
|
67
dist/smartacme.classes.smartacme.js
vendored
67
dist/smartacme.classes.smartacme.js
vendored
@ -1,67 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// third party modules
|
||||
const q = require("smartq"); // promises
|
||||
const plugins = require("./smartacme.plugins");
|
||||
const helpers = require("./smartacme.helpers");
|
||||
const smartacme_classes_acmeaccount_1 = require("./smartacme.classes.acmeaccount");
|
||||
var smartacme_classes_acmeaccount_2 = require("./smartacme.classes.acmeaccount");
|
||||
exports.AcmeAccount = smartacme_classes_acmeaccount_2.AcmeAccount;
|
||||
var smartacme_classes_acmecert_1 = require("./smartacme.classes.acmecert");
|
||||
exports.AcmeCert = smartacme_classes_acmecert_1.AcmeCert;
|
||||
/**
|
||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
||||
*/
|
||||
class SmartAcme {
|
||||
/**
|
||||
* the constructor for class SmartAcme
|
||||
*/
|
||||
constructor(productionArg = false) {
|
||||
this.productionBool = productionArg;
|
||||
this.keyPair = helpers.createKeypair();
|
||||
if (this.productionBool) {
|
||||
this.acmeUrl = plugins.rawacme.LETSENCRYPT_URL;
|
||||
}
|
||||
else {
|
||||
this.acmeUrl = plugins.rawacme.LETSENCRYPT_STAGING_URL;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* init the smartacme instance
|
||||
*/
|
||||
init() {
|
||||
let done = q.defer();
|
||||
plugins.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;
|
||||
}
|
||||
// make client available in class
|
||||
this.rawacmeClient = client;
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
/**
|
||||
* creates an account if not currently present in module
|
||||
* @executes ASYNC
|
||||
*/
|
||||
createAcmeAccount() {
|
||||
let done = q.defer();
|
||||
let acmeAccount = new smartacme_classes_acmeaccount_1.AcmeAccount(this);
|
||||
acmeAccount.register().then(() => {
|
||||
return acmeAccount.agreeTos();
|
||||
}).then(() => {
|
||||
done.resolve(acmeAccount);
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
}
|
||||
exports.SmartAcme = SmartAcme;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsc0JBQXNCO0FBQ3RCLDRCQUEyQixDQUFDLFdBQVc7QUFDdkMsK0NBQThDO0FBQzlDLCtDQUE4QztBQUU5QyxtRkFBNkQ7QUFVN0QsaUZBQTZEO0FBQXBELHNEQUFBLFdBQVcsQ0FBQTtBQUNwQiwyRUFBdUc7QUFBOUYsZ0RBQUEsUUFBUSxDQUFBO0FBRWpCOztHQUVHO0FBQ0g7SUFNRTs7T0FFRztJQUNILFlBQVksZ0JBQXlCLEtBQUs7UUFDeEMsSUFBSSxDQUFDLGNBQWMsR0FBRyxhQUFhLENBQUE7UUFDbkMsSUFBSSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUMsYUFBYSxFQUFFLENBQUE7UUFDdEMsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDLENBQUM7WUFDeEIsSUFBSSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLGVBQWUsQ0FBQTtRQUNoRCxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixJQUFJLENBQUMsT0FBTyxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsdUJBQXVCLENBQUE7UUFDeEQsQ0FBQztJQUNILENBQUM7SUFFRDs7T0FFRztJQUNILElBQUk7UUFDRixJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDcEIsT0FBTyxDQUFDLE9BQU8sQ0FBQyxZQUFZLENBQzFCO1lBQ0UsR0FBRyxFQUFFLElBQUksQ0FBQyxPQUFPO1lBQ2pCLFNBQVMsRUFBRSxJQUFJLENBQUMsT0FBTyxDQUFDLFNBQVM7WUFDakMsVUFBVSxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsVUFBVTtTQUNwQyxFQUNELENBQUMsR0FBRyxFQUFFLE1BQU07WUFDVixFQUFFLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO2dCQUNSLE9BQU8sQ0FBQyxLQUFLLENBQUMsa0NBQWtDLENBQUMsQ0FBQTtnQkFDakQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQTtnQkFDaEIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQTtnQkFDaEIsTUFBTSxDQUFBO1lBQ1IsQ0FBQztZQUVELGtDQUFrQztZQUNsQyxJQUFJLENBQUMsYUFBYSxHQUFHLE1BQU0sQ0FBQTtZQUMzQixJQUFJLENBQUMsT0FBTyxFQUFFLENBQUE7UUFDaEIsQ0FBQyxDQUNGLENBQUE7UUFDRCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUNyQixDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsaUJBQWlCO1FBQ2YsSUFBSSxJQUFJLEdBQUcsQ0FBQyxDQUFDLEtBQUssRUFBZSxDQUFBO1FBQ2pDLElBQUksV0FBVyxHQUFHLElBQUksMkNBQVcsQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUN2QyxXQUFXLENBQUMsUUFBUSxFQUFFLENBQUMsSUFBSSxDQUFDO1lBQzFCLE1BQU0sQ0FBQyxXQUFXLENBQUMsUUFBUSxFQUFFLENBQUE7UUFDL0IsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDO1lBQ04sSUFBSSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUMzQixDQUFDLENBQUMsQ0FBQTtRQUNGLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3JCLENBQUM7Q0FDRjtBQTVERCw4QkE0REMifQ==
|
10
dist/smartacme.helpers.d.ts
vendored
10
dist/smartacme.helpers.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
import 'typings-global';
|
||||
import { IRsaKeypair } from './smartacme.classes.smartacme';
|
||||
/**
|
||||
* creates a keypair to use with requests and to generate JWK from
|
||||
*/
|
||||
export declare let createKeypair: (bit?: number) => IRsaKeypair;
|
||||
/**
|
||||
* prefix a domain name to make sure it complies with letsencrypt
|
||||
*/
|
||||
export declare let prefixName: (domainNameArg: string) => string;
|
41
dist/smartacme.helpers.js
vendored
41
dist/smartacme.helpers.js
vendored
@ -1,41 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const q = require("smartq");
|
||||
const plugins = require("./smartacme.plugins");
|
||||
/**
|
||||
* creates a keypair to use with requests and to generate JWK from
|
||||
*/
|
||||
exports.createKeypair = (bit = 2048) => {
|
||||
let result = plugins.rsaKeygen.generate(bit);
|
||||
return {
|
||||
publicKey: result.public_key,
|
||||
privateKey: result.private_key
|
||||
};
|
||||
};
|
||||
/**
|
||||
* prefix a domain name to make sure it complies with letsencrypt
|
||||
*/
|
||||
exports.prefixName = (domainNameArg) => {
|
||||
return '_acme-challenge.' + domainNameArg;
|
||||
};
|
||||
/**
|
||||
* gets an existing registration
|
||||
* @executes ASYNC
|
||||
*/
|
||||
let getReg = (SmartAcmeArg, location) => {
|
||||
let done = q.defer();
|
||||
let body = { resource: 'reg' };
|
||||
SmartAcmeArg.rawacmeClient.post(location, body, SmartAcmeArg.keyPair, (err, res) => {
|
||||
if (err) {
|
||||
console.error('smartacme: something went wrong:');
|
||||
console.log(err);
|
||||
done.reject(err);
|
||||
return;
|
||||
}
|
||||
console.log(JSON.stringify(res.body));
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmhlbHBlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFjbWUuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qiw0QkFBMkI7QUFFM0IsK0NBQThDO0FBSzlDOztHQUVHO0FBQ1EsUUFBQSxhQUFhLEdBQUcsQ0FBQyxHQUFHLEdBQUcsSUFBSTtJQUNwQyxJQUFJLE1BQU0sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsQ0FBQTtJQUM1QyxNQUFNLENBQUM7UUFDTCxTQUFTLEVBQUUsTUFBTSxDQUFDLFVBQVU7UUFDNUIsVUFBVSxFQUFFLE1BQU0sQ0FBQyxXQUFXO0tBQy9CLENBQUE7QUFDSCxDQUFDLENBQUE7QUFFRDs7R0FFRztBQUNRLFFBQUEsVUFBVSxHQUFHLENBQUMsYUFBcUI7SUFDNUMsTUFBTSxDQUFDLGtCQUFrQixHQUFHLGFBQWEsQ0FBQTtBQUMzQyxDQUFDLENBQUE7QUFFRDs7O0dBR0c7QUFDSCxJQUFJLE1BQU0sR0FBRyxDQUFDLFlBQXVCLEVBQUUsUUFBZ0I7SUFDckQsSUFBSSxJQUFJLEdBQUcsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFBO0lBQ3BCLElBQUksSUFBSSxHQUFHLEVBQUUsUUFBUSxFQUFFLEtBQUssRUFBRSxDQUFBO0lBQzlCLFlBQVksQ0FBQyxhQUFhLENBQUMsSUFBSSxDQUM3QixRQUFRLEVBQ1IsSUFBSSxFQUNKLFlBQVksQ0FBQyxPQUFPLEVBQ3BCLENBQUMsR0FBRyxFQUFFLEdBQUc7UUFDUCxFQUFFLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO1lBQ1IsT0FBTyxDQUFDLEtBQUssQ0FBQyxrQ0FBa0MsQ0FBQyxDQUFBO1lBQ2pELE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7WUFDaEIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQTtZQUNoQixNQUFNLENBQUE7UUFDUixDQUFDO1FBQ0QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFBO1FBQ3JDLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtJQUNoQixDQUFDLENBQ0YsQ0FBQTtJQUNELE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3JCLENBQUMsQ0FBQSJ9
|
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;
|
8
dist/smartacme.paths.js
vendored
8
dist/smartacme.paths.js
vendored
@ -1,8 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhY21lLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsNkJBQTRCO0FBQzVCLHVDQUFzQztBQUUzQixRQUFBLFVBQVUsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxLQUFLLENBQUMsQ0FBQTtBQUN2QyxRQUFBLFFBQVEsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLGtCQUFVLEVBQUMsU0FBUyxDQUFDLENBQUE7QUFDckQsU0FBUyxDQUFDLEVBQUUsQ0FBQyxhQUFhLENBQUMsZ0JBQVEsQ0FBQyxDQUFBIn0=
|
9
dist/smartacme.plugins.d.ts
vendored
9
dist/smartacme.plugins.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
import 'typings-global';
|
||||
declare let rsaKeygen: any;
|
||||
declare let rawacme: any;
|
||||
declare let nodeForge: any;
|
||||
import * as dnsly from 'dnsly';
|
||||
import * as smartdelay from 'smartdelay';
|
||||
import * as smartfile from 'smartfile';
|
||||
import * as smartstring from 'smartstring';
|
||||
export { dnsly, rsaKeygen, rawacme, nodeForge, smartdelay, smartfile, smartstring };
|
19
dist/smartacme.plugins.js
vendored
19
dist/smartacme.plugins.js
vendored
@ -1,19 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global"); // typings for node
|
||||
let rsaKeygen = require('rsa-keygen'); // rsa keygen
|
||||
exports.rsaKeygen = rsaKeygen;
|
||||
let rawacme = require('rawacme'); // acme helper functions
|
||||
exports.rawacme = rawacme;
|
||||
let nodeForge = require('node-forge');
|
||||
exports.nodeForge = nodeForge;
|
||||
// push.rocks modules here
|
||||
const dnsly = require("dnsly");
|
||||
exports.dnsly = dnsly;
|
||||
const smartdelay = require("smartdelay");
|
||||
exports.smartdelay = smartdelay;
|
||||
const smartfile = require("smartfile");
|
||||
exports.smartfile = smartfile;
|
||||
const smartstring = require("smartstring");
|
||||
exports.smartstring = smartstring;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFjbWUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QixDQUFDLG1CQUFtQjtBQUczQyxJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUEsQ0FBQyxhQUFhO0FBWWpELDhCQUFTO0FBWFgsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBLENBQUMsd0JBQXdCO0FBWXZELDBCQUFPO0FBWFQsSUFBSSxTQUFTLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFBO0FBWW5DLDhCQUFTO0FBVlgsMEJBQTBCO0FBQzFCLCtCQUE4QjtBQU01QixzQkFBSztBQUxQLHlDQUF3QztBQVN0QyxnQ0FBVTtBQVJaLHVDQUFzQztBQVNwQyw4QkFBUztBQVJYLDJDQUEwQztBQVN4QyxrQ0FBVyJ9
|
@ -1,59 +0,0 @@
|
||||
# smartacme
|
||||
acme implementation in TypeScript
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/smartacme)
|
||||
[](https://GitLab.com/umbrellazone/smartacme)
|
||||
[](https://github.com/umbrellazone/smartacme)
|
||||
[](https://umbrellazone.gitlab.io/smartacme/)
|
||||
|
||||
## Status for master
|
||||
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
||||
[](https://GitLab.com/umbrellazone/smartacme/commits/master)
|
||||
[](https://www.npmjs.com/package/smartacme)
|
||||
[](https://david-dm.org/umbrellazone/smartacme)
|
||||
[](https://www.bithound.io/github/umbrellazone/smartacme/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/umbrellazone/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.
|
||||
|
||||
```javascript
|
||||
import { SmartAcme } from 'smartacme'
|
||||
|
||||
let smac = new SmartAcme()
|
||||
|
||||
(async () => { // learn async/await, it'll make your life easier
|
||||
|
||||
// optionally accepts a filePath Arg with a stored acmeaccount.json
|
||||
// will create an account and
|
||||
let myAccount = await smac.createAcmeAccount()
|
||||
|
||||
// will return a dnsHash to set in your DNS record
|
||||
let myCert = await myAccount.createAcmeCert('example.com')
|
||||
|
||||
// gets and accepts the specified challenge
|
||||
// first argument optional, defaults to dns-01 (which is the cleanest method for production use)
|
||||
let myChallenge = await myCert.getChallenge('dns-01')
|
||||
|
||||
/* ----------
|
||||
Now you need to set the challenge in your DNS
|
||||
myChallenge.domainNamePrefixed is the address for the record
|
||||
myChallenge.dnsKeyHash is the ready to use txt record value expected by letsencrypt
|
||||
-------------*/
|
||||
})()
|
||||
```
|
||||
|
||||
## Other relevant npm modules
|
||||
module name | description
|
||||
--- | ---
|
||||
cert | a higlevel production module that uses smartacme to manage certs
|
||||
smartnginx | a highlevel production tool for docker environments to manage nginx
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://umbrella.zone
|
@ -1,7 +1,6 @@
|
||||
{
|
||||
"npmci": {
|
||||
"globalNpmTools": [
|
||||
"npmts"
|
||||
]
|
||||
}
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
}
|
||||
}
|
2579
package-lock.json
generated
Normal file
2579
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
42
package.json
42
package.json
@ -1,11 +1,13 @@
|
||||
{
|
||||
"name": "smartacme",
|
||||
"version": "1.0.11",
|
||||
"name": "@pushrocks/smartacme",
|
||||
"version": "2.0.35",
|
||||
"private": false,
|
||||
"description": "acme implementation in TypeScript",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts --nodocs)"
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -23,20 +25,28 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/umbrellazone/smartacme#README",
|
||||
"dependencies": {
|
||||
"@types/node-forge": "^0.6.8",
|
||||
"dnsly": "^2.0.4",
|
||||
"node-forge": "^0.7.1",
|
||||
"rawacme": "^0.2.1",
|
||||
"rsa-keygen": "^1.0.6",
|
||||
"smartdelay": "^1.0.1",
|
||||
"smartfile": "^4.1.10",
|
||||
"smartq": "^1.1.1",
|
||||
"smartstring": "^2.0.24",
|
||||
"typings-global": "^1.0.16"
|
||||
"@pushrocks/lik": "^3.0.4",
|
||||
"@pushrocks/smartdata": "^3.1.13",
|
||||
"@pushrocks/smartdelay": "^2.0.2",
|
||||
"@pushrocks/smartdns": "^3.0.8",
|
||||
"@pushrocks/smartexpress": "^3.0.6",
|
||||
"@pushrocks/smartlog": "^2.0.11",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartrequest": "^1.1.14",
|
||||
"@pushrocks/smartstring": "^3.0.8",
|
||||
"@pushrocks/smarttime": "^3.0.5",
|
||||
"@pushrocks/smartunique": "^3.0.1",
|
||||
"acme-client": "2.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cflare": "0.0.19",
|
||||
"qenv": "^1.1.3",
|
||||
"tapbundle": "^1.0.10"
|
||||
"@gitzone/tsbuild": "^2.1.4",
|
||||
"@gitzone/tsrun": "^1.1.17",
|
||||
"@gitzone/tstest": "^1.0.18",
|
||||
"@mojoio/cloudflare": "^2.0.0",
|
||||
"@pushrocks/qenv": "^4.0.0",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.12.18",
|
||||
"tslint": "^5.12.1",
|
||||
"tslint-config-prettier": "^1.17.0"
|
||||
}
|
||||
}
|
||||
|
9
qenv.yml
9
qenv.yml
@ -1,3 +1,6 @@
|
||||
vars:
|
||||
- CF_EMAIL
|
||||
- CF_KEY
|
||||
required:
|
||||
- CF_EMAIL
|
||||
- CF_KEY
|
||||
- MONGODB_URL
|
||||
- MONGODB_PASSWORD
|
||||
- MONGODB_DATABASE
|
||||
|
118
test/test.ts
118
test/test.ts
@ -1,90 +1,42 @@
|
||||
import { expect, tap } from 'tapbundle'
|
||||
import * as cflare from 'cflare'
|
||||
import * as qenv from 'qenv'
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
import { Qenv } from '@pushrocks/qenv';
|
||||
|
||||
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit')
|
||||
const testQenv = new Qenv('./', './.nogit/');
|
||||
|
||||
// import the module to test
|
||||
import * as smartacme from '../dist/index'
|
||||
import * as smartacme from '../ts/index';
|
||||
|
||||
let myCflareAccount = new cflare.CflareAccount()
|
||||
myCflareAccount.auth({
|
||||
email: process.env.CF_EMAIL,
|
||||
key: process.env.CF_KEY
|
||||
})
|
||||
let smartAcmeInstance: smartacme.SmartAcme;
|
||||
|
||||
let testSmartAcme: smartacme.SmartAcme
|
||||
let testAcmeAccount: smartacme.AcmeAccount
|
||||
let testAcmeCert: smartacme.AcmeCert
|
||||
let testChallenge: smartacme.ISmartAcmeChallengeChosen
|
||||
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')
|
||||
},
|
||||
removeChallenge: async (...args) => {
|
||||
console.log(args);
|
||||
},
|
||||
setChallenge: async (...args) => {
|
||||
console.log(args);
|
||||
},
|
||||
environment: "integration"
|
||||
});
|
||||
await smartAcmeInstance.init();
|
||||
// await smartAcmeInstance.getCertificateForDomain('bleu.de');
|
||||
});
|
||||
|
||||
tap.test('smartacme -> should create a valid instance', async (tools) => {
|
||||
tools.timeout(10000)
|
||||
testSmartAcme = new smartacme.SmartAcme(false)
|
||||
await testSmartAcme.init().then(async () => {
|
||||
expect(testSmartAcme).to.be.instanceOf(smartacme.SmartAcme)
|
||||
})
|
||||
})
|
||||
tap.test('certmatcher should correctly match domains', async () => {
|
||||
const certMatcherMod = await import('../ts/smartacme.classes.certmatcher');
|
||||
const certMatcher = new certMatcherMod.CertMatcher();
|
||||
const matchedCert = certMatcher.getCertificateDomainNameByDomainName('level3.level2.level1');
|
||||
expect(matchedCert).to.equal('level2.level1');
|
||||
});
|
||||
|
||||
tap.test('smartacme -> should have created keyPair', async () => {
|
||||
expect(testSmartAcme.acmeUrl).to.be.a('string')
|
||||
})
|
||||
tap.test('should stop correctly', async () => {
|
||||
await smartAcmeInstance.stop();
|
||||
});
|
||||
|
||||
tap.test('smartacme -> should register a new account', async (tools) => {
|
||||
tools.timeout(10000)
|
||||
await testSmartAcme.createAcmeAccount().then(async x => {
|
||||
testAcmeAccount = x
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('smartacme -> should create a AcmeCert', async () => {
|
||||
await testAcmeAccount.createAcmeCert('test2.bleu.de').then(async x => {
|
||||
testAcmeCert = x
|
||||
expect(testAcmeAccount).to.be.instanceOf(smartacme.AcmeCert)
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('smartacme -> should get a challenge for a AcmeCert', async (tools) => {
|
||||
tools.timeout(10000)
|
||||
await testAcmeCert.requestChallenge().then(async (challengeChosen) => {
|
||||
console.log(challengeChosen)
|
||||
testChallenge = challengeChosen
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('smartacme -> should set the challenge', async (tools) => {
|
||||
tools.timeout(20000)
|
||||
await myCflareAccount.createRecord(
|
||||
testChallenge.domainNamePrefixed,
|
||||
'TXT', testChallenge.dnsKeyHash
|
||||
)
|
||||
})
|
||||
|
||||
tap.test('smartacme -> should check for a DNS record', async (tools) => {
|
||||
tools.timeout(20000)
|
||||
await testAcmeCert.checkDns().then(x => {
|
||||
console.log(x)
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('smartacme -> should accept the challenge', async (tools) => {
|
||||
tools.timeout(10000)
|
||||
await testAcmeCert.acceptChallenge()
|
||||
})
|
||||
|
||||
tap.test('smartacme -> should poll for validation of a challenge', async (tools) => {
|
||||
tools.timeout(10000)
|
||||
await testAcmeCert.requestValidation().then(async x => {
|
||||
console.log(x)
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('smartacme -> should remove the challenge', async (tools) => {
|
||||
tools.timeout(20000)
|
||||
await myCflareAccount.removeRecord(
|
||||
testChallenge.domainNamePrefixed,
|
||||
'TXT'
|
||||
)
|
||||
})
|
||||
|
||||
tap.start()
|
||||
tap.start();
|
||||
|
@ -1 +1,3 @@
|
||||
export * from './smartacme.classes.smartacme'
|
||||
export * from './smartacme.classes.smartacme';
|
||||
|
||||
export * from './smartacme.classes.certremoteclient';
|
||||
|
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;
|
||||
}
|
10
ts/interfaces/cert.ts
Normal file
10
ts/interfaces/cert.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export type TCertStatus = 'existing' | 'nonexisting' | 'pending' | 'failed';
|
||||
|
||||
export interface ICert {
|
||||
id: string;
|
||||
domainName: string;
|
||||
created: number;
|
||||
privateKey: string;
|
||||
publicKey: string;
|
||||
csr: string;
|
||||
}
|
11
ts/interfaces/certremote.ts
Normal file
11
ts/interfaces/certremote.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { ICert, TCertStatus } from './cert';
|
||||
|
||||
export interface ICertRemoteRequest {
|
||||
secret: string;
|
||||
domainName: string;
|
||||
}
|
||||
|
||||
export interface ICertRemoteResponse {
|
||||
status: TCertStatus;
|
||||
certificate?: ICert;
|
||||
}
|
3
ts/interfaces/index.ts
Normal file
3
ts/interfaces/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './accountdata';
|
||||
export * from './cert';
|
||||
export * from './certremote';
|
@ -1,94 +0,0 @@
|
||||
import * as q from 'smartq'
|
||||
|
||||
import * as plugins from './smartacme.plugins'
|
||||
import * as helpers from './smartacme.helpers'
|
||||
|
||||
import { SmartAcme, IRsaKeypair } from './smartacme.classes.smartacme'
|
||||
import { AcmeCert } from './smartacme.classes.acmecert'
|
||||
|
||||
/**
|
||||
* class AcmeAccount represents an AcmeAccount
|
||||
*/
|
||||
export class AcmeAccount {
|
||||
parentSmartAcme: SmartAcme
|
||||
location: string
|
||||
link: string
|
||||
JWK
|
||||
constructor(smartAcmeParentArg: SmartAcme) {
|
||||
this.parentSmartAcme = smartAcmeParentArg
|
||||
}
|
||||
|
||||
/**
|
||||
* register the account with letsencrypt
|
||||
*/
|
||||
register() {
|
||||
let done = q.defer()
|
||||
this.parentSmartAcme.rawacmeClient.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
|
||||
this.link = res.headers.link
|
||||
console.log(this.link)
|
||||
this.location = res.headers.location
|
||||
done.resolve()
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* agree to letsencrypr terms of service
|
||||
*/
|
||||
agreeTos() {
|
||||
let done = q.defer()
|
||||
let tosPart = this.link.split(',')[ 1 ]
|
||||
let tosLinkPortion = tosPart.split(';')[ 0 ]
|
||||
let url = tosLinkPortion.split(';')[ 0 ].trim().replace(/[<>]/g, '')
|
||||
this.parentSmartAcme.rawacmeClient.post(this.location, { Agreement: url, resource: 'reg' }, (err, res) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
return
|
||||
}
|
||||
done.resolve()
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
|
||||
createAcmeCert(
|
||||
domainNameArg: string,
|
||||
countryArg = 'Germany',
|
||||
countryShortArg = 'DE',
|
||||
city = 'Bremen',
|
||||
companyArg = 'Some Company',
|
||||
companyShortArg = 'SC'
|
||||
|
||||
) {
|
||||
let done = q.defer<AcmeCert>()
|
||||
let acmeCert = new AcmeCert(
|
||||
{
|
||||
bit: 2064,
|
||||
key: null, // not needed right now
|
||||
domain: domainNameArg,
|
||||
country: countryArg,
|
||||
country_short: countryShortArg,
|
||||
locality: city,
|
||||
organization: companyArg,
|
||||
organization_short: companyShortArg,
|
||||
password: null,
|
||||
unstructured: null,
|
||||
subject_alt_names: null
|
||||
},
|
||||
this
|
||||
)
|
||||
done.resolve(acmeCert)
|
||||
return done.promise
|
||||
}
|
||||
}
|
@ -1,255 +0,0 @@
|
||||
import * as q from 'smartq'
|
||||
|
||||
import * as plugins from './smartacme.plugins'
|
||||
import * as helpers from './smartacme.helpers'
|
||||
|
||||
import { SmartAcme, IRsaKeypair } from './smartacme.classes.smartacme'
|
||||
import { AcmeAccount } from './smartacme.classes.acmeaccount'
|
||||
|
||||
/**
|
||||
* types of challenges supported by letsencrypt and this module
|
||||
*/
|
||||
export type TChallengeType = 'dns-01' | 'http-01'
|
||||
|
||||
/**
|
||||
* values that a challenge's status can have
|
||||
*/
|
||||
export type TChallengeStatus = 'pending'
|
||||
|
||||
export interface ISmartAcmeChallenge {
|
||||
uri: string
|
||||
status: TChallengeStatus
|
||||
type: TChallengeType
|
||||
token: string
|
||||
keyAuthorization: string
|
||||
}
|
||||
|
||||
export interface ISmartAcmeChallengeChosen extends ISmartAcmeChallenge {
|
||||
dnsKeyHash: string
|
||||
domainName: string
|
||||
domainNamePrefixed: string
|
||||
}
|
||||
|
||||
export interface IAcmeCsrConstructorOptions {
|
||||
bit: number,
|
||||
key: string,
|
||||
domain: string,
|
||||
country: string,
|
||||
country_short: string,
|
||||
locality: string,
|
||||
organization: string,
|
||||
organization_short: string,
|
||||
password: string,
|
||||
unstructured: string,
|
||||
subject_alt_names: string[]
|
||||
}
|
||||
|
||||
// Dnsly instance (we really just need one)
|
||||
let myDnsly = new plugins.dnsly.Dnsly('google')
|
||||
|
||||
/**
|
||||
* class AcmeCert represents a cert for domain
|
||||
*/
|
||||
export class AcmeCert {
|
||||
domainName: string
|
||||
attributes
|
||||
fullchain: string
|
||||
parentAcmeAccount: AcmeAccount
|
||||
csr
|
||||
validFrom: Date
|
||||
validTo: Date
|
||||
keypair: IRsaKeypair
|
||||
keyPairFinal: IRsaKeypair
|
||||
chosenChallenge: ISmartAcmeChallengeChosen
|
||||
dnsKeyHash: string
|
||||
constructor(optionsArg: IAcmeCsrConstructorOptions, parentAcmeAccount: AcmeAccount) {
|
||||
this.domainName = optionsArg.domain
|
||||
this.parentAcmeAccount = parentAcmeAccount
|
||||
this.keypair = helpers.createKeypair(optionsArg.bit)
|
||||
let privateKeyForged = plugins.nodeForge.pki.privateKeyFromPem(this.keypair.privateKey)
|
||||
let publicKeyForged = plugins.nodeForge.pki.publicKeyToPem(
|
||||
plugins.nodeForge.pki.setRsaPublicKey(privateKeyForged.n, privateKeyForged.e)
|
||||
)
|
||||
this.keyPairFinal = {
|
||||
privateKey: privateKeyForged,
|
||||
publicKey: publicKeyForged
|
||||
}
|
||||
|
||||
// set dates
|
||||
this.validFrom = new Date()
|
||||
this.validTo = new Date()
|
||||
this.validTo.setDate(this.validFrom.getDate() + 90)
|
||||
|
||||
// set attributes
|
||||
this.attributes = [
|
||||
{ name: 'commonName', value: optionsArg.domain },
|
||||
{ name: 'countryName', value: optionsArg.country },
|
||||
{ shortName: 'ST', value: optionsArg.country_short },
|
||||
{ name: 'localityName', value: optionsArg.locality },
|
||||
{ name: 'organizationName', value: optionsArg.organization },
|
||||
{ shortName: 'OU', value: optionsArg.organization_short },
|
||||
{ name: 'challengePassword', value: optionsArg.password },
|
||||
{ name: 'unstructuredName', value: optionsArg.unstructured }
|
||||
]
|
||||
|
||||
// set up csr
|
||||
this.csr = plugins.nodeForge.pki.createCertificationRequest()
|
||||
this.csr.setSubject(this.attributes)
|
||||
this.csr.setAttributes(this.attributes)
|
||||
}
|
||||
|
||||
/**
|
||||
* requests a challenge for a domain
|
||||
* @param domainNameArg - the domain name to request a challenge for
|
||||
* @param challengeType - the challenge type to request
|
||||
*/
|
||||
requestChallenge(challengeTypeArg: TChallengeType = 'dns-01') {
|
||||
let done = q.defer<ISmartAcmeChallengeChosen>()
|
||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.newAuthz(
|
||||
{
|
||||
identifier: {
|
||||
type: 'dns',
|
||||
value: this.domainName
|
||||
}
|
||||
},
|
||||
this.parentAcmeAccount.parentSmartAcme.keyPair,
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
console.error('smartacme: something went wrong:')
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
}
|
||||
let preChosenChallenge = res.body.challenges.filter(x => {
|
||||
return x.type === challengeTypeArg
|
||||
})[ 0 ]
|
||||
|
||||
/**
|
||||
* the key is needed to accept the challenge
|
||||
*/
|
||||
let authKey: string = plugins.rawacme.keyAuthz(
|
||||
preChosenChallenge.token,
|
||||
this.parentAcmeAccount.parentSmartAcme.keyPair.publicKey
|
||||
)
|
||||
|
||||
/**
|
||||
* needed in case selected challenge is of type dns-01
|
||||
*/
|
||||
this.dnsKeyHash = plugins.rawacme.dnsKeyAuthzHash(authKey) // needed if dns challenge is chosen
|
||||
/**
|
||||
* the return challenge
|
||||
*/
|
||||
this.chosenChallenge = {
|
||||
uri: preChosenChallenge.uri,
|
||||
type: preChosenChallenge.type,
|
||||
token: preChosenChallenge.token,
|
||||
keyAuthorization: authKey,
|
||||
status: preChosenChallenge.status,
|
||||
dnsKeyHash: this.dnsKeyHash,
|
||||
domainName: this.domainName,
|
||||
domainNamePrefixed: helpers.prefixName(this.domainName)
|
||||
}
|
||||
done.resolve(this.chosenChallenge)
|
||||
}
|
||||
)
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if DNS records are set, will go through a max of 30 cycles
|
||||
*/
|
||||
async checkDns(cycleArg = 1) {
|
||||
let result = await myDnsly.checkUntilAvailable(helpers.prefixName(this.domainName), 'TXT', this.dnsKeyHash)
|
||||
if (result) {
|
||||
console.log('DNS is set!')
|
||||
return
|
||||
} else {
|
||||
throw new Error('DNS not set!')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validates a challenge, only call after you have set the challenge at the expected location
|
||||
*/
|
||||
async requestValidation() {
|
||||
let makeRequest = () => {
|
||||
let done = q.defer()
|
||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.poll(this.chosenChallenge.uri, async (err, res) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return
|
||||
}
|
||||
console.log(`Validation response:`)
|
||||
console.log(JSON.stringify(res.body))
|
||||
if (res.body.status === 'pending' || res.body.status === 'invalid') {
|
||||
await plugins.smartdelay.delayFor(3000)
|
||||
makeRequest().then((x: any) => { done.resolve(x) })
|
||||
} else {
|
||||
console.log('perfect!')
|
||||
done.resolve(res.body)
|
||||
}
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
await makeRequest()
|
||||
}
|
||||
|
||||
/**
|
||||
* requests a certificate
|
||||
*/
|
||||
requestCert() {
|
||||
let done = q.defer()
|
||||
let payload = {
|
||||
csr: plugins.rawacme.base64.encode(
|
||||
plugins.rawacme.toDer(
|
||||
plugins.nodeForge.pki.certificationRequestToPem(
|
||||
this.csr
|
||||
)
|
||||
)
|
||||
),
|
||||
notBefore: this.validFrom.toISOString(),
|
||||
notAfter: this.validTo.toISOString()
|
||||
}
|
||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.newCert(
|
||||
payload,
|
||||
helpers.createKeypair(),
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
}
|
||||
console.log(res.body)
|
||||
done.resolve(res.body)
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* getCertificate - takes care of cooldown, validation polling and certificate retrieval
|
||||
*/
|
||||
getCertificate() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* accept a challenge - for private use only
|
||||
*/
|
||||
acceptChallenge() {
|
||||
let done = q.defer()
|
||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.post(
|
||||
this.chosenChallenge.uri,
|
||||
{
|
||||
resource: 'challenge',
|
||||
keyAuthorization: this.chosenChallenge.keyAuthorization
|
||||
},
|
||||
this.parentAcmeAccount.parentSmartAcme.keyPair,
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
}
|
||||
done.resolve(res.body)
|
||||
}
|
||||
)
|
||||
return done.promise
|
||||
}
|
||||
}
|
40
ts/smartacme.classes.cert.ts
Normal file
40
ts/smartacme.classes.cert.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import * as plugins from './smartacme.plugins';
|
||||
|
||||
import * as interfaces from './interfaces';
|
||||
|
||||
import { CertManager } from './smartacme.classes.certmanager';
|
||||
|
||||
import { Collection, svDb, unI } from '@pushrocks/smartdata';
|
||||
import { ICert } from './interfaces';
|
||||
|
||||
@plugins.smartdata.Collection(() => {
|
||||
return CertManager.activeDB;
|
||||
})
|
||||
export class Cert extends plugins.smartdata.SmartDataDbDoc<Cert> implements interfaces.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;
|
||||
|
||||
constructor(optionsArg: ICert) {
|
||||
super();
|
||||
if (optionsArg) {
|
||||
Object.keys(optionsArg).forEach(key => {
|
||||
this[key] = optionsArg[key];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
104
ts/smartacme.classes.certmanager.ts
Normal file
104
ts/smartacme.classes.certmanager.ts
Normal file
@ -0,0 +1,104 @@
|
||||
import * as plugins from './smartacme.plugins';
|
||||
import { Cert } from './smartacme.classes.cert';
|
||||
import { SmartAcme } from './smartacme.classes.smartacme';
|
||||
|
||||
import * as interfaces from './interfaces';
|
||||
|
||||
|
||||
export class CertManager {
|
||||
// =========
|
||||
// STATIC
|
||||
// =========
|
||||
public static activeDB: plugins.smartdata.SmartdataDb;
|
||||
|
||||
|
||||
// =========
|
||||
// INSTANCE
|
||||
// =========
|
||||
private mongoDescriptor: plugins.smartdata.IMongoDescriptor;
|
||||
public smartdataDb: plugins.smartdata.SmartdataDb;
|
||||
|
||||
public pendingMap: plugins.lik.Stringmap;
|
||||
|
||||
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();
|
||||
CertManager.activeDB = this.smartdataDb;
|
||||
|
||||
// Pending Map
|
||||
this.pendingMap = new plugins.lik.Stringmap();
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves a certificate
|
||||
* @returns the Cert class or null
|
||||
* @param domainName the domain Name to retrieve the vcertificate for
|
||||
*/
|
||||
public async retrieveCertificate(domainName: string): Promise<Cert> {
|
||||
await this.checkCerts();
|
||||
const existingCertificate: Cert = await Cert.getInstance({
|
||||
domainName
|
||||
});
|
||||
|
||||
if(existingCertificate) {
|
||||
return existingCertificate;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* stores the certificate
|
||||
* @param optionsArg
|
||||
*/
|
||||
public async storeCertificate(optionsArg: interfaces.ICert) {
|
||||
const cert = new Cert(optionsArg);
|
||||
await cert.save();
|
||||
this.pendingMap.removeString(optionsArg.domainName);
|
||||
}
|
||||
|
||||
public async deleteCertificate(domainNameArg: string) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* announce a certificate as being in the process of being retrieved
|
||||
*/
|
||||
public async announceCertificate (domainNameArg: string) {
|
||||
this.pendingMap.addString(domainNameArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the status of a certificate by certDomain name
|
||||
* @param certDomainArg
|
||||
*/
|
||||
public async getCertificateStatus(certDomainArg: string): Promise<interfaces.TCertStatus> {
|
||||
const isPending = this.pendingMap.checkString(certDomainArg);
|
||||
if (isPending) {
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
// otherwise lets continue
|
||||
const existingCertificate = await this.retrieveCertificate(certDomainArg);
|
||||
if (existingCertificate) {
|
||||
return 'existing';
|
||||
}
|
||||
|
||||
return 'nonexisting';
|
||||
}
|
||||
|
||||
/**
|
||||
* checks all certs for expiration
|
||||
*/
|
||||
private async checkCerts() {
|
||||
// TODO
|
||||
};
|
||||
}
|
10
ts/smartacme.classes.certmatcher.ts
Normal file
10
ts/smartacme.classes.certmatcher.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import * as plugins from './smartacme.plugins';
|
||||
|
||||
export class CertMatcher {
|
||||
public getCertificateDomainNameByDomainName(domainNameArg: string): string {
|
||||
const originalDomain = new plugins.smartstring.Domain(domainNameArg);
|
||||
if (!originalDomain.level4) {
|
||||
return `${originalDomain.level2}.${originalDomain.level1}`;
|
||||
}
|
||||
}
|
||||
}
|
56
ts/smartacme.classes.certremoteclient.ts
Normal file
56
ts/smartacme.classes.certremoteclient.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import * as plugins from './smartacme.plugins';
|
||||
import * as interfaces from './interfaces';
|
||||
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
export class CertRemoteClient {
|
||||
private remoteUrl: string;
|
||||
private secret: string;
|
||||
private logger: plugins.smartlog.Smartlog;
|
||||
|
||||
constructor(optionsArg: {
|
||||
remoteUrl: string;
|
||||
secret: string;
|
||||
logger?: plugins.smartlog.Smartlog;
|
||||
}) {
|
||||
this.remoteUrl = optionsArg.remoteUrl;
|
||||
this.secret = optionsArg.secret;
|
||||
optionsArg.logger
|
||||
? (this.logger = optionsArg.logger)
|
||||
: (this.logger = plugins.smartlog.defaultLogger);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param domainNameArg
|
||||
*/
|
||||
public async getCertificateForDomain(domainNameArg: string): Promise<interfaces.ICert> {
|
||||
let certificate: interfaces.ICert;
|
||||
const doRequestCycle = async (): Promise<interfaces.ICert> => {
|
||||
const responseBody: interfaces.ICertRemoteResponse = (await plugins.smartrequest.postJson(
|
||||
this.remoteUrl,
|
||||
{
|
||||
requestBody: <interfaces.ICertRemoteRequest>{
|
||||
domainName: domainNameArg,
|
||||
secret: this.secret
|
||||
}
|
||||
}
|
||||
)).body;
|
||||
console.log(responseBody);
|
||||
switch (responseBody.status as interfaces.TCertStatus) {
|
||||
case 'pending':
|
||||
await plugins.smartdelay.delayFor(5000);
|
||||
const finalResponse = await doRequestCycle();
|
||||
return finalResponse;
|
||||
case 'existing':
|
||||
this.logger.log('ok', `got certificate for ${domainNameArg}`);
|
||||
return responseBody.certificate;
|
||||
case 'failed':
|
||||
default:
|
||||
console.log(`could not retrieve certificate for ${domainNameArg}`);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
certificate = await doRequestCycle();
|
||||
return certificate;
|
||||
}
|
||||
}
|
@ -1,82 +1,231 @@
|
||||
// third party modules
|
||||
import * as q from 'smartq' // promises
|
||||
import * as plugins from './smartacme.plugins'
|
||||
import * as helpers from './smartacme.helpers'
|
||||
import * as plugins from './smartacme.plugins';
|
||||
import { Cert } from './smartacme.classes.cert';
|
||||
import { CertManager } from './smartacme.classes.certmanager';
|
||||
import { CertMatcher } from './smartacme.classes.certmatcher';
|
||||
|
||||
import { AcmeAccount } from './smartacme.classes.acmeaccount'
|
||||
import * as interfaces from './interfaces';
|
||||
import { request } from 'http';
|
||||
|
||||
/**
|
||||
* a rsa keypair needed for account creation and subsequent requests
|
||||
* the options for the class @see SmartAcme
|
||||
*/
|
||||
export interface IRsaKeypair {
|
||||
publicKey: string
|
||||
privateKey: string
|
||||
export interface ISmartAcmeOptions {
|
||||
accountPrivateKey?: string;
|
||||
accountEmail: string;
|
||||
mongoDescriptor: plugins.smartdata.IMongoDescriptor;
|
||||
setChallenge: (domainName: string, keyAuthorization: string) => Promise<any>;
|
||||
removeChallenge: (domainName: string) => Promise<any>;
|
||||
environment: 'production' | 'integration';
|
||||
logger?: plugins.smartlog.Smartlog;
|
||||
}
|
||||
|
||||
export { AcmeAccount } from './smartacme.classes.acmeaccount'
|
||||
export { AcmeCert, ISmartAcmeChallenge, ISmartAcmeChallengeChosen } from './smartacme.classes.acmecert'
|
||||
|
||||
/**
|
||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
||||
* 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 {
|
||||
acmeUrl: string // the acme url to use for this instance
|
||||
productionBool: boolean // a boolean to quickly know wether we are in production or not
|
||||
keyPair: IRsaKeypair // the keyPair needed for account creation
|
||||
rawacmeClient
|
||||
private options: ISmartAcmeOptions;
|
||||
|
||||
// the acme client
|
||||
private client: any;
|
||||
private smartdns = new plugins.smartdns.Smartdns();
|
||||
public logger: plugins.smartlog.Smartlog;
|
||||
|
||||
// the account private key
|
||||
private privateKey: string;
|
||||
|
||||
// challenge fullfillment
|
||||
private setChallenge: (domainName: string, keyAuthorization: string) => Promise<any>;
|
||||
private removeChallenge: (domainName: string) => Promise<any>;
|
||||
|
||||
// certmanager
|
||||
private certmanager: CertManager;
|
||||
private certmatcher: CertMatcher;
|
||||
|
||||
/**
|
||||
* the constructor for class SmartAcme
|
||||
* the remote handler to hand the request and response to.
|
||||
*/
|
||||
constructor(productionArg: boolean = false) {
|
||||
this.productionBool = productionArg
|
||||
this.keyPair = helpers.createKeypair()
|
||||
if (this.productionBool) {
|
||||
this.acmeUrl = plugins.rawacme.LETSENCRYPT_URL
|
||||
} else {
|
||||
this.acmeUrl = plugins.rawacme.LETSENCRYPT_STAGING_URL
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* init the smartacme instance
|
||||
*/
|
||||
init() {
|
||||
let done = q.defer()
|
||||
plugins.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
|
||||
public certremoteHandler = async (
|
||||
req: plugins.smartexpress.Request,
|
||||
res: plugins.smartexpress.Response
|
||||
) => {
|
||||
const requestBody: interfaces.ICertRemoteRequest = req.body;
|
||||
this.logger.log('ok', `got certificate request for ${requestBody.domainName}`);
|
||||
const certDomain = this.certmatcher.getCertificateDomainNameByDomainName(
|
||||
requestBody.domainName
|
||||
);
|
||||
this.logger.log('ok', `mapping ${requestBody.domainName} to ${certDomain}`);
|
||||
let status: interfaces.TCertStatus = await this.certmanager.getCertificateStatus(certDomain);
|
||||
let response: interfaces.ICertRemoteResponse;
|
||||
switch (status) {
|
||||
case 'existing':
|
||||
this.logger.log('ok', `certificate exists for ${certDomain}. Sending certificate!`);
|
||||
response = {
|
||||
status,
|
||||
certificate: await (await this.certmanager.retrieveCertificate(
|
||||
certDomain
|
||||
)).createSavableObject()
|
||||
};
|
||||
break;
|
||||
default:
|
||||
if (status === 'nonexisting') {
|
||||
this.getCertificateForDomain(certDomain);
|
||||
status = 'pending';
|
||||
}
|
||||
response = {
|
||||
status
|
||||
};
|
||||
break;
|
||||
}
|
||||
res.status(200);
|
||||
res.send(response);
|
||||
res.end();
|
||||
}
|
||||
|
||||
// make client available in class
|
||||
this.rawacmeClient = client
|
||||
done.resolve()
|
||||
}
|
||||
)
|
||||
return done.promise
|
||||
constructor(optionsArg: ISmartAcmeOptions) {
|
||||
this.options = optionsArg;
|
||||
this.options.logger
|
||||
? (this.logger = optionsArg.logger)
|
||||
: (this.logger = plugins.smartlog.defaultLogger);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an account if not currently present in module
|
||||
* @executes ASYNC
|
||||
* inits the instance
|
||||
* ```ts
|
||||
* await myCloudlyInstance.init() // does not support options
|
||||
* ```
|
||||
*/
|
||||
createAcmeAccount() {
|
||||
let done = q.defer<AcmeAccount>()
|
||||
let acmeAccount = new AcmeAccount(this)
|
||||
acmeAccount.register().then(() => {
|
||||
return acmeAccount.agreeTos()
|
||||
}).then(() => {
|
||||
done.resolve(acmeAccount)
|
||||
})
|
||||
return done.promise
|
||||
public async init() {
|
||||
this.privateKey =
|
||||
this.options.accountPrivateKey || (await plugins.acme.forge.createPrivateKey());
|
||||
this.setChallenge = this.options.setChallenge;
|
||||
this.removeChallenge = this.options.removeChallenge;
|
||||
|
||||
// CertMangaer
|
||||
this.certmanager = new CertManager(this, {
|
||||
mongoDescriptor: this.options.mongoDescriptor
|
||||
});
|
||||
await this.certmanager.init();
|
||||
|
||||
// CertMatcher
|
||||
this.certmatcher = new CertMatcher();
|
||||
|
||||
// ACME Client
|
||||
this.client = new plugins.acme.Client({
|
||||
directoryUrl: (() => {
|
||||
if (this.options.environment === 'production') {
|
||||
return plugins.acme.directory.letsencrypt.production;
|
||||
} else {
|
||||
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 return it
|
||||
* * of 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<Cert> {
|
||||
const certDomain = this.certmatcher.getCertificateDomainNameByDomainName(domainArg);
|
||||
const retrievedCertificate = await this.certmanager.retrieveCertificate(certDomain);
|
||||
|
||||
if (retrievedCertificate) {
|
||||
return retrievedCertificate;
|
||||
} else {
|
||||
await this.certmanager.announceCertificate(certDomain);
|
||||
}
|
||||
|
||||
/* Place new order */
|
||||
const order = await this.client.createOrder({
|
||||
identifiers: [{ type: 'dns', value: certDomain }, { type: 'dns', value: `*.${certDomain}` }]
|
||||
});
|
||||
|
||||
/* Get authorizations and select challenges */
|
||||
const authorizations = await this.client.getAuthorizations(order);
|
||||
|
||||
for (const authz of authorizations) {
|
||||
console.log(authz);
|
||||
const domainDnsName: 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(domainDnsName, keyAuthorization);
|
||||
await this.smartdns.checkUntilAvailable(domainDnsName, '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(domainDnsName);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Finalize order */
|
||||
const [key, csr] = await plugins.acme.forge.createCsr({
|
||||
commonName: `*.${certDomain}`,
|
||||
altNames: [certDomain]
|
||||
});
|
||||
|
||||
await this.client.finalizeOrder(order, csr);
|
||||
const cert = await this.client.getCertificate(order);
|
||||
|
||||
/* Done */
|
||||
|
||||
await this.certmanager.storeCertificate({
|
||||
id: plugins.smartunique.shortId(),
|
||||
domainName: certDomain,
|
||||
privateKey: key.toString(),
|
||||
publicKey: cert.toString(),
|
||||
csr: csr.toString(),
|
||||
created: Date.now()
|
||||
});
|
||||
|
||||
const newCertificate = await this.certmanager.retrieveCertificate(certDomain);
|
||||
return newCertificate;
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
import 'typings-global'
|
||||
import * as q from 'smartq'
|
||||
|
||||
import * as plugins from './smartacme.plugins'
|
||||
|
||||
import { SmartAcme, IRsaKeypair } from './smartacme.classes.smartacme'
|
||||
import { AcmeAccount } from './smartacme.classes.acmeaccount'
|
||||
|
||||
/**
|
||||
* creates a keypair to use with requests and to generate JWK from
|
||||
*/
|
||||
export let createKeypair = (bit = 2048): IRsaKeypair => {
|
||||
let result = plugins.rsaKeygen.generate(bit)
|
||||
return {
|
||||
publicKey: result.public_key,
|
||||
privateKey: result.private_key
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* prefix a domain name to make sure it complies with letsencrypt
|
||||
*/
|
||||
export let prefixName = (domainNameArg: string): string => {
|
||||
return '_acme-challenge.' + domainNameArg
|
||||
}
|
||||
|
||||
/**
|
||||
* gets an existing registration
|
||||
* @executes ASYNC
|
||||
*/
|
||||
let getReg = (SmartAcmeArg: SmartAcme, location: string) => {
|
||||
let done = q.defer()
|
||||
let body = { resource: 'reg' }
|
||||
SmartAcmeArg.rawacmeClient.post(
|
||||
location,
|
||||
body,
|
||||
SmartAcmeArg.keyPair,
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
console.error('smartacme: something went wrong:')
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
return
|
||||
}
|
||||
console.log(JSON.stringify(res.body))
|
||||
done.resolve()
|
||||
}
|
||||
)
|
||||
return done.promise
|
||||
}
|
@ -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)
|
@ -1,22 +1,19 @@
|
||||
import 'typings-global' // typings for node
|
||||
// @pushrocks scope
|
||||
import * as lik from '@pushrocks/lik';
|
||||
import * as smartdata from '@pushrocks/smartdata';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartdns from '@pushrocks/smartdns';
|
||||
import * as smartexpress from '@pushrocks/smartexpress';
|
||||
import * as smartlog from '@pushrocks/smartlog';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
import * as smarttime from '@pushrocks/smarttime';
|
||||
|
||||
import * as path from 'path' // native node path module
|
||||
let rsaKeygen = require('rsa-keygen') // rsa keygen
|
||||
let rawacme = require('rawacme') // acme helper functions
|
||||
let nodeForge = require('node-forge')
|
||||
export { lik, smartdata, smartdelay, smartdns, smartexpress, smartlog, smartpromise, smartrequest, smartunique, smartstring, smarttime };
|
||||
|
||||
// push.rocks modules here
|
||||
import * as dnsly from 'dnsly'
|
||||
import * as smartdelay from 'smartdelay'
|
||||
import * as smartfile from 'smartfile'
|
||||
import * as smartstring from 'smartstring'
|
||||
// thirs party scope
|
||||
import * as acme from 'acme-client';
|
||||
|
||||
export {
|
||||
dnsly,
|
||||
rsaKeygen,
|
||||
rawacme,
|
||||
nodeForge,
|
||||
smartdelay,
|
||||
smartfile,
|
||||
smartstring
|
||||
}
|
||||
export { acme };
|
||||
|
7
tsconfig.json
Normal file
7
tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"target": "es2017",
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
16
tslint.json
16
tslint.json
@ -1,3 +1,17 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
||||
|
Reference in New Issue
Block a user