# @fabcotech/dappy-lookup

> library that resolves names from dappy name system

Latest version **2.3.17** (published 2023-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fabcotech/dappy-lookup
pnpm add @fabcotech/dappy-lookup
yarn add @fabcotech/dappy-lookup
bun add @fabcotech/dappy-lookup
```

Provides the command `dappy-lookup`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.17 |
| Published | 2023-09-26 |
| First published | 2022-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 6 |
| Unpacked size | 424.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | FABCO |
| Maintainers | popul, fabcotechraf |
| Keywords | dappy, rchain, blockchain, domain, name system, dns |

## Links

- npm: https://www.npmjs.com/package/@fabcotech/dappy-lookup
- Repository: https://github.com/fabcotech/dappy-lookup
- Issues: https://github.com/fabcotech/dappy-lookup/issues
- npm.io page: https://npm.io/package/@fabcotech/dappy-lookup

## Dependencies (6)

- [zod](https://npm.io/package/zod.md) ^3.19.1
- [express](https://npm.io/package/express.md) ^4.18.2
- [dns-packet](https://npm.io/package/dns-packet.md) ^5.5.0
- [body-parser](https://npm.io/package/body-parser.md) ^1.20.2
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2
- [@fabcotech/bees](https://npm.io/package/@fabcotech/bees.md) *

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 2.3.17 (latest) — 2023-09-26
- 2.2.4 (master) — 2022-05-23
- 2.3.16 — 2023-09-25
- 2.3.15 — 2023-02-21
- 2.3.14 — 2022-10-24
- 2.3.13 — 2022-10-14
- 2.3.12 — 2022-10-10
- 2.3.11 — 2022-10-07
- 2.3.10 — 2022-10-04
- 2.3.9 — 2022-10-04
- 2.3.8 — 2022-10-04
- 2.3.7 — 2022-10-03
- 2.3.6 — 2022-09-26
- 2.3.5 — 2022-09-23
- 2.3.4 — 2022-09-23
- … 14 more at https://npm.io/package/@fabcotech/dappy-lookup/versions

## README

### dappy-lookup

A library written in Typescript that resolves any type of record (A, AAAA, CERT) on a dappy name system with co-resolution over HTTPS (DoH).

[dappy website](https://dappy.tech)

[docs for domain purchase and management](http://docs.dappy.tech/)

[dappy-tools repository](https://github.com/fabcotech/dappy-tools)

#### Try it with the CLI

```sh
npx @fabcotech/dappy-lookup fabcotech A --network=gamma
```

#### Building and testing

```sh
# In dappy-tools root
npm i & npx lerna bootstrap

# In dappy-tools/packages/gossip
npm i

# test
npm run test

# build
npm run build
```

#### Using in any web nodeJS repository

```sh
npm i -S @fabcotech/dappy-lookup
```

### Examples

### Stand-alone dappy lookup

Here is an example to get you started:

```typescript
import { lookup } from '@fabcotech/dappy-lookup';

async function run() {
    // lookup the A records for example.dappy on d network
    const packetA = await lookup('example.dappy', 'A');
    console.log(packet);

    // lookup the AAAA records for example.dappy on d network
    const packetAAAA = await lookup('example.dappy', 'AAAA');
    console.log(packet);

    // lookup the CERT records for example.dappy on d network
    const packetCERT = await lookup('example.dappy', 'CERT');
    console.log(packet);
});

run();
```

This example above will resolve a name on default dappy network which is the `d` network, which is the DappyNS production ready network.

Next example do the same but on `gamma` network (used for testing purposes)

```typescript
import { lookup } from '@fabcotech/dappy-lookup;

async function run() {
    // lookup the A records for example.dappy on gamma network
    const packetA = await lookup('example.dappy', 'A', { network: 'gamma' });
    console.log(packetA);
});

run();
```

### NodeJS request using dappy-lookup with CA certificate retrieval

It's a really a pain point to get a valid CA certificate and to install it at operating system level.

On DappyNS, name servers not only distribute IPv4 (**A** records) and IPv6 addresses (**AAAA** records) but also certificates to trust over **CERT** records (alternative of [DANE](https://datatracker.ietf.org/doc/html/rfc6698)). It enable dappy-lookup client to fetch dynamically and in a trusted manner (using coresolution mecanism) CA certificates.

The example below demonstrates how to do this:

```typescript
import { lookup, nodeLookup } from '@fabcotech/dappy-lookup;

const { answers: [{ data: ca }]} = await lookup('example.dappy', 'CERT')

https.get('https://example.dappy/', {
    lookup: nodeLookup,
    ca,
}, (res) => {
  ...
});
```

NodeJS enables to override [lookup function](https://nodejs.org/api/http.html#httprequesturl-options-callback) for [HTTP](https://nodejs.org/api/http.html) and [HTTPS](https://nodejs.org/api/https.html) native modules.

So dappy-lookup provide a lookup function (created with `nodeLookup`) with the same signature as [dns.lookup](https://nodejs.org/api/dns.html#dnslookuphostname-options-callback) provided by NodeJS.

### NodeJS requests using dappy-lookup

The example below shows how to replace native NodeJS lookup function with the dappy-lookup equivalent function. In this example the certificate is not recovered dynamically, it is installed previously on the operating system.

```typescript
import { nodeLookup } from '@fabcotech/dappy-lookup;

https.get('https://example.dappy/', {
    lookup: nodeLookup,
}, (res) => {
  ...
});
```

## Reference

Please read [Reference](REFERENCE.md) to learn more about CLI commands and api.

---
_Source: https://npm.io/package/@fabcotech/dappy-lookup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
