Compare commits

...

8 Commits

Author SHA1 Message Date
bef54799b6 2.0.8 2019-01-07 00:36:51 +01:00
dbe09f320a fix(core): update 2019-01-07 00:36:51 +01:00
18045dadaf 2.0.7 2019-01-06 23:54:47 +01:00
ee300c3e12 fix(core): update 2019-01-06 23:54:46 +01:00
ed4ba0cb61 2.0.6 2019-01-06 23:30:39 +01:00
a8ab27045d fix(core): update 2019-01-06 23:30:38 +01:00
975c3ed190 2.0.5 2019-01-06 20:41:43 +01:00
a99dea549b fix(core): update 2019-01-06 20:41:42 +01:00
5 changed files with 38 additions and 22 deletions

11
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartacme", "name": "@pushrocks/smartacme",
"version": "2.0.4", "version": "2.0.8",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -137,6 +137,15 @@
"@pushrocks/smartpromise": "^2.0.5" "@pushrocks/smartpromise": "^2.0.5"
} }
}, },
"@pushrocks/smartdns": {
"version": "3.0.7",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdns/-/smartdns-3.0.7.tgz",
"integrity": "sha512-qaLuTa2CWsdEuWNA0jz8QgiZJCG5DEGkbwa2g1rUlUy40TKfiHZralkTOMrBzXGGsDv3CZDBK4U5pWlxCsTrMQ==",
"requires": {
"@pushrocks/smartdelay": "^2.0.2",
"@pushrocks/smartpromise": "^2.0.5"
}
},
"@pushrocks/smartevent": { "@pushrocks/smartevent": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.3.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.3.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartacme", "name": "@pushrocks/smartacme",
"version": "2.0.4", "version": "2.0.8",
"private": false, "private": false,
"description": "acme implementation in TypeScript", "description": "acme implementation in TypeScript",
"main": "dist/index.js", "main": "dist/index.js",
@ -26,6 +26,7 @@
"homepage": "https://gitlab.com/umbrellazone/smartacme#README", "homepage": "https://gitlab.com/umbrellazone/smartacme#README",
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.2", "@pushrocks/smartdelay": "^2.0.2",
"@pushrocks/smartdns": "^3.0.7",
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^2.0.5",
"acme-client": "^2.2.1" "acme-client": "^2.2.1"
}, },

View File

@ -16,7 +16,7 @@ tap.test('should create a valid instance of SmartAcme', async () => {
console.log(args); console.log(args);
} }
}); });
await smartAcmeInstance.getCertificateForDomain('bleu.de'); // await smartAcmeInstance.getCertificateForDomain('bleu.de');
}); });
tap.start(); tap.start();

View File

@ -8,19 +8,20 @@ export interface ISmartAcmeStorage {}
export class SmartAcme { export class SmartAcme {
// the acme client // the acme client
private client: any; private client: any;
private smartdns = new plugins.smartdns.Smartdns();
// the account private key // the account private key
private privateKey: string; private privateKey: string;
// challenge fullfillment // challenge fullfillment
private setChallenge: (authz, challenge, keyAuthorization) => Promise<any>; private setChallenge: (domainName: string, keyAuthorization: string) => Promise<any>;
private removeChallenge: (authz, challenge, keyAuthorization) => Promise<any>; private removeChallenge: (domainName: string) => Promise<any>;
public async init(optionsArg: { public async init(optionsArg: {
accountPrivateKey?: string; accountPrivateKey?: string;
accountEmail: string; accountEmail: string;
setChallenge: (authz, challenge, keyAuthorization) => Promise<any>; setChallenge: (domainName: string, keyAuthorization: string) => Promise<any>
removeChallenge: (authz, challenge, keyAuthorization) => Promise<any>; removeChallenge: (domainName: string) => Promise<any>;
}) { }) {
this.privateKey = optionsArg.accountPrivateKey || (await plugins.acme.forge.createPrivateKey()); this.privateKey = optionsArg.accountPrivateKey || (await plugins.acme.forge.createPrivateKey());
this.setChallenge = optionsArg.setChallenge; this.setChallenge = optionsArg.setChallenge;
@ -48,34 +49,38 @@ export class SmartAcme {
/* Get authorizations and select challenges */ /* Get authorizations and select challenges */
const authorizations = await this.client.getAuthorizations(order); const authorizations = await this.client.getAuthorizations(order);
const promises = authorizations.map(async authz => { for (const authz of authorizations) {
const challenge = authz.challenges.pop(); console.log(authz);
const keyAuthorization = await this.client.getChallengeKeyAuthorization(challenge); 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 { try {
/* Satisfy challenge */ /* Satisfy challenge */
await this.setChallenge(authz, challenge, keyAuthorization); await this.setChallenge(domainDnsName, keyAuthorization);
await this.smartdns.checkUntilAvailable(domainDnsName, 'TXT', keyAuthorization);
/* Verify that challenge is satisfied */ /* Verify that challenge is satisfied */
await this.client.verifyChallenge(authz, challenge); await this.client.verifyChallenge(authz, dnsChallenge);
/* Notify ACME provider that challenge is satisfied */ /* Notify ACME provider that challenge is satisfied */
await this.client.completeChallenge(challenge); await this.client.completeChallenge(dnsChallenge);
/* Wait for ACME provider to respond with valid status */ /* Wait for ACME provider to respond with valid status */
await this.client.waitForValidStatus(challenge); await this.client.waitForValidStatus(dnsChallenge);
} finally { } finally {
/* Clean up challenge response */ /* Clean up challenge response */
try { try {
await this.removeChallenge(authz, challenge, keyAuthorization); await this.removeChallenge(domainDnsName);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
} }
}); }
/* Wait for challenges to complete */
await Promise.all(promises);
/* Finalize order */ /* Finalize order */
const [key, csr] = await plugins.acme.forge.createCsr({ const [key, csr] = await plugins.acme.forge.createCsr({
@ -92,5 +97,5 @@ export class SmartAcme {
console.log(`Certificate:\n${cert.toString()}`); console.log(`Certificate:\n${cert.toString()}`);
} }
toStorageObject () {}; toStorageObject() {}
} }

View File

@ -1,8 +1,9 @@
// @pushrocks scope // @pushrocks scope
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartdns from '@pushrocks/smartdns';
import * as smartpromise from '@pushrocks/smartpromise';
export { smartpromise, smartdelay }; export { smartdelay, smartdns, smartpromise };
// thirs party scope // thirs party scope
import * as acme from 'acme-client'; import * as acme from 'acme-client';