npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@layered/dns-records

v2.1.0

Published

Discover publicly available DNS Records for a domain

Downloads

5,623

Readme

🌍 DNS Records

@layered/dns-records is a DNS helper library than can quickly discover and retrieve all DNS records for a domain.

  • Retrieves DNS records for a domain
  • Discovers (almost) all A, AAAA, CNAME, and TXT for a domain
  • Detects wildcard * records
  • Option to specify extra subdomains to check for
  • Provides results in common format, see DnsRecord
  • Works in all JavaScript runtimes: Browsers, Node.js, CloudFlare Workers, Deno, Bun, etc

→ See it in action here https://dmns.app

Getting Started

Installation

npm i @layered/dns-records

Usage

The library has a simple API. Use getAllDnsRecords(domain) to retrieve all DNS records for a domain OR request specific record types with getDnsRecords(hostname, 'TXT')

Example

import { getDnsRecords, getAllDnsRecords } from '@layered/dns-records'

const txtRecords = await getDnsRecords('google.com', 'TXT')
const allRecords = await getAllDnsRecords('x.com')

DNS Resolvers

Here is the list of supported DNS resolvers:

|Name|JS Runtime|Notes| |:--|:--|:--| |cloudflare-dns|Works on all|Requires fetch as global| |google-dns|Works on all|Requires fetch as global| |node-dns|Works only in Node.js|Uses Node.js DNS module| |node-dig|Works only in Node.js|Uses dig command| |deno-dns|Works only in Deno|Uses Deno.resolveDns|

Client API

DNS Records by type

getDnsRecords(name: string, type: string = 'A', resolver?): Promise<DnsRecord[]>

|Params|type|default|description| |-----|---|---|---| |name |string| |hostname. Ex: 'x.com' or email.apple.com| |type |string|A|record type: Ex: 'TXT', 'MX', 'CNAME'| |resolver |string| |DNS resolver to use, see resolvers above. If not set, the best match for current runtime will be used|

import { getDnsRecords } from '@layered/dns-records'

const records1 = await getDnsRecords('google.com', 'A')
console.log('DNS A records', records1)

const records2 = await getDnsRecords('google.com', 'TXT')
console.log('DNS TXT records', records2)

Returns a promise which resolves with an DnsRecord[] of records found:

[ { name: 'google.com.',
    ttl: 608,
    type: 'TXT',
    data: '"v=spf1 include:_spf.google.com ~all"' },
  ...
]

All DNS records

getAllDnsRecords(domain: string, options: GetAllDnsRecordsOptions): Promise<DnsRecord[]>

|Params|type|description| |-----|---|---| |domain|string|Valid domain name, ex: 'google.com'| |options|object|see GetAllDnsRecordsOptions|

import { getAllDnsRecords } from '@layered/dns-records'

const allRecords = await getAllDnsRecords('x.com', {
  resolver: 'cloudflare-dns',
  commonSubdomainsCheck: true,
})
console.log('DNS all records', allRecords)

Returns a Promise which resolves with DnsRecord[] of all records found:

[ { name: 'x.com.', ttl: 3600, type: 'NS', data: 'ns71.domaincontrol.com.' },
  { name: 'x.com.', ttl: 3600, type: 'NS', data: 'ns72.domaincontrol.com.' },
  { name: 'x.com.', ttl: 600, type: 'SOA', data: 'ns71.domaincontrol.com. dns.jomax.net. 2018071100 28800 7200 604800 600' },
  { name: 'x.com.', ttl: 600, type: 'A', data: '160.153.63.10' },
  { name: 'x.com.', ttl: 600, type: 'A', data: '160.153.63.10' },
  { name: 'www.x.com.',  ttl: 3600, type: 'CNAME', data: 'x.com.' },
  { name: 'x.com.', ttl: 3600, type: 'MX', data: '10 mx-van.mail.am0.yahoodns.net.' }
]

More

Please report any issues here on GitHub. Any contributions are welcome

License

MIT

Copyright (c) Andrei Igna, Layered