@nictool/dns-resource-record 1.2.2 → 1.2.4

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +21 -2
  2. package/README.md +2 -13
  3. package/package.json +15 -9
  4. package/rr/a.js +1 -3
  5. package/rr/aaaa.js +6 -7
  6. package/rr/caa.js +13 -2
  7. package/rr/cname.js +1 -3
  8. package/rr/dname.js +1 -3
  9. package/rr/dnskey.js +38 -5
  10. package/rr/ds.js +13 -2
  11. package/rr/ipseckey.js +26 -10
  12. package/rr/key.js +14 -2
  13. package/rr/mx.js +1 -3
  14. package/rr/naptr.js +5 -1
  15. package/rr/rrsig.js +13 -2
  16. package/rr/smimea.js +29 -3
  17. package/rr/srv.js +1 -3
  18. package/rr/sshfp.js +20 -3
  19. package/rr/tlsa.js +29 -3
  20. package/rr.js +15 -6
  21. package/.codeclimate.yml +0 -25
  22. package/.github/FUNDING.yml +0 -3
  23. package/.github/workflows/ci.yml +0 -43
  24. package/.github/workflows/codeql.yml +0 -14
  25. package/.github/workflows/publish.yml +0 -16
  26. package/.gitmodules +0 -3
  27. package/.prettierrc.yml +0 -3
  28. package/DEVELOP.md +0 -9
  29. package/eslint.config.mjs +0 -41
  30. package/test/a.js +0 -75
  31. package/test/aaaa.js +0 -86
  32. package/test/base.js +0 -148
  33. package/test/caa.js +0 -111
  34. package/test/cert.js +0 -48
  35. package/test/cname.js +0 -40
  36. package/test/dname.js +0 -57
  37. package/test/dnskey.js +0 -45
  38. package/test/ds.js +0 -45
  39. package/test/fake.js +0 -34
  40. package/test/hinfo.js +0 -80
  41. package/test/https.js +0 -56
  42. package/test/ipseckey.js +0 -141
  43. package/test/key.js +0 -36
  44. package/test/loc.js +0 -75
  45. package/test/mx.js +0 -78
  46. package/test/naptr.js +0 -47
  47. package/test/ns.js +0 -56
  48. package/test/nsec.js +0 -37
  49. package/test/nsec3.js +0 -47
  50. package/test/nsec3param.js +0 -23
  51. package/test/nxt.js +0 -37
  52. package/test/openpgpkey.js +0 -85
  53. package/test/ptr.js +0 -56
  54. package/test/rr.js +0 -212
  55. package/test/smimea.js +0 -51
  56. package/test/soa.js +0 -99
  57. package/test/spf.js +0 -51
  58. package/test/srv.js +0 -101
  59. package/test/sshfp.js +0 -69
  60. package/test/svcb.js +0 -56
  61. package/test/tinydns.js +0 -163
  62. package/test/tlsa.js +0 -63
  63. package/test/txt.js +0 -82
  64. package/test/uri.js +0 -65
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.2.4] - 2025-10-06
8
+
9
+ - rr: rename ucfirst -> ucFirst
10
+ - rr: setTTL was checking this.owner (copy/paste error)
11
+ - rr: improved throwHelp message formatting
12
+ - aaaa: compress & expand returns lower case
13
+ - caa, dnskey, ds, ipseckey, key, naptr, rrsig, smimea, sshfp, tlsa: refactored opts as JS maps
14
+ - deps: bump to latest versions
15
+
16
+ ### [1.2.3] - 2025-04-14
17
+
18
+ - test(\*): fully qualify node modules
19
+ - feat(rr.isIPv?): added regexes to validate format
20
+ - dep(node:{net|util): remove, for browser compatiblity
21
+ - doc(CONTRIBUTORS.md): added
22
+ - ci: disable codeql schedule (#45)
23
+
7
24
  ### [1.2.2] - 2024-11-17
8
25
 
9
26
  - dep(eslint): update to v9 & config
@@ -300,7 +317,9 @@ Notable changes to this project are documented in this file.
300
317
  [1.1.5]: https://github.com/NicTool/dns-resource-record/releases/tag/1.1.5
301
318
  [1.1.6]: https://github.com/NicTool/dns-resource-record/releases/tag/1.1.6
302
319
  [1.1.8]: https://github.com/NicTool/dns-resource-record/releases/tag/1.1.8
303
- [1.2.1]: https://github.com/NicTool/dns-resource-record/releases/tag/1.2.1
304
- [1.2.2]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.2.2
305
320
  [1.1.7]: https://github.com/NicTool/dns-resource-record/releases/tag/1.1.7
306
321
  [1.2.0]: https://github.com/NicTool/dns-resource-record/releases/tag/1.2.0
322
+ [1.2.1]: https://github.com/NicTool/dns-resource-record/releases/tag/1.2.1
323
+ [1.2.2]: https://github.com/NicTool/dns-resource-record/releases/tag/1.2.2
324
+ [1.2.3]: https://github.com/NicTool/dns-resource-record/releases/tag/1.2.3
325
+ [1.2.4]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.2.4
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # dns-resource-record
5
5
 
6
- DNS resource record parser, validator, importer, and exporter.
6
+ DNS resource record parser, validator, importer, and exporter for node.js & browsers.
7
7
 
8
8
  ## SYNOPSIS
9
9
 
@@ -181,7 +181,7 @@ Consider this a "running with scissors" mode.
181
181
 
182
182
  ## Supported Records
183
183
 
184
- This module intends to include support for all current (ie, not officially deprecated) DNS RRs **and** all RRs that are in active use on the internet.
184
+ This module intends to support all current (ie, not officially deprecated) DNS RRs **and** all RRs that are in active use on the internet.
185
185
 
186
186
  PRs are welcome, especially PRs with tests.
187
187
 
@@ -244,17 +244,6 @@ PRs are welcome, especially PRs with tests.
244
244
 
245
245
  ## TODO
246
246
 
247
- - [x] Change all IPs to use [RFC example/doc](https://en.wikipedia.org/wiki/Reserved_IP_addresses) address space
248
- - [x] change all domains to use reserved doc names
249
- - [x] import tests from nictool/server/t/12_records.t
250
- - [x] add defaults for empty values like TTL
251
- - [x] DNSSEC RRs: DS, NSEC, NSEC3, NSEC3PARAM, RRSIG
252
- - [x] CERT RRs: CERT, KEY, SIG, OPENPGPKEY
253
- - [x] RFC 4034: if the type of RR is NS, MD, MF, CNAME, SOA, MB,
254
- MG, MR, PTR, HINFO, MINFO, MX, RP, AFSDB, RT, SIG, PX, NXT,
255
- NAPTR, KX, SRV, DNAME, A6, RRSIG, or NSEC, all uppercase
256
- letters in the DNS names contained within the RDATA are replaced by the lowercase letters;
257
- - [x] LOC record ingest/out isn't consistent with API
258
247
  - [ ] export a web page for each RR type
259
248
 
260
249
  ## DEVELOP
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@nictool/dns-resource-record",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "DNS Resource Records",
5
5
  "main": "index.js",
6
- "file": [
6
+ "files": [
7
7
  "lib",
8
8
  "rr",
9
9
  "CHANGELOG.md",
@@ -13,13 +13,14 @@
13
13
  "scripts": {
14
14
  "format:check": "npm run prettier; npm run lint",
15
15
  "format": "npm run prettier -- --write && npm run lint --fix",
16
- "lint": "npx eslint@9 **/*.js",
16
+ "lint": "npx eslint **/*.js",
17
17
  "lint:fix": "npm run lint -- --fix",
18
18
  "prettier": "npx prettier --ignore-path .gitignore --check .",
19
19
  "prettier:fix": "npx prettier --ignore-path .gitignore --write .",
20
20
  "test": "npx mocha",
21
21
  "versions": "npx dependency-version-checker check",
22
- "watch": "npm run test -- --watch"
22
+ "watch": "npm run test -- --watch",
23
+ "versions:fix": "npx dependency-version-checker update"
23
24
  },
24
25
  "repository": {
25
26
  "type": "git",
@@ -45,9 +46,14 @@
45
46
  },
46
47
  "homepage": "https://github.com/NicTool/dns-resource-record#readme",
47
48
  "devDependencies": {
48
- "@eslint/js": "^9.15.0",
49
- "eslint": "^9.15.0",
50
- "globals": "^15.12.0",
51
- "mocha": "^10.8.2"
49
+ "@eslint/js": "^10.0.0",
50
+ "eslint": "^9.37.0",
51
+ "globals": "^16.4.0",
52
+ "mocha": "^11.7.4"
53
+ },
54
+ "prettier": {
55
+ "semi": false,
56
+ "singleQuote": true,
57
+ "trailingComma": "all"
52
58
  }
53
- }
59
+ }
package/rr/a.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
 
5
3
  export default class A extends RR {
@@ -10,7 +8,7 @@ export default class A extends RR {
10
8
  /****** Resource record specific setters *******/
11
9
  setAddress(val) {
12
10
  if (!val) this.throwHelp('A: address is required')
13
- if (!net.isIPv4(val)) this.throwHelp('A address must be IPv4')
11
+ if (!this.isIPv4(val)) this.throwHelp('A address must be IPv4')
14
12
  this.set('address', val)
15
13
  }
16
14
 
package/rr/aaaa.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
  import * as TINYDNS from '../lib/tinydns.js'
5
3
 
@@ -11,13 +9,13 @@ export default class AAAA extends RR {
11
9
  /****** Resource record specific setters *******/
12
10
  setAddress(val) {
13
11
  if (!val) this.throwHelp('AAAA: address is required')
14
- if (!net.isIPv6(val)) this.throwHelp(`AAAA: address must be IPv6 (${val})`)
12
+ if (!this.isIPv6(val)) this.throwHelp(`AAAA: address must be IPv6 (${val})`)
15
13
 
16
14
  this.set('address', this.expand(val.toLowerCase())) // lower case: RFC 5952
17
15
  }
18
16
 
19
17
  getCompressed(val) {
20
- this.compress(val || this.get('address'))
18
+ return this.compress(val || this.get('address'))
21
19
  }
22
20
 
23
21
  getDescription() {
@@ -114,12 +112,12 @@ export default class AAAA extends RR {
114
112
 
115
113
  for (const re of mostConsecutiveZeros) {
116
114
  if (re.test(r)) {
117
- r = r.replace(re, '::')
115
+ r = r.replace(re, '::') // 4.2
118
116
  break
119
117
  }
120
118
  }
121
119
 
122
- return r
120
+ return r.toLowerCase() // 4.3
123
121
  }
124
122
 
125
123
  expand(val, delimiter) {
@@ -136,11 +134,12 @@ export default class AAAA extends RR {
136
134
  .split(':')
137
135
  .map((s) => s.padStart(4, 0))
138
136
  .join(delimiter)
137
+ .toLowerCase()
139
138
  }
140
139
 
141
140
  /****** EXPORTERS *******/
142
141
  toBind(zone_opts) {
143
- return `${this.getPrefix(zone_opts)}\t${this.compress(this.get('address'))}\n`
142
+ return `${this.getPrefix(zone_opts)}\t${this.getCompressed()}\n`
144
143
  }
145
144
 
146
145
  toTinydns() {
package/rr/caa.js CHANGED
@@ -10,25 +10,36 @@ export default class CAA extends RR {
10
10
  setFlags(val) {
11
11
  this.is8bitInt('CAA', 'flags', val)
12
12
 
13
- if (![0, 128].includes(val)) {
13
+ if (!this.getFlagsOptions().has(val)) {
14
14
  this.throwHelp(`CAA flags ${val} not recognized`)
15
15
  }
16
16
 
17
17
  this.set('flags', val)
18
18
  }
19
19
 
20
+ getFlagsOptions() {
21
+ return new Map([
22
+ [0, 'Non Critical'],
23
+ [128, 'Critical'],
24
+ ])
25
+ }
26
+
20
27
  setTag(val) {
21
28
  if (typeof val !== 'string' || val.length < 1 || /[^a-z0-9]/.test(val))
22
29
  this.throwHelp(
23
30
  `CAA tag must be a sequence of ASCII letters and numbers in lowercase`,
24
31
  )
25
32
 
26
- if (!['issue', 'issuewild', 'iodef'].includes(val)) {
33
+ if (!this.getTagOptions().has(val)) {
27
34
  this.throwHelp(`CAA tag ${val} not recognized`)
28
35
  }
29
36
  this.set('tag', val)
30
37
  }
31
38
 
39
+ getTagOptions() {
40
+ return new Map([['issue'], ['issuewild'], ['iodef']])
41
+ }
42
+
32
43
  setValue(val) {
33
44
  // either (2) a quoted string or
34
45
  // (1) a contiguous set of characters without interior spaces
package/rr/cname.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
 
5
3
  export default class CNAME extends RR {
@@ -14,7 +12,7 @@ export default class CNAME extends RR {
14
12
 
15
13
  if (!val) this.throwHelp('CNAME: cname is required')
16
14
 
17
- if (net.isIPv4(val) || net.isIPv6(val))
15
+ if (this.isIPv4(val) || this.isIPv6(val))
18
16
  this.throwHelp(`CNAME: cname must be a FQDN: RFC 2181`)
19
17
 
20
18
  if (!this.isFullyQualified('CNAME', 'cname', val)) return
package/rr/dname.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
  import * as TINYDNS from '../lib/tinydns.js'
5
3
 
@@ -12,7 +10,7 @@ export default class DNAME extends RR {
12
10
  setTarget(val) {
13
11
  if (!val) this.throwHelp('DNAME: target is required')
14
12
 
15
- if (net.isIPv4(val) || net.isIPv6(val))
13
+ if (this.isIPv4(val) || this.isIPv6(val))
16
14
  this.throwHelp(`DNAME: target must be a domain name`)
17
15
 
18
16
  this.isFullyQualified('DNAME', 'target', val)
package/rr/dnskey.js CHANGED
@@ -12,34 +12,67 @@ export default class DNSKEY extends RR {
12
12
  // a 2 octet Flags Field
13
13
  this.is16bitInt('DNSKEY', 'flags', val)
14
14
 
15
- // the possible values are: 0, 256, and 257; RFC 4034
16
- if (![0, 256, 257].includes(val)) this.throwHelp(`DNSKEY: flags invalid`)
15
+ if (!this.getFlagsOptions().has(val)) {
16
+ this.throwHelp(
17
+ `DNSKEY: flags must be in the set: ${this.getFlagsOptions()}`,
18
+ )
19
+ }
17
20
 
18
21
  this.set('flags', val)
19
22
  }
20
23
 
24
+ // possible values are: 0, 256, and 257; RFC 4034
25
+ getFlagsOptions() {
26
+ return new Map([[0], [256], [257]])
27
+ }
28
+
21
29
  setProtocol(val) {
22
30
  // 1 octet
23
31
  this.is8bitInt('DNSKEY', 'protocol', val)
24
32
 
25
33
  // The Protocol Field MUST be represented as an unsigned decimal integer with a value of 3.
26
- if (![3].includes(val)) this.throwHelp(`DNSKEY: protocol invalid`)
34
+ if (!this.getProtocolOptions().has(val))
35
+ this.throwHelp(`DNSKEY: protocol invalid`)
27
36
 
28
37
  this.set('protocol', val)
29
38
  }
30
39
 
40
+ getProtocolOptions() {
41
+ return new Map([[3]])
42
+ }
43
+
31
44
  setAlgorithm(val) {
32
45
  // 1 octet
33
46
  this.is8bitInt('DNSKEY', 'algorithm', val)
34
47
 
35
48
  // https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml
36
- // 1=RSA/MD5, 2=DH, 3=DSA/SHA-1, 4=EC, 5=RSA/SHA-1
37
- if (![...Array(16).keys(), 253, 254].includes(val))
49
+ if (!this.getAlgorithmOptions().has(val))
38
50
  console.error(`DNSKEY: algorithm (${val}) not recognized`)
39
51
 
40
52
  this.set('algorithm', val)
41
53
  }
42
54
 
55
+ getAlgorithmOptions() {
56
+ return new Map([
57
+ [1, 'RSA/MD5 (DEPRECATED)'],
58
+ [2, 'DH'],
59
+ [3, 'DSA/SHA-1'],
60
+ [4, 'EC'],
61
+ [5, 'RSA/SHA-1'],
62
+ [6, 'DSA-NSEC3-SHA1'],
63
+ [7, 'RSASHA1-NSEC3-SHA1'],
64
+ [8, 'RSA/SHA-256'],
65
+ [9, ''],
66
+ [10, 'RSA/SHA-512'],
67
+ [13, 'ECDSA Curve P-256 with SHA-256'],
68
+ [14, 'ECDSA Curve P-384 with SHA-384'],
69
+ [15, 'Ed25519'],
70
+ [16, 'Ed448'],
71
+ [253],
72
+ [254],
73
+ ])
74
+ }
75
+
43
76
  setPublickey(val) {
44
77
  if (!val) this.throwHelp(`DNSKEY: publickey is required`)
45
78
 
package/rr/ds.js CHANGED
@@ -17,13 +17,24 @@ export default class DS extends RR {
17
17
  }
18
18
 
19
19
  setAlgorithm(val) {
20
- // 1=RSA/MD5, 2=DH, 3=DSA/SHA-1, 4=EC, 5=RSA/SHA-1
21
- if (![1, 2, 3, 4, 5, 253, 254].includes(val))
20
+ if (!this.getAlgorithmOptions().has(val))
22
21
  this.throwHelp(`DS: algorithm invalid`)
23
22
 
24
23
  this.set('algorithm', val)
25
24
  }
26
25
 
26
+ getAlgorithmOptions() {
27
+ return new Map([
28
+ [1, 'RSA/MD5'],
29
+ [2, 'DH'],
30
+ [3, 'DSA/SHA-1'],
31
+ [4, 'EC'],
32
+ [5, 'RSA/SHA-1'],
33
+ [253, ''],
34
+ [254, ''],
35
+ ])
36
+ }
37
+
27
38
  setDigestType(val) {
28
39
  if (![1, 2].includes(val)) this.throwHelp(`DS: digest type invalid`)
29
40
 
package/rr/ipseckey.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
 
5
3
  import * as TINYDNS from '../lib/tinydns.js'
@@ -18,31 +16,49 @@ export default class IPSECKEY extends RR {
18
16
  }
19
17
 
20
18
  setGatewayType(val) {
21
- // 0 (none), 1 (4-byte IPv4), 2 (16-byte IPv6), 3 (wire encoded domain name)
22
- if (![0, 1, 2, 3].includes(val))
19
+ if (!this.getGatewayTypeOptions().has(val))
23
20
  this.throwHelp(`IPSECKEY: Gateway Type is invalid`)
24
21
 
25
22
  this.set('gateway type', val)
26
23
  }
27
24
 
25
+ getGatewayTypeOptions() {
26
+ return new Map([
27
+ [0, 'none'],
28
+ [1, '4-byte IPv4'],
29
+ [2, '16-byte IPv6'],
30
+ [3, 'wire encoded domain name'],
31
+ ])
32
+ }
33
+
28
34
  setAlgorithm(val) {
29
- // unsigned int, 1 octet, values: 1=DSA, 2=RSA
30
- if (![1, 2].includes(val)) this.throwHelp(`IPSECKEY: Algorithm invalid`)
35
+ if (!this.getAlgorithmOptions().has(val))
36
+ this.throwHelp(`IPSECKEY: Algorithm invalid`)
31
37
 
32
38
  this.set('algorithm', val)
33
39
  }
34
40
 
41
+ getAlgorithmOptions() {
42
+ return new Map([
43
+ [1, 'DSA'],
44
+ [2, 'RSA'],
45
+ ])
46
+ }
47
+
35
48
  setGateway(val) {
36
- const gwErr = new Error(`IPSECKEY: gateway invalid (${val})`)
37
- switch (this.get('gateway type')) {
49
+ const type = this.get('gateway type')
50
+ const gwErr = new Error(
51
+ `IPSECKEY: gateway invalid (${val}) for type ${type}`,
52
+ )
53
+ switch (type) {
38
54
  case 0:
39
55
  if (val !== '.') throw gwErr
40
56
  break
41
57
  case 1:
42
- if (!net.isIPv4(val)) throw gwErr
58
+ if (!this.isIPv4(val)) throw gwErr
43
59
  break
44
60
  case 2:
45
- if (!net.isIPv6(val)) throw gwErr
61
+ if (!this.isIPv6(val)) throw gwErr
46
62
  break
47
63
  }
48
64
 
package/rr/key.js CHANGED
@@ -22,13 +22,25 @@ export default class KEY extends RR {
22
22
 
23
23
  setAlgorithm(val) {
24
24
  // 1 octet
25
- // 1=RSA/MD5, 2=DH, 3=DSA/SHA-1, 4=EC, 5=RSA/SHA-1
26
- if (![1, 2, 3, 4, 5, 253, 254].includes(val))
25
+
26
+ if (!this.getAlgorithmOptions().has(val))
27
27
  this.throwHelp(`KEY: algorithm invalid`)
28
28
 
29
29
  this.set('algorithm', val)
30
30
  }
31
31
 
32
+ getAlgorithmOptions() {
33
+ return new Map([
34
+ [1, 'RSA/MD5'],
35
+ [2, 'DH'],
36
+ [3, 'DSA/SHA-1'],
37
+ [4, 'EC'],
38
+ [5, 'RSA/SHA-1'],
39
+ [253, ''],
40
+ [254, ''],
41
+ ])
42
+ }
43
+
32
44
  setPublickey(val) {
33
45
  if (!val) this.throwHelp(`KEY: publickey is required`)
34
46
 
package/rr/mx.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
 
5
3
  export default class MX extends RR {
@@ -18,7 +16,7 @@ export default class MX extends RR {
18
16
  setExchange(val) {
19
17
  if (!val) this.throwHelp('MX: exchange is required')
20
18
 
21
- if (net.isIPv4(val) || net.isIPv6(val))
19
+ if (this.isIPv4(val) || this.isIPv6(val))
22
20
  this.throwHelp(`MX: exchange must be a FQDN`)
23
21
 
24
22
  this.isFullyQualified('MX', 'exchange', val)
package/rr/naptr.js CHANGED
@@ -40,12 +40,16 @@ export default class NAPTR extends RR {
40
40
  }
41
41
 
42
42
  setFlags(val) {
43
- if (!['', 'S', 'A', 'U', 'P'].includes(val.toUpperCase()))
43
+ if (!this.getFlagsOptions().has(val.toUpperCase()))
44
44
  this.throwHelp(`NAPTR flags are invalid`)
45
45
 
46
46
  this.set('flags', val.toUpperCase())
47
47
  }
48
48
 
49
+ getFlagsOptions() {
50
+ return new Map([[''], ['S'], ['A'], ['U'], ['P']])
51
+ }
52
+
49
53
  setService(val) {
50
54
  this.set('service', val)
51
55
  }
package/rr/rrsig.js CHANGED
@@ -16,13 +16,24 @@ export default class RRSIG extends RR {
16
16
 
17
17
  setAlgorithm(val) {
18
18
  // a 1 octet Algorithm field
19
- // 1=RSA/MD5, 2=DH, 3=RRSIGA/SHA-1, 4=EC, 5=RSA/SHA-1
20
- if (![1, 2, 3, 4, 5, 253, 254].includes(val))
19
+ if (!this.getAlgorithmOptions().has(val))
21
20
  this.throwHelp(`RRSIG: algorithm invalid`)
22
21
 
23
22
  this.set('algorithm', val)
24
23
  }
25
24
 
25
+ getAlgorithmOptions() {
26
+ return new Map([
27
+ [1, 'RSA/MD5'],
28
+ [2, 'DH'],
29
+ [3, 'RRSIGA/SHA-1'],
30
+ [4, 'EC'],
31
+ [5, 'RSA/SHA-1'],
32
+ [253],
33
+ [254],
34
+ ])
35
+ }
36
+
26
37
  setLabels(val) {
27
38
  // a 1 octet Labels field
28
39
  this.is8bitInt('RRSIG', 'labels', val)
package/rr/smimea.js CHANGED
@@ -7,24 +7,50 @@ export default class SMIMEA extends RR {
7
7
 
8
8
  /****** Resource record specific setters *******/
9
9
  setCertificateUsage(val) {
10
- if (![0, 1, 2, 3].includes(val))
10
+ if (!this.getCertificateUsageOptions().has(val))
11
11
  this.throwHelp(`SMIMEA: certificate usage invalid`)
12
12
 
13
13
  this.set('certificate usage', val)
14
14
  }
15
15
 
16
+ getCertificateUsageOptions() {
17
+ return new Map([
18
+ [0, 'CA certificate'],
19
+ [1, 'an end entity certificate'],
20
+ [2, 'the trust anchor'],
21
+ [3, 'domain-issued certificate'],
22
+ ])
23
+ }
24
+
16
25
  setSelector(val) {
17
- if (![0, 1].includes(val)) this.throwHelp(`SMIMEA: selector invalid`)
26
+ if (!this.getSelectorOptions().has(val))
27
+ this.throwHelp(`SMIMEA: selector invalid`)
18
28
 
19
29
  this.set('selector', val)
20
30
  }
21
31
 
32
+ getSelectorOptions() {
33
+ return new Map([
34
+ [0, 'Full certificate'],
35
+ [1, 'SubjectPublicKeyInfo'],
36
+ ])
37
+ }
38
+
22
39
  setMatchingType(val) {
23
- if (![0, 1, 2].includes(val)) this.throwHelp(`SMIMEA: matching type`)
40
+ if (!this.getMatchingTypeOptions().has(val))
41
+ this.throwHelp(`SMIMEA: matching type`)
24
42
 
25
43
  this.set('matching type', val)
26
44
  }
27
45
 
46
+ getMatchingTypeOptions() {
47
+ return new Map([
48
+ [0, 'Exact match'],
49
+ [1, 'SHA-256 hash'],
50
+ [2, 'SHA-512 hash'],
51
+ ])
52
+ }
53
+
28
54
  setCertificateAssociationData(val) {
29
55
  this.set('certificate association data', val)
30
56
  }
package/rr/srv.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
  import * as TINYDNS from '../lib/tinydns.js'
5
3
 
@@ -30,7 +28,7 @@ export default class SRV extends RR {
30
28
  setTarget(val) {
31
29
  if (!val) this.throwHelp(`SRV: target is required`)
32
30
 
33
- if (net.isIPv4(val) || net.isIPv6(val))
31
+ if (this.isIPv4(val) || this.isIPv6(val))
34
32
  this.throwHelp(`SRV: target must be a FQDN`)
35
33
 
36
34
  this.isFullyQualified('SRV', 'target', val)
package/rr/sshfp.js CHANGED
@@ -8,19 +8,36 @@ export default class SSHFP extends RR {
8
8
 
9
9
  /****** Resource record specific setters *******/
10
10
  setAlgorithm(val) {
11
- // 0: reserved 1: RSA 2: DSA 3: ECDSA 4: Ed25519 6: Ed448
12
11
  this.is8bitInt('SSHFP', 'algorithm', val)
13
12
 
14
13
  this.set('algorithm', val)
15
14
  }
16
15
 
16
+ getAlgorithmOptions() {
17
+ return new Map([
18
+ [0, 'reserved'],
19
+ [1, 'RSA'],
20
+ [2, 'DSA'],
21
+ [3, 'ECDSA'],
22
+ [4, 'Ed25519'],
23
+ [6, 'Ed448'],
24
+ ])
25
+ }
26
+
17
27
  setFptype(val) {
18
- // 0: reserved, 1: SHA-1, 2: SHA-256
19
- this.is8bitInt('SSHFP', 'type', val)
28
+ this.is8bitInt('SSHFP', 'fptype', val)
20
29
 
21
30
  this.set('fptype', val)
22
31
  }
23
32
 
33
+ getFptypeOptions() {
34
+ return new Map([
35
+ [0, 'reserved'],
36
+ [1, 'SHA-1'],
37
+ [2, 'SHA-256'],
38
+ ])
39
+ }
40
+
24
41
  setFingerprint(val) {
25
42
  this.set('fingerprint', val)
26
43
  }
package/rr/tlsa.js CHANGED
@@ -9,24 +9,50 @@ export default class TLSA extends RR {
9
9
 
10
10
  /****** Resource record specific setters *******/
11
11
  setCertificateUsage(val) {
12
- if (![0, 1, 2, 3].includes(val))
12
+ if (!this.getCertificateUsageOptions().has(val))
13
13
  this.throwHelp(`TLSA: certificate usage invalid`)
14
14
 
15
15
  this.set('certificate usage', val)
16
16
  }
17
17
 
18
+ getCertificateUsageOptions() {
19
+ return new Map([
20
+ [0, 'CA certificate'],
21
+ [1, 'an end entity certificate'],
22
+ [2, 'the trust anchor'],
23
+ [3, 'domain-issued certificate'],
24
+ ])
25
+ }
26
+
18
27
  setSelector(val) {
19
- if (![0, 1].includes(val)) this.throwHelp(`TLSA: selector invalid`)
28
+ if (!this.getSelectorOptions().has(val))
29
+ this.throwHelp(`TLSA: selector invalid`)
20
30
 
21
31
  this.set('selector', val)
22
32
  }
23
33
 
34
+ getSelectorOptions() {
35
+ return new Map([
36
+ [0, 'Full certificate'],
37
+ [1, 'SubjectPublicKeyInfo'],
38
+ ])
39
+ }
40
+
24
41
  setMatchingType(val) {
25
- if (![0, 1, 2].includes(val)) this.throwHelp(`TLSA: matching type`)
42
+ if (!this.getMatchingTypeOptions().has(val))
43
+ this.throwHelp(`TLSA: matching type`)
26
44
 
27
45
  this.set('matching type', val)
28
46
  }
29
47
 
48
+ getMatchingTypeOptions() {
49
+ return new Map([
50
+ [0, 'Exact match'],
51
+ [1, 'SHA-256 hash'],
52
+ [2, 'SHA-512 hash'],
53
+ ])
54
+ }
55
+
30
56
  setCertificateAssociationData(val) {
31
57
  this.set('certificate association data', val)
32
58
  }