66 lines
4.2 KiB
JavaScript
66 lines
4.2 KiB
JavaScript
"use strict";
|
|
// third party modules
|
|
const q = require("q"); // promises
|
|
const plugins = require("./smartacme.plugins");
|
|
const helpers = require("./smartacme.helpers");
|
|
const smartacme_classes_acmeaccount_1 = require("./smartacme.classes.acmeaccount");
|
|
var smartacme_classes_acmeaccount_2 = require("./smartacme.classes.acmeaccount");
|
|
exports.AcmeAccount = smartacme_classes_acmeaccount_2.AcmeAccount;
|
|
var smartacme_classes_acmecert_1 = require("./smartacme.classes.acmecert");
|
|
exports.AcmeCert = smartacme_classes_acmecert_1.AcmeCert;
|
|
/**
|
|
* class SmartAcme exports methods for maintaining SSL Certificates
|
|
*/
|
|
class SmartAcme {
|
|
/**
|
|
* the constructor for class SmartAcme
|
|
*/
|
|
constructor(productionArg = false) {
|
|
this.productionBool = productionArg;
|
|
this.keyPair = helpers.createKeypair();
|
|
if (this.productionBool) {
|
|
this.acmeUrl = plugins.rawacme.LETSENCRYPT_URL;
|
|
}
|
|
else {
|
|
this.acmeUrl = plugins.rawacme.LETSENCRYPT_STAGING_URL;
|
|
}
|
|
}
|
|
/**
|
|
* init the smartacme instance
|
|
*/
|
|
init() {
|
|
let done = q.defer();
|
|
plugins.rawacme.createClient({
|
|
url: this.acmeUrl,
|
|
publicKey: this.keyPair.publicKey,
|
|
privateKey: this.keyPair.privateKey
|
|
}, (err, client) => {
|
|
if (err) {
|
|
console.error('smartacme: something went wrong:');
|
|
console.log(err);
|
|
done.reject(err);
|
|
return;
|
|
}
|
|
// make client available in class
|
|
this.rawacmeClient = client;
|
|
done.resolve();
|
|
});
|
|
return done.promise;
|
|
}
|
|
/**
|
|
* creates an account if not currently present in module
|
|
* @executes ASYNC
|
|
*/
|
|
createAcmeAccount() {
|
|
let done = q.defer();
|
|
let acmeAccount = new smartacme_classes_acmeaccount_1.AcmeAccount(this);
|
|
acmeAccount.register().then(() => {
|
|
return acmeAccount.agreeTos();
|
|
}).then(() => {
|
|
done.resolve(acmeAccount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