Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
3c862158f3 | |||
e226bb7c4a | |||
66407cb214 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ node_modules/
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
.nogit/
|
||||
|
@ -1,4 +1,10 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .yarn/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- test
|
||||
@ -10,6 +16,7 @@ testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
@ -18,6 +25,7 @@ testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
@ -25,6 +33,7 @@ testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
@ -47,10 +56,13 @@ trigger:
|
||||
- docker
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
script:
|
||||
- npmci command npmpage --host gitlab
|
||||
- npmci command yarn global add npmpage
|
||||
- npmci command npmpage
|
||||
tags:
|
||||
- docker
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
|
4
.npmignore
Normal file
4
.npmignore
Normal file
@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
30
README.md
30
README.md
@ -1,19 +1,29 @@
|
||||
# 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/)
|
||||
[](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/pushrocks/smartacme/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartacme/commits/master)
|
||||
[](https://david-dm.org/pushrocks/smartacme)
|
||||
[](https://www.bithound.io/github/pushrocks/smartacme/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartacme)
|
||||
[](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/)
|
||||
|
||||
[](https://push.rocks)
|
||||
## Usage
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> 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,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/Jnue4srZJ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ocFq3vvbiRNCsEcXtsq
|
||||
imIi6UM1OmxiYVQ0NoLvBtpaWk+ETvNIjmUgh5QQaQfRyRGoWvhskp+E8p6go4Gs
|
||||
bRtzx0TvL8uINTcC3SHHo6Qvl5994QUUPUrioHdh+lX1oj+zIPVUOaL4dl0US1Eb
|
||||
s5vrZVbCfNXSm86vBaPIj6IkWEkj4S5xGsYlVaQUI8Tvv2fbPziIivbkxS1v/EEM
|
||||
nfk6i5PWgCsnMupYxz58WaVp9xyu+v/DMPB09mqo4DzchtUNF/b5eOWh3pDJoewY
|
||||
yRVMDDPJoQiTKkJn3kt64EaQuZK2nUXcihlmaKIx5ayxirsgfvIvxidHnkQcluvc
|
||||
iQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
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=
|
29
dist/smartacme.classes.smartacme.d.ts
vendored
29
dist/smartacme.classes.smartacme.d.ts
vendored
@ -1,29 +0,0 @@
|
||||
/// <reference types="q" />
|
||||
import 'typings-global';
|
||||
import * as q from 'q';
|
||||
/**
|
||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
||||
*/
|
||||
export declare class SmartAcme {
|
||||
preparedBool: boolean;
|
||||
acmeUrls: any;
|
||||
productionBool: boolean;
|
||||
keyPair: any;
|
||||
constructor(productionArg?: boolean);
|
||||
/**
|
||||
* prepares the SmartAcme class
|
||||
*/
|
||||
prepareAcme(): q.Promise<{}>;
|
||||
/**
|
||||
* creates an account if not currently present in module
|
||||
*/
|
||||
createAccount(): q.Promise<{}>;
|
||||
/**
|
||||
* creates a keyPair
|
||||
*/
|
||||
createKeyPair(): q.Promise<{}>;
|
||||
/**
|
||||
* gets the Acme Urls
|
||||
*/
|
||||
getAcmeUrls(): q.Promise<{}>;
|
||||
}
|
101
dist/smartacme.classes.smartacme.js
vendored
101
dist/smartacme.classes.smartacme.js
vendored
@ -1,101 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
const q = require("q");
|
||||
let ACME = require('le-acme-core').ACME.create();
|
||||
let RSA = require('rsa-compat').RSA;
|
||||
let bitlen = 1024;
|
||||
let exp = 65537;
|
||||
let options = {
|
||||
public: true,
|
||||
pem: true,
|
||||
internal: true
|
||||
};
|
||||
/**
|
||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
||||
*/
|
||||
class SmartAcme {
|
||||
constructor(productionArg = false) {
|
||||
this.preparedBool = false;
|
||||
this.productionBool = productionArg;
|
||||
}
|
||||
/**
|
||||
* prepares the SmartAcme class
|
||||
*/
|
||||
prepareAcme() {
|
||||
let done = q.defer();
|
||||
if (this.preparedBool === false) {
|
||||
this.getAcmeUrls()
|
||||
.then(() => {
|
||||
return this.createKeyPair();
|
||||
})
|
||||
.then((x) => {
|
||||
console.log('prepared smartacme instance');
|
||||
done.resolve();
|
||||
});
|
||||
}
|
||||
else {
|
||||
done.resolve();
|
||||
}
|
||||
return done.promise;
|
||||
}
|
||||
/**
|
||||
* creates an account if not currently present in module
|
||||
*/
|
||||
createAccount() {
|
||||
let done = q.defer();
|
||||
this.prepareAcme()
|
||||
.then(() => {
|
||||
let options = {
|
||||
newRegUrl: this.acmeUrls.newReg,
|
||||
email: 'domains@lossless.org',
|
||||
accountKeypair: {
|
||||
privateKeyPem: this.keyPair
|
||||
},
|
||||
agreeToTerms: function (tosUrl, done) {
|
||||
done(null, tosUrl);
|
||||
}
|
||||
};
|
||||
ACME.registerNewAccount(options, (err, regr) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
done.reject(err);
|
||||
}
|
||||
done.resolve(regr);
|
||||
});
|
||||
}).catch(err => { console.log(err); });
|
||||
return done.promise;
|
||||
}
|
||||
/**
|
||||
* creates a keyPair
|
||||
*/
|
||||
createKeyPair() {
|
||||
let done = q.defer();
|
||||
RSA.generateKeypair(bitlen, exp, options, (err, keypair) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
done.reject(err);
|
||||
}
|
||||
console.log(keypair);
|
||||
this.keyPair = keypair;
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
/**
|
||||
* gets the Acme Urls
|
||||
*/
|
||||
getAcmeUrls() {
|
||||
let done = q.defer();
|
||||
ACME.getAcmeUrls(ACME.stagingServerUrl, (err, urls) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
this.acmeUrls = urls;
|
||||
console.log(this.acmeUrls);
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
}
|
||||
exports.SmartAcme = SmartAcme;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFDdkIsdUJBQXNCO0FBTXRCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUE7QUFDaEQsSUFBSSxHQUFHLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDLEdBQUcsQ0FBQTtBQUVuQyx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endored
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==
|
59
docs/index.md
Normal file
59
docs/index.md
Normal file
@ -0,0 +1,59 @@
|
||||
# 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
|
7
npmextra.json
Normal file
7
npmextra.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"npmci": {
|
||||
"globalNpmTools": [
|
||||
"npmts"
|
||||
]
|
||||
}
|
||||
}
|
1384
package-lock.json
generated
Normal file
1384
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "smartacme",
|
||||
"version": "1.0.2",
|
||||
"version": "1.1.1",
|
||||
"description": "acme implementation in TypeScript",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts --nodocs)"
|
||||
"test": "(tstest test/)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartacme.git"
|
||||
"url": "git+ssh://git@gitlab.com/umbrellazone/smartacme.git"
|
||||
},
|
||||
"keywords": [
|
||||
"TypeScript",
|
||||
@ -19,21 +19,22 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/smartacme/issues"
|
||||
"url": "https://gitlab.com/umbrellazone/smartacme/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartacme#README",
|
||||
"homepage": "https://gitlab.com/umbrellazone/smartacme#README",
|
||||
"dependencies": {
|
||||
"@types/q": "0.x.x",
|
||||
"le-acme-core": "^2.0.7",
|
||||
"q": "^1.4.1",
|
||||
"rsa-compat": "^1.2.7",
|
||||
"smartfile": "^4.1.0",
|
||||
"smartstring": "^2.0.20",
|
||||
"typings-global": "^1.0.14"
|
||||
"@pushrocks/smartdelay": "^2.0.2",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"acme-v2": "^1.2.0",
|
||||
"rsa-compat": "^1.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/should": "^8.1.30",
|
||||
"should": "^11.1.1",
|
||||
"typings-test": "^1.0.3"
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tsrun": "^1.1.12",
|
||||
"@gitzone/tstest": "^1.0.13",
|
||||
"@types/node": "^10.5.8",
|
||||
"cflare": "^1.0.5",
|
||||
"qenv": "^1.1.7",
|
||||
"tapbundle": "^2.0.2"
|
||||
}
|
||||
}
|
||||
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
||||
import 'typings-test';
|
31
test/test.js
31
test/test.js
@ -1,31 +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 get the ACME urls', function (done) {
|
||||
testAcme.getAcmeUrls().then(() => { done(); });
|
||||
});
|
||||
it('should prepare the Instance', function (done) {
|
||||
testAcme.prepareAcme().then(done);
|
||||
});
|
||||
it('should have created keyPair', function () {
|
||||
});
|
||||
it('should register a new account', function (done) {
|
||||
testAcme.createAccount().then(x => {
|
||||
console.log(x);
|
||||
done();
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFFaEMsNEJBQTRCO0FBQzVCLDJDQUEwQztBQUUxQyxRQUFRLENBQUMsV0FBVyxFQUFFO0lBQ2xCLElBQUksUUFBNkIsQ0FBQTtJQUNqQyxFQUFFLENBQUMsZ0NBQWdDLEVBQUU7UUFDakMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQTtRQUNuQixRQUFRLEdBQUcsSUFBSSxTQUFTLENBQUMsU0FBUyxFQUFFLENBQUE7UUFDcEMsTUFBTSxD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||
// import the module to test
|
||||
import * as smartacme from '../dist/index'
|
||||
import * as smartacme from '../ts/index';
|
||||
|
||||
describe('smartacme', function () {
|
||||
let testAcme: smartacme.SmartAcme
|
||||
it('should create a valid instance', function () {
|
||||
this.timeout(10000)
|
||||
testAcme = new smartacme.SmartAcme()
|
||||
should(testAcme).be.instanceOf(smartacme.SmartAcme)
|
||||
})
|
||||
let smartAcmeInstance: smartacme.SmartAcme;
|
||||
|
||||
it('should get the ACME urls', function (done) {
|
||||
testAcme.getAcmeUrls().then(() => { done() })
|
||||
})
|
||||
|
||||
it('should prepare the Instance', function (done) {
|
||||
testAcme.prepareAcme().then(done)
|
||||
})
|
||||
it('should have created keyPair', function () {
|
||||
|
||||
})
|
||||
it('should register a new account', function (done) {
|
||||
testAcme.createAccount().then(x => {
|
||||
console.log(x)
|
||||
done()
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
tap.test('should create a valid instance of SmartAcme' , async () => {
|
||||
smartAcmeInstance = new smartacme.SmartAcme();
|
||||
await smartAcmeInstance.init()
|
||||
console.log(smartAcmeInstance.directoryUrls);
|
||||
await smartAcmeInstance.getCertificateForDomain('bleu.de');
|
||||
})
|
||||
|
||||
tap.start();
|
27
ts/smartacme.classes.keypair.ts
Normal file
27
ts/smartacme.classes.keypair.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import * as plugins from './smartacme.plugins';
|
||||
const rsa = require('rsa-compat').RSA;
|
||||
|
||||
export class KeyPair {
|
||||
rsaKeyPair: any
|
||||
|
||||
/**
|
||||
* generates a fresh rsa keyPair
|
||||
*/
|
||||
static async generateFresh(): Promise<KeyPair> {
|
||||
const done = plugins.smartpromise.defer();
|
||||
var options = { bitlen: 2048, exp: 65537, public: true, pem: true, internal: true };
|
||||
rsa.generateKeypair(options, function(err, keypair) {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
}
|
||||
done.resolve(keypair);
|
||||
});
|
||||
const result: any = await done.promise;
|
||||
const keyPair = new KeyPair(result);
|
||||
return keyPair;
|
||||
}
|
||||
|
||||
constructor(rsaKeyPairArg) {
|
||||
this.rsaKeyPair = rsaKeyPairArg;
|
||||
}
|
||||
}
|
@ -1,111 +1,89 @@
|
||||
import 'typings-global'
|
||||
import * as q from 'q'
|
||||
import * as path from 'path'
|
||||
import * as smartfile from 'smartfile'
|
||||
import * as smartstring from 'smartstring'
|
||||
import * as paths from './smartacme.paths'
|
||||
const acme = require('acme-v2').ACME.create({
|
||||
RSA: require('rsa-compat').RSA,
|
||||
|
||||
let ACME = require('le-acme-core').ACME.create()
|
||||
let RSA = require('rsa-compat').RSA
|
||||
// other overrides
|
||||
promisify: require('util').promisify,
|
||||
|
||||
// used for constructing user-agent
|
||||
os: require('os'),
|
||||
process: require('process'),
|
||||
|
||||
// used for overriding the default user-agent
|
||||
userAgent: 'My custom UA String',
|
||||
getUserAgentString: function(deps) {
|
||||
return 'My custom UA String';
|
||||
},
|
||||
|
||||
// don't try to validate challenges locally
|
||||
skipChallengeTest: true
|
||||
});
|
||||
|
||||
import { KeyPair } from './smartacme.classes.keypair';
|
||||
import * as plugins from './smartacme.plugins';
|
||||
const rsa = require('rsa-compat').RSA;
|
||||
|
||||
let bitlen = 1024
|
||||
let exp = 65537
|
||||
let options = {
|
||||
public: true,
|
||||
pem: true,
|
||||
internal: true
|
||||
}
|
||||
/**
|
||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
||||
*/
|
||||
export class SmartAcme {
|
||||
preparedBool: boolean = false
|
||||
acmeUrls: any
|
||||
productionBool: boolean
|
||||
keyPair: any
|
||||
constructor(productionArg: boolean = false) {
|
||||
this.productionBool = productionArg
|
||||
}
|
||||
domainKeyPair: KeyPair;
|
||||
accountKeyPair: KeyPair;
|
||||
accountData: any;
|
||||
directoryUrls: any;
|
||||
|
||||
/**
|
||||
* prepares the SmartAcme class
|
||||
*/
|
||||
prepareAcme() {
|
||||
let done = q.defer()
|
||||
if (this.preparedBool === false) {
|
||||
this.getAcmeUrls()
|
||||
.then(() => {
|
||||
return this.createKeyPair()
|
||||
})
|
||||
.then((x) => {
|
||||
console.log('prepared smartacme instance')
|
||||
done.resolve()
|
||||
})
|
||||
} else {
|
||||
done.resolve()
|
||||
async init() {
|
||||
// get directory url
|
||||
this.directoryUrls = await acme.init('https://acme-staging-v02.api.letsencrypt.org/directory');
|
||||
|
||||
// create keyPairs
|
||||
this.domainKeyPair = await KeyPair.generateFresh();
|
||||
this.accountKeyPair = await KeyPair.generateFresh();
|
||||
|
||||
// get account
|
||||
const registrationData = await acme.accounts
|
||||
.create({
|
||||
email: 'domains@lossless.org', // valid email (server checks MX records)
|
||||
accountKeypair: this.accountKeyPair.rsaKeyPair,
|
||||
agreeToTerms: async tosUrl => {
|
||||
return tosUrl;
|
||||
}
|
||||
return done.promise
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
this.accountData = registrationData;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an account if not currently present in module
|
||||
*/
|
||||
createAccount() {
|
||||
let done = q.defer()
|
||||
this.prepareAcme()
|
||||
.then(() => {
|
||||
let options = {
|
||||
newRegUrl: this.acmeUrls.newReg,
|
||||
email: 'domains@lossless.org', // valid email (server checks MX records)
|
||||
accountKeypair: { // privateKeyPem or privateKeyJwt
|
||||
privateKeyPem: this.keyPair
|
||||
},
|
||||
agreeToTerms: function (tosUrl, done) {
|
||||
done(null, tosUrl)
|
||||
}
|
||||
}
|
||||
ACME.registerNewAccount(options, (err, regr) => {
|
||||
if(err) {
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
}
|
||||
done.resolve(regr)
|
||||
})
|
||||
}).catch(err => { console.log(err) })
|
||||
async getCertificateForDomain(domain) {
|
||||
const result = await acme.certificates
|
||||
.create({
|
||||
domainKeypair: this.domainKeyPair.rsaKeyPair,
|
||||
accountKeypair: this.accountKeyPair.rsaKeyPair,
|
||||
domains: ['bleu.de'],
|
||||
challengeType: 'dns-01',
|
||||
|
||||
return done.promise
|
||||
}
|
||||
setChallenge: async (hostname, key, val, cb) => {
|
||||
console.log('set challenge');
|
||||
console.log(hostname);
|
||||
//console.log(key);
|
||||
//console.log(val);
|
||||
const dnsKey = rsa.utils.toWebsafeBase64(
|
||||
require('crypto')
|
||||
.createHash('sha256')
|
||||
.update(val)
|
||||
.digest('base64')
|
||||
);
|
||||
|
||||
/**
|
||||
* creates a keyPair
|
||||
*/
|
||||
createKeyPair() {
|
||||
let done = q.defer()
|
||||
RSA.generateKeypair(bitlen, exp, options, (err, keypair) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
done.reject(err)
|
||||
}
|
||||
console.log(keypair)
|
||||
this.keyPair = keypair
|
||||
done.resolve()
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the Acme Urls
|
||||
*/
|
||||
getAcmeUrls() {
|
||||
let done = q.defer()
|
||||
ACME.getAcmeUrls(ACME.stagingServerUrl, (err, urls) => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
this.acmeUrls = urls
|
||||
console.log(this.acmeUrls)
|
||||
done.resolve()
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
console.log(dnsKey);
|
||||
await plugins.smartdelay.delayFor(20000);
|
||||
console.log('ready!');
|
||||
cb();
|
||||
}, // return Promise
|
||||
removeChallenge: async (hostname, key) => {
|
||||
console.log('removing challenge');
|
||||
return;
|
||||
} // return Promise
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
}); // returns Promise<pems={ privkey (key), cert, chain (ca) }>
|
||||
console.log(result);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
7
ts/smartacme.plugins.ts
Normal file
7
ts/smartacme.plugins.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
|
||||
export {
|
||||
smartpromise,
|
||||
smartdelay
|
||||
}
|
Reference in New Issue
Block a user