2019-07-23 05:31:48 +00:00
|
|
|
'use strict';
|
|
|
|
|
2019-07-31 05:58:48 +00:00
|
|
|
var defaults = {};
|
2019-10-29 04:57:05 +00:00
|
|
|
var _memdb = {};
|
2019-07-23 05:31:48 +00:00
|
|
|
|
|
|
|
module.exports.create = function(config) {
|
2019-10-29 04:57:05 +00:00
|
|
|
var memdb = config.cache || _memdb;
|
2019-07-31 05:37:03 +00:00
|
|
|
|
2019-07-23 05:31:48 +00:00
|
|
|
return {
|
|
|
|
init: function(opts) {
|
2019-07-31 05:37:03 +00:00
|
|
|
//request = opts.request;
|
2019-10-29 04:57:05 +00:00
|
|
|
return Promise.resolve(null);
|
2019-07-23 05:31:48 +00:00
|
|
|
},
|
2019-07-31 03:46:43 +00:00
|
|
|
|
2019-07-23 05:31:48 +00:00
|
|
|
set: function(data) {
|
2019-10-29 04:57:05 +00:00
|
|
|
return Promise.resolve().then(function() {
|
|
|
|
// console.log('Add Key Auth URL', data);
|
2019-07-31 05:37:03 +00:00
|
|
|
|
2019-10-29 04:57:05 +00:00
|
|
|
var ch = data.challenge;
|
|
|
|
var key = ch.identifier.value + '#' + ch.token;
|
|
|
|
memdb[key] = ch.keyAuthorization;
|
2019-07-31 05:37:03 +00:00
|
|
|
|
2019-10-29 04:57:05 +00:00
|
|
|
return null;
|
|
|
|
});
|
2019-07-23 05:31:48 +00:00
|
|
|
},
|
2019-07-31 03:46:43 +00:00
|
|
|
|
2019-07-31 05:37:03 +00:00
|
|
|
get: function(data) {
|
2019-10-29 04:57:05 +00:00
|
|
|
return Promise.resolve().then(function() {
|
|
|
|
// console.log('List Key Auth URL', data);
|
2019-07-31 05:37:03 +00:00
|
|
|
|
2019-10-29 04:57:05 +00:00
|
|
|
var ch = data.challenge;
|
|
|
|
var key = ch.identifier.value + '#' + ch.token;
|
2019-07-31 05:37:03 +00:00
|
|
|
|
2019-10-29 04:57:05 +00:00
|
|
|
if (memdb[key]) {
|
|
|
|
return { keyAuthorization: memdb[key] };
|
|
|
|
}
|
2019-07-31 05:58:48 +00:00
|
|
|
|
2019-10-29 04:57:05 +00:00
|
|
|
return null;
|
|
|
|
});
|
2019-07-23 05:31:48 +00:00
|
|
|
},
|
2019-07-31 03:46:43 +00:00
|
|
|
|
2019-07-31 05:37:03 +00:00
|
|
|
remove: function(data) {
|
2019-10-29 04:57:05 +00:00
|
|
|
return Promise.resolve().then(function() {
|
|
|
|
// console.log('Remove Key Auth URL', data);
|
2019-07-31 05:37:03 +00:00
|
|
|
|
2019-10-29 04:57:05 +00:00
|
|
|
var ch = data.challenge;
|
|
|
|
var key = ch.identifier.value + '#' + ch.token;
|
2019-07-31 05:37:03 +00:00
|
|
|
|
2019-10-29 04:57:05 +00:00
|
|
|
delete memdb[key];
|
|
|
|
return null;
|
|
|
|
});
|
2019-07-23 05:31:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|