greenlock-cli.js/lib/standalone.js

33 lines
875 B
JavaScript
Raw Normal View History

2015-12-16 12:27:23 +00:00
'use strict';
2016-08-10 02:39:39 +00:00
module.exports.create = function (defaults) {
2015-12-16 12:51:14 +00:00
var handlers = {
2016-08-10 02:39:39 +00:00
getOptions: function () {
return defaults;
}
2015-12-16 12:42:04 +00:00
//
// set,get,remove challenges
//
// Note: this is fine for a one-off CLI tool
// but a webserver using node-cluster or multiple
// servers should use a database of some sort
2016-08-10 02:39:39 +00:00
, _challenges: {}
, set: function (args, domain, token, secret, cb) {
handlers._challenges[token] = secret;
2015-12-16 12:42:04 +00:00
cb(null);
}
2016-08-10 02:39:39 +00:00
, get: function (args, domain, token, cb) {
2015-12-16 12:42:04 +00:00
// TODO keep in mind that, generally get args are just args.domains
// and it is disconnected from the flow of setChallenge and removeChallenge
2016-08-10 02:39:39 +00:00
cb(null, handlers._challenges[token]);
2015-12-16 12:27:23 +00:00
}
2016-08-10 02:39:39 +00:00
, remove: function (args, domain, token, cb) {
delete handlers._challenges[token];
2015-12-16 12:42:04 +00:00
cb(null);
}
};
2015-12-16 12:51:14 +00:00
return handlers;
2015-12-16 12:27:23 +00:00
};