greenlock.js-ARCHIVED/lib/default-handlers.js

38 lines
928 B
JavaScript
Raw Normal View History

2015-12-15 11:51:41 +00:00
'use strict';
2015-12-15 12:01:05 +00:00
var fs = require('fs');
var path = require('path');
2015-12-15 11:51:41 +00:00
module.exports.agreeToTerms = function (args, agree) {
2015-12-15 13:13:52 +00:00
agree(null, args.agreeTos);
2015-12-15 12:01:05 +00:00
};
module.exports.setChallenge = function (args, challengePath, keyAuthorization, done) {
//var hostname = args.domains[0];
var mkdirp = require('mkdirp');
// TODO should be args.webrootPath
mkdirp(path.join(args.webrootPath, challengePath), function (err) {
if (err) {
done(err);
return;
}
fs.writeFile(path.join(args.webrootPath, challengePath), keyAuthorization, 'utf8', function (err) {
done(err);
});
});
};
module.exports.getChallenge = function (args, key, done) {
//var hostname = args.domains[0];
fs.readFile(path.join(args.webroot, key), 'utf8', done);
};
module.exports.removeChallenge = function (args, key, done) {
//var hostname = args.domains[0];
fs.unlinkSync(path.join(args.webroot, key), done);
2015-12-15 11:51:41 +00:00
};