@nictool/dns-resource-record 1.7.0 → 1.8.0
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/CHANGELOG.md +14 -0
- package/README.md +45 -12
- package/dist/dns-rr.cjs +7050 -0
- package/dist/dns-rr.min.js +14 -14
- package/dist/dns-rr.min.js.map +3 -3
- package/lib/bind.js +7 -5
- package/lib/wire.js +112 -2
- package/package.json +8 -5
- package/rr/cert.js +8 -0
- package/rr/cname.js +5 -0
- package/rr/dname.js +5 -0
- package/rr/ds.js +20 -1
- package/rr/mx.js +4 -0
- package/rr/rrsig.js +39 -1
- package/rr/spf.js +5 -1
- package/rr/srv.js +17 -0
- package/rr/sshfp.js +15 -0
- package/rr/txt.js +37 -9
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ Notable changes to this project are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
#### Unreleased
|
|
6
6
|
|
|
7
|
+
### [1.8.0] - 2026-05-25
|
|
8
|
+
|
|
9
|
+
- lib/wire.js — hardened readWireName()
|
|
10
|
+
- new wirePackDomainCompressed() for RFC 1035 §4.1.4 name compression
|
|
11
|
+
- charstrs decoder preserves multi-string boundaries
|
|
12
|
+
- lib/bind.js — fromBind() returns array for charstrs (TXT) when input has multiple quoted strings.
|
|
13
|
+
- rr/rrsig.js — getAlgorithmOptions() extended with DNSSEC algorithms 6, 7, 8, 10, 13, 14, 15, 16.
|
|
14
|
+
- rr/ds.js — setDigestType() now accepts SHA-384 (4)
|
|
15
|
+
- rr/txt.js — getWireRdata() and fromTinydnsGeneric() preserve per-segment boundaries.
|
|
16
|
+
- package.json — engines lowered to >=20
|
|
17
|
+
- new build:cjs script via Rollup.
|
|
18
|
+
- test/wire.js, test/base.js, test/rr/{rrsig,ds,txt}.js — round-trip + negative tests for each fix.
|
|
19
|
+
|
|
7
20
|
### [1.7.0] - 2026-04-20
|
|
8
21
|
|
|
9
22
|
#### Fixes
|
|
@@ -418,3 +431,4 @@ Notable changes to this project are documented in this file.
|
|
|
418
431
|
[1.6.0]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.6.0
|
|
419
432
|
[1.6.1]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.6.1
|
|
420
433
|
[1.7.0]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.7.0
|
|
434
|
+
[1.8.0]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.8.0
|
package/README.md
CHANGED
|
@@ -43,6 +43,24 @@ This module supports all current DNS RRs in active use on the internet.
|
|
|
43
43
|
npm install @nictool/dns-resource-record
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
### ESM and CommonJS
|
|
47
|
+
|
|
48
|
+
The package ships both ESM and CJS, selected automatically via the package `exports` map:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
// ESM
|
|
52
|
+
import * as RR from '@nictool/dns-resource-record'
|
|
53
|
+
import RR, { A, TXT } from '@nictool/dns-resource-record'
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
// CommonJS
|
|
58
|
+
const RR = require('@nictool/dns-resource-record')
|
|
59
|
+
const { A, TXT } = require('@nictool/dns-resource-record')
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The default export (the base `RR` class) is reached as `require('@nictool/dns-resource-record').default` from CommonJS.
|
|
63
|
+
|
|
46
64
|
### Validation
|
|
47
65
|
|
|
48
66
|
Validate an A record:
|
|
@@ -57,14 +75,14 @@ const validA = new RR.A({
|
|
|
57
75
|
})
|
|
58
76
|
|
|
59
77
|
console.log(validA.toBind())
|
|
60
|
-
// example.com
|
|
78
|
+
// example.com. 3600 IN A 192.0.2.1
|
|
61
79
|
```
|
|
62
80
|
|
|
63
81
|
Invalid records throw immediately:
|
|
64
82
|
|
|
65
83
|
```js
|
|
66
84
|
try {
|
|
67
|
-
new RR.A({ owner: 'example.com.', address: 'not-an-ip' })
|
|
85
|
+
new RR.A({ owner: 'example.com.', address: 'not-an-ip', ttl: 3600 })
|
|
68
86
|
} catch (err) {
|
|
69
87
|
console.error(err.message) // Error: A address must be IPv4
|
|
70
88
|
}
|
|
@@ -148,7 +166,7 @@ new RR.MX({
|
|
|
148
166
|
exchange: 'mail.example.com.',
|
|
149
167
|
ttl: 3600,
|
|
150
168
|
}).toBind()
|
|
151
|
-
// example.com
|
|
169
|
+
// example.com. 3600 IN MX 10 mail.example.com.
|
|
152
170
|
```
|
|
153
171
|
|
|
154
172
|
**When to use:** Generating zone files, displaying records for editing, exporting to BIND nameservers.
|
|
@@ -182,7 +200,7 @@ const fromTiny = RR.CAA.fromTinydns(
|
|
|
182
200
|
':ns1.example.com:257:\\000\\005issue"http\\072\\057\\057letsencrypt.org":3600::\n',
|
|
183
201
|
)
|
|
184
202
|
console.log(fromTiny.toBind())
|
|
185
|
-
// ns1.example.com
|
|
203
|
+
// ns1.example.com. 3600 IN CAA 0 issue "http://letsencrypt.org"
|
|
186
204
|
```
|
|
187
205
|
|
|
188
206
|
**When to use:** DNS migrations, format conversions, tool interoperability.
|
|
@@ -204,7 +222,7 @@ a.setAddress('192.0.2.2')
|
|
|
204
222
|
a.setTtl(7200)
|
|
205
223
|
|
|
206
224
|
console.log(a.toBind())
|
|
207
|
-
// example.com
|
|
225
|
+
// example.com. 7200 IN A 192.0.2.2
|
|
208
226
|
```
|
|
209
227
|
|
|
210
228
|
Setters include validation. Invalid values throw with helpful error messages.
|
|
@@ -214,7 +232,7 @@ For a list of available setters, check `getFields('rdata')` for your record type
|
|
|
214
232
|
```js
|
|
215
233
|
new RR.SSHFP(null).getFields('rdata')
|
|
216
234
|
// ['algorithm', 'fptype', 'fingerprint']
|
|
217
|
-
// So use:
|
|
235
|
+
// So use: setAlgorithm(), setFptype(), setFingerprint()
|
|
218
236
|
```
|
|
219
237
|
|
|
220
238
|
---
|
|
@@ -340,23 +358,38 @@ Domain owner names are:
|
|
|
340
358
|
**Example:**
|
|
341
359
|
|
|
342
360
|
```js
|
|
343
|
-
new RR.A({ owner: 'EXAMPLE.COM', address: '192.0.2.1', ttl: 3600 })
|
|
344
|
-
//
|
|
361
|
+
const r = new RR.A({ owner: 'EXAMPLE.COM.', address: '192.0.2.1', ttl: 3600 })
|
|
362
|
+
r.get('owner') // 'example.com.' — uppercase normalized to lowercase
|
|
345
363
|
```
|
|
346
364
|
|
|
365
|
+
Owner names are required to be fully qualified (trailing dot). Unqualified
|
|
366
|
+
names throw at construction; this library does not add the dot for you.
|
|
367
|
+
|
|
347
368
|
### Relative vs Absolute Names
|
|
348
369
|
|
|
349
370
|
Master zone file expansions (relative domain names) are handled by [dns-zone](https://github.com/NicTool/dns-zone). This library works only with fully qualified names.
|
|
350
371
|
|
|
351
372
|
### Export Options
|
|
352
373
|
|
|
353
|
-
The `toBind()`
|
|
374
|
+
The `toBind()` method accepts a zone-options object (typically supplied by
|
|
375
|
+
[dns-zone](https://github.com/NicTool/dns-zone) when emitting full zone files)
|
|
376
|
+
to elide redundant per-record output:
|
|
354
377
|
|
|
355
378
|
```js
|
|
356
|
-
record.toBind({
|
|
379
|
+
record.toBind({
|
|
380
|
+
origin: 'example.com.', // strips matching suffix from owner; emits '@' for an exact match
|
|
381
|
+
ttl: 3600, // the zone default; lets `hide.ttl` skip records whose TTL matches it
|
|
382
|
+
previousOwner: 'example.com.', // lets `hide.sameOwner` blank the owner column when it repeats
|
|
383
|
+
hide: {
|
|
384
|
+
ttl: true, // omit TTL when it equals the zone default
|
|
385
|
+
class: true, // omit class column (usually IN)
|
|
386
|
+
sameOwner: true, // omit owner when it matches `previousOwner`
|
|
387
|
+
origin: true, // shorten owners relative to `origin`
|
|
388
|
+
},
|
|
389
|
+
})
|
|
357
390
|
```
|
|
358
391
|
|
|
359
|
-
See [dns-zone](https://github.com/NicTool/dns-zone) for full options
|
|
392
|
+
See [dns-zone](https://github.com/NicTool/dns-zone) for the full per-zone pipeline that supplies these options.
|
|
360
393
|
|
|
361
394
|
## Development
|
|
362
395
|
|
|
@@ -368,7 +401,7 @@ No external dependencies. Runs on node.js and modern browsers.
|
|
|
368
401
|
- `npm run watch` — Run tests in watch mode during development
|
|
369
402
|
- `npm run lint` — Check code with ESLint
|
|
370
403
|
- `npm run format` — Auto-format with Prettier and fix linting issues
|
|
371
|
-
- `npm run build` — Regenerate browser
|
|
404
|
+
- `npm run build` — Regenerate the browser and CommonJS bundles in `dist/`
|
|
372
405
|
- `npm run test:coverage` — Generate test coverage report
|
|
373
406
|
|
|
374
407
|
**Architecture:**
|