make shim of letiny-core possible #37
This commit is contained in:
parent
635b130ab3
commit
3590842ce8
21
index.js
21
index.js
|
@ -24,7 +24,8 @@ Object.keys(LE.defaults).forEach(function (key) {
|
||||||
// show all possible options
|
// show all possible options
|
||||||
var u; // undefined
|
var u; // undefined
|
||||||
LE._undefined = {
|
LE._undefined = {
|
||||||
store: u
|
acme: u
|
||||||
|
, store: u
|
||||||
, challenger: u
|
, challenger: u
|
||||||
, register: u
|
, register: u
|
||||||
, check: u
|
, check: u
|
||||||
|
@ -49,6 +50,7 @@ LE._undefine = function (le) {
|
||||||
LE.create = function (le) {
|
LE.create = function (le) {
|
||||||
var PromiseA = require('bluebird');
|
var PromiseA = require('bluebird');
|
||||||
|
|
||||||
|
le.acme = le.acme || leCore;
|
||||||
le.store = le.store || require('le-store-certbot').create({ debug: le.debug });
|
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.challenger = le.challenger || require('le-store-certbot').create({ debug: le.debug });
|
||||||
le.core = require('./lib/core');
|
le.core = require('./lib/core');
|
||||||
|
@ -72,13 +74,24 @@ LE.create = function (le) {
|
||||||
le.server = LE.productionServerUrl;
|
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) {
|
if (le.store.create) {
|
||||||
le.store = le.store.create(le);
|
le.store = le.store.create(le);
|
||||||
}
|
}
|
||||||
le.store = PromiseA.promisifyAll(le.store);
|
le.store = PromiseA.promisifyAll(le.store);
|
||||||
le._storeOpts = le.store.getOptions();
|
le._storeOpts = le.store.getOptions();
|
||||||
Object.keys(le._storeOpts).forEach(function (key) {
|
Object.keys(le._storeOpts).forEach(function (key) {
|
||||||
if (!(key in le._storeOpts)) {
|
if (!(key in le)) {
|
||||||
le[key] = le._storeOpts[key];
|
le[key] = le._storeOpts[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -88,8 +101,8 @@ LE.create = function (le) {
|
||||||
}
|
}
|
||||||
le.challenger = PromiseA.promisifyAll(le.challenger);
|
le.challenger = PromiseA.promisifyAll(le.challenger);
|
||||||
le._challengerOpts = le.challenger.getOptions();
|
le._challengerOpts = le.challenger.getOptions();
|
||||||
Object.keys(le._storeOpts).forEach(function (key) {
|
Object.keys(le._challengerOpts).forEach(function (key) {
|
||||||
if (!(key in le._challengerOpts)) {
|
if (!(key in le)) {
|
||||||
le[key] = le._challengerOpts[key];
|
le[key] = le._challengerOpts[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,6 @@ module.exports.create = function (le) {
|
||||||
var PromiseA = require('bluebird');
|
var PromiseA = require('bluebird');
|
||||||
var utils = require('./utils'); // merge, tplCopy;
|
var utils = require('./utils'); // merge, tplCopy;
|
||||||
var RSA = PromiseA.promisifyAll(require('rsa-compat').RSA);
|
var RSA = PromiseA.promisifyAll(require('rsa-compat').RSA);
|
||||||
var LeCore = PromiseA.promisifyAll(require('letiny-core'));
|
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
|
|
||||||
var core = {
|
var core = {
|
||||||
|
@ -19,7 +18,7 @@ module.exports.create = function (le) {
|
||||||
return PromiseA.resolve(le._ipc.acmeUrls);
|
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.acmeUrlsUpdatedAt = Date.now();
|
||||||
le._ipc.acmeUrls = data;
|
le._ipc.acmeUrls = data;
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ module.exports.create = function (le) {
|
||||||
registerAsync: function (args) {
|
registerAsync: function (args) {
|
||||||
return RSA.generateKeypairAsync(args.rsaKeySize, 65537, { public: true, pem: true }).then(function (keypair) {
|
return RSA.generateKeypairAsync(args.rsaKeySize, 65537, { public: true, pem: true }).then(function (keypair) {
|
||||||
|
|
||||||
return LeCore.registerNewAccountAsync({
|
return le.acme.registerNewAccountAsync({
|
||||||
email: args.email
|
email: args.email
|
||||||
, newRegUrl: args._acmeUrls.newReg
|
, newRegUrl: args._acmeUrls.newReg
|
||||||
, agreeToTerms: function (tosUrl, agreeCb) {
|
, agreeToTerms: function (tosUrl, agreeCb) {
|
||||||
|
@ -151,7 +150,7 @@ module.exports.create = function (le) {
|
||||||
args.domainKeypair = domainKeypair;
|
args.domainKeypair = domainKeypair;
|
||||||
//args.registration = domainKey;
|
//args.registration = domainKey;
|
||||||
|
|
||||||
return LeCore.getCertificateAsync({
|
return le.acme.getCertificateAsync({
|
||||||
debug: args.debug || le.debug
|
debug: args.debug || le.debug
|
||||||
|
|
||||||
, newAuthzUrl: args._acmeUrls.newAuthz
|
, newAuthzUrl: args._acmeUrls.newAuthz
|
||||||
|
|
Loading…
Reference in New Issue