diggy 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/readme.md +73 -53
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diggy",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Multi-backend DNS resolver for Node.js/Browser — supports dig, DNS over HTTPS, and native Node.js DNS.",
|
|
5
5
|
"repository": "git@github.com:OzzyCzech/diggy.git",
|
|
6
6
|
"author": "Roman Ožana <roman@ozana.cz>",
|
package/readme.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 👾 Diggy
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/diggy)
|
|
4
|
+
[](https://www.npmjs.com/package/diggy)
|
|
5
|
+
[](https://github.com/OzzyCzech/diggy/blob/main/LICENSE)
|
|
6
|
+
[](https://github.com/OzzyCzech/diggy/commits/main)
|
|
7
|
+
[](https://github.com/OzzyCzech/diggy/actions)
|
|
8
|
+
|
|
3
9
|
👾 **Diggy** is a flexible, multi-backend JavaScript **DNS resolver** for fetching **DNS records**
|
|
4
10
|
with support for various resolution methods including DNS over HTTPS, native `dig` commands, and Node.js built-in DNS
|
|
5
11
|
functionality.
|
|
@@ -60,9 +66,9 @@ const records: AnyDNSRecord[] = await getDnsRecords('example.com', 'A');
|
|
|
60
66
|
|
|
61
67
|
```typescript
|
|
62
68
|
function getDnsRecords(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
host: string,
|
|
70
|
+
type?: string,
|
|
71
|
+
resolver?: string | BuildInDNSResolver | DNSResolver,
|
|
66
72
|
): Promise<AnyDNSRecord[]>
|
|
67
73
|
```
|
|
68
74
|
|
|
@@ -74,6 +80,20 @@ function getDnsRecords(
|
|
|
74
80
|
|
|
75
81
|
**Returns:** Promise resolving to an array of DNS records
|
|
76
82
|
|
|
83
|
+
## 🌍 Browser Usage
|
|
84
|
+
|
|
85
|
+
You can also use Diggy in the browser via ESM imports. This allows you to fetch DNS records directly from client-side
|
|
86
|
+
JavaScript. There are built-in resolvers for Google and Cloudflare DNS over HTTPS, which work seamlessly in the browser.
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
|
|
90
|
+
<script type="module">
|
|
91
|
+
import { getDnsRecords } from 'https://esm.sh/diggy';
|
|
92
|
+
|
|
93
|
+
const records = await getDnsRecords('ozana.cz');
|
|
94
|
+
</script>
|
|
95
|
+
```
|
|
96
|
+
|
|
77
97
|
## 🌐 Available Resolvers
|
|
78
98
|
|
|
79
99
|
### Built-in Resolvers
|
|
@@ -94,12 +114,12 @@ const records = await getDnsRecords('example.com', 'A', "nodejs");
|
|
|
94
114
|
const records = await getDnsRecords('example.com', 'A', "dig");
|
|
95
115
|
```
|
|
96
116
|
|
|
97
|
-
| Resolver | Description | Environment
|
|
98
|
-
|
|
99
|
-
| `google` | Google DNS over HTTPS |
|
|
100
|
-
| `cloudflare` | Cloudflare DNS over HTTPS |
|
|
101
|
-
| `nodejs` | Node.js built-in DNS module | Node.js
|
|
102
|
-
| `dig` | Native dig command | `dig` installed
|
|
117
|
+
| Resolver | Description | Environment |
|
|
118
|
+
|--------------|-----------------------------|----------------------------------------|
|
|
119
|
+
| `google` | Google DNS over HTTPS | Browsers, Node.js |
|
|
120
|
+
| `cloudflare` | Cloudflare DNS over HTTPS | Browsers, Node.js |
|
|
121
|
+
| `nodejs` | Node.js built-in DNS module | Node.js only |
|
|
122
|
+
| `dig` | Native dig command | Node.js only, requires `dig` installed |
|
|
103
123
|
|
|
104
124
|
### Configure built-in resolvers
|
|
105
125
|
|
|
@@ -134,8 +154,8 @@ You can also **create your own custom resolver** by implementing the `DNSResolve
|
|
|
134
154
|
|
|
135
155
|
```typescript
|
|
136
156
|
export type DNSResolver = (
|
|
137
|
-
|
|
138
|
-
|
|
157
|
+
host: string,
|
|
158
|
+
type: DNSRecordType,
|
|
139
159
|
) => Promise<AnyDNSRecord[]>;
|
|
140
160
|
```
|
|
141
161
|
|
|
@@ -161,19 +181,19 @@ DNS records are returned as an array of objects with the following structure:
|
|
|
161
181
|
import { CaaRecordData, MxRecordData, SoaRecordData, SrvRecordData, NaptrRecordData } from "./types";
|
|
162
182
|
|
|
163
183
|
interface AnyDNSRecord {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
184
|
+
name: string; // Domain name
|
|
185
|
+
type: string; // Record type (A, AAAA, MX, etc.)
|
|
186
|
+
ttl: number; // Time-to-live in seconds
|
|
187
|
+
|
|
188
|
+
// Record data (format varies by type)
|
|
189
|
+
data:
|
|
190
|
+
| string
|
|
191
|
+
| string[]
|
|
192
|
+
| MxRecordData
|
|
193
|
+
| SoaRecordData
|
|
194
|
+
| CaaRecordData
|
|
195
|
+
| NaptrRecordData
|
|
196
|
+
| SrvRecordData;
|
|
177
197
|
}
|
|
178
198
|
```
|
|
179
199
|
|
|
@@ -181,35 +201,35 @@ interface AnyDNSRecord {
|
|
|
181
201
|
|
|
182
202
|
```json
|
|
183
203
|
[
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
204
|
+
{
|
|
205
|
+
"name": "example.com",
|
|
206
|
+
"type": "SOA",
|
|
207
|
+
"ttl": 3600,
|
|
208
|
+
"data": {
|
|
209
|
+
"nsname": "ns1.example.com.",
|
|
210
|
+
"hostmaster": "hostmaster.example.com.",
|
|
211
|
+
"serial": 2025051204,
|
|
212
|
+
"refresh": 10800,
|
|
213
|
+
"retry": 3600,
|
|
214
|
+
"expire": 604800,
|
|
215
|
+
"minttl": 3600
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"name": "example.cz",
|
|
220
|
+
"type": "A",
|
|
221
|
+
"ttl": 1800,
|
|
222
|
+
"data": "66.33.66.33"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"name": "example.cz",
|
|
226
|
+
"type": "MX",
|
|
227
|
+
"ttl": 60,
|
|
228
|
+
"data": {
|
|
229
|
+
"priority": 10,
|
|
230
|
+
"exchange": "mail.example.com"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
213
233
|
]
|
|
214
234
|
```
|
|
215
235
|
|