@nictool/dns-resource-record 1.7.0 → 1.8.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/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ Notable changes to this project are documented in this file.
4
4
 
5
5
  #### Unreleased
6
6
 
7
+ ### [1.8.1] - 2026-07-25
8
+
9
+ - rr/bind: merge charstrs for opaque rdata types
10
+
11
+ ### [1.8.0] - 2026-05-25
12
+
13
+ - lib/wire.js — hardened readWireName()
14
+ - new wirePackDomainCompressed() for RFC 1035 §4.1.4 name compression
15
+ - charstrs decoder preserves multi-string boundaries
16
+ - lib/bind.js — fromBind() returns array for charstrs (TXT) when input has multiple quoted strings.
17
+ - rr/rrsig.js — getAlgorithmOptions() extended with DNSSEC algorithms 6, 7, 8, 10, 13, 14, 15, 16.
18
+ - rr/ds.js — setDigestType() now accepts SHA-384 (4)
19
+ - rr/txt.js — getWireRdata() and fromTinydnsGeneric() preserve per-segment boundaries.
20
+ - package.json — engines lowered to >=20
21
+ - new build:cjs script via Rollup.
22
+ - test/wire.js, test/base.js, test/rr/{rrsig,ds,txt}.js — round-trip + negative tests for each fix.
23
+
7
24
  ### [1.7.0] - 2026-04-20
8
25
 
9
26
  #### Fixes
@@ -418,3 +435,5 @@ Notable changes to this project are documented in this file.
418
435
  [1.6.0]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.6.0
419
436
  [1.6.1]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.6.1
420
437
  [1.7.0]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.7.0
438
+ [1.8.0]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.8.0
439
+ [1.8.1]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.8.1
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 3600 IN A 192.0.2.1
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 3600 IN MX 10 mail.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 3600 IN CAA 0 issue "http://letsencrypt.org"
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 7200 IN A 192.0.2.2
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: setSshfp(), setFptype(), setFingerprint()
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
- // Automatically normalized to: 'example.com.'
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()` and `toMaraDNS()` methods accept an options object to customize output:
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 omit redundant per-record output:
354
377
 
355
378
  ```js
356
- record.toBind({ suppressTtl: true, suppressClass: true, relativeName: true })
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 documentation.
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 bundle and README
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:**