index.js
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict';
var defaults = {};
var _memdb = {};
module.exports.create = function(config) {
var memdb = config.cache || _memdb;
return {
init: function(opts) {
//request = opts.request;
return Promise.resolve(null);
},
set: function(data) {
return Promise.resolve().then(function() {
// 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) {
return Promise.resolve().then(function() {
// 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) {
return Promise.resolve().then(function() {
// console.log('Remove Key Auth URL', data);
var ch = data.challenge;
var key = ch.identifier.value + '#' + ch.token;
delete memdb[key];
return null;
});
}
};
};