bug fixes
This commit is contained in:
		
							parent
							
								
									0aa6f28f85
								
							
						
					
					
						commit
						9071b0c048
					
				
							
								
								
									
										47
									
								
								lib/index.js
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								lib/index.js
									
									
									
									
									
								
							| @ -11,7 +11,7 @@ const PRODUCTION_URL = 'https://api.namecheap.com/xml.response'; | ||||
| 
 | ||||
| 
 | ||||
| var defaults = { | ||||
|     baseUrl: PRODUCTION_URL | ||||
|     baseUrl: SANDBOX_URL | ||||
| }; | ||||
| 
 | ||||
| function extend(obj) { | ||||
| @ -53,7 +53,9 @@ module.exports.create = function (config) { | ||||
|         assign(requestParams,params); | ||||
| 
 | ||||
|         var url = requestUrl(baseUrl, requestParams); | ||||
|         // console.log(url);
 | ||||
|         console.log('DEBUG >>> url: ' + url); | ||||
|         console.log('DEBUG >>> requestParams: ' + JSON.stringify(requestParams, null, 2)); | ||||
| 
 | ||||
|         return request({ | ||||
|             method: 'POST', | ||||
|             url: url, | ||||
| @ -64,7 +66,7 @@ module.exports.create = function (config) { | ||||
|                 // check response status
 | ||||
|                 if (result['ApiResponse']['$']['Status'] === 'ERROR') { | ||||
|                     for (let i = 0; i < result['ApiResponse']['Errors'].length; i++) { | ||||
|                         console.log(result['ApiResponse']['Errors'][i]) | ||||
|                         console.log('DEBUG >>> error: ' + JSON.stringify(result['ApiResponse']['Errors'][i]['Error'][0], null, 2)); | ||||
|                     } | ||||
|                     throw new Error('API Error'); | ||||
|                 } else { // Status="OK"
 | ||||
| @ -92,15 +94,29 @@ module.exports.create = function (config) { | ||||
|         }, | ||||
| 
 | ||||
|         set: function (data) { | ||||
|             console.log(`DEBUG >>> data: ${JSON.stringify(data, null, 2)}`); | ||||
|             var ch = data.challenge; | ||||
|             var txt = ch.dnsAuthorization; | ||||
| 
 | ||||
|             var params = {}; | ||||
|             var zone = ch.dnsZone; | ||||
|             // var zone = ch.dnsZone;
 | ||||
|             var zone = ch.identifier.value; | ||||
|             console.log(`DEBUG >>> zone: ${zone}`); | ||||
|              | ||||
|             // the domain is the first part
 | ||||
|             params['SLD'] = zone.split('.')[0]; | ||||
|             // params['SLD'] = zone.split('.')[0];
 | ||||
|             // the rest of the components are the TLD
 | ||||
|             params['TLD'] = zone.split('.').splice(1).join('.'); | ||||
|             // params['TLD'] = zone.split('.').splice(1).join('.');
 | ||||
| 
 | ||||
|             var domains = zone.split('.'); | ||||
|             console.log('DEBUG >>> ' + domains); | ||||
| 
 | ||||
|             // if you have subdomain foo.blah.com, SLD = blah and TLD = com
 | ||||
|             params['TLD'] = domains[domains.length - 1]; | ||||
|             params['SLD'] = domains[domains.length - 2]; | ||||
| 
 | ||||
|             console.log(`DEBUG >>> SLD: ${params['SLD']}`); | ||||
|             console.log(`DEBUG >>> TLD: ${params['TLD']}`); | ||||
| 
 | ||||
|             // setting a host record overwrites all existing,
 | ||||
|             // adding a new records means you've have to send back all previous records too
 | ||||
| @ -139,11 +155,11 @@ module.exports.create = function (config) { | ||||
|             var ch = data.challenge; | ||||
| 
 | ||||
|             var params = {}; | ||||
|             var zone = ch.dnsZone; | ||||
|             // the domain is the first part
 | ||||
|             params['SLD'] = zone.split('.')[0]; | ||||
|             // the rest of the components are the TLD
 | ||||
|             params['TLD'] = zone.split('.').splice(1).join('.'); | ||||
|             var zone = ch.identifier.value; | ||||
|             var domains = zone.split('.');   | ||||
|              | ||||
|             params['TLD'] = domains[domains.length - 1]; | ||||
|             params['SLD'] = domains[domains.length - 2]; | ||||
| 
 | ||||
|             // setting a host record overwrites all existing,
 | ||||
|             // removing a new records means you've have to send back all previous records without removed
 | ||||
| @ -176,12 +192,11 @@ module.exports.create = function (config) { | ||||
|             var ch = data.challenge; | ||||
| 
 | ||||
|             var params = {}; | ||||
|             var zone = ch.dnsZone; | ||||
|             var zone = ch.identifier.value; | ||||
|             var domains = zone.split('.');   | ||||
| 
 | ||||
|             // the domain is the first part
 | ||||
|             params['SLD'] = zone.split('.')[0]; | ||||
|             // the rest of the components are the TLD
 | ||||
|             params['TLD'] = zone.split('.').splice(1).join('.'); | ||||
|             params['TLD'] = domains[domains.length - 1]; | ||||
|             params['SLD'] = domains[domains.length - 2]; | ||||
| 
 | ||||
|             return api('namecheap.domains.dns.getHosts',params).then(function (hostsResponse) { | ||||
|                 // console.log('hosts');
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user