almost there
This commit is contained in:
parent
56736c4f98
commit
ae91c08dd1
27
lib/core.js
27
lib/core.js
|
@ -1,16 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
var LE = require('../');
|
||||
var ipc = {}; // in-process cache
|
||||
|
||||
module.exports.create = function (defaults, handlers, backend) {
|
||||
var backendDefaults = backend.getDefaults && backend.getDefaults || backend.defaults || {};
|
||||
|
||||
defaults.server = defaults.server || LE.liveServer;
|
||||
handlers.merge = require('./common').merge;
|
||||
handlers.tplCopy = require('./common').tplCopy;
|
||||
|
||||
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');
|
||||
|
@ -28,8 +20,6 @@ module.exports.create = function (defaults, handlers, backend) {
|
|||
}
|
||||
|
||||
function createAccount(args, handlers) {
|
||||
args.rsaKeySize = args.rsaKeySize || 2048;
|
||||
|
||||
return RSA.generateKeypairAsync(args.rsaKeySize, 65537, { public: true, pem: true }).then(function (keypair) {
|
||||
|
||||
return LeCore.registerNewAccountAsync({
|
||||
|
@ -73,21 +63,19 @@ module.exports.create = function (defaults, handlers, backend) {
|
|||
var now = Date.now();
|
||||
|
||||
// TODO check response header on request for cache time
|
||||
if ((now - ipc.acmeUrlsUpdatedAt) < 10 * 60 * 1000) {
|
||||
return PromiseA.resolve(ipc.acmeUrls);
|
||||
if ((now - le._ipc.acmeUrlsUpdatedAt) < 10 * 60 * 1000) {
|
||||
return PromiseA.resolve(le._ipc.acmeUrls);
|
||||
}
|
||||
|
||||
return LeCore.getAcmeUrlsAsync(args.server).then(function (data) {
|
||||
ipc.acmeUrlsUpdatedAt = Date.now();
|
||||
ipc.acmeUrls = data;
|
||||
le._ipc.acmeUrlsUpdatedAt = Date.now();
|
||||
le._ipc.acmeUrls = data;
|
||||
|
||||
return ipc.acmeUrls;
|
||||
return le._ipc.acmeUrls;
|
||||
});
|
||||
}
|
||||
|
||||
function getCertificateAsync(args, defaults, handlers) {
|
||||
args.rsaKeySize = args.rsaKeySize || 2048;
|
||||
args.challengeType = args.challengeType || 'http-01';
|
||||
|
||||
function log() {
|
||||
if (args.debug || defaults.debug) {
|
||||
|
@ -223,7 +211,6 @@ module.exports.create = function (defaults, handlers, backend) {
|
|||
|
||||
var wrapped = {
|
||||
registerAsync: function (args) {
|
||||
var utils = require('./lib/common');
|
||||
var err;
|
||||
|
||||
if (!Array.isArray(args.domains)) {
|
||||
|
|
Loading…
Reference in New Issue