basic functionality
This commit is contained in:
parent
68e570c32a
commit
b4de8cc2be
2
dist/smartacme.classes.acmecert.d.ts
vendored
2
dist/smartacme.classes.acmecert.d.ts
vendored
@ -60,7 +60,7 @@ export declare class AcmeCert {
|
||||
/**
|
||||
* checks if DNS records are set, will go through a max of 30 cycles
|
||||
*/
|
||||
checkDns(cycleArg?: number): any;
|
||||
checkDns(cycleArg?: number): Promise<void>;
|
||||
/**
|
||||
* validates a challenge, only call after you have set the challenge at the expected location
|
||||
*/
|
||||
|
38
dist/smartacme.classes.acmecert.js
vendored
38
dist/smartacme.classes.acmecert.js
vendored
File diff suppressed because one or more lines are too long
@ -25,8 +25,8 @@
|
||||
"dependencies": {
|
||||
"@types/node-forge": "^0.6.5",
|
||||
"@types/q": "0.x.x",
|
||||
"dnsly": "^1.0.7",
|
||||
"node-forge": "^0.6.47",
|
||||
"dnsly": "^2.0.3",
|
||||
"node-forge": "^0.6.48",
|
||||
"q": "^1.4.1",
|
||||
"rawacme": "^0.2.1",
|
||||
"rsa-keygen": "^1.0.6",
|
||||
@ -36,10 +36,9 @@
|
||||
"typings-global": "^1.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/should": "^8.1.30",
|
||||
"cflare": "0.0.11",
|
||||
"qenv": "^1.1.3",
|
||||
"should": "^11.1.2",
|
||||
"smartchai": "^1.0.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
22
test/test.js
22
test/test.js
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
const should = require("should");
|
||||
const smartchai_1 = require("smartchai");
|
||||
const cflare = require("cflare");
|
||||
const qenv = require("qenv");
|
||||
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit');
|
||||
@ -20,12 +20,12 @@ describe('smartacme', function () {
|
||||
this.timeout(10000);
|
||||
testSmartAcme = new smartacme.SmartAcme(false);
|
||||
testSmartAcme.init().then(() => {
|
||||
should(testSmartAcme).be.instanceOf(smartacme.SmartAcme);
|
||||
smartchai_1.expect(testSmartAcme).to.be.instanceOf(smartacme.SmartAcme);
|
||||
done();
|
||||
}).catch(err => { done(err); });
|
||||
});
|
||||
it('should have created keyPair', function () {
|
||||
should(testSmartAcme.acmeUrl).be.of.type('string');
|
||||
smartchai_1.expect(testSmartAcme.acmeUrl).to.be.a('string');
|
||||
});
|
||||
it('should register a new account', function (done) {
|
||||
this.timeout(10000);
|
||||
@ -38,9 +38,9 @@ describe('smartacme', function () {
|
||||
});
|
||||
});
|
||||
it('should create a AcmeCert', function () {
|
||||
testAcmeAccount.createAcmeCert('carglide.com').then(x => {
|
||||
testAcmeAccount.createAcmeCert('test2.bleu.de').then(x => {
|
||||
testAcmeCert = x;
|
||||
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert);
|
||||
smartchai_1.expect(testAcmeAccount).to.be.instanceOf(smartacme.AcmeCert);
|
||||
});
|
||||
});
|
||||
it('should get a challenge for a AcmeCert', function (done) {
|
||||
@ -52,7 +52,7 @@ describe('smartacme', function () {
|
||||
});
|
||||
});
|
||||
it('should set the challenge', function (done) {
|
||||
this.timeout(10000);
|
||||
this.timeout(20000);
|
||||
myCflareAccount.createRecord(testChallenge.domainNamePrefixed, 'TXT', testChallenge.dnsKeyHash).then(() => {
|
||||
done();
|
||||
});
|
||||
@ -69,11 +69,17 @@ describe('smartacme', function () {
|
||||
testAcmeCert.acceptChallenge().then(() => { done(); });
|
||||
});
|
||||
it('should poll for validation of a challenge', function (done) {
|
||||
this.timeout(700000);
|
||||
this.timeout(10000);
|
||||
testAcmeCert.requestValidation().then(x => {
|
||||
console.log(x);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should remove the challenge', function (done) {
|
||||
this.timeout(20000);
|
||||
myCflareAccount.removeRecord(testChallenge.domainNamePrefixed, 'TXT').then(() => {
|
||||
done();
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvd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WUFDbkMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQTtZQUNkLElBQUksRUFBRSxDQUFBO1FBQ1YsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUVGLEVBQUUsQ0FBQyw2QkFBNkIsRUFBRSxVQUFTLElBQUk7UUFDM0MsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQTtRQUNuQixlQUFlLENBQUMsWUFBWSxDQUN4QixhQUFhLENBQUMsa0JBQWtCLEVBQ2hDLEtBQUssQ0FDUixDQUFDLElBQUksQ0FBQztZQUNILElBQUksRUFBRSxDQUFBO1FBQ1YsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFBIn0=
|
24
test/test.ts
24
test/test.ts
@ -1,5 +1,5 @@
|
||||
import 'typings-test'
|
||||
import * as should from 'should'
|
||||
import { expect } from 'smartchai'
|
||||
import * as cflare from 'cflare'
|
||||
import * as qenv from 'qenv'
|
||||
|
||||
@ -24,13 +24,13 @@ describe('smartacme', function () {
|
||||
this.timeout(10000)
|
||||
testSmartAcme = new smartacme.SmartAcme(false)
|
||||
testSmartAcme.init().then(() => {
|
||||
should(testSmartAcme).be.instanceOf(smartacme.SmartAcme)
|
||||
expect(testSmartAcme).to.be.instanceOf(smartacme.SmartAcme)
|
||||
done()
|
||||
}).catch(err => { done(err) })
|
||||
})
|
||||
|
||||
it('should have created keyPair', function () {
|
||||
should(testSmartAcme.acmeUrl).be.of.type('string')
|
||||
expect(testSmartAcme.acmeUrl).to.be.a('string')
|
||||
})
|
||||
|
||||
it('should register a new account', function (done) {
|
||||
@ -45,9 +45,9 @@ describe('smartacme', function () {
|
||||
})
|
||||
|
||||
it('should create a AcmeCert', function() {
|
||||
testAcmeAccount.createAcmeCert('carglide.com').then(x => {
|
||||
testAcmeAccount.createAcmeCert('test2.bleu.de').then(x => {
|
||||
testAcmeCert = x
|
||||
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert)
|
||||
expect(testAcmeAccount).to.be.instanceOf(smartacme.AcmeCert)
|
||||
})
|
||||
})
|
||||
|
||||
@ -61,7 +61,7 @@ describe('smartacme', function () {
|
||||
})
|
||||
|
||||
it('should set the challenge', function(done) {
|
||||
this.timeout(10000)
|
||||
this.timeout(20000)
|
||||
myCflareAccount.createRecord(
|
||||
testChallenge.domainNamePrefixed,
|
||||
'TXT', testChallenge.dnsKeyHash
|
||||
@ -84,10 +84,20 @@ describe('smartacme', function () {
|
||||
})
|
||||
|
||||
it('should poll for validation of a challenge', function (done) {
|
||||
this.timeout(700000)
|
||||
this.timeout(10000)
|
||||
testAcmeCert.requestValidation().then(x => {
|
||||
console.log(x)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should remove the challenge', function(done) {
|
||||
this.timeout(20000)
|
||||
myCflareAccount.removeRecord(
|
||||
testChallenge.domainNamePrefixed,
|
||||
'TXT'
|
||||
).then(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -158,31 +158,12 @@ export class AcmeCert {
|
||||
* checks if DNS records are set, will go through a max of 30 cycles
|
||||
*/
|
||||
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
|
||||
try {
|
||||
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()
|
||||
}
|
||||
let result = await myDnsly.checkUntilAvailable(helpers.prefixName(this.domainName), 'TXT', this.dnsKeyHash)
|
||||
if (result) {
|
||||
console.log('DNS is set!')
|
||||
return myRecord
|
||||
} catch (err) {
|
||||
return redoCheck()
|
||||
return
|
||||
} else {
|
||||
throw new Error('DNS not set!')
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +171,6 @@ export class AcmeCert {
|
||||
* validates a challenge, only call after you have set the challenge at the expected location
|
||||
*/
|
||||
async requestValidation() {
|
||||
await plugins.smartdelay.delayFor(20000)
|
||||
let makeRequest = () => {
|
||||
let done = q.defer()
|
||||
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.poll(this.chosenChallenge.uri, async (err, res) => {
|
||||
@ -200,11 +180,11 @@ export class AcmeCert {
|
||||
}
|
||||
console.log(`Validation response:`)
|
||||
console.log(JSON.stringify(res.body))
|
||||
if (res.body.status === 'pending' || 'invalid') {
|
||||
console.log('retry in 6 minutes!')
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user