Compare commits

...

10 Commits

Author SHA1 Message Date
d4d50b7dcf 2.0.9 2019-01-07 01:00:58 +01:00
2492fd4de2 fix(core): update 2019-01-07 01:00:58 +01:00
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",
"version": "2.0.4",
"version": "2.0.9",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -137,6 +137,15 @@
"@pushrocks/smartpromise": "^2.0.5"
}
},
"@pushrocks/smartdns": {
"version": "3.0.8",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdns/-/smartdns-3.0.8.tgz",
"integrity": "sha512-f6cyO3FOnUJQTjHUjcePP6xMDytjk4DrmRDpqooQtMipTf8t0R25Yvg7GooSdWiBJDrIXHrXVu+oq82L5mFuUQ==",
"requires": {
"@pushrocks/smartdelay": "^2.0.2",
"@pushrocks/smartpromise": "^2.0.5"
}
},
"@pushrocks/smartevent": {
"version": "2.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.3.tgz",

View File

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

View File

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

View File

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

View File

@ -1,8 +1,9 @@
// @pushrocks scope
import * as smartpromise from '@pushrocks/smartpromise';
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
import * as acme from 'acme-client';