getting pretty close

This commit is contained in:
AJ ONeal 2016-08-05 18:16:29 -04:00
parent 5ff91ec37e
commit 63b9cb5ec9
1 changed files with 75 additions and 51 deletions

126
index.js
View File

@ -23,58 +23,82 @@ Object.keys(LE.defaults).forEach(function (key) {
LE[key] = LE.defaults[key]; LE[key] = LE.defaults[key];
}); });
LE.create = function (defaults, handlers, backend) { var u; // undefined
var Core = require('./lib/core'); LE._undefined = {
var core; store: u
if (!backend) { backend = require('./lib/pycompat'); } , challenger: u
if (!handlers) { handlers = {}; } , register: u
if (!handlers.renewWithin) { handlers.renewWithin = 3 * 24 * 60 * 60 * 1000; } , check: u
if (!handlers.memorizeFor) { handlers.memorizeFor = 1 * 24 * 60 * 60 * 1000; } , renewWithin: u
if (!handlers.sniRegisterCallback) { , memorizeFor: u
handlers.sniRegisterCallback = function (args, cache, cb) { , acmeChallengePrefix: u
// TODO when we have ECDSA, just do this automatically };
cb(null, null); LE._undefine = function (le) {
}; Object.keys(LE._undefined).forEach(function (key) {
} if (!(key in le)) {
le[key] = u;
if (backend.create) {
backend = backend.create(defaults);
}
backend = PromiseA.promisifyAll(backend);
core = Core.create(defaults, handlers, backend);
var le = {
backend: backend
, core: core
// register
, create: function (args, cb) {
return core.registerAsync(args).then(function (pems) {
cb(null, pems);
}, cb);
} }
// fetch });
, domain: function (args, cb) {
// TODO must return email, domains, tos, pems return le;
return core.fetchAsync(args).then(function (certInfo) { };
cb(null, certInfo); LE.create = function (le) {
}, cb); le = LE._undefine(le);
} var store = le.store || require('le-store-certbot').create({ debug: le.debug });
, domains: function (args, cb) { var challenger = le.challenge || require('le-store-certbot').create({ debug: le.debug });
// TODO show all domains or limit by account var core = le.core = require('./lib/core');
throw new Error('not implemented');
} le.acmeChallengePrefix = LE.acmeChallengePrefix;
, accounts: function (args, cb) {
// TODO show all accounts or limit by domain if (!le.renewWithin) { le.renewWithin = 3 * 24 * 60 * 60 * 1000; }
throw new Error('not implemented'); if (!le.memorizeFor) { le.memorizeFor = 1 * 24 * 60 * 60 * 1000; }
}
, account: function (args, cb) { if (!le.server) {
// TODO return one account throw new Error("opts.server must be set to 'staging' or a production url, such as LE.productionServerUrl'");
throw new Error('not implemented'); }
} if ('staging' === le.server) {
}; le.server = LE.stagingServerUrl;
}
// exists else if ('production' === le.server) {
// get le.server = LE.productionServerUrl;
}
if (store.create) {
store = store.create(le);
}
store = PromiseA.promisifyAll(store);
le._storeOpts = store.getOptions();
Object.keys(le._storeOpts).forEach(function (key) {
if (!(key in le._storeOpts)) {
le[key] = le._storeOpts[key];
}
});
if (challenger.create) {
challenger = challenger.create(le);
}
challenger = PromiseA.promisifyAll(challenger);
le._challengerOpts = challenger.getOptions();
Object.keys(le._storeOpts).forEach(function (key) {
if (!(key in le._challengerOpts)) {
le[key] = le._challengerOpts[key];
}
});
core = le.core = core.create(le);
le.register = function (args) {
return core.registerAsync(args);
};
le.check = function (args) {
// TODO must return email, domains, tos, pems
return core.fetchAsync(args);
};
le.middleware = function () {
return require('./lib/middleware')(le);
};
return le; return le;
}; };