{"name":"dns-over-http-resolver","version":"3.0.9","keywords":["dns","doh","http"],"author":{"name":"Vasco Santos"},"license":"Apache-2.0 OR MIT","_id":"dns-over-http-resolver@3.0.9","maintainers":[{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"vascosantos","email":"santos.vasco10@gmail.com"}],"homepage":"https://github.com/vasco-santos/dns-over-http-resolver#readme","bugs":{"url":"https://github.com/vasco-santos/dns-over-http-resolver/issues"},"dist":{"shasum":"8ed9493f32fa444f4bd601978f579e715fbe67bb","tarball":"http://registry-npm.ywwl.com/dns-over-http-resolver/download/dns-over-http-resolver-3.0.9.tgz","fileCount":15,"integrity":"sha512-HxgY2zqPZ23QKYWokgmRGGtvZZlinvP/bfo4sOHWqLgkRojIJU73YdUVagDVjCtcDq8Kd55jVhVQWsbIA1+ZLA==","signatures":[{"sig":"MEUCIF+2yNIzbFXS7VFTpPkYiidnguhkf3m0neXOeMkB4PyMAiEAhO5C4azUMgDGrfVyZSmQsu5KnTnbanpylYgOojQrGSQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54012,"size":13056,"noattachment":false,"key":"/dns-over-http-resolver/-/dns-over-http-resolver-3.0.9.tgz"},"type":"module","types":"./dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"0a09bdc9f83ce1d996f5f62b70464b1da60a5eef","release":{"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits","releaseRules":[{"release":"major","breaking":true},{"revert":true,"release":"patch"},{"type":"feat","release":"minor"},{"type":"fix","release":"patch"},{"type":"docs","release":"patch"},{"type":"test","release":"patch"},{"type":"deps","release":"patch"},{"scope":"no-release","release":false}]}],["@semantic-release/release-notes-generator",{"preset":"conventionalcommits","presetConfig":{"types":[{"type":"feat","section":"Features"},{"type":"fix","section":"Bug Fixes"},{"type":"chore","section":"Trivial Changes"},{"type":"docs","section":"Documentation"},{"type":"deps","section":"Dependencies"},{"type":"test","section":"Tests"}]}}],"@semantic-release/changelog","@semantic-release/npm","@semantic-release/github","@semantic-release/git"],"branches":["main"]},"scripts":{"docs":"aegir docs","lint":"aegir lint","test":"aegir test","build":"aegir build","release":"aegir release","dep-check":"aegir dep-check","test:node":"aegir test -t node","test:browser":"aegir test -t browser","test:electron-main":"aegir test -t electron-main"},"_npmUser":{"name":"vascosantos","email":"santos.vasco10@gmail.com"},"repository":{"url":"git+https://github.com/vasco-santos/dns-over-http-resolver.git","type":"git"},"_npmVersion":"10.9.2","description":"DNS over HTTP resolver","directories":{},"_nodeVersion":"22.14.0","dependencies":{"weald":"^1.0.2","quick-lru":"^7.0.0"},"eslintConfig":{"extends":"ipfs","parserOptions":{"project":true,"sourceType":"module"}},"_hasShrinkwrap":false,"devDependencies":{"aegir":"^45.0.9","sinon":"^19.0.2","@types/sinon":"^17.0.3"},"_npmOperationalInternal":{"tmp":"tmp/dns-over-http-resolver_3.0.9_1742465161501_0.20895159297077237","host":"s3://npm-registry-packages-npm-production"},"readme":"# dns-over-http-resolver <!-- omit in toc -->\n\n[![codecov](https://img.shields.io/codecov/c/github/vasco-santos/dns-over-http-resolver.svg?style=flat-square)](https://codecov.io/gh/vasco-santos/dns-over-http-resolver)\n[![CI](https://img.shields.io/github/actions/workflow/status/vasco-santos/dns-over-http-resolver/js-test-and-release.yml?branch=main\\&style=flat-square)](https://github.com/vasco-santos/dns-over-http-resolver/actions/workflows/js-test-and-release.yml?query=branch%3Amain)\n\n> DNS over HTTP resolver\n\n## Table of contents <!-- omit in toc -->\n\n- [Install](#install)\n  - [Browser `<script>` tag](#browser-script-tag)\n- [Usage](#usage)\n  - [options](#options)\n- [API](#api)\n  - [resolve(hostname, rrType)](#resolvehostname-rrtype)\n    - [Parameters](#parameters)\n    - [Returns](#returns)\n    - [Example](#example)\n  - [resolve4(hostname)](#resolve4hostname)\n    - [Parameters](#parameters-1)\n    - [Returns](#returns-1)\n    - [Example](#example-1)\n  - [resolve6(hostname)](#resolve6hostname)\n    - [Parameters](#parameters-2)\n    - [Returns](#returns-2)\n    - [Example](#example-2)\n  - [resolveTxt(hostname)](#resolvetxthostname)\n    - [Parameters](#parameters-3)\n    - [Returns](#returns-3)\n    - [Example](#example-3)\n  - [getServers()](#getservers)\n    - [Returns](#returns-4)\n    - [Example](#example-4)\n  - [setServers(servers)](#setserversservers)\n    - [Parameters](#parameters-4)\n    - [Example](#example-5)\n- [Contribute](#contribute)\n- [API Docs](#api-docs)\n- [License](#license)\n- [Contribution](#contribution)\n\n## Install\n\n```console\n$ npm i dns-over-http-resolver\n```\n\n### Browser `<script>` tag\n\nLoading this module through a script tag will make it's exports available as `DnsOverHttpResolver` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/dns-over-http-resolver/dist/index.min.js\"></script>\n```\n\nIsomorphic DNS over HTTP resolver using fetch.\n\nAPI based on [Node.js' dns promises API](https://nodejs.org/dist/latest-v14.x/docs/api/dns.html#dns_dns_promises_api), allowing the native `dns` module to be used if available when relying on this API.\n\n## Usage\n\n```js\nconst DnsOverHttpResolver = require('dns-over-http-resolver')\n\nconst dohResolver = new DnsOverHttpResolver(options)\n```\n\n[Cloudflare](https://cloudflare-dns.com/dns-query) and [Google](https://dns.google/resolve) DNS servers are used by default. They can be replaced via the API.\n\nYou can also use `require('dns').promises` in Node.js in lieu of this module.\n\n### options\n\nYou can provide the following options for the DnsOverHttpResolver:\n\n| Name     | Type     | Description                          | Default |\n| -------- | -------- | ------------------------------------ | ------- |\n| maxCache | `number` | maximum number of cached dns records | 100     |\n\n## API\n\n### resolve(hostname, rrType)\n\nUses the DNS protocol to resolve the given host name into a DNS record.\n\n#### Parameters\n\n| Name      | Type     | Description                         |\n| --------- | -------- | ----------------------------------- |\n| hostname  | `string` | host name to resolve                |\n| \\[rrType] | `string` | resource record type (default: 'A') |\n\n#### Returns\n\n| Type                     | Description                                                    |\n| ------------------------ | -------------------------------------------------------------- |\n| `Promise<Array<string>>` | returns a Promise resolving a DNS record according to its type |\n\n#### Example\n\n```js\nconst DnsOverHttpResolver = require('dns-over-http-resolver')\nconst resolver = new DnsOverHttpResolver()\n\nconst hostname = 'google.com'\nconst recordType = 'TXT'\n\nconst dnsRecord = await resolver.resolve(hostname, recordType)\n```\n\n### resolve4(hostname)\n\nUses the DNS protocol to resolve the given host name into IPv4 addresses.\n\n#### Parameters\n\n| Name     | Type     | Description          |\n| -------- | -------- | -------------------- |\n| hostname | `string` | host name to resolve |\n\n#### Returns\n\n| Type                     | Description                                |\n| ------------------------ | ------------------------------------------ |\n| `Promise<Array<string>>` | returns a Promise resolving IPv4 addresses |\n\n#### Example\n\n```js\nconst DnsOverHttpResolver = require('dns-over-http-resolver')\nconst resolver = new DnsOverHttpResolver()\n\nconst hostname = 'google.com'\n\nconst address = await resolver.resolve4(hostname) // ['216.58.212.142']\n```\n\n### resolve6(hostname)\n\nUses the DNS protocol to resolve the given host name into IPv6 addresses.\n\n#### Parameters\n\n| Name     | Type     | Description          |\n| -------- | -------- | -------------------- |\n| hostname | `string` | host name to resolve |\n\n#### Returns\n\n| Type                     | Description                                |\n| ------------------------ | ------------------------------------------ |\n| `Promise<Array<string>>` | returns a Promise resolving IPv6 addresses |\n\n#### Example\n\n```js\nconst DnsOverHttpResolver = require('dns-over-http-resolver')\nconst resolver = new DnsOverHttpResolver()\n\nconst hostname = 'google.com'\n\nconst address = await resolver.resolve6(hostname) // ['2a00:1450:4001:801::200e']\n```\n\n### resolveTxt(hostname)\n\nUses the DNS protocol to resolve the given host name into a Text Record.\n\n#### Parameters\n\n| Name     | Type     | Description          |\n| -------- | -------- | -------------------- |\n| hostname | `string` | host name to resolve |\n\n#### Returns\n\n| Type                            | Description                               |\n| ------------------------------- | ----------------------------------------- |\n| `Promise<Array<Array<string>>>` | returns a Promise resolving a Text Record |\n\n#### Example\n\n```js\nconst DnsOverHttpResolver = require('dns-over-http-resolver')\nconst resolver = new DnsOverHttpResolver()\n\nconst hostname = 'google.com'\n\nconst address = await resolver.resolveTxt(hostname) // [['v=spf1 -all']]\n```\n\n### getServers()\n\nGet an array of the IP addresses currently configured for DNS resolution.\nThese addresses are formatted according to RFC 5952. It can include a custom port.\n\n#### Returns\n\n| Type            | Description                       |\n| --------------- | --------------------------------- |\n| `Array<string>` | returns array of DNS servers used |\n\n#### Example\n\n```js\nconst DnsOverHttpResolver = require('dns-over-http-resolver')\n\nconst resolver = new DnsOverHttpResolver()\nconst servers = resolver.getServers()\n```\n\n### setServers(servers)\n\nSets the IP address and port of servers to be used when performing DNS resolution.\nNote that the servers order will be randomized on each request for load distribution.\n\n#### Parameters\n\n| Name    | Type            | Description                            |\n| ------- | --------------- | -------------------------------------- |\n| servers | `Array<string>` | Array of RFC 5952 formatted addresses. |\n\n#### Example\n\n```js\nconst DnsOverHttpResolver = require('dns-over-http-resolver')\n\nconst resolver = new DnsOverHttpResolver()\nresolver.setServers(['https://cloudflare-dns.com/dns-query'])\n```\n\n## Contribute\n\nFeel free to dive in! [Open an issue](https://github.com/vasco-santos/dns-over-http-resolver/issues/new) or submit PRs.\n\n## API Docs\n\n- <https://vasco-santos.github.io/dns-over-http-resolver>\n\n## License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","publish_time":1742465161688,"_cnpm_publish_time":1742465161688,"dist-tags":{"latest":"3.0.16"}}