| 
									
										
										
										
											2017-03-20 23:29:03 -06:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var fs = require('fs'); | 
					
						
							|  |  |  | var path = require('path'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = { | 
					
						
							|  |  |  |   directives: { | 
					
						
							| 
									
										
										
										
											2017-03-22 09:48:04 -06:00
										 |  |  |     get: function (providerUri) { | 
					
						
							| 
									
										
										
										
											2017-03-20 23:29:03 -06:00
										 |  |  |       // TODO make safe
 | 
					
						
							|  |  |  |       try { | 
					
						
							|  |  |  |         return require(path.join(process.cwd(), providerUri + '.directives.json')); | 
					
						
							|  |  |  |       } catch(e) { | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-03-22 09:48:04 -06:00
										 |  |  |   , set: function (providerUri, directives) { | 
					
						
							| 
									
										
										
										
											2017-03-20 23:29:03 -06:00
										 |  |  |       fs.writeFileSync(path.join(process.cwd(), providerUri + '.directives.json'), JSON.stringify(directives, null, 2)); | 
					
						
							|  |  |  |       return directives; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-03-21 01:02:41 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-22 09:48:04 -06:00
										 |  |  | , sessions: { | 
					
						
							|  |  |  |     get: function (providerUri, id) { | 
					
						
							| 
									
										
										
										
											2017-03-21 01:02:41 -06:00
										 |  |  |       // TODO make safe
 | 
					
						
							|  |  |  |       try { | 
					
						
							| 
									
										
										
										
											2017-03-22 09:48:04 -06:00
										 |  |  |         if (id) { | 
					
						
							|  |  |  |           return require(path.join(process.cwd(), providerUri + '.' + id + '.session.json')); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |           return require(path.join(process.cwd(), providerUri + '.session.json')); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-03-21 01:02:41 -06:00
										 |  |  |       } catch(e) { | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-03-22 09:48:04 -06:00
										 |  |  |   , set: function (providerUri, session, id) { | 
					
						
							|  |  |  |       if (id) { | 
					
						
							|  |  |  |         fs.writeFileSync(path.join(process.cwd(), providerUri + '.' + id + '.session.json'), JSON.stringify(session, null, 2)); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							|  |  |  |         fs.writeFileSync(path.join(process.cwd(), providerUri + '.session.json'), JSON.stringify(session, null, 2)); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-03-21 01:02:41 -06:00
										 |  |  |       return session; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-03-20 23:29:03 -06:00
										 |  |  | }; |