make shim of letiny-core possible #37

This commit is contained in:
AJ ONeal 2016-08-08 11:21:33 -04:00
parent 635b130ab3
commit 3590842ce8
2 changed files with 20 additions and 8 deletions

View File

@ -24,7 +24,8 @@ Object.keys(LE.defaults).forEach(function (key) {
// show all possible options
var u; // undefined
LE._undefined = {
store: u
acme: u
, store: u
, challenger: u
, register: u
, check: u
@ -49,6 +50,7 @@ LE._undefine = function (le) {
LE.create = function (le) {
var PromiseA = require('bluebird');
le.acme = le.acme || leCore;
le.store = le.store || require('le-store-certbot').create({ debug: le.debug });
le.challenger = le.challenger || require('le-store-certbot').create({ debug: le.debug });
le.core = require('./lib/core');
@ -72,13 +74,24 @@ LE.create = function (le) {
le.server = LE.productionServerUrl;
}
if (le.acme.create) {
le.acme = le.acme.create(le);
}
le.acme = PromiseA.promisifyAll(le.acme);
le._acmeOpts = le.acme.getOptions();
Object.keys(le._acmeOpts).forEach(function (key) {
if (!(key in le)) {
le[key] = le._acmeOpts[key];
}
});
if (le.store.create) {
le.store = le.store.create(le);
}
le.store = PromiseA.promisifyAll(le.store);
le._storeOpts = le.store.getOptions();
Object.keys(le._storeOpts).forEach(function (key) {
if (!(key in le._storeOpts)) {
if (!(key in le)) {
le[key] = le._storeOpts[key];
}
});
@ -88,8 +101,8 @@ LE.create = function (le) {
}
le.challenger = PromiseA.promisifyAll(le.challenger);
le._challengerOpts = le.challenger.getOptions();
Object.keys(le._storeOpts).forEach(function (key) {
if (!(key in le._challengerOpts)) {
Object.keys(le._challengerOpts).forEach(function (key) {
if (!(key in le)) {
le[key] = le._challengerOpts[key];
}
});

View File

@ -4,7 +4,6 @@ module.exports.create = function (le) {
var PromiseA = require('bluebird');
var utils = require('./utils'); // merge, tplCopy;
var RSA = PromiseA.promisifyAll(require('rsa-compat').RSA);
var LeCore = PromiseA.promisifyAll(require('letiny-core'));
var crypto = require('crypto');
var core = {
@ -19,7 +18,7 @@ module.exports.create = function (le) {
return PromiseA.resolve(le._ipc.acmeUrls);
}
return LeCore.getAcmeUrlsAsync(args.server).then(function (data) {
return le.acme.getAcmeUrlsAsync(args.server).then(function (data) {
le._ipc.acmeUrlsUpdatedAt = Date.now();
le._ipc.acmeUrls = data;
@ -39,7 +38,7 @@ module.exports.create = function (le) {
registerAsync: function (args) {
return RSA.generateKeypairAsync(args.rsaKeySize, 65537, { public: true, pem: true }).then(function (keypair) {
return LeCore.registerNewAccountAsync({
return le.acme.registerNewAccountAsync({
email: args.email
, newRegUrl: args._acmeUrls.newReg
, agreeToTerms: function (tosUrl, agreeCb) {
@ -151,7 +150,7 @@ module.exports.create = function (le) {
args.domainKeypair = domainKeypair;
//args.registration = domainKey;
return LeCore.getCertificateAsync({
return le.acme.getCertificateAsync({
debug: args.debug || le.debug
, newAuthzUrl: args._acmeUrls.newAuthz