smartacme/dist/smartacme.classes.acmeaccount.js
2017-04-28 18:56:55 +02:00

72 lines
5.3 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const q = require("smartq");
const smartacme_classes_acmecert_1 = require("./smartacme.classes.acmecert");
/**
* class AcmeAccount represents an AcmeAccount
*/
class AcmeAccount {
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, 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;
}
}
exports.AcmeAccount = AcmeAccount;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmNsYXNzZXMuYWNtZWFjY291bnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFjbWUuY2xhc3Nlcy5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