| 
									
										
										
										
											2015-12-16 12:27:23 +00:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-09 22:39:39 -04:00
										 |  |  | module.exports.create = function (defaults) { | 
					
						
							| 
									
										
										
										
											2015-12-16 12:51:14 +00:00
										 |  |  |   var handlers =  { | 
					
						
							| 
									
										
										
										
											2016-08-09 22:39:39 -04:00
										 |  |  |     getOptions: function () { | 
					
						
							|  |  |  |       return defaults; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-12-16 12:42:04 +00:00
										 |  |  |     //
 | 
					
						
							|  |  |  |     // set,get,remove challenges
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // Note: this is fine for a one-off CLI tool
 | 
					
						
							|  |  |  |     // but a webserver using node-cluster or multiple
 | 
					
						
							|  |  |  |     // servers should use a database of some sort
 | 
					
						
							| 
									
										
										
										
											2016-08-09 22:39:39 -04:00
										 |  |  |   , _challenges: {} | 
					
						
							|  |  |  |   , set: function (args, domain, token, secret, cb) { | 
					
						
							|  |  |  |       console.log('bloh 1'); | 
					
						
							|  |  |  |       handlers._challenges[token] = secret; | 
					
						
							| 
									
										
										
										
											2015-12-16 12:42:04 +00:00
										 |  |  |       cb(null); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-08-09 22:39:39 -04:00
										 |  |  |   , get: function (args, domain, token, cb) { | 
					
						
							|  |  |  |       console.log('bloh 2'); | 
					
						
							| 
									
										
										
										
											2015-12-16 12:42:04 +00:00
										 |  |  |       // TODO keep in mind that, generally get args are just args.domains
 | 
					
						
							|  |  |  |       // and it is disconnected from the flow of setChallenge and removeChallenge
 | 
					
						
							| 
									
										
										
										
											2016-08-09 22:39:39 -04:00
										 |  |  |       cb(null, handlers._challenges[token]); | 
					
						
							| 
									
										
										
										
											2015-12-16 12:27:23 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-08-09 22:39:39 -04:00
										 |  |  |   , remove: function (args, domain, token, cb) { | 
					
						
							|  |  |  |       console.log('balh 3'); | 
					
						
							|  |  |  |       delete handlers._challenges[token]; | 
					
						
							| 
									
										
										
										
											2015-12-16 12:42:04 +00:00
										 |  |  |       cb(null); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2015-12-16 12:51:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return handlers; | 
					
						
							| 
									
										
										
										
											2015-12-16 12:27:23 +00:00
										 |  |  | }; |