@nictool/dns-resource-record 1.1.7 → 1.2.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.
Files changed (74) hide show
  1. package/.prettierrc.yml +3 -0
  2. package/CHANGELOG.md +17 -43
  3. package/README.md +45 -47
  4. package/index.js +77 -29
  5. package/lib/tinydns.js +68 -61
  6. package/package.json +1 -2
  7. package/rr/a.js +19 -20
  8. package/rr/aaaa.js +35 -31
  9. package/rr/caa.js +41 -39
  10. package/rr/cert.js +21 -19
  11. package/rr/cname.js +19 -20
  12. package/rr/dname.js +19 -19
  13. package/rr/dnskey.js +48 -41
  14. package/rr/ds.js +38 -36
  15. package/rr/hinfo.js +26 -25
  16. package/rr/ipseckey.js +53 -45
  17. package/rr/key.js +21 -21
  18. package/rr/loc.js +67 -54
  19. package/rr/mx.js +26 -24
  20. package/rr/naptr.js +51 -52
  21. package/rr/ns.js +25 -22
  22. package/rr/nsec.js +26 -20
  23. package/rr/nsec3.js +63 -44
  24. package/rr/nsec3param.js +29 -26
  25. package/rr/nxt.js +67 -0
  26. package/rr/openpgpkey.js +13 -14
  27. package/rr/ptr.js +20 -21
  28. package/rr/rrsig.js +27 -21
  29. package/rr/sig.js +24 -19
  30. package/rr/smimea.js +35 -28
  31. package/rr/soa.js +57 -42
  32. package/rr/spf.js +20 -17
  33. package/rr/srv.js +41 -41
  34. package/rr/sshfp.js +29 -30
  35. package/rr/tlsa.js +47 -40
  36. package/rr/tsig.js +48 -0
  37. package/rr/txt.js +40 -33
  38. package/rr/uri.js +31 -31
  39. package/rr/wks.js +44 -0
  40. package/rr.js +111 -77
  41. package/.codeclimate.yml +0 -25
  42. package/DEVELOP.md +0 -23
  43. package/test/a.js +0 -76
  44. package/test/aaaa.js +0 -79
  45. package/test/base.js +0 -138
  46. package/test/caa.js +0 -104
  47. package/test/cert.js +0 -48
  48. package/test/cname.js +0 -41
  49. package/test/dname.js +0 -53
  50. package/test/dnskey.js +0 -44
  51. package/test/ds.js +0 -44
  52. package/test/fake.js +0 -26
  53. package/test/hinfo.js +0 -75
  54. package/test/ipseckey.js +0 -115
  55. package/test/key.js +0 -37
  56. package/test/loc.js +0 -71
  57. package/test/mx.js +0 -75
  58. package/test/naptr.js +0 -40
  59. package/test/ns.js +0 -53
  60. package/test/nsec.js +0 -38
  61. package/test/nsec3.js +0 -40
  62. package/test/nsec3param.js +0 -26
  63. package/test/openpgpkey.js +0 -35
  64. package/test/ptr.js +0 -54
  65. package/test/rr.js +0 -196
  66. package/test/smimea.js +0 -45
  67. package/test/soa.js +0 -77
  68. package/test/spf.js +0 -48
  69. package/test/srv.js +0 -81
  70. package/test/sshfp.js +0 -62
  71. package/test/tinydns.js +0 -140
  72. package/test/tlsa.js +0 -54
  73. package/test/txt.js +0 -70
  74. package/test/uri.js +0 -61
package/rr/naptr.js CHANGED
@@ -1,136 +1,135 @@
1
-
2
1
  import RR from '../rr.js'
3
2
  import * as TINYDNS from '../lib/tinydns.js'
4
3
 
5
4
  const rdataRe = /[\r\n\t:\\/]/
6
5
 
7
6
  export default class NAPTR extends RR {
8
- constructor (opts) {
7
+ constructor(opts) {
9
8
  super(opts)
10
9
  }
11
10
 
12
- getDescription () {
11
+ getDescription() {
13
12
  return 'Naming Authority Pointer'
14
13
  }
15
14
 
16
- getQuotedFields () {
17
- return [ 'flags', 'service', 'regexp' ]
15
+ getQuotedFields() {
16
+ return ['flags', 'service', 'regexp']
18
17
  }
19
18
 
20
- getRdataFields (arg) {
21
- return [ 'order', 'preference', 'flags', 'service', 'regexp', 'replacement' ]
19
+ getRdataFields(arg) {
20
+ return ['order', 'preference', 'flags', 'service', 'regexp', 'replacement']
22
21
  }
23
22
 
24
- getRFCs () {
25
- return [ 2915, 3403 ]
23
+ getRFCs() {
24
+ return [2915, 3403]
26
25
  }
27
26
 
28
- getTypeId () {
27
+ getTypeId() {
29
28
  return 35
30
29
  }
31
30
 
32
31
  /****** Resource record specific setters *******/
33
- setOrder (val) {
32
+ setOrder(val) {
34
33
  this.is16bitInt('NAPTR', 'order', val)
35
34
  this.set('order', val)
36
35
  }
37
36
 
38
- setPreference (val) {
37
+ setPreference(val) {
39
38
  this.is16bitInt('NAPTR', 'preference', val)
40
39
  this.set('preference', val)
41
40
  }
42
41
 
43
- setFlags (val) {
44
- if (![ '', 'S', 'A', 'U', 'P' ].includes(val.toUpperCase()))
45
- throw new Error (`NAPTR flags are invalid, ${this.citeRFC()}`)
42
+ setFlags(val) {
43
+ if (!['', 'S', 'A', 'U', 'P'].includes(val.toUpperCase()))
44
+ throw new Error(`NAPTR flags are invalid, ${this.citeRFC()}`)
46
45
 
47
46
  this.set('flags', val.toUpperCase())
48
47
  }
49
48
 
50
- setService (val) {
49
+ setService(val) {
51
50
  this.set('service', val)
52
51
  }
53
52
 
54
- setRegexp (val) {
53
+ setRegexp(val) {
55
54
  this.set('regexp', val)
56
55
  }
57
56
 
58
- setReplacement (val) {
57
+ setReplacement(val) {
59
58
  this.set('replacement', val)
60
59
  }
61
60
 
62
61
  /****** IMPORTERS *******/
63
- fromTinydns (opts) {
62
+ fromTinydns(opts) {
64
63
  // NAPTR via generic, :fqdn:n:rdata:ttl:timestamp:lo
65
- const [ fqdn, n, rdata, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
64
+ const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
66
65
  if (n != 35) throw new Error('NAPTR fromTinydns, invalid n')
67
66
 
68
67
  const binRdata = Buffer.from(TINYDNS.octalToChar(rdata), 'binary')
69
68
 
70
69
  const rec = {
71
- type : 'NAPTR',
72
- owner : this.fullyQualify(fqdn),
73
- ttl : parseInt(ttl, 10),
74
- timestamp : ts,
75
- location : loc !== '' && loc !== '\n' ? loc : '',
76
- order : binRdata.readUInt16BE(0,2),
77
- preference: binRdata.readUInt16BE(2,4),
70
+ type: 'NAPTR',
71
+ owner: this.fullyQualify(fqdn),
72
+ ttl: parseInt(ttl, 10),
73
+ timestamp: ts,
74
+ location: loc !== '' && loc !== '\n' ? loc : '',
75
+ order: binRdata.readUInt16BE(0, 2),
76
+ preference: binRdata.readUInt16BE(2, 4),
78
77
  }
79
78
 
80
79
  let idx = 4
81
- const flagsLength = binRdata.readUInt8(idx); idx++
82
- rec.flags = binRdata.slice(idx, flagsLength).toString()
80
+ const flagsLength = binRdata.readUInt8(idx)
81
+ idx++
82
+ rec.flags = binRdata.slice(idx, flagsLength).toString()
83
83
  idx += flagsLength
84
84
 
85
- const serviceLen = binRdata.readUInt8(idx); idx++
86
- rec.service = binRdata.slice(idx, idx+serviceLen).toString()
85
+ const serviceLen = binRdata.readUInt8(idx)
86
+ idx++
87
+ rec.service = binRdata.slice(idx, idx + serviceLen).toString()
87
88
  idx += serviceLen
88
89
 
89
- const regexpLen = binRdata.readUInt8(idx); idx++
90
- rec.regexp = binRdata.slice(idx, idx+regexpLen).toString()
90
+ const regexpLen = binRdata.readUInt8(idx)
91
+ idx++
92
+ rec.regexp = binRdata.slice(idx, idx + regexpLen).toString()
91
93
  idx += regexpLen
92
94
 
93
- const replaceLen = binRdata.readUInt8(idx); idx++
94
- rec.replacement = binRdata.slice(idx, idx+replaceLen).toString()
95
+ const replaceLen = binRdata.readUInt8(idx)
96
+ idx++
97
+ rec.replacement = binRdata.slice(idx, idx + replaceLen).toString()
95
98
 
96
99
  return new NAPTR(rec)
97
100
  }
98
101
 
99
- fromBind (opts) {
102
+ fromBind(opts) {
100
103
  const str = opts.bindline
101
104
  // test.example.com 3600 IN NAPTR order, preference, "flags", "service", "regexp", replacement
102
- const [ owner, ttl, c, type, order, preference ] = str.split(/\s+/)
103
- const [ flags, service, regexp ] = str.match(/(?:").*?(?:"\s)/g)
105
+ const [owner, ttl, c, type, order, preference] = str.split(/\s+/)
106
+ const [flags, service, regexp] = str.match(/(?:").*?(?:"\s)/g)
104
107
  const replacement = str.trim().split(/\s+/).pop()
105
108
 
106
109
  const bits = {
107
- owner : owner,
108
- ttl : parseInt(ttl, 10),
109
- class : c,
110
- type : type,
111
- order : parseInt(order, 10),
112
- preference : parseInt(preference, 10),
113
- flags : flags.trim().replace(/^['"]|['"]$/g, ''),
114
- service : service.trim().replace(/^['"]|['"]$/g, ''),
115
- regexp : regexp.trim().replace(/^['"]|['"]/g, ''),
110
+ owner: owner,
111
+ ttl: parseInt(ttl, 10),
112
+ class: c,
113
+ type: type,
114
+ order: parseInt(order, 10),
115
+ preference: parseInt(preference, 10),
116
+ flags: flags.trim().replace(/^['"]|['"]$/g, ''),
117
+ service: service.trim().replace(/^['"]|['"]$/g, ''),
118
+ regexp: regexp.trim().replace(/^['"]|['"]/g, ''),
116
119
  replacement: replacement,
117
120
  }
118
121
  return new NAPTR(bits)
119
122
  }
120
123
 
121
124
  /****** EXPORTERS *******/
122
- toTinydns () {
123
-
125
+ toTinydns() {
124
126
  let rdata =
125
127
  TINYDNS.UInt16toOctal(this.get('order')) +
126
128
  TINYDNS.UInt16toOctal(this.get('preference')) +
127
-
128
129
  TINYDNS.UInt8toOctal(this.get('flags').length) +
129
130
  this.get('flags') +
130
-
131
131
  TINYDNS.UInt8toOctal(this.get('service').length) +
132
132
  TINYDNS.escapeOctal(rdataRe, this.get('service')) +
133
-
134
133
  TINYDNS.UInt8toOctal(this.get('regexp').length) +
135
134
  TINYDNS.escapeOctal(rdataRe, this.get('regexp'))
136
135
 
package/rr/ns.js CHANGED
@@ -1,14 +1,13 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class NS extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  if (opts === null) return
8
7
  }
9
8
 
10
9
  /****** Resource record specific setters *******/
11
- setDname (val) {
10
+ setDname(val) {
12
11
  if (!val) throw new Error(`NS: dname is required, ${this.citeRFC()}`)
13
12
 
14
13
  this.isFullyQualified('NS', 'dname', val)
@@ -18,57 +17,61 @@ export default class NS extends RR {
18
17
  this.set('dname', val.toLowerCase())
19
18
  }
20
19
 
21
- getDescription () {
20
+ getDescription() {
22
21
  return 'Name Server'
23
22
  }
24
23
 
25
- getRdataFields (arg) {
26
- return [ 'dname' ]
24
+ getRdataFields(arg) {
25
+ return ['dname']
27
26
  }
28
27
 
29
- getRFCs () {
30
- return [ 1035 ]
28
+ getRFCs() {
29
+ return [1035]
31
30
  }
32
31
 
33
- getTypeId () {
32
+ getTypeId() {
34
33
  return 2
35
34
  }
36
35
 
37
36
  /****** IMPORTERS *******/
38
- fromTinydns (opts) {
37
+ fromTinydns(opts) {
39
38
  // &fqdn:ip:x:ttl:timestamp:lo
40
39
  // eslint-disable-next-line no-unused-vars
41
- const [ fqdn, ip, dname, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
40
+ const [fqdn, ip, dname, ttl, ts, loc] = opts.tinyline
41
+ .substring(1)
42
+ .split(':')
42
43
 
43
44
  return new NS({
44
- type : 'NS',
45
- owner : this.fullyQualify(fqdn),
46
- dname : this.fullyQualify(/\./.test(dname) ? dname : `${dname}.ns.${fqdn}`),
47
- ttl : parseInt(ttl, 10),
45
+ type: 'NS',
46
+ owner: this.fullyQualify(fqdn),
47
+ dname: this.fullyQualify(
48
+ /\./.test(dname) ? dname : `${dname}.ns.${fqdn}`,
49
+ ),
50
+ ttl: parseInt(ttl, 10),
48
51
  timestamp: ts,
49
- location : loc !== '' && loc !== '\n' ? loc : '',
52
+ location: loc !== '' && loc !== '\n' ? loc : '',
50
53
  })
51
54
  }
52
55
 
53
- fromBind (opts) {
56
+ fromBind(opts) {
54
57
  // test.example.com 3600 IN NS dname
55
- const [ owner, ttl, c, type, dname ] = opts.bindline.split(/\s+/)
58
+ const [owner, ttl, c, type, dname] = opts.bindline.split(/\s+/)
56
59
 
57
60
  return new NS({
58
61
  owner,
59
- ttl : parseInt(ttl, 10),
62
+ ttl: parseInt(ttl, 10),
60
63
  class: c,
61
- type : type,
64
+ type: type,
62
65
  dname: dname,
63
66
  })
64
67
  }
65
68
 
66
69
  /****** EXPORTERS *******/
67
- toBind (zone_opts) {
70
+ toBind(zone_opts) {
68
71
  return `${this.getPrefix(zone_opts)}\t${this.getFQDN('dname', zone_opts)}\n`
69
72
  }
70
73
 
71
- toTinydns () {
74
+ toTinydns() {
72
75
  return `&${this.getTinyFQDN('owner')}::${this.getTinyFQDN('dname')}:${this.getTinydnsPostamble()}\n`
73
76
  }
74
77
  }
package/rr/nsec.js CHANGED
@@ -1,15 +1,15 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class NSEC extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  if (opts === null) return
8
7
  }
9
8
 
10
9
  /****** Resource record specific setters *******/
11
- setNextDomain (val) {
12
- if (!val) throw new Error(`NSEC: 'next domain' is required:, ${this.citeRFC()}`)
10
+ setNextDomain(val) {
11
+ if (!val)
12
+ throw new Error(`NSEC: 'next domain' is required:, ${this.citeRFC()}`)
13
13
 
14
14
  this.isFullyQualified('NSEC', 'next domain', val)
15
15
  this.isValidHostname('NSEC', 'next domain', val)
@@ -18,44 +18,50 @@ export default class NSEC extends RR {
18
18
  this.set('next domain', val.toLowerCase())
19
19
  }
20
20
 
21
- setTypeBitMaps (val) {
22
- if (!val) throw new Error(`NSEC: 'type bit maps' is required, ${this.citeRFC()}`)
21
+ setTypeBitMaps(val) {
22
+ if (!val)
23
+ throw new Error(`NSEC: 'type bit maps' is required, ${this.citeRFC()}`)
23
24
 
24
25
  this.set('type bit maps', val)
25
26
  }
26
27
 
27
- getDescription () {
28
+ getDescription() {
28
29
  return 'Next Secure'
29
30
  }
30
31
 
31
- getRdataFields (arg) {
32
- return [ 'next domain', 'type bit maps' ]
32
+ getRdataFields(arg) {
33
+ return ['next domain', 'type bit maps']
33
34
  }
34
35
 
35
- getRFCs () {
36
- return [ 4034 ]
36
+ getRFCs() {
37
+ return [4034]
37
38
  }
38
39
 
39
- getTypeId () {
40
+ getTypeId() {
40
41
  return 47
41
42
  }
42
43
 
43
44
  /****** IMPORTERS *******/
44
45
 
45
- fromBind (opts) {
46
+ fromBind(opts) {
46
47
  // test.example.com 3600 IN NSEC NextDomain TypeBitMaps
47
- const [ owner, ttl, c, type, next ] = opts.bindline.split(/\s+/)
48
+ const [owner, ttl, c, type, next] = opts.bindline.split(/\s+/)
48
49
  return new NSEC({
49
50
  owner,
50
- ttl : parseInt(ttl, 10),
51
- class : c,
52
- type : type,
53
- 'next domain' : next,
54
- 'type bit maps': opts.bindline.split(/\s+/).slice(5).filter(removeParens).join(' ').trim(),
51
+ ttl: parseInt(ttl, 10),
52
+ class: c,
53
+ type: type,
54
+ 'next domain': next,
55
+ 'type bit maps': opts.bindline
56
+ .split(/\s+/)
57
+ .slice(5)
58
+ .filter(removeParens)
59
+ .join(' ')
60
+ .trim(),
55
61
  })
56
62
  }
57
63
 
58
64
  /****** EXPORTERS *******/
59
65
  }
60
66
 
61
- const removeParens = a => ![ '(',')' ].includes(a)
67
+ const removeParens = (a) => !['(', ')'].includes(a)
package/rr/nsec3.js CHANGED
@@ -1,26 +1,26 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  import * as TINYDNS from '../lib/tinydns.js'
5
4
 
6
5
  export default class NSEC3 extends RR {
7
- constructor (opts) {
6
+ constructor(opts) {
8
7
  super(opts)
9
8
  if (opts === null) return
10
9
  }
11
10
 
12
11
  /****** Resource record specific setters *******/
13
- setHashAlgorithm (val) {
12
+ setHashAlgorithm(val) {
14
13
  // Hash Algorithm is a single octet.
15
14
  // The Hash Algorithm field is represented as an unsigned decimal integer.
16
- if (!val) throw new Error(`NSEC3: 'hash algorithm' is required, ${this.citeRFC()}`)
15
+ if (!val)
16
+ throw new Error(`NSEC3: 'hash algorithm' is required, ${this.citeRFC()}`)
17
17
 
18
18
  this.is8bitInt('NSEC3', 'hash algorithm', val)
19
19
 
20
20
  this.set('hash algorithm', val)
21
21
  }
22
22
 
23
- setFlags (val) {
23
+ setFlags(val) {
24
24
  // The Flags field is represented as an unsigned decimal integer.
25
25
  if (!val) throw new Error(`NSEC3: 'flags' is required, ${this.citeRFC()}`)
26
26
 
@@ -29,16 +29,17 @@ export default class NSEC3 extends RR {
29
29
  this.set('flags', val)
30
30
  }
31
31
 
32
- setIterations (val) {
32
+ setIterations(val) {
33
33
  // The Iterations field is represented as an unsigned decimal integer. 0-65535
34
- if (!val) throw new Error(`NSEC3: 'iterations' is required, ${this.citeRFC()}`)
34
+ if (!val)
35
+ throw new Error(`NSEC3: 'iterations' is required, ${this.citeRFC()}`)
35
36
 
36
37
  this.is16bitInt('NSEC3', 'flags', val)
37
38
 
38
39
  this.set('iterations', val)
39
40
  }
40
41
 
41
- setSalt (val) {
42
+ setSalt(val) {
42
43
  // The Salt field is represented as a sequence of case-insensitive
43
44
  // hexadecimal digits. Whitespace is not allowed within the
44
45
  // sequence. The Salt field is represented as "-" (without the
@@ -46,95 +47,113 @@ export default class NSEC3 extends RR {
46
47
  this.set('salt', val)
47
48
  }
48
49
 
49
- setNextHashedOwnerName (val) {
50
+ setNextHashedOwnerName(val) {
50
51
  // The Next Hashed Owner Name field is represented as an unpadded
51
52
  // sequence of case-insensitive base32 digits, without whitespace
52
- if (!val) throw new Error(`NSEC3: 'next hashed owner name' is required, ${this.citeRFC()}`)
53
+ if (!val)
54
+ throw new Error(
55
+ `NSEC3: 'next hashed owner name' is required, ${this.citeRFC()}`,
56
+ )
53
57
 
54
58
  this.set('next hashed owner name', val)
55
59
  }
56
60
 
57
- setTypeBitMaps (val) {
61
+ setTypeBitMaps(val) {
58
62
  // The Type Bit Maps field is represented as a sequence of RR type mnemonics.
59
- if (!val) throw new Error(`NSEC3: 'type bit maps' is required, ${this.citeRFC()}`)
63
+ if (!val)
64
+ throw new Error(`NSEC3: 'type bit maps' is required, ${this.citeRFC()}`)
60
65
 
61
66
  this.set('type bit maps', val)
62
67
  }
63
68
 
64
- getDescription () {
69
+ getDescription() {
65
70
  return 'Next Secure'
66
71
  }
67
72
 
68
- getRdataFields (arg) {
69
- return [ 'hash algorithm', 'flags', 'iterations', 'salt', 'next hashed owner name', 'type bit maps' ]
73
+ getRdataFields(arg) {
74
+ return [
75
+ 'hash algorithm',
76
+ 'flags',
77
+ 'iterations',
78
+ 'salt',
79
+ 'next hashed owner name',
80
+ 'type bit maps',
81
+ ]
70
82
  }
71
83
 
72
- getRFCs () {
73
- return [ 5155, 9077 ]
84
+ getRFCs() {
85
+ return [5155, 9077]
74
86
  }
75
87
 
76
- getTypeId () {
88
+ getTypeId() {
77
89
  return 50
78
90
  }
79
91
 
80
92
  /****** IMPORTERS *******/
81
93
 
82
- fromBind (opts) {
94
+ fromBind(opts) {
83
95
  // test.example.com. 3600 IN NSEC3 1 1 12 aabbccdd (2vptu5timamqttgl4luu9kg21e0aor3s A RRSIG)
84
- const [ owner, ttl, c, type, ha, flags, iterations, salt ] = opts.bindline.split(/\s+/)
96
+ const [owner, ttl, c, type, ha, flags, iterations, salt] =
97
+ opts.bindline.split(/\s+/)
85
98
  const rdata = opts.bindline.split(/\(|\)/)[1]
86
99
 
87
100
  return new NSEC3({
88
101
  owner,
89
- ttl : parseInt(ttl, 10),
90
- class : c,
91
- type : type,
92
- 'hash algorithm' : parseInt(ha, 10),
93
- flags : parseInt(flags, 10),
94
- iterations : parseInt(iterations, 10),
102
+ ttl: parseInt(ttl, 10),
103
+ class: c,
104
+ type: type,
105
+ 'hash algorithm': parseInt(ha, 10),
106
+ flags: parseInt(flags, 10),
107
+ iterations: parseInt(iterations, 10),
95
108
  salt,
96
109
  'next hashed owner name': rdata.split(/\s+/)[0],
97
- 'type bit maps' : rdata.split(/\s+/).slice(1).join('\t'),
110
+ 'type bit maps': rdata.split(/\s+/).slice(1).join('\t'),
98
111
  })
99
112
  }
100
113
 
101
- fromTinydns (opts) {
102
- const [ fqdn, n, rdata, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
114
+ fromTinydns(opts) {
115
+ const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
103
116
  if (n != 50) throw new Error('NSEC3 fromTinydns, invalid n')
104
117
 
105
118
  const bytes = Buffer.from(TINYDNS.octalToChar(rdata), 'binary')
106
119
 
107
120
  return new NSEC3({
108
- owner : this.fullyQualify(fqdn),
109
- ttl : parseInt(ttl, 10),
110
- type : 'NSEC3',
121
+ owner: this.fullyQualify(fqdn),
122
+ ttl: parseInt(ttl, 10),
123
+ type: 'NSEC3',
111
124
  'hash algorithm': bytes.readUInt8(0),
112
- flags : bytes.readUInt8(1),
113
- iterations : bytes.readUInt16BE(2),
125
+ flags: bytes.readUInt8(1),
126
+ iterations: bytes.readUInt16BE(2),
114
127
  // salt : ,
115
128
  // 'next hashed owner name': ,
116
129
  // 'type bit maps' : ,
117
- timestamp : ts,
118
- location : loc !== '' && loc !== '\n' ? loc : '',
130
+ timestamp: ts,
131
+ location: loc !== '' && loc !== '\n' ? loc : '',
119
132
  })
120
133
  }
121
134
 
122
135
  /****** EXPORTERS *******/
123
136
 
124
- toBind (zone_opts) {
125
- return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tNSEC3${this.getRdataFields().slice(0,4).map(f => '\t' + this.get(f)).join('')}\t(${this.getRdataFields().slice(4).map(f => this.get(f)).join('\t')})\n`
137
+ toBind(zone_opts) {
138
+ return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tNSEC3${this.getRdataFields()
139
+ .slice(0, 4)
140
+ .map((f) => '\t' + this.get(f))
141
+ .join('')}\t(${this.getRdataFields()
142
+ .slice(4)
143
+ .map((f) => this.get(f))
144
+ .join('\t')})\n`
126
145
  }
127
146
 
128
- toTinydns () {
147
+ toTinydns() {
129
148
  const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
130
149
 
131
150
  return this.getTinydnsGeneric(
132
151
  TINYDNS.UInt8toOctal(this.get('hash algorithm')) +
133
- TINYDNS.UInt8toOctal(this.get('flags')) +
134
- TINYDNS.UInt16toOctal(this.get('iterations')) +
135
- TINYDNS.escapeOctal(dataRe, this.get('salt')) +
136
- TINYDNS.escapeOctal(dataRe, this.get('next hashed owner name')) +
137
- TINYDNS.escapeOctal(dataRe, this.get('type bit maps'))
152
+ TINYDNS.UInt8toOctal(this.get('flags')) +
153
+ TINYDNS.UInt16toOctal(this.get('iterations')) +
154
+ TINYDNS.escapeOctal(dataRe, this.get('salt')) +
155
+ TINYDNS.escapeOctal(dataRe, this.get('next hashed owner name')) +
156
+ TINYDNS.escapeOctal(dataRe, this.get('type bit maps')),
138
157
  )
139
158
  }
140
159
  }