npm.io
0.0.13 • Published 2 years ago

@blockcore/dns

Licence
MIT
Version
0.0.13
Deps
0
Size
12 kB
Vulns
0
Weekly
0
Stars
2

Blockcore

Blockcore DNS Provider

DNS Provider package to query and resolve dynamic and decentralized DNS entries

Work-in-Progress - use with caution!

Blockcore DNS Provider

Install

npm install @blockcore/dns

Warning: This package is native ESM and does not provide a CommonJS export. If your project uses CommonJS, you'll have to convert to ESM or use the dynamic import() function.

Usage

import { BlockcoreDns } from '@blockcore/dns';

let dns = new BlockcoreDns();

// This relies on a central nameserver registry:
await dns.load();
let indexers = await dns.getServicesByType('Indexer');

Get servers from known nameservers:

import { BlockcoreDns } from '@blockcore/dns';

let dns = new BlockcoreDns();

// This relies on fixed set of nameservers:
await dns.load({ url: 'https://ns.blockcore.net', contact: 'post@blockcore.net' });
let indexers = await dns.getServicesByType('Indexer');

You can create an load the nameservers using this static function:

let dnsServers = await BlockcoreDns.getDnsServers();
dns.setActiveServer(dnsServers[0].url);

await dns.api.getServicesByType('Indexer');
await dns.api.getServicesByNetwork('CITY');
await dns.api.getServicesByTypeAndNetwork('Indexer', 'CITY');
await dns.api.getExternalIP();