"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // third party modules const q = require("smartq"); // 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); }); return done.promise; } } exports.SmartAcme = SmartAcme; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsc0JBQXNCO0FBQ3RCLDRCQUEyQixDQUFDLFdBQVc7QUFDdkMsK0NBQThDO0F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