Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/
.release/
2 changes: 1 addition & 1 deletion .release
Submodule .release updated 2 files
+11 −13 js/contributors.cjs
+2 −1 start.sh
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ Notable changes to this project are documented in this file.

#### Unreleased

### [1.8.0] - 2026-05-25

- lib/wire.js — hardened readWireName()
- new wirePackDomainCompressed() for RFC 1035 §4.1.4 name compression
- charstrs decoder preserves multi-string boundaries
- lib/bind.js — fromBind() returns array for charstrs (TXT) when input has multiple quoted strings.
- rr/rrsig.js — getAlgorithmOptions() extended with DNSSEC algorithms 6, 7, 8, 10, 13, 14, 15, 16.
- rr/ds.js — setDigestType() now accepts SHA-384 (4)
- rr/txt.js — getWireRdata() and fromTinydnsGeneric() preserve per-segment boundaries.
- package.json — engines lowered to >=20
- new build:cjs script via Rollup.
- test/wire.js, test/base.js, test/rr/{rrsig,ds,txt}.js — round-trip + negative tests for each fix.

### [1.7.0] - 2026-04-20

#### Fixes
Expand Down Expand Up @@ -418,3 +431,4 @@ Notable changes to this project are documented in this file.
[1.6.0]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.6.0
[1.6.1]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.6.1
[1.7.0]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.7.0
[1.8.0]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.8.0
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

This handcrafted artisanal software is brought to you by:

| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/NicTool/dns-resource-record/commits?author=msimerson">67</a>) | <img height="80" src="https://avatars.githubusercontent.com/in/1143301?v=4"><br><a href="https://github.com/apps/copilot-swe-agent">Copilot</a> (<a href="https://github.com/NicTool/dns-resource-record/commits?author=Copilot">3</a>) |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/NicTool/dns-resource-record/commits?author=msimerson">68</a>) |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is generated by [.release](https://github.com/msimerson/.release).
Contribute to this project to get your GitHub profile included here.</sub>
57 changes: 45 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ This module supports all current DNS RRs in active use on the internet.
npm install @nictool/dns-resource-record
```

### ESM and CommonJS

The package ships both ESM and CJS, selected automatically via the package `exports` map:

```js
// ESM
import * as RR from '@nictool/dns-resource-record'
import RR, { A, TXT } from '@nictool/dns-resource-record'
```

```js
// CommonJS
const RR = require('@nictool/dns-resource-record')
const { A, TXT } = require('@nictool/dns-resource-record')
```

The default export (the base `RR` class) is reached as `require('@nictool/dns-resource-record').default` from CommonJS.

### Validation

Validate an A record:
Expand All @@ -57,14 +75,14 @@ const validA = new RR.A({
})

console.log(validA.toBind())
// example.com 3600 IN A 192.0.2.1
// example.com. 3600 IN A 192.0.2.1
```

Invalid records throw immediately:

```js
try {
new RR.A({ owner: 'example.com.', address: 'not-an-ip' })
new RR.A({ owner: 'example.com.', address: 'not-an-ip', ttl: 3600 })
} catch (err) {
console.error(err.message) // Error: A address must be IPv4
}
Expand Down Expand Up @@ -148,7 +166,7 @@ new RR.MX({
exchange: 'mail.example.com.',
ttl: 3600,
}).toBind()
// example.com 3600 IN MX 10 mail.example.com.
// example.com. 3600 IN MX 10 mail.example.com.
```

**When to use:** Generating zone files, displaying records for editing, exporting to BIND nameservers.
Expand Down Expand Up @@ -182,7 +200,7 @@ const fromTiny = RR.CAA.fromTinydns(
':ns1.example.com:257:\\000\\005issue"http\\072\\057\\057letsencrypt.org":3600::\n',
)
console.log(fromTiny.toBind())
// ns1.example.com 3600 IN CAA 0 issue "http://letsencrypt.org"
// ns1.example.com. 3600 IN CAA 0 issue "http://letsencrypt.org"
```

**When to use:** DNS migrations, format conversions, tool interoperability.
Expand All @@ -204,7 +222,7 @@ a.setAddress('192.0.2.2')
a.setTtl(7200)

console.log(a.toBind())
// example.com 7200 IN A 192.0.2.2
// example.com. 7200 IN A 192.0.2.2
```

Setters include validation. Invalid values throw with helpful error messages.
Expand All @@ -214,7 +232,7 @@ For a list of available setters, check `getFields('rdata')` for your record type
```js
new RR.SSHFP(null).getFields('rdata')
// ['algorithm', 'fptype', 'fingerprint']
// So use: setSshfp(), setFptype(), setFingerprint()
// So use: setAlgorithm(), setFptype(), setFingerprint()
```

---
Expand Down Expand Up @@ -340,23 +358,38 @@ Domain owner names are:
**Example:**

```js
new RR.A({ owner: 'EXAMPLE.COM', address: '192.0.2.1', ttl: 3600 })
// Automatically normalized to: 'example.com.'
const r = new RR.A({ owner: 'EXAMPLE.COM.', address: '192.0.2.1', ttl: 3600 })
r.get('owner') // 'example.com.' — uppercase normalized to lowercase
```

Owner names are required to be fully qualified (trailing dot). Unqualified
names throw at construction; this library does not add the dot for you.

### Relative vs Absolute Names

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.

### Export Options

The `toBind()` and `toMaraDNS()` methods accept an options object to customize output:
The `toBind()` method accepts a zone-options object (typically supplied by
[dns-zone](https://github.com/NicTool/dns-zone) when emitting full zone files)
to elide redundant per-record output:

```js
record.toBind({ suppressTtl: true, suppressClass: true, relativeName: true })
record.toBind({
origin: 'example.com.', // strips matching suffix from owner; emits '@' for an exact match
ttl: 3600, // the zone default; lets `hide.ttl` skip records whose TTL matches it
previousOwner: 'example.com.', // lets `hide.sameOwner` blank the owner column when it repeats
hide: {
ttl: true, // omit TTL when it equals the zone default
class: true, // omit class column (usually IN)
sameOwner: true, // omit owner when it matches `previousOwner`
origin: true, // shorten owners relative to `origin`
},
})
```

See [dns-zone](https://github.com/NicTool/dns-zone) for full options documentation.
See [dns-zone](https://github.com/NicTool/dns-zone) for the full per-zone pipeline that supplies these options.

## Development

Expand All @@ -368,7 +401,7 @@ No external dependencies. Runs on node.js and modern browsers.
- `npm run watch` — Run tests in watch mode during development
- `npm run lint` — Check code with ESLint
- `npm run format` — Auto-format with Prettier and fix linting issues
- `npm run build` — Regenerate browser bundle and README
- `npm run build` — Regenerate the browser and CommonJS bundles in `dist/`
- `npm run test:coverage` — Generate test coverage report

**Architecture:**
Expand Down
Loading
Loading