Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
68e570c32a | |||
20ea599f9d | |||
5fa530456b | |||
2cd1794e7e | |||
1f38e12bd3 | |||
1c777f6f05 | |||
aad113a8ea |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ node_modules/
|
|||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
.nogit/
|
||||||
|
4
.npmignore
Normal file
4
.npmignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
31
README.md
31
README.md
@ -26,11 +26,32 @@ import { SmartAcme } from 'smartacme'
|
|||||||
|
|
||||||
let smac = new SmartAcme()
|
let smac = new SmartAcme()
|
||||||
|
|
||||||
let myAccount = smac.getAccount() // optionally accepts a filePath Arg with a stored acmeaccount.json
|
(async () => { // learn async/await, it'll make your life easier
|
||||||
let myCert = myAccount.getChallenge('example.com','dns-01') // will return a dnsHash to set in your DNS record
|
|
||||||
myCert.get().then(() => {
|
// optionally accepts a filePath Arg with a stored acmeaccount.json
|
||||||
console.log(myCert.certificate) // your certificate, ready to use in whatever way you prefer
|
// 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
|
||||||
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
[](https://push.rocks)
|
||||||
|
15
dist/smartacme.classes.acmecert.d.ts
vendored
15
dist/smartacme.classes.acmecert.d.ts
vendored
@ -17,7 +17,7 @@ export interface ISmartAcmeChallenge {
|
|||||||
token: string;
|
token: string;
|
||||||
keyAuthorization: string;
|
keyAuthorization: string;
|
||||||
}
|
}
|
||||||
export interface ISmartAcmeChallengeAccepted extends ISmartAcmeChallenge {
|
export interface ISmartAcmeChallengeChosen extends ISmartAcmeChallenge {
|
||||||
dnsKeyHash: string;
|
dnsKeyHash: string;
|
||||||
domainName: string;
|
domainName: string;
|
||||||
domainNamePrefixed: string;
|
domainNamePrefixed: string;
|
||||||
@ -41,7 +41,6 @@ export interface IAcmeCsrConstructorOptions {
|
|||||||
export declare class AcmeCert {
|
export declare class AcmeCert {
|
||||||
domainName: string;
|
domainName: string;
|
||||||
attributes: any;
|
attributes: any;
|
||||||
acceptedChallenge: ISmartAcmeChallengeAccepted;
|
|
||||||
fullchain: string;
|
fullchain: string;
|
||||||
parentAcmeAccount: AcmeAccount;
|
parentAcmeAccount: AcmeAccount;
|
||||||
csr: any;
|
csr: any;
|
||||||
@ -49,21 +48,23 @@ export declare class AcmeCert {
|
|||||||
validTo: Date;
|
validTo: Date;
|
||||||
keypair: IRsaKeypair;
|
keypair: IRsaKeypair;
|
||||||
keyPairFinal: IRsaKeypair;
|
keyPairFinal: IRsaKeypair;
|
||||||
|
chosenChallenge: ISmartAcmeChallengeChosen;
|
||||||
|
dnsKeyHash: string;
|
||||||
constructor(optionsArg: IAcmeCsrConstructorOptions, parentAcmeAccount: AcmeAccount);
|
constructor(optionsArg: IAcmeCsrConstructorOptions, parentAcmeAccount: AcmeAccount);
|
||||||
/**
|
/**
|
||||||
* requests a challenge for a domain
|
* requests a challenge for a domain
|
||||||
* @param domainNameArg - the domain name to request a challenge for
|
* @param domainNameArg - the domain name to request a challenge for
|
||||||
* @param challengeType - the challenge type to request
|
* @param challengeType - the challenge type to request
|
||||||
*/
|
*/
|
||||||
requestChallenge(challengeTypeArg?: TChallengeType): q.Promise<ISmartAcmeChallengeAccepted>;
|
requestChallenge(challengeTypeArg?: TChallengeType): q.Promise<ISmartAcmeChallengeChosen>;
|
||||||
/**
|
/**
|
||||||
* checks if DNS records are set
|
* checks if DNS records are set, will go through a max of 30 cycles
|
||||||
*/
|
*/
|
||||||
checkDns(): Promise<any>;
|
checkDns(cycleArg?: number): any;
|
||||||
/**
|
/**
|
||||||
* validates a challenge, only call after you have set the challenge at the expected location
|
* validates a challenge, only call after you have set the challenge at the expected location
|
||||||
*/
|
*/
|
||||||
requestValidation(): q.Promise<{}>;
|
requestValidation(): Promise<void>;
|
||||||
/**
|
/**
|
||||||
* requests a certificate
|
* requests a certificate
|
||||||
*/
|
*/
|
||||||
@ -75,5 +76,5 @@ export declare class AcmeCert {
|
|||||||
/**
|
/**
|
||||||
* accept a challenge - for private use only
|
* accept a challenge - for private use only
|
||||||
*/
|
*/
|
||||||
private acceptChallenge(challengeArg);
|
acceptChallenge(): q.Promise<{}>;
|
||||||
}
|
}
|
||||||
|
129
dist/smartacme.classes.acmecert.js
vendored
129
dist/smartacme.classes.acmecert.js
vendored
File diff suppressed because one or more lines are too long
4
dist/smartacme.classes.smartacme.d.ts
vendored
4
dist/smartacme.classes.smartacme.d.ts
vendored
@ -9,7 +9,7 @@ export interface IRsaKeypair {
|
|||||||
privateKey: string;
|
privateKey: string;
|
||||||
}
|
}
|
||||||
export { AcmeAccount } from './smartacme.classes.acmeaccount';
|
export { AcmeAccount } from './smartacme.classes.acmeaccount';
|
||||||
export { AcmeCert, ISmartAcmeChallenge, ISmartAcmeChallengeAccepted } from './smartacme.classes.acmecert';
|
export { AcmeCert, ISmartAcmeChallenge, ISmartAcmeChallengeChosen } from './smartacme.classes.acmecert';
|
||||||
/**
|
/**
|
||||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
* class SmartAcme exports methods for maintaining SSL Certificates
|
||||||
*/
|
*/
|
||||||
@ -30,5 +30,5 @@ export declare class SmartAcme {
|
|||||||
* creates an account if not currently present in module
|
* creates an account if not currently present in module
|
||||||
* @executes ASYNC
|
* @executes ASYNC
|
||||||
*/
|
*/
|
||||||
createAccount(): q.Promise<AcmeAccount>;
|
createAcmeAccount(): q.Promise<AcmeAccount>;
|
||||||
}
|
}
|
||||||
|
4
dist/smartacme.classes.smartacme.js
vendored
4
dist/smartacme.classes.smartacme.js
vendored
@ -51,7 +51,7 @@ class SmartAcme {
|
|||||||
* creates an account if not currently present in module
|
* creates an account if not currently present in module
|
||||||
* @executes ASYNC
|
* @executes ASYNC
|
||||||
*/
|
*/
|
||||||
createAccount() {
|
createAcmeAccount() {
|
||||||
let done = q.defer();
|
let done = q.defer();
|
||||||
let acmeAccount = new smartacme_classes_acmeaccount_1.AcmeAccount(this);
|
let acmeAccount = new smartacme_classes_acmeaccount_1.AcmeAccount(this);
|
||||||
acmeAccount.register().then(() => {
|
acmeAccount.register().then(() => {
|
||||||
@ -63,4 +63,4 @@ class SmartAcme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.SmartAcme = SmartAcme;
|
exports.SmartAcme = SmartAcme;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxzQkFBc0I7QUFDdEIsdUJBQXNCLENBQUMsV0FBVztBQUNsQywrQ0FBOEM7QUFDOUMsK0NBQThDO0FBRTlDLG1GQUE2RDtBQVU3RCxpRkFBNkQ7QUFBcEQsc0RBQUE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UNqRCxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFBO2dCQUNoQixJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFBO2dCQUNoQixNQUFNLENBQUE7WUFDVixDQUFDO1lBRUQsa0NBQWtDO1lBQ2xDLElBQUksQ0FBQyxhQUFhLEdBQUcsTUFBTSxDQUFBO1lBQzNCLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUNsQixDQUFDLENBQ0osQ0FBQTtRQUNELE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3ZCLENBQUM7SUFFRDs7O09BR0c7SUFDSCxpQkFBaUI7UUFDYixJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFlLENBQUE7UUFDakMsSUFBSSxXQUFXLEdBQUcsSUFBSSwyQ0FBVyxDQUFDLElBQUksQ0FBQyxDQUFBO1FBQ3ZDLFdBQVcsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxJQUFJLENBQUM7WUFDeEIsTUFBTSxDQUFDLFdBQVcsQ0FBQyxRQUFRLEVBQUUsQ0FBQTtRQUNqQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUM7WUFDSixJQUFJLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFBO1FBQ0YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDdkIsQ0FBQztDQUNKO0FBNURELDhCQTREQyJ9
|
3
dist/smartacme.plugins.d.ts
vendored
3
dist/smartacme.plugins.d.ts
vendored
@ -3,6 +3,7 @@ declare let rsaKeygen: any;
|
|||||||
declare let rawacme: any;
|
declare let rawacme: any;
|
||||||
declare let nodeForge: any;
|
declare let nodeForge: any;
|
||||||
import * as dnsly from 'dnsly';
|
import * as dnsly from 'dnsly';
|
||||||
|
import * as smartdelay from 'smartdelay';
|
||||||
import * as smartfile from 'smartfile';
|
import * as smartfile from 'smartfile';
|
||||||
import * as smartstring from 'smartstring';
|
import * as smartstring from 'smartstring';
|
||||||
export { dnsly, rsaKeygen, rawacme, nodeForge, smartfile, smartstring };
|
export { dnsly, rsaKeygen, rawacme, nodeForge, smartdelay, smartfile, smartstring };
|
||||||
|
4
dist/smartacme.plugins.js
vendored
4
dist/smartacme.plugins.js
vendored
@ -9,8 +9,10 @@ exports.nodeForge = nodeForge;
|
|||||||
// push.rocks modules here
|
// push.rocks modules here
|
||||||
const dnsly = require("dnsly");
|
const dnsly = require("dnsly");
|
||||||
exports.dnsly = dnsly;
|
exports.dnsly = dnsly;
|
||||||
|
const smartdelay = require("smartdelay");
|
||||||
|
exports.smartdelay = smartdelay;
|
||||||
const smartfile = require("smartfile");
|
const smartfile = require("smartfile");
|
||||||
exports.smartfile = smartfile;
|
exports.smartfile = smartfile;
|
||||||
const smartstring = require("smartstring");
|
const smartstring = require("smartstring");
|
||||||
exports.smartstring = smartstring;
|
exports.smartstring = smartstring;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFjbWUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCLENBQUMsbUJBQW1CO0FBRzNDLElBQUksU0FBUyxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQSxDQUFDLGFBQWE7QUFXL0MsOEJBQVM7QUFWYixJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUEsQ0FBQyx3QkFBd0I7QUFXckQsMEJBQU87QUFWWCxJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUE7QUFXakMsOEJBQVM7QUFUYiwwQkFBMEI7QUFDMUIsK0JBQThCO0FBSzFCLHNCQUFLO0FBSlQsdUNBQXNDO0FBUWxDLDhCQUFTO0FBUGIsMkNBQTBDO0FBUXRDLGtDQUFXIn0=
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFjbWUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCLENBQUMsbUJBQW1CO0FBRzNDLElBQUksU0FBUyxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQSxDQUFDLGFBQWE7QUFZL0MsOEJBQVM7QUFYYixJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUEsQ0FBQyx3QkFBd0I7QUFZckQsMEJBQU87QUFYWCxJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUE7QUFZakMsOEJBQVM7QUFWYiwwQkFBMEI7QUFDMUIsK0JBQThCO0FBTTFCLHNCQUFLO0FBTFQseUNBQXdDO0FBU3BDLGdDQUFVO0FBUmQsdUNBQXNDO0FBU2xDLDhCQUFTO0FBUmIsMkNBQTBDO0FBU3RDLGtDQUFXIn0=
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartacme",
|
"name": "smartacme",
|
||||||
"version": "1.0.6",
|
"version": "1.0.8",
|
||||||
"description": "acme implementation in TypeScript",
|
"description": "acme implementation in TypeScript",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
@ -30,14 +30,15 @@
|
|||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"rawacme": "^0.2.1",
|
"rawacme": "^0.2.1",
|
||||||
"rsa-keygen": "^1.0.6",
|
"rsa-keygen": "^1.0.6",
|
||||||
"smartfile": "^4.1.2",
|
"smartdelay": "^1.0.1",
|
||||||
|
"smartfile": "^4.1.4",
|
||||||
"smartstring": "^2.0.22",
|
"smartstring": "^2.0.22",
|
||||||
"typings-global": "^1.0.14"
|
"typings-global": "^1.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.30",
|
"@types/should": "^8.1.30",
|
||||||
"cflare": "0.0.10",
|
"cflare": "0.0.11",
|
||||||
"qenv": "^1.1.1",
|
"qenv": "^1.1.3",
|
||||||
"should": "^11.1.2",
|
"should": "^11.1.2",
|
||||||
"typings-test": "^1.0.3"
|
"typings-test": "^1.0.3"
|
||||||
}
|
}
|
||||||
|
36
test/test.js
36
test/test.js
@ -1,8 +1,16 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-test");
|
require("typings-test");
|
||||||
const should = require("should");
|
const should = require("should");
|
||||||
|
const cflare = require("cflare");
|
||||||
|
const qenv = require("qenv");
|
||||||
|
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit');
|
||||||
// import the module to test
|
// import the module to test
|
||||||
const smartacme = require("../dist/index");
|
const smartacme = require("../dist/index");
|
||||||
|
let myCflareAccount = new cflare.CflareAccount();
|
||||||
|
myCflareAccount.auth({
|
||||||
|
email: process.env.CF_EMAIL,
|
||||||
|
key: process.env.CF_KEY
|
||||||
|
});
|
||||||
describe('smartacme', function () {
|
describe('smartacme', function () {
|
||||||
let testSmartAcme;
|
let testSmartAcme;
|
||||||
let testAcmeAccount;
|
let testAcmeAccount;
|
||||||
@ -10,7 +18,7 @@ describe('smartacme', function () {
|
|||||||
let testChallenge;
|
let testChallenge;
|
||||||
it('should create a valid instance', function (done) {
|
it('should create a valid instance', function (done) {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
testSmartAcme = new smartacme.SmartAcme();
|
testSmartAcme = new smartacme.SmartAcme(false);
|
||||||
testSmartAcme.init().then(() => {
|
testSmartAcme.init().then(() => {
|
||||||
should(testSmartAcme).be.instanceOf(smartacme.SmartAcme);
|
should(testSmartAcme).be.instanceOf(smartacme.SmartAcme);
|
||||||
done();
|
done();
|
||||||
@ -21,7 +29,7 @@ describe('smartacme', function () {
|
|||||||
});
|
});
|
||||||
it('should register a new account', function (done) {
|
it('should register a new account', function (done) {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
testSmartAcme.createAccount().then(x => {
|
testSmartAcme.createAcmeAccount().then(x => {
|
||||||
testAcmeAccount = x;
|
testAcmeAccount = x;
|
||||||
done();
|
done();
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
@ -30,30 +38,42 @@ describe('smartacme', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should create a AcmeCert', function () {
|
it('should create a AcmeCert', function () {
|
||||||
testAcmeAccount.createAcmeCert('test1.bleu.de').then(x => {
|
testAcmeAccount.createAcmeCert('carglide.com').then(x => {
|
||||||
testAcmeCert = x;
|
testAcmeCert = x;
|
||||||
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert);
|
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should get a challenge for a AcmeCert', function (done) {
|
it('should get a challenge for a AcmeCert', function (done) {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
testAcmeCert.requestChallenge().then((challengeAccepted) => {
|
testAcmeCert.requestChallenge().then((challengeChosen) => {
|
||||||
console.log(challengeAccepted);
|
console.log(challengeChosen);
|
||||||
testChallenge = challengeAccepted;
|
testChallenge = challengeChosen;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('should set the challenge', function (done) {
|
||||||
|
this.timeout(10000);
|
||||||
|
myCflareAccount.createRecord(testChallenge.domainNamePrefixed, 'TXT', testChallenge.dnsKeyHash).then(() => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should check for a DNS record', function (done) {
|
it('should check for a DNS record', function (done) {
|
||||||
|
this.timeout(20000);
|
||||||
testAcmeCert.checkDns().then(x => {
|
testAcmeCert.checkDns().then(x => {
|
||||||
console.log(x);
|
console.log(x);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should poll for validation of a challenge', function (done) {
|
it('should accept the challenge', function (done) {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
|
testAcmeCert.acceptChallenge().then(() => { done(); });
|
||||||
|
});
|
||||||
|
it('should poll for validation of a challenge', function (done) {
|
||||||
|
this.timeout(700000);
|
||||||
testAcmeCert.requestValidation().then(x => {
|
testAcmeCert.requestValidation().then(x => {
|
||||||
|
console.log(x);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFHaEMsNEJBQTRCO0FBQzVCLDJDQUEwQztBQUUxQyxRQUFRLENBQUMsV0FBVyxFQUFFO0lBQ2xCLElBQUksYUFBa0MsQ0FBQTtJQUN0QyxJQUFJLGVBQXNDLENBQUE7SUFDMUMsSUFBSSxZQUFnQyxDQUFBO0lBQ3BDLElBQUksYUFBb0QsQ0FBQTtJQUV4RCxFQUFFLENBQUMsZ0NBQWdDLEVBQUUsVUFBVSxJQUFJO1FBQy9DLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUE7UUFDbkIsYUFBYSxHQUFHLElBQUksU0FBUyxDQUFDLFNBQVMsRUFBRSxDQUFBO1FBQ3pDLGFBQWEsQ0FBQyxJQUFJLEVBQUUsQ0FBQyxJQUFJLENBQUM7WUFDdEIsTUFBTSxDQUF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QUFBO0lBRUYsRUFBRSxDQUFDLDZCQUE2QixFQUFFLFVBQVMsSUFBSTtRQUMzQyxJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO1FBQ25CLFlBQVksQ0FBQyxlQUFlLEVBQUUsQ0FBQyxJQUFJLENBQUMsUUFBUSxJQUFJLEVBQUUsQ0FBQSxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBQ3pELENBQUMsQ0FBQyxDQUFBO0lBRUYsRUFBRSxDQUFDLDJDQUEyQyxFQUFFLFVBQVUsSUFBSTtRQUMxRCxJQUFJLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFBO1FBQ3BCLFlBQVksQ0FBQyxpQkFBaUIsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQ25DLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUE7WUFDZCxJQUFJLEVBQUUsQ0FBQTtRQUNWLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9
|
41
test/test.ts
41
test/test.ts
@ -3,18 +3,26 @@ import * as should from 'should'
|
|||||||
import * as cflare from 'cflare'
|
import * as cflare from 'cflare'
|
||||||
import * as qenv from 'qenv'
|
import * as qenv from 'qenv'
|
||||||
|
|
||||||
|
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit')
|
||||||
|
|
||||||
// import the module to test
|
// import the module to test
|
||||||
import * as smartacme from '../dist/index'
|
import * as smartacme from '../dist/index'
|
||||||
|
|
||||||
|
let myCflareAccount = new cflare.CflareAccount()
|
||||||
|
myCflareAccount.auth({
|
||||||
|
email: process.env.CF_EMAIL,
|
||||||
|
key: process.env.CF_KEY
|
||||||
|
})
|
||||||
|
|
||||||
describe('smartacme', function () {
|
describe('smartacme', function () {
|
||||||
let testSmartAcme: smartacme.SmartAcme
|
let testSmartAcme: smartacme.SmartAcme
|
||||||
let testAcmeAccount: smartacme.AcmeAccount
|
let testAcmeAccount: smartacme.AcmeAccount
|
||||||
let testAcmeCert: smartacme.AcmeCert
|
let testAcmeCert: smartacme.AcmeCert
|
||||||
let testChallenge: smartacme.ISmartAcmeChallengeAccepted
|
let testChallenge: smartacme.ISmartAcmeChallengeChosen
|
||||||
|
|
||||||
it('should create a valid instance', function (done) {
|
it('should create a valid instance', function (done) {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
testSmartAcme = new smartacme.SmartAcme()
|
testSmartAcme = new smartacme.SmartAcme(false)
|
||||||
testSmartAcme.init().then(() => {
|
testSmartAcme.init().then(() => {
|
||||||
should(testSmartAcme).be.instanceOf(smartacme.SmartAcme)
|
should(testSmartAcme).be.instanceOf(smartacme.SmartAcme)
|
||||||
done()
|
done()
|
||||||
@ -27,7 +35,7 @@ describe('smartacme', function () {
|
|||||||
|
|
||||||
it('should register a new account', function (done) {
|
it('should register a new account', function (done) {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
testSmartAcme.createAccount().then(x => {
|
testSmartAcme.createAcmeAccount().then(x => {
|
||||||
testAcmeAccount = x
|
testAcmeAccount = x
|
||||||
done()
|
done()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
@ -37,7 +45,7 @@ describe('smartacme', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should create a AcmeCert', function() {
|
it('should create a AcmeCert', function() {
|
||||||
testAcmeAccount.createAcmeCert('test1.bleu.de').then(x => {
|
testAcmeAccount.createAcmeCert('carglide.com').then(x => {
|
||||||
testAcmeCert = x
|
testAcmeCert = x
|
||||||
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert)
|
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert)
|
||||||
})
|
})
|
||||||
@ -45,23 +53,40 @@ describe('smartacme', function () {
|
|||||||
|
|
||||||
it('should get a challenge for a AcmeCert', function (done) {
|
it('should get a challenge for a AcmeCert', function (done) {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
testAcmeCert.requestChallenge().then((challengeAccepted) => {
|
testAcmeCert.requestChallenge().then((challengeChosen) => {
|
||||||
console.log(challengeAccepted)
|
console.log(challengeChosen)
|
||||||
testChallenge = challengeAccepted
|
testChallenge = challengeChosen
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should set the challenge', function(done) {
|
||||||
|
this.timeout(10000)
|
||||||
|
myCflareAccount.createRecord(
|
||||||
|
testChallenge.domainNamePrefixed,
|
||||||
|
'TXT', testChallenge.dnsKeyHash
|
||||||
|
).then(() => {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should check for a DNS record', function(done) {
|
it('should check for a DNS record', function(done) {
|
||||||
|
this.timeout(20000)
|
||||||
testAcmeCert.checkDns().then(x => {
|
testAcmeCert.checkDns().then(x => {
|
||||||
console.log(x)
|
console.log(x)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('should poll for validation of a challenge', function (done) {
|
it('should accept the challenge', function(done){
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
testAcmeCert.acceptChallenge().then(() => { done() })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should poll for validation of a challenge', function (done) {
|
||||||
|
this.timeout(700000)
|
||||||
testAcmeCert.requestValidation().then(x => {
|
testAcmeCert.requestValidation().then(x => {
|
||||||
|
console.log(x)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -24,7 +24,7 @@ export interface ISmartAcmeChallenge {
|
|||||||
keyAuthorization: string
|
keyAuthorization: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISmartAcmeChallengeAccepted extends ISmartAcmeChallenge {
|
export interface ISmartAcmeChallengeChosen extends ISmartAcmeChallenge {
|
||||||
dnsKeyHash: string
|
dnsKeyHash: string
|
||||||
domainName: string
|
domainName: string
|
||||||
domainNamePrefixed: string
|
domainNamePrefixed: string
|
||||||
@ -53,7 +53,6 @@ let myDnsly = new plugins.dnsly.Dnsly('google')
|
|||||||
export class AcmeCert {
|
export class AcmeCert {
|
||||||
domainName: string
|
domainName: string
|
||||||
attributes
|
attributes
|
||||||
acceptedChallenge: ISmartAcmeChallengeAccepted
|
|
||||||
fullchain: string
|
fullchain: string
|
||||||
parentAcmeAccount: AcmeAccount
|
parentAcmeAccount: AcmeAccount
|
||||||
csr
|
csr
|
||||||
@ -61,6 +60,8 @@ export class AcmeCert {
|
|||||||
validTo: Date
|
validTo: Date
|
||||||
keypair: IRsaKeypair
|
keypair: IRsaKeypair
|
||||||
keyPairFinal: IRsaKeypair
|
keyPairFinal: IRsaKeypair
|
||||||
|
chosenChallenge: ISmartAcmeChallengeChosen
|
||||||
|
dnsKeyHash: string
|
||||||
constructor(optionsArg: IAcmeCsrConstructorOptions, parentAcmeAccount: AcmeAccount) {
|
constructor(optionsArg: IAcmeCsrConstructorOptions, parentAcmeAccount: AcmeAccount) {
|
||||||
this.domainName = optionsArg.domain
|
this.domainName = optionsArg.domain
|
||||||
this.parentAcmeAccount = parentAcmeAccount
|
this.parentAcmeAccount = parentAcmeAccount
|
||||||
@ -103,7 +104,7 @@ export class AcmeCert {
|
|||||||
* @param challengeType - the challenge type to request
|
* @param challengeType - the challenge type to request
|
||||||
*/
|
*/
|
||||||
requestChallenge(challengeTypeArg: TChallengeType = 'dns-01') {
|
requestChallenge(challengeTypeArg: TChallengeType = 'dns-01') {
|
||||||
let done = q.defer<ISmartAcmeChallengeAccepted>()
|
let done = q.defer<ISmartAcmeChallengeChosen>()
|
||||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.newAuthz(
|
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.newAuthz(
|
||||||
{
|
{
|
||||||
identifier: {
|
identifier: {
|
||||||
@ -118,55 +119,98 @@ export class AcmeCert {
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
done.reject(err)
|
done.reject(err)
|
||||||
}
|
}
|
||||||
let dnsChallenge = res.body.challenges.filter(x => {
|
let preChosenChallenge = res.body.challenges.filter(x => {
|
||||||
return x.type === challengeTypeArg
|
return x.type === challengeTypeArg
|
||||||
})[0]
|
})[0]
|
||||||
this.acceptChallenge(dnsChallenge)
|
|
||||||
.then((x: ISmartAcmeChallengeAccepted) => {
|
/**
|
||||||
done.resolve(x)
|
* 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
|
return done.promise
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if DNS records are set
|
* checks if DNS records are set, will go through a max of 30 cycles
|
||||||
*/
|
*/
|
||||||
async checkDns() {
|
async checkDns(cycleArg = 1) {
|
||||||
|
let redoCheck = async (err?) => {
|
||||||
|
if (cycleArg < 30) {
|
||||||
|
cycleArg++
|
||||||
|
await plugins.smartdelay.delayFor(2000)
|
||||||
|
return await this.checkDns(cycleArg)
|
||||||
|
} else {
|
||||||
|
console.log('failed permanently...')
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(`checkDns failed ${cycleArg} times and has ${30 - cycleArg} cycles to go before it fails permanently!`)
|
||||||
let myRecord
|
let myRecord
|
||||||
try {
|
try {
|
||||||
myRecord = await myDnsly.getRecord(helpers.prefixName(this.domainName), 'TXT')
|
myRecord = await myDnsly.getRecord(helpers.prefixName(this.domainName), 'TXT')
|
||||||
|
myRecord = myRecord[0][0]
|
||||||
|
if (myRecord === this.dnsKeyHash) {
|
||||||
|
console.log('and matches the required dnsKeyHash')
|
||||||
|
} else {
|
||||||
|
console.log('but does not match required dns keyHash!')
|
||||||
|
return redoCheck()
|
||||||
|
}
|
||||||
|
console.log('DNS is set!')
|
||||||
|
return myRecord
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await this.checkDns()
|
return redoCheck()
|
||||||
}
|
}
|
||||||
return myRecord[0][0]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* validates a challenge, only call after you have set the challenge at the expected location
|
* validates a challenge, only call after you have set the challenge at the expected location
|
||||||
*/
|
*/
|
||||||
requestValidation() {
|
async requestValidation() {
|
||||||
let done = q.defer()
|
await plugins.smartdelay.delayFor(20000)
|
||||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.poll(this.acceptedChallenge.uri, (err, res) => {
|
let makeRequest = () => {
|
||||||
if (err) {
|
let done = q.defer()
|
||||||
console.log(err)
|
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.poll(this.chosenChallenge.uri, async (err, res) => {
|
||||||
done.reject(err)
|
if (err) {
|
||||||
}
|
console.log(err)
|
||||||
console.log(`Validation response:`)
|
return
|
||||||
console.log(JSON.stringify(res.body))
|
}
|
||||||
if (res.body.status === 'pending' || 'invalid') {
|
console.log(`Validation response:`)
|
||||||
setTimeout(
|
console.log(JSON.stringify(res.body))
|
||||||
() => {
|
if (res.body.status === 'pending' || 'invalid') {
|
||||||
this.requestValidation().then(x => { done.resolve(x) })
|
console.log('retry in 6 minutes!')
|
||||||
},
|
await plugins.smartdelay.delayFor(3000)
|
||||||
2000
|
makeRequest().then((x: any) => { done.resolve(x) })
|
||||||
)
|
} else {
|
||||||
} else {
|
done.resolve(res.body)
|
||||||
done.resolve(res.body)
|
}
|
||||||
}
|
})
|
||||||
})
|
return done.promise
|
||||||
return done.promise
|
}
|
||||||
|
await makeRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,27 +253,13 @@ export class AcmeCert {
|
|||||||
/**
|
/**
|
||||||
* accept a challenge - for private use only
|
* accept a challenge - for private use only
|
||||||
*/
|
*/
|
||||||
private acceptChallenge(challengeArg: ISmartAcmeChallenge) {
|
acceptChallenge() {
|
||||||
let done = q.defer()
|
let done = q.defer()
|
||||||
|
|
||||||
/**
|
|
||||||
* the key is needed to accept the challenge
|
|
||||||
*/
|
|
||||||
let authKey: string = plugins.rawacme.keyAuthz(
|
|
||||||
challengeArg.token,
|
|
||||||
this.parentAcmeAccount.parentSmartAcme.keyPair.publicKey
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* needed in case selected challenge is of type dns-01
|
|
||||||
*/
|
|
||||||
let keyHash: string = plugins.rawacme.dnsKeyAuthzHash(authKey) // needed if dns challenge is chosen
|
|
||||||
|
|
||||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.post(
|
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.post(
|
||||||
challengeArg.uri,
|
this.chosenChallenge.uri,
|
||||||
{
|
{
|
||||||
resource: 'challenge',
|
resource: 'challenge',
|
||||||
keyAuthorization: authKey
|
keyAuthorization: this.chosenChallenge.keyAuthorization
|
||||||
},
|
},
|
||||||
this.parentAcmeAccount.parentSmartAcme.keyPair,
|
this.parentAcmeAccount.parentSmartAcme.keyPair,
|
||||||
(err, res) => {
|
(err, res) => {
|
||||||
@ -237,21 +267,7 @@ export class AcmeCert {
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
done.reject(err)
|
done.reject(err)
|
||||||
}
|
}
|
||||||
/**
|
done.resolve(res.body)
|
||||||
* the return challenge
|
|
||||||
*/
|
|
||||||
let returnDNSChallenge: ISmartAcmeChallengeAccepted = {
|
|
||||||
uri: res.body.uri,
|
|
||||||
type: res.body.type,
|
|
||||||
token: res.body.token,
|
|
||||||
keyAuthorization: res.body.keyAuthorization,
|
|
||||||
status: res.body.status,
|
|
||||||
dnsKeyHash: keyHash,
|
|
||||||
domainName: this.domainName,
|
|
||||||
domainNamePrefixed: helpers.prefixName(this.domainName)
|
|
||||||
}
|
|
||||||
this.acceptedChallenge = returnDNSChallenge
|
|
||||||
done.resolve(returnDNSChallenge)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return done.promise
|
return done.promise
|
||||||
|
@ -14,7 +14,7 @@ export interface IRsaKeypair {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export { AcmeAccount } from './smartacme.classes.acmeaccount'
|
export { AcmeAccount } from './smartacme.classes.acmeaccount'
|
||||||
export { AcmeCert, ISmartAcmeChallenge, ISmartAcmeChallengeAccepted } from './smartacme.classes.acmecert'
|
export { AcmeCert, ISmartAcmeChallenge, ISmartAcmeChallengeChosen } from './smartacme.classes.acmecert'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class SmartAcme exports methods for maintaining SSL Certificates
|
* class SmartAcme exports methods for maintaining SSL Certificates
|
||||||
@ -69,7 +69,7 @@ export class SmartAcme {
|
|||||||
* creates an account if not currently present in module
|
* creates an account if not currently present in module
|
||||||
* @executes ASYNC
|
* @executes ASYNC
|
||||||
*/
|
*/
|
||||||
createAccount() {
|
createAcmeAccount() {
|
||||||
let done = q.defer<AcmeAccount>()
|
let done = q.defer<AcmeAccount>()
|
||||||
let acmeAccount = new AcmeAccount(this)
|
let acmeAccount = new AcmeAccount(this)
|
||||||
acmeAccount.register().then(() => {
|
acmeAccount.register().then(() => {
|
||||||
|
@ -7,6 +7,7 @@ let nodeForge = require('node-forge')
|
|||||||
|
|
||||||
// push.rocks modules here
|
// push.rocks modules here
|
||||||
import * as dnsly from 'dnsly'
|
import * as dnsly from 'dnsly'
|
||||||
|
import * as smartdelay from 'smartdelay'
|
||||||
import * as smartfile from 'smartfile'
|
import * as smartfile from 'smartfile'
|
||||||
import * as smartstring from 'smartstring'
|
import * as smartstring from 'smartstring'
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ export {
|
|||||||
rsaKeygen,
|
rsaKeygen,
|
||||||
rawacme,
|
rawacme,
|
||||||
nodeForge,
|
nodeForge,
|
||||||
|
smartdelay,
|
||||||
smartfile,
|
smartfile,
|
||||||
smartstring
|
smartstring
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user