@nictool/dns-resource-record 1.1.7 → 1.2.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +26 -43
  2. package/README.md +48 -48
  3. package/index.js +83 -29
  4. package/lib/tinydns.js +68 -61
  5. package/package.json +1 -2
  6. package/rr/a.js +32 -23
  7. package/rr/aaaa.js +49 -35
  8. package/rr/caa.js +56 -44
  9. package/rr/cert.js +21 -19
  10. package/rr/cname.js +22 -23
  11. package/rr/dname.js +23 -23
  12. package/rr/dnskey.js +45 -43
  13. package/rr/ds.js +40 -40
  14. package/rr/hinfo.js +29 -28
  15. package/rr/https.js +62 -0
  16. package/rr/ipseckey.js +69 -50
  17. package/rr/key.js +23 -23
  18. package/rr/loc.js +71 -58
  19. package/rr/mx.js +41 -27
  20. package/rr/naptr.js +52 -53
  21. package/rr/ns.js +26 -23
  22. package/rr/nsec.js +24 -20
  23. package/rr/nsec3.js +59 -46
  24. package/rr/nsec3param.js +24 -26
  25. package/rr/nxt.js +65 -0
  26. package/rr/openpgpkey.js +18 -15
  27. package/rr/ptr.js +20 -21
  28. package/rr/rrsig.js +28 -23
  29. package/rr/sig.js +25 -20
  30. package/rr/smimea.js +36 -31
  31. package/rr/soa.js +56 -42
  32. package/rr/spf.js +21 -18
  33. package/rr/srv.js +45 -45
  34. package/rr/sshfp.js +30 -31
  35. package/rr/svcb.js +64 -0
  36. package/rr/tlsa.js +50 -45
  37. package/rr/tsig.js +56 -0
  38. package/rr/txt.js +42 -35
  39. package/rr/uri.js +33 -33
  40. package/rr/wks.js +45 -0
  41. package/rr.js +133 -87
  42. package/.codeclimate.yml +0 -25
  43. package/DEVELOP.md +0 -23
  44. package/test/a.js +0 -76
  45. package/test/aaaa.js +0 -79
  46. package/test/base.js +0 -138
  47. package/test/caa.js +0 -104
  48. package/test/cert.js +0 -48
  49. package/test/cname.js +0 -41
  50. package/test/dname.js +0 -53
  51. package/test/dnskey.js +0 -44
  52. package/test/ds.js +0 -44
  53. package/test/fake.js +0 -26
  54. package/test/hinfo.js +0 -75
  55. package/test/ipseckey.js +0 -115
  56. package/test/key.js +0 -37
  57. package/test/loc.js +0 -71
  58. package/test/mx.js +0 -75
  59. package/test/naptr.js +0 -40
  60. package/test/ns.js +0 -53
  61. package/test/nsec.js +0 -38
  62. package/test/nsec3.js +0 -40
  63. package/test/nsec3param.js +0 -26
  64. package/test/openpgpkey.js +0 -35
  65. package/test/ptr.js +0 -54
  66. package/test/rr.js +0 -196
  67. package/test/smimea.js +0 -45
  68. package/test/soa.js +0 -77
  69. package/test/spf.js +0 -48
  70. package/test/srv.js +0 -81
  71. package/test/sshfp.js +0 -62
  72. package/test/tinydns.js +0 -140
  73. package/test/tlsa.js +0 -54
  74. package/test/txt.js +0 -70
  75. package/test/uri.js +0 -61
package/rr/rrsig.js CHANGED
@@ -1,85 +1,91 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class RRSIG extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  }
8
7
 
9
8
  /****** Resource record specific setters *******/
10
- setTypeCovered (val) {
9
+ setTypeCovered(val) {
11
10
  // a 2 octet Type Covered field
12
- if (!val) throw new Error(`RRSIG: 'type covered' is required`)
13
- if (val.length > 2) throw new Error(`RRSIG: 'type covered' is too long, ${this.citeRFC()}`)
11
+ if (!val) this.throwHelp(`RRSIG: 'type covered' is required`)
12
+ if (val.length > 2) this.throwHelp(`RRSIG: 'type covered' is too long`)
14
13
 
15
14
  this.set('type covered', val)
16
15
  }
17
16
 
18
- setAlgorithm (val) {
17
+ setAlgorithm(val) {
19
18
  // a 1 octet Algorithm field
20
19
  // 1=RSA/MD5, 2=DH, 3=RRSIGA/SHA-1, 4=EC, 5=RSA/SHA-1
21
- if (![ 1,2,3,4,5,253,254 ].includes(val))
22
- throw new Error(`RRSIG: algorithm invalid, ${this.citeRFC()}`)
20
+ if (![1, 2, 3, 4, 5, 253, 254].includes(val))
21
+ this.throwHelp(`RRSIG: algorithm invalid`)
23
22
 
24
23
  this.set('algorithm', val)
25
24
  }
26
25
 
27
- setLabels (val) {
26
+ setLabels(val) {
28
27
  // a 1 octet Labels field
29
28
  this.is8bitInt('RRSIG', 'labels', val)
30
29
 
31
30
  this.set('labels', val)
32
31
  }
33
32
 
34
- setOriginalTtl (val) {
33
+ setOriginalTtl(val) {
35
34
  // a 4 octet Original TTL field
36
35
  this.is32bitInt('RRSIG', 'original ttl', val)
37
36
 
38
37
  this.set('original ttl', val)
39
38
  }
40
39
 
41
- setSignatureExpiration (val) {
40
+ setSignatureExpiration(val) {
42
41
  // a 4 octet Signature Expiration field
43
42
  this.set('signature expiration', val)
44
43
  }
45
44
 
46
- setSignatureInception (val) {
45
+ setSignatureInception(val) {
47
46
  // a 4 octet Signature Inception field
48
47
  this.set('signature inception', val)
49
48
  }
50
49
 
51
- setKeyTag (val) {
50
+ setKeyTag(val) {
52
51
  // a 2 octet Key tag
53
52
  this.set('key tag', val)
54
53
  }
55
54
 
56
- setSignersName (val) {
55
+ setSignersName(val) {
57
56
  // the Signer's Name field
58
57
  this.set('signers name', val)
59
58
  }
60
59
 
61
- setSignature (val) {
60
+ setSignature(val) {
62
61
  // the Signature field.
63
62
 
64
63
  this.set('signature', val)
65
64
  }
66
65
 
67
- getDescription () {
66
+ getDescription() {
68
67
  return 'Resource Record Signature'
69
68
  }
70
69
 
71
- getRdataFields (arg) {
70
+ getRdataFields(arg) {
72
71
  return [
73
- 'type covered', 'algorithm', 'labels', 'original ttl', 'signature expiration',
74
- 'signature inception', 'key tag', 'signers name', 'signature',
72
+ 'type covered',
73
+ 'algorithm',
74
+ 'labels',
75
+ 'original ttl',
76
+ 'signature expiration',
77
+ 'signature inception',
78
+ 'key tag',
79
+ 'signers name',
80
+ 'signature',
75
81
  ]
76
82
  }
77
83
 
78
- getRFCs () {
79
- return [ 4034 ]
84
+ getRFCs() {
85
+ return [4034]
80
86
  }
81
87
 
82
- getTypeId () {
88
+ getTypeId() {
83
89
  return 46
84
90
  }
85
91
 
@@ -97,5 +103,4 @@ export default class RRSIG extends RR {
97
103
  // }
98
104
 
99
105
  /****** EXPORTERS *******/
100
-
101
106
  }
package/rr/sig.js CHANGED
@@ -1,20 +1,19 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class SIG extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  }
8
7
 
9
8
  /****** Resource record specific setters *******/
10
- setTypeCovered (val) {
9
+ setTypeCovered(val) {
11
10
  // a 2 octet Type Covered field
12
- if (!val) throw new Error(`SIG: 'type covered' is required`)
11
+ if (!val) this.throwHelp(`SIG: 'type covered' is required`)
13
12
 
14
13
  this.set('type covered', val)
15
14
  }
16
15
 
17
- setAlgorithm (val) {
16
+ setAlgorithm(val) {
18
17
  // a 1 octet Algorithm field
19
18
 
20
19
  this.is8bitInt('SIG', 'labels', val)
@@ -22,64 +21,71 @@ export default class SIG extends RR {
22
21
  this.set('algorithm', val)
23
22
  }
24
23
 
25
- setLabels (val) {
24
+ setLabels(val) {
26
25
  // a 1 octet Labels field
27
26
  this.is8bitInt('SIG', 'labels', val)
28
27
 
29
28
  this.set('labels', val)
30
29
  }
31
30
 
32
- setOriginalTtl (val) {
31
+ setOriginalTtl(val) {
33
32
  // a 4 octet Original TTL field
34
33
  this.is32bitInt('SIG', 'original ttl', val)
35
34
 
36
35
  this.set('original ttl', val)
37
36
  }
38
37
 
39
- setSignatureExpiration (val) {
38
+ setSignatureExpiration(val) {
40
39
  // a 4 octet Signature Expiration field
41
40
  this.set('signature expiration', val)
42
41
  }
43
42
 
44
- setSignatureInception (val) {
43
+ setSignatureInception(val) {
45
44
  // a 4 octet Signature Inception field
46
45
  this.set('signature inception', val)
47
46
  }
48
47
 
49
- setKeyTag (val) {
48
+ setKeyTag(val) {
50
49
  // a 2 octet Key tag
51
50
  this.set('key tag', val)
52
51
  }
53
52
 
54
- setSignersName (val) {
53
+ setSignersName(val) {
55
54
  // the domain name of the signer generating the SIG RR
56
55
 
57
56
  // RFC 4034: letters in the DNS names are lower cased
58
57
  this.set('signers name', val.toLowerCase())
59
58
  }
60
59
 
61
- setSignature (val) {
60
+ setSignature(val) {
62
61
  // the Signature field.
63
62
 
64
63
  this.set('signature', val)
65
64
  }
66
65
 
67
- getDescription () {
66
+ getDescription() {
68
67
  return 'Signature'
69
68
  }
70
69
 
71
- getRdataFields (arg) {
70
+ getRdataFields(arg) {
72
71
  return [
73
- 'type covered', 'algorithm', 'labels', 'original ttl', 'signature expiration',
74
- 'signature inception', 'key tag', 'signers name', 'signature',
72
+ 'type covered',
73
+ 'algorithm',
74
+ 'labels',
75
+ 'original ttl',
76
+ 'signature expiration',
77
+ 'signature inception',
78
+ 'key tag',
79
+ 'signers name',
80
+ 'signature',
75
81
  ]
76
82
  }
77
83
 
78
- getRFCs () {
79
- return [ 2535 ]
84
+ getRFCs() {
85
+ return [2535]
80
86
  }
81
87
 
82
- getTypeId () {
88
+ getTypeId() {
83
89
  return 24
84
90
  }
85
91
 
@@ -96,5 +102,4 @@ export default class SIG extends RR {
96
102
  // }
97
103
 
98
104
  /****** EXPORTERS *******/
99
-
100
105
  }
package/rr/smimea.js CHANGED
@@ -1,73 +1,78 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class SMIMEA extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  }
8
7
 
9
8
  /****** Resource record specific setters *******/
10
- setCertificateUsage (val) {
11
- if (![ 0,1,2,3 ].includes(val))
12
- throw new Error(`SMIMEA: certificate usage invalid, ${this.citeRFC()}`)
9
+ setCertificateUsage(val) {
10
+ if (![0, 1, 2, 3].includes(val))
11
+ this.throwHelp(`SMIMEA: certificate usage invalid`)
13
12
 
14
13
  this.set('certificate usage', val)
15
14
  }
16
15
 
17
- setSelector (val) {
18
- if (![ 0,1 ].includes(val))
19
- throw new Error(`SMIMEA: selector invalid, ${this.citeRFC()}`)
16
+ setSelector(val) {
17
+ if (![0, 1].includes(val)) this.throwHelp(`SMIMEA: selector invalid`)
20
18
 
21
19
  this.set('selector', val)
22
20
  }
23
21
 
24
- setMatchingType (val) {
25
- if (![ 0,1,2 ].includes(val))
26
- throw new Error(`SMIMEA: matching type, ${this.citeRFC()}`)
22
+ setMatchingType(val) {
23
+ if (![0, 1, 2].includes(val)) this.throwHelp(`SMIMEA: matching type`)
27
24
 
28
25
  this.set('matching type', val)
29
26
  }
30
27
 
31
- setCertificateAssociationData (val) {
28
+ setCertificateAssociationData(val) {
32
29
  this.set('certificate association data', val)
33
30
  }
34
31
 
35
-
36
- getDescription () {
32
+ getDescription() {
37
33
  return 'S/MIME cert association'
38
34
  }
39
35
 
40
- getRdataFields (arg) {
41
- return [ 'certificate usage', 'selector', 'matching type', 'certificate association data' ]
36
+ getRdataFields(arg) {
37
+ return [
38
+ 'certificate usage',
39
+ 'selector',
40
+ 'matching type',
41
+ 'certificate association data',
42
+ ]
42
43
  }
43
44
 
44
- getRFCs () {
45
- return [ 8162 ]
45
+ getRFCs() {
46
+ return [8162]
46
47
  }
47
48
 
48
- getTypeId () {
49
+ getTypeId() {
49
50
  return 53
50
51
  }
51
52
 
52
- getQuotedFields () {
53
- return [ ]
53
+ getQuotedFields() {
54
+ return []
54
55
  }
55
56
 
56
57
  /****** IMPORTERS *******/
57
58
 
58
- fromBind (opts) {
59
+ fromBind(opts) {
59
60
  // test.example.com 3600 IN SMIMEA, usage, selector, match, data
60
- const [ owner, ttl, c, type, usage, selector, match ] = opts.bindline.split(/\s+/)
61
+ const [owner, ttl, c, type, usage, selector, match] =
62
+ opts.bindline.split(/\s+/)
61
63
  return new SMIMEA({
62
64
  owner,
63
- ttl : parseInt(ttl, 10),
64
- class : c,
65
- type : type,
66
- 'certificate usage' : parseInt(usage, 10),
67
- selector : parseInt(selector, 10),
68
- 'matching type' : parseInt(match , 10),
69
- 'certificate association data': opts.bindline.split(/\s+/).slice(7).join(' ').trim(),
65
+ ttl: parseInt(ttl, 10),
66
+ class: c,
67
+ type: type,
68
+ 'certificate usage': parseInt(usage, 10),
69
+ selector: parseInt(selector, 10),
70
+ 'matching type': parseInt(match, 10),
71
+ 'certificate association data': opts.bindline
72
+ .split(/\s+/)
73
+ .slice(7)
74
+ .join(' ')
75
+ .trim(),
70
76
  })
71
77
  }
72
-
73
78
  }
package/rr/soa.js CHANGED
@@ -1,13 +1,12 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class SOA extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  }
8
7
 
9
8
  /****** Resource record specific setters *******/
10
- setMinimum (val) {
9
+ setMinimum(val) {
11
10
  // minimum (used for negative caching, since RFC 2308)
12
11
  // RFC 1912 sugggests 1-5 days
13
12
  // RIPE recommends 3600 (1 hour)
@@ -16,7 +15,7 @@ export default class SOA extends RR {
16
15
  this.set('minimum', val)
17
16
  }
18
17
 
19
- setMname (val) {
18
+ setMname(val) {
20
19
  // MNAME (primary NS)
21
20
  this.isValidHostname('SOA', 'MNAME', val)
22
21
  this.isFullyQualified('SOA', 'MNAME', val)
@@ -25,23 +24,23 @@ export default class SOA extends RR {
25
24
  this.set('mname', val.toLowerCase())
26
25
  }
27
26
 
28
- setRname (val) {
27
+ setRname(val) {
29
28
  // RNAME (email of admin) (escape . with \)
30
29
  this.isValidHostname('SOA', 'RNAME', val)
31
30
  this.isFullyQualified('SOA', 'RNAME', val)
32
- if (/@/.test(val)) throw new Error(`SOA rname replaces @ with a . (dot), ${this.citeRFC()}`)
31
+ if (/@/.test(val)) this.throwHelp(`SOA rname replaces @ with a . (dot)`)
33
32
 
34
33
  // RFC 4034: letters in the DNS names are lower cased
35
34
  this.set('rname', val.toLowerCase())
36
35
  }
37
36
 
38
- setSerial (val) {
37
+ setSerial(val) {
39
38
  this.is32bitInt('SOA', 'serial', val)
40
39
 
41
40
  this.set('serial', val)
42
41
  }
43
42
 
44
- setRefresh (val) {
43
+ setRefresh(val) {
45
44
  // refresh (seconds after which to check with master for update)
46
45
  // RFC 1912 suggests 20 min to 12 hours
47
46
  // RIPE recommends 86400 (24 hours)
@@ -50,7 +49,7 @@ export default class SOA extends RR {
50
49
  this.set('refresh', val)
51
50
  }
52
51
 
53
- setRetry (val) {
52
+ setRetry(val) {
54
53
  // seconds after which to retry serial # update
55
54
  // RIPE recommends 7200 seconds (2 hours)
56
55
 
@@ -59,7 +58,7 @@ export default class SOA extends RR {
59
58
  this.set('retry', val)
60
59
  }
61
60
 
62
- setExpire (val) {
61
+ setExpire(val) {
63
62
  // seconds after which secondary should drop zone if no master response
64
63
  // RFC 1912 suggests 2-4 weeks
65
64
  // RIPE suggests 3600000 (1,000 hours, 6 weeks)
@@ -68,73 +67,88 @@ export default class SOA extends RR {
68
67
  this.set('expire', val)
69
68
  }
70
69
 
71
- getDescription () {
70
+ getDescription() {
72
71
  return 'Start Of Authority'
73
72
  }
74
73
 
75
- getRdataFields (arg) {
76
- return [ 'mname', 'rname', 'serial', 'refresh', 'retry', 'expire', 'minimum' ]
74
+ getRdataFields(arg) {
75
+ return ['mname', 'rname', 'serial', 'refresh', 'retry', 'expire', 'minimum']
77
76
  }
78
77
 
79
- getRFCs () {
80
- return [ 1035, 2308 ]
78
+ getRFCs() {
79
+ return [1035, 2308]
81
80
  }
82
81
 
83
- getTypeId () {
82
+ getTypeId() {
84
83
  return 6
85
84
  }
86
85
 
87
86
  /****** IMPORTERS *******/
88
- fromBind (opts) {
87
+ fromBind(opts) {
89
88
  // example.com TTL IN SOA mname rname serial refresh retry expire minimum
90
- const [ owner, ttl, c, type, mname, rname, serial, refresh, retry, expire, minimum ] = opts.bindline.split(/[\s+]/)
89
+ const [
90
+ owner,
91
+ ttl,
92
+ c,
93
+ type,
94
+ mname,
95
+ rname,
96
+ serial,
97
+ refresh,
98
+ retry,
99
+ expire,
100
+ minimum,
101
+ ] = opts.bindline.split(/[\s+]/)
91
102
 
92
103
  return new SOA({
93
104
  owner,
94
- ttl : parseInt(ttl) || parseInt(minimum),
95
- class : c,
105
+ ttl: parseInt(ttl) || parseInt(minimum),
106
+ class: c,
96
107
  type,
97
108
  mname,
98
109
  rname,
99
- serial : parseInt(serial , 10),
110
+ serial: parseInt(serial, 10),
100
111
  refresh: parseInt(refresh, 10),
101
- retry : parseInt(retry , 10),
102
- expire : parseInt(expire , 10),
112
+ retry: parseInt(retry, 10),
113
+ expire: parseInt(expire, 10),
103
114
  minimum: parseInt(minimum, 10),
104
115
  })
105
116
  }
106
117
 
107
- fromTinydns (opts) {
118
+ fromTinydns(opts) {
108
119
  // Zfqdn:mname:rname:ser:ref:ret:exp:min:ttl:time:lo
109
- const [ fqdn, mname, rname, ser, ref, ret, exp, min, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
120
+ const [fqdn, mname, rname, ser, ref, ret, exp, min, ttl, ts, loc] =
121
+ opts.tinyline.substring(1).split(':')
110
122
 
111
123
  return new SOA({
112
- owner : this.fullyQualify(fqdn),
113
- ttl : parseInt(ttl, 10),
114
- type : 'SOA',
115
- mname : this.fullyQualify(mname),
116
- rname : this.fullyQualify(rname),
117
- serial : parseInt(ser || opts.default?.serial, 10),
118
- refresh : parseInt(ref, 10) || 16384,
119
- retry : parseInt(ret, 10) || 2048,
120
- expire : parseInt(exp, 10) || 1048576,
121
- minimum : parseInt(min, 10) || 2560,
124
+ owner: this.fullyQualify(fqdn),
125
+ ttl: parseInt(ttl, 10),
126
+ type: 'SOA',
127
+ mname: this.fullyQualify(mname),
128
+ rname: this.fullyQualify(rname),
129
+ serial: parseInt(ser || opts.default?.serial, 10),
130
+ refresh: parseInt(ref, 10) || 16384,
131
+ retry: parseInt(ret, 10) || 2048,
132
+ expire: parseInt(exp, 10) || 1048576,
133
+ minimum: parseInt(min, 10) || 2560,
122
134
  timestamp: parseInt(ts) || '',
123
- location : loc !== '' && loc !== '\n' ? loc : '',
135
+ location: loc !== '' && loc !== '\n' ? loc : '',
124
136
  })
125
137
  }
126
138
 
127
139
  /****** EXPORTERS *******/
128
- toBind (zone_opts) {
129
- const numFields = [ 'serial', 'refresh', 'retry', 'expire', 'minimum' ]
130
- return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tSOA\t${this.getFQDN('mname', zone_opts)}\t${this.getFQDN('rname', zone_opts)}${numFields.map(f => '\t' + this.get(f) ).join('')}\n`
140
+ toBind(zone_opts) {
141
+ const numFields = ['serial', 'refresh', 'retry', 'expire', 'minimum']
142
+ return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tSOA\t${this.getFQDN('mname', zone_opts)}\t${this.getFQDN('rname', zone_opts)}${numFields.map((f) => '\t' + this.get(f)).join('')}\n`
131
143
  }
132
144
 
133
- toMaraDNS () {
134
- return `${this.get('owner')}\t SOA\t${this.getRdataFields().map(f => this.getQuoted(f)).join('\t')} ~\n`
145
+ toMaraDNS() {
146
+ return `${this.get('owner')}\t SOA\t${this.getRdataFields()
147
+ .map((f) => this.getQuoted(f))
148
+ .join('\t')} ~\n`
135
149
  }
136
150
 
137
- toTinydns () {
151
+ toTinydns() {
138
152
  return `Z${this.getTinyFQDN('owner')}:${this.getTinyFQDN('mname')}:${this.getTinyFQDN('rname')}:${this.getEmpty('serial')}:${this.getEmpty('refresh')}:${this.getEmpty('retry')}:${this.getEmpty('expire')}:${this.getEmpty('minimum')}:${this.getTinydnsPostamble()}\n`
139
153
  }
140
154
  }
package/rr/spf.js CHANGED
@@ -5,50 +5,53 @@ import TXT from './txt.js'
5
5
  import * as TINYDNS from '../lib/tinydns.js'
6
6
 
7
7
  export default class SPF extends TXT {
8
- constructor (opts) {
8
+ constructor(opts) {
9
9
  super(opts)
10
10
  }
11
11
 
12
12
  /****** Resource record specific setters *******/
13
- setData (val) {
13
+ setData(val) {
14
14
  this.set('data', val)
15
15
  }
16
16
 
17
- getDescription () {
17
+ getDescription() {
18
18
  return 'Sender Policy Framework'
19
19
  }
20
20
 
21
- getRdataFields (arg) {
22
- return [ 'data' ]
21
+ getRdataFields(arg) {
22
+ return ['data']
23
23
  }
24
24
 
25
- getRFCs () {
26
- return [ 4408, 7208 ]
25
+ getRFCs() {
26
+ return [4408, 7208]
27
27
  }
28
28
 
29
- getTypeId () {
29
+ getTypeId() {
30
30
  return 99
31
31
  }
32
32
 
33
33
  /****** IMPORTERS *******/
34
- fromTinydns (opts) {
34
+ fromTinydns(opts) {
35
35
  // SPF via generic, :fqdn:n:rdata:ttl:timestamp:lo
36
- const [ fqdn, n, rdata, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
37
- if (n != 99) throw new Error('SPF fromTinydns, invalid n')
36
+ const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
37
+ if (n != 99) this.throwHelp('SPF fromTinydns, invalid n')
38
38
 
39
39
  return new SPF({
40
- type : 'SPF',
41
- owner : this.fullyQualify(fqdn),
42
- data : TINYDNS.octalToChar(rdata),
43
- ttl : parseInt(ttl, 10),
40
+ type: 'SPF',
41
+ owner: this.fullyQualify(fqdn),
42
+ data: TINYDNS.octalToChar(rdata),
43
+ ttl: parseInt(ttl, 10),
44
44
  timestamp: ts,
45
- location : loc !== '' && loc !== '\n' ? loc : '',
45
+ location: loc !== '' && loc !== '\n' ? loc : '',
46
46
  })
47
47
  }
48
48
 
49
49
  /****** EXPORTERS *******/
50
- toTinydns () {
51
- const rdata = TINYDNS.escapeOctal(new RegExp(/[\r\n\t:\\/]/, 'g'), this.get('data'))
50
+ toTinydns() {
51
+ const rdata = TINYDNS.escapeOctal(
52
+ new RegExp(/[\r\n\t:\\/]/, 'g'),
53
+ this.get('data'),
54
+ )
52
55
  return this.getTinydnsGeneric(rdata)
53
56
  }
54
57
  }