60 lines
4.0 KiB
JavaScript
60 lines
4.0 KiB
JavaScript
"use strict";
|
|
require("typings-global");
|
|
const q = require("q");
|
|
let rsaKeygen = require('rsa-keygen');
|
|
let rawacme = require('rawacme');
|
|
const smartacme_classes_helper_1 = require("./smartacme.classes.helper");
|
|
/**
|
|
* class SmartAcme exports methods for maintaining SSL Certificates
|
|
*/
|
|
class SmartAcme {
|
|
/**
|
|
* the constructor for class SmartAcme
|
|
*/
|
|
constructor(productionArg = false) {
|
|
this.productionBool = productionArg;
|
|
this.helper = new smartacme_classes_helper_1.SmartacmeHelper();
|
|
this.keyPair = this.helper.createKeypair();
|
|
if (this.productionBool) {
|
|
this.acmeUrl = rawacme.LETSENCRYPT_STAGING_URL;
|
|
}
|
|
else {
|
|
this.acmeUrl = rawacme.LETSENCRYPT_URL;
|
|
}
|
|
}
|
|
/**
|
|
* creates an account if not currently present in module
|
|
* @executes ASYNC
|
|
*/
|
|
createAccount() {
|
|
let done = q.defer();
|
|
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;
|
|
}
|
|
client.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;
|
|
console.log(this.JWK);
|
|
done.resolve();
|
|
});
|
|
});
|
|
return done.promise;
|
|
}
|
|
}
|
|
exports.SmartAcme = SmartAcme;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLmNsYXNzZXMuc21hcnRhY21lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRhY21lLmNsYXNzZXMu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