From 0ce04b74669b809debf43e623a25f48528c835c2 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 29 Apr 2019 02:01:14 -0600 Subject: [PATCH] WIP properly fails dry challenge --- app.js | 1 + lib/acme.js | 20 +++++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index c8a5332..3531ee2 100644 --- a/app.js +++ b/app.js @@ -163,6 +163,7 @@ }).catch(function (err) { console.error("A bad thing happened:"); console.error(err); + window.alert(err.message || JSON.stringify(err, null, 2)); }); }); }); diff --git a/lib/acme.js b/lib/acme.js index cfb20fe..d5b3438 100644 --- a/lib/acme.js +++ b/lib/acme.js @@ -823,17 +823,15 @@ ACME.create = function create(me) { if (!me.dig) { me.dig = function (query) { // TODO use digd.js - return new Promise(function (resolve, reject) { - var dns = require('dns'); - dns.resolveTxt(query.name, function (err, records) { - if (err) { reject(err); return; } - - resolve({ - answer: records.map(function (rr) { - return { data: rr }; - }) - }); - }); + return new me.request({ url: "/api/dns/" + query.name + "?type=" + query.type }).then(function (resp) { + if (!resp.body || !Array.isArray(resp.body.answer)) { + throw new Error("failed to get DNS response"); + } + return { + answer: resp.body.answer.map(function (ans) { + return { data: ans.data, ttl: ans.ttl }; + }) + }; }); }; }