2017-01-14 13:14:50 +00:00
|
|
|
"use strict";
|
2017-01-14 17:36:33 +00:00
|
|
|
const q = require("q");
|
|
|
|
/**
|
|
|
|
* class AcmeAccount represents an AcmeAccount
|
|
|
|
*/
|
2017-01-14 13:14:50 +00:00
|
|
|
class AcmeAccount {
|
2017-01-14 17:36:33 +00:00
|
|
|
constructor(smartAcmeParentArg) {
|
|
|
|
this.parentSmartAcme = smartAcmeParentArg;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* register the account with letsencrypt
|
|
|
|
*/
|
|
|
|
register() {
|
|
|
|
let done = q.defer();
|
|
|
|
this.parentSmartAcme.rawacmeClient.newReg({
|
|
|
|
contact: ['mailto:domains@lossless.org']
|
|
|
|
}, (err, res) => {
|
|
|
|
if (err) {
|
|
|
|
console.error('smartacme: something went wrong:');
|
|
|
|
console.log(err);
|
|
|
|
done.reject(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.JWK = res.body.key;
|
|
|
|
this.link = res.headers.link;
|
|
|
|
console.log(this.link);
|
|
|
|
this.location = res.headers.location;
|
|
|
|
done.resolve();
|
|
|
|
});
|
|
|
|
return done.promise;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* agree to letsencrypr terms of service
|
|
|
|
*/
|
|
|
|
agreeTos() {
|
|
|
|
let done = q.defer();
|
|
|
|
let tosPart = this.link.split(',')[1];
|
|
|
|
let tosLinkPortion = tosPart.split(';')[0];
|
|
|
|
let url = tosLinkPortion.split(';')[0].trim().replace(/[<>]/g, '');
|
|
|
|
this.parentSmartAcme.rawacmeClient.post(this.location, { Agreement: url, resource: 'reg' }, (err, res) => {
|
|
|
|
if (err) {
|
|
|
|
console.log(err);
|
|
|
|
done.reject(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
done.resolve();
|
|
|
|
});
|
|
|
|
return done.promise;
|
|
|
|
}
|
|
|
|
createAcmeCert(domainNameArg) {
|
|
|
|
}
|
2017-01-14 13:14:50 +00:00
|
|
|
}
|
|
|
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