smartacme/dist/smartacme.classes.acmeaccount.js

71 lines
5.2 KiB
JavaScript
Raw Normal View History

2017-01-14 13:14:50 +00:00
"use strict";
2017-01-14 17:36:33 +00:00
const q = require("q");
2017-01-15 11:21:29 +00:00
const smartacme_classes_acmecert_1 = require("./smartacme.classes.acmecert");
2017-01-14 17:36:33 +00:00
/**
* 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;
}
2017-01-15 11:21:29 +00:00
createAcmeCert(domainNameArg, countryArg = 'Germany', countryShortArg = 'DE', city = 'Bremen', companyArg = 'Some Company', companyShortArg = 'SC') {
let done = q.defer();
let acmeCert = new smartacme_classes_acmecert_1.AcmeCert({
bit: 2064,
key: null,
domain: domainNameArg,
country: countryArg,
country_short: countryShortArg,
locality: city,
organization: companyArg,
organization_short: companyShortArg,
password: null,
unstructured: null,
subject_alt_names: null
}, this);
done.resolve(acmeCert);
return done.promise;
2017-01-14 17:36:33 +00:00
}
2017-01-14 13:14:50 +00:00
}
exports.AcmeAccount = AcmeAccount;
2017-01-15 21:30:33 +00:00
//# sourceMapp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