diff --git a/src/dns/caas.js b/src/dns/caas.js index ee86ccf75..50a9a0874 100644 --- a/src/dns/caas.js +++ b/src/dns/caas.js @@ -130,7 +130,8 @@ function verifyDnsConfig(dnsConfig, domain, zoneName, ip, callback) { var credentials = { token: dnsConfig.token, - fqdn: domain + fqdn: domain, + hyphenatedSubdomains: true // this will ensure we always use them, regardless of passed-in configs }; const testSubdomain = 'cloudrontestdns'; diff --git a/src/dns/cloudflare.js b/src/dns/cloudflare.js index f43c3b5af..e7f47a0ab 100644 --- a/src/dns/cloudflare.js +++ b/src/dns/cloudflare.js @@ -234,7 +234,8 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) { var credentials = { token: dnsConfig.token, - email: dnsConfig.email + email: dnsConfig.email, + hyphenatedSubdomains: !!dnsConfig.hyphenatedSubdomains }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here diff --git a/src/dns/digitalocean.js b/src/dns/digitalocean.js index 0949a5d50..e77da4e05 100644 --- a/src/dns/digitalocean.js +++ b/src/dns/digitalocean.js @@ -203,7 +203,8 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) { if (!dnsConfig.token || typeof dnsConfig.token !== 'string') return callback(new DomainsError(DomainsError.BAD_FIELD, 'token must be a non-empty string')); var credentials = { - token: dnsConfig.token + token: dnsConfig.token, + hyphenatedSubdomains: !!dnsConfig.hyphenatedSubdomains }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here diff --git a/src/dns/gandi.js b/src/dns/gandi.js index 420f2ee65..8eccbd0b9 100644 --- a/src/dns/gandi.js +++ b/src/dns/gandi.js @@ -115,7 +115,8 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) { if (!dnsConfig.token || typeof dnsConfig.token !== 'string') return callback(new DomainsError(DomainsError.BAD_FIELD, 'token must be a non-empty string')); var credentials = { - token: dnsConfig.token + token: dnsConfig.token, + hyphenatedSubdomains: !!dnsConfig.hyphenatedSubdomains }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here diff --git a/src/dns/gcdns.js b/src/dns/gcdns.js index 28b039396..f7f6ef120 100644 --- a/src/dns/gcdns.js +++ b/src/dns/gcdns.js @@ -24,7 +24,8 @@ function getDnsCredentials(dnsConfig) { credentials: { client_email: dnsConfig.credentials.client_email, private_key: dnsConfig.credentials.private_key - } + }, + hyphenatedSubdomains: !!dnsConfig.hyphenatedSubdomains }; } diff --git a/src/dns/godaddy.js b/src/dns/godaddy.js index 16e0a5866..be7063467 100644 --- a/src/dns/godaddy.js +++ b/src/dns/godaddy.js @@ -151,7 +151,8 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) { var credentials = { apiKey: dnsConfig.apiKey, - apiSecret: dnsConfig.apiSecret + apiSecret: dnsConfig.apiSecret, + hyphenatedSubdomains: !!dnsConfig.hyphenatedSubdomains }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here diff --git a/src/dns/manual.js b/src/dns/manual.js index 9e24ecf77..1a3412042 100644 --- a/src/dns/manual.js +++ b/src/dns/manual.js @@ -55,11 +55,16 @@ function verifyDnsConfig(dnsConfig, domain, zoneName, ip, callback) { assert.strictEqual(typeof ip, 'string'); assert.strictEqual(typeof callback, 'function'); + var config = { + wildcard: !!dnsConfig.wildcard, + hyphenatedSubdomains: !!dnsConfig.hyphenatedSubdomains + } + // Very basic check if the nameservers can be fetched dns.resolve(zoneName, 'NS', { timeout: 5000 }, function (error, nameservers) { if (error && error.code === 'ENOTFOUND') return callback(new DomainsError(DomainsError.BAD_FIELD, 'Unable to resolve nameservers for this domain')); if (error || !nameservers) return callback(new DomainsError(DomainsError.BAD_FIELD, error ? error.message : 'Unable to get nameservers')); - callback(null, { wildcard: !!dnsConfig.wildcard }); + callback(null, config); }); } diff --git a/src/dns/namecom.js b/src/dns/namecom.js index 6e010fe7b..afad1720f 100644 --- a/src/dns/namecom.js +++ b/src/dns/namecom.js @@ -210,7 +210,8 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) { var credentials = { username: dnsConfig.username, - token: dnsConfig.token + token: dnsConfig.token, + hyphenatedSubdomains: !!dnsConfig.hyphenatedSubdomains }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here diff --git a/src/dns/route53.js b/src/dns/route53.js index f36b26c28..a878092d7 100644 --- a/src/dns/route53.js +++ b/src/dns/route53.js @@ -241,7 +241,8 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) { secretAccessKey: dnsConfig.secretAccessKey, region: dnsConfig.region || 'us-east-1', endpoint: dnsConfig.endpoint || null, - listHostedZonesByName: true // new/updated creds require this perm + listHostedZonesByName: true, // new/updated creds require this perm + hyphenatedSubdomains: !!dnsConfig.hyphenatedSubdomains }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here diff --git a/src/domains.js b/src/domains.js index 6b8e13ed8..88b196392 100644 --- a/src/domains.js +++ b/src/domains.js @@ -101,15 +101,7 @@ function verifyDnsConfig(config, domain, zoneName, provider, ip, callback) { var backend = api(provider); if (!backend) return callback(new DomainsError(DomainsError.INVALID_PROVIDER)); - api(provider).verifyDnsConfig(config, domain, zoneName, ip, function (error, result) { - if (error) return callback(error); - - // set potential hyphenatedSubdomains property if true, otherwise unset - // TODO this should possibly be verified against in the backend and passed normally through the result - if ('hyphenatedSubdomains' in config && !!config.hyphenatedSubdomains) result.hyphenatedSubdomains = !!config.hyphenatedSubdomains; - - callback(null, result); - }); + api(provider).verifyDnsConfig(config, domain, zoneName, ip, callback); } function add(domain, zoneName, provider, config, fallbackCertificate, tlsConfig, callback) {