acme-http-01-standalone.js/lib/index.js

50 lines
883 B
JavaScript

'use strict';
//var request;
var defaults = {};
module.exports.create = function(config) {
var memdb = config.cache || {};
return {
init: function(opts) {
//request = opts.request;
return null;
},
set: function(data) {
// console.log('Add Key Auth URL', data);
var ch = data.challenge;
var key = ch.identifier.value + '#' + ch.token;
memdb[key] = ch.keyAuthorization;
return null;
},
get: function(data) {
// console.log('List Key Auth URL', data);
var ch = data.challenge;
var key = ch.identifier.value + '#' + ch.token;
if (memdb[key]) {
return { keyAuthorization: memdb[key] };
}
return null;
},
remove: function(data) {
// console.log('Remove Key Auth URL', data);
var ch = data.challenge;
var key = ch.identifier.value + '#' + ch.token;
delete memdb[key];
return null;
}
};
};