Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
ed4ba0cb61 | |||
a8ab27045d | |||
975c3ed190 | |||
a99dea549b |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartacme",
|
"name": "@pushrocks/smartacme",
|
||||||
"version": "2.0.4",
|
"version": "2.0.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartacme",
|
"name": "@pushrocks/smartacme",
|
||||||
"version": "2.0.4",
|
"version": "2.0.6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "acme implementation in TypeScript",
|
"description": "acme implementation in TypeScript",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -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();
|
||||||
|
@ -13,14 +13,14 @@ export class SmartAcme {
|
|||||||
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;
|
||||||
@ -49,25 +49,30 @@ export class SmartAcme {
|
|||||||
const authorizations = await this.client.getAuthorizations(order);
|
const authorizations = await this.client.getAuthorizations(order);
|
||||||
|
|
||||||
const promises = authorizations.map(async authz => {
|
const promises = authorizations.map(async authz => {
|
||||||
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);
|
||||||
|
|
||||||
/* 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);
|
||||||
}
|
}
|
||||||
@ -92,5 +97,5 @@ export class SmartAcme {
|
|||||||
console.log(`Certificate:\n${cert.toString()}`);
|
console.log(`Certificate:\n${cert.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
toStorageObject () {};
|
toStorageObject() {}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user