This commit is contained in:
AJ ONeal 2016-08-05 04:10:33 -04:00
parent d5ab9de773
commit 11f38bee5c
3 changed files with 62 additions and 16 deletions

View File

@ -39,8 +39,8 @@ Exposed Methods
For ACME Challenge:
* `setChallange(opts, domain, key, val, done)`
* `getChallange(domain, key, done)`
* `removeChallange(domain, key, done)`
* `getChallange(opts, domain, key, done)`
* `removeChallange(opts, domain, key, done)`
For node-letsencrypt internals:

View File

@ -3,17 +3,38 @@
var fs = require('fs');
var path = require('path');
module.exports.agreeToTerms = function (args, agreeCb) {
agreeCb(null, args.agreeTos);
var defaults = {
webrootPath: '~/letsencrypt/var/lib'
, debug: false
};
module.exports.setChallenge = function (args, domain, challengePath, keyAuthorization, done) {
//var hostname = args.domains[0];
var Challenger = module.exports;
Challenger.create = function (options) {
var results = {};
Object.keys(Challenger).forEach(function (key) {
results[key] = Challenger[key];
});
results._options = options;
Object.keys(defaults).forEach(function (key) {
if (!(key in options)) {
options[key] = defaults[key];
}
});
results.getOptions = function () {
return results._options;
};
return results;
};
Challenger.setChallenge = function (args, domain, challengePath, keyAuthorization, done) {
var mkdirp = require('mkdirp');
// TODO should be args.webrootPath
//console.log('args.webrootPath, challengePath');
//console.log(args.webrootPath, challengePath);
mkdirp(args.webrootPath, function (err) {
if (err) {
done(err);
@ -26,15 +47,10 @@ module.exports.setChallenge = function (args, domain, challengePath, keyAuthoriz
});
};
module.exports.getChallenge = function (args, domain, key, done) {
//var hostname = args.domains[0];
//console.log("getting the challenge", args, key);
Challenger.getChallenge = function (args, domain, key, done) {
fs.readFile(path.join(args.webrootPath, key), 'utf8', done);
};
module.exports.removeChallenge = function (args, domain, key, done) {
//var hostname = args.domains[0];
Challenger.removeChallenge = function (args, domain, key, done) {
fs.unlink(path.join(args.webrootPath, key), done);
};

30
package.json Normal file
View File

@ -0,0 +1,30 @@
{
"name": "le-challenge-fs",
"version": "2.0.0",
"description": "A fs-based strategy for node-letsencrypt for setting, retrieving, and clearing ACME challenges issued by the ACME server",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Daplie/le-challenge-fs.git"
},
"keywords": [
"le",
"letsencrypt",
"le-challenge",
"le-challenge-",
"acme",
"challenge",
"fs",
"cluster",
"ephemeral"
],
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
"license": "(MIT OR Apache-2.0)",
"bugs": {
"url": "https://github.com/Daplie/le-challenge-fs/issues"
},
"homepage": "https://github.com/Daplie/le-challenge-fs#readme"
}