Installations
npm install dns-txt
Releases
Unable to fetch releases
Developer
watson
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
4.2.2
NPM Version
2.14.7
Statistics
25 Stars
18 Commits
7 Forks
4 Watching
1 Branches
2 Contributors
Updated on 03 Jul 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
1,857,041,684
Last day
-7.9%
553,738
Compared to previous day
Last week
-0.2%
3,264,508
Compared to previous week
Last month
11.5%
13,691,023
Compared to previous month
Last year
-37.6%
166,336,196
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
dns-txt
Encode or decode the RDATA field in multicast DNS TXT records. For use with DNS-Based Service Discovery. For details see RFC 6763.
Installation
npm install dns-txt
Usage
1var txt = require('dns-txt')() 2 3var obj = { 4 foo: 1, 5 bar: 2 6} 7 8var enc = txt.encode(obj) // <Buffer 05 66 6f 6f 3d 31 05 62 61 72 3d 32> 9 10txt.decode(enc) // { foo: '1', bar: '2' }
API
The encoder and decoder conforms to RFC 6763.
Initialize
The module exposes a constructor function which can be called with an optional options object:
1var txt = require('dns-txt')({ binary: true })
The options are:
binary
- If set totrue
all values will be returned asBuffer
objects. The default behavior is to turn all values into strings. But according to the RFC the values can be any binary data. If you expect binary data, use this option.
txt.encode(obj, [buffer], [offset])
Takes a key/value object and returns a buffer with the encoded TXT
record. If a buffer is passed as the second argument the object should
be encoded into that buffer. Otherwise a new buffer should be allocated
If an offset is passed as the third argument the object should be
encoded at that byte offset. The byte offset defaults to 0
.
This module does not actively validate the key/value pairs, but keep the following in rules in mind:
-
To be RFC compliant, each key should conform with the rules as specified in section 6.4.
-
To be RFC compliant, each value should conform with the rules as specified in section 6.5.
After encoding txt.encode.bytes
is set to the amount of bytes used to
encode the object.
txt.decode(buffer, [offset], [length])
Takes a buffer and returns a decoded key/value object. If an offset is
passed as the second argument the object should be decoded from that
byte offset. The byte offset defaults to 0
. Note that all keys will be
lowercased and all values will be Buffer objects.
After decoding txt.decode.bytes
is set to the amount of bytes used to
decode the object.
txt.encodingLength(obj)
Takes a single key/value object and returns the number of bytes that the given object would require if encoded.
License
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More