diff --git a/pkg/dohdec/lib/dnsUtils.js b/pkg/dohdec/lib/dnsUtils.js index 9de8ba9..baac6db 100644 --- a/pkg/dohdec/lib/dnsUtils.js +++ b/pkg/dohdec/lib/dnsUtils.js @@ -15,10 +15,14 @@ const PAD_SIZE = 128; * @property {string} [rrtype] The Resource Record type to retrive. * @property {number} [id] The 2-byte unsigned integer for the request. * For DOH, should be 0 or undefined. - * @property {boolean} [json] Force JSON lookups for DOH. Ignored for DOT. + * @property {boolean} [decode=true] Decode the response, either into JSON + * or an object representing the DNS format result. * @property {boolean} [stream=false] Encode for streaming, with the packet * prefixed by a 2-byte big-endian integer of the number of bytes in the * packet. + * @property {boolean} [dnssec=false] Request DNSSec records. Currently + * requires `json: false`. + * @property {boolean} [dnssecCheckingDisabled=false] Disable DNSSEC */ // Extracted from node source. @@ -236,7 +240,7 @@ export class DNSutils extends EventEmitter { */ static normalizeArgs(name, opts, defaults) { /** @type {LookupOptions} */ - let nopts = {}; + let nopts = Object.create(null); if (name != null) { switch (typeof name) { case 'object': diff --git a/pkg/dohdec/lib/doh.js b/pkg/dohdec/lib/doh.js index 62226de..f98a1d1 100644 --- a/pkg/dohdec/lib/doh.js +++ b/pkg/dohdec/lib/doh.js @@ -18,20 +18,17 @@ const USER_AGENT = `${pkg.name} v${pkg.version}`; /** * Options for doing DOH lookups. * - * @typedef {object} DOH_LookupOptions - * @property {string} [name] The DNS name to look up. - * @property {string} [rrtype='A'] The Resource Record type - * to retrive. - * @property {boolean} [json=true] Retrieve a JSON response. If false, - * retrieve using DNS format. - * @property {boolean} [decode=true] Decode the response, either into JSON - * or an object representing the DNS format result. + * @typedef {object} DOH_SpecificLookupOptions * @property {boolean} [preferPost=true] For DNS format requests, should * the HTTP POST verb be used? If false, uses GET. - * @property {boolean} [dnssec=false] Request DNSSec records. Currently - * requires `json: false`. * @property {string} [url=CLOUDFLARE_API] What DoH endpoint should be * used? + * @property {boolean} [json=true] Force JSON lookups for DOH. + */ + +/** + * @typedef {DOH_SpecificLookupOptions & + * import('./dnsUtils.js').LookupOptions} DOH_LookupOptions */ /** @@ -200,13 +197,15 @@ export class DNSoverHTTPS extends DNSutils { * @returns {Promise} DNS result. */ lookup(name, opts = {}) { - const nopts = DNSutils.normalizeArgs(name, opts, { - rrtype: 'A', - json: true, - decode: true, - dnssec: false, - dnssecCheckingDisabled: false, - }); + const nopts = /** @type {Required} */ ( + DNSutils.normalizeArgs(name, opts, { + rrtype: 'A', + json: true, + decode: true, + dnssec: false, + dnssecCheckingDisabled: false, + }) + ); this.verbose(1, 'DNSoverHTTPS.lookup options:', nopts); return nopts.json ? this.getJSON(nopts) : this.getDNS(nopts); diff --git a/pkg/dohdec/lib/dot.js b/pkg/dohdec/lib/dot.js index 8fabfee..69e214b 100644 --- a/pkg/dohdec/lib/dot.js +++ b/pkg/dohdec/lib/dot.js @@ -15,15 +15,7 @@ const DEFAULT_SERVER = '1.1.1.1'; /** * Options for doing DOT lookups. * - * @typedef {object} DOT_LookupOptions - * @property {string} [name] The DNS name to look up. - * @property {string} [rrtype='A'] The Resource Record type - * to retrive. - * @property {number} [id] 2-byte ID for the DNS packet. Defaults to random. - * @property {boolean} [decode=true] Decode the response, either into JSON - * or an object representing the DNS format result. - * @property {boolean} [dnssec=false] Request DNSSec records. Currently - * requires `json: false`. + * @typedef {import('./dnsUtils.js').LookupOptions} DOT_LookupOptions */ /**