0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

1
web/node_modules/dns-txt/.npmignore generated vendored Normal file
View file

@ -0,0 +1 @@
node_modules

9
web/node_modules/dns-txt/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,9 @@
language: node_js
node_js:
- '5'
- '4'
- '0.12'
- '0.10'
- '0.8'
before_install:
- 'if [ "${TRAVIS_NODE_VERSION}" == "0.8" ]; then npm install -g npm@2.12.1; fi'

21
web/node_modules/dns-txt/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Thomas Watson Steen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

91
web/node_modules/dns-txt/README.md generated vendored Normal file
View file

@ -0,0 +1,91 @@
# 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](https://tools.ietf.org/html/rfc6763).
[![Build status](https://travis-ci.org/watson/dns-txt.svg?branch=master)](https://travis-ci.org/watson/dns-txt)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)
[![abstract-encoding](https://img.shields.io/badge/abstract--encoding-compliant-brightgreen.svg?style=flat)](https://github.com/mafintosh/abstract-encoding)
## Installation
```
npm install dns-txt
```
## Usage
```js
var txt = require('dns-txt')()
var obj = {
foo: 1,
bar: 2
}
var enc = txt.encode(obj) // <Buffer 05 66 6f 6f 3d 31 05 62 61 72 3d 32>
txt.decode(enc) // { foo: '1', bar: '2' }
```
## API
The encoder and decoder conforms to [RFC 6763](https://tools.ietf.org/html/rfc6763).
### Initialize
The module exposes a constructor function which can be called with an
optional options object:
```js
var txt = require('dns-txt')({ binary: true })
```
The options are:
- `binary` - If set to `true` all values will be returned as `Buffer`
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](https://tools.ietf.org/html/rfc6763#section-6.4).
- To be RFC compliant, each value should conform with the rules as
specified in [section
6.5](https://tools.ietf.org/html/rfc6763#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

94
web/node_modules/dns-txt/index.js generated vendored Normal file
View file

@ -0,0 +1,94 @@
'use strict'
var bindexOf = require('buffer-indexof')
var equalSign = new Buffer('=')
module.exports = function (opts) {
var binary = opts ? opts.binary : false
var that = {}
that.encode = function (data, buf, offset) {
if (!data) data = {}
if (!offset) offset = 0
if (!buf) buf = new Buffer(that.encodingLength(data) + offset)
var oldOffset = offset
var keys = Object.keys(data)
if (keys.length === 0) {
buf[offset] = 0
offset++
}
keys.forEach(function (key) {
var val = data[key]
var oldOffset = offset
offset++
if (val === true) {
offset += buf.write(key, offset)
} else if (Buffer.isBuffer(val)) {
offset += buf.write(key + '=', offset)
var len = val.length
val.copy(buf, offset, 0, len)
offset += len
} else {
offset += buf.write(key + '=' + val, offset)
}
buf[oldOffset] = offset - oldOffset - 1
})
that.encode.bytes = offset - oldOffset
return buf
}
that.decode = function (buf, offset, len) {
if (!offset) offset = 0
if (!Number.isFinite(len)) len = buf.length
var data = {}
var oldOffset = offset
while (offset < len) {
var b = decodeBlock(buf, offset)
var i = bindexOf(b, equalSign)
offset += decodeBlock.bytes
if (b.length === 0) continue // ignore: most likely a single zero byte
if (i === -1) data[b.toString().toLowerCase()] = true
else if (i === 0) continue // ignore: invalid key-length
else {
var key = b.slice(0, i).toString().toLowerCase()
if (key in data) continue // ignore: overwriting not allowed
data[key] = binary ? b.slice(i + 1) : b.slice(i + 1).toString()
}
}
that.decode.bytes = offset - oldOffset
return data
}
that.encodingLength = function (data) {
if (!data) return 1 // 1 byte (single empty byte)
var keys = Object.keys(data)
if (keys.length === 0) return 1 // 1 byte (single empty byte)
return keys.reduce(function (total, key) {
var val = data[key]
total += Buffer.byteLength(key) + 1 // +1 byte to store field length
if (Buffer.isBuffer(val)) total += val.length + 1 // +1 byte to fit equal sign
else if (val !== true) total += Buffer.byteLength(String(val)) + 1 // +1 byte to fit equal sign
return total
}, 0)
}
return that
}
function decodeBlock (buf, offset) {
var len = buf[offset]
var to = offset + 1 + len
var b = buf.slice(offset + 1, to > buf.length ? buf.length : to)
decodeBlock.bytes = len + 1
return b
}

50
web/node_modules/dns-txt/package.json generated vendored Normal file
View file

@ -0,0 +1,50 @@
{
"name": "dns-txt",
"version": "2.0.2",
"description": "Encode/decode DNS-SD TXT record RDATA fields",
"main": "index.js",
"dependencies": {
"buffer-indexof": "^1.0.0"
},
"devDependencies": {
"tape": "^4.2.2",
"standard": "^5.3.1"
},
"scripts": {
"test": "standard && tape test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/watson/dns-txt.git"
},
"keywords": [
"rfc6763",
"6763",
"rfc6762",
"6762",
"dns",
"mdns",
"multicast",
"txt",
"rdata",
"dns-sd",
"encode",
"decode",
"parse",
"encoder",
"decoder",
"parser",
"service",
"discovery"
],
"author": "Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)",
"license": "MIT",
"bugs": {
"url": "https://github.com/watson/dns-txt/issues"
},
"homepage": "https://github.com/watson/dns-txt",
"coordinates": [
55.6465696,
12.5491067
]
}

160
web/node_modules/dns-txt/test.js generated vendored Normal file
View file

@ -0,0 +1,160 @@
'use strict'
var test = require('tape')
var txtStr = require('./')()
var txtBin = require('./')({ binary: true })
var obj = {
String: 'foo',
number: 42,
empty: '',
null: null,
bool: true,
buffer: new Buffer('bar')
}
test('encodingLength', function (t) {
var len = txtBin.encodingLength(obj)
t.equal(len, 54)
t.end()
})
test('encode', function (t) {
var buf = txtBin.encode(obj)
var expected = new Buffer('0a' + '537472696e67' + '3d' + '666f6f' +
'09' + '6e756d626572' + '3d' + '3432' +
'06' + '656d707479' + '3d' +
'09' + '6e756c6c' + '3d' + '6e756c6c' +
'04' + '626f6f6c' +
'0a' + '627566666572' + '3d' + '626172', 'hex')
t.deepEqual(buf, expected)
t.equal(txtBin.encode.bytes, expected.length)
t.end()
})
test('encode - empty', function (t) {
var buf = txtBin.encode({})
var expected = new Buffer('00', 'hex')
t.deepEqual(buf, expected)
t.equal(txtBin.encode.bytes, expected.length)
t.end()
})
test('encode - undefined', function (t) {
var buf = txtBin.encode()
var expected = new Buffer('00', 'hex')
t.deepEqual(buf, expected)
t.equal(txtBin.encode.bytes, expected.length)
t.end()
})
test('encode - with buffer', function (t) {
var buf = new Buffer(3)
buf.fill(255)
txtBin.encode({}, buf)
var expected = new Buffer('00ffff', 'hex')
t.deepEqual(buf, expected)
t.equal(txtBin.encode.bytes, 1)
t.end()
})
test('encode - with buffer and offset', function (t) {
var buf = new Buffer(3)
buf.fill(255)
txtBin.encode({}, buf, 1)
var expected = new Buffer('ff00ff', 'hex')
t.deepEqual(buf, expected)
t.equal(txtBin.encode.bytes, 1)
t.end()
})
test('decode', function (t) {
var encoded = txtBin.encode(obj)
var result = txtBin.decode(encoded)
var expected = {
string: new Buffer('foo'),
number: new Buffer('42'),
empty: new Buffer(0),
null: new Buffer('null'),
bool: true,
buffer: new Buffer('bar')
}
t.deepEqual(result, expected)
t.equal(txtBin.decode.bytes, encoded.length)
t.end()
})
test('decode - strings', function (t) {
var encoded = txtStr.encode(obj)
var result = txtStr.decode(encoded)
var expected = {
string: 'foo',
number: '42',
empty: '',
null: 'null',
bool: true,
buffer: 'bar'
}
t.deepEqual(result, expected)
t.equal(txtStr.decode.bytes, encoded.length)
t.end()
})
test('decode - duplicate', function (t) {
var orig = {
Foo: 'bar',
foo: 'ignore this'
}
var expected = {
foo: new Buffer('bar')
}
var encoded = txtBin.encode(orig)
var result = txtBin.decode(encoded)
t.deepEqual(result, expected)
t.equal(txtBin.decode.bytes, encoded.length)
t.end()
})
test('decode - single zero bype', function (t) {
var encoded = new Buffer('00', 'hex')
var result = txtBin.decode(encoded)
t.deepEqual(result, {})
t.equal(txtBin.decode.bytes, encoded.length)
t.end()
})
test('decode - with offset', function (t) {
var encoded = new Buffer('012300', 'hex')
var result = txtBin.decode(encoded, 2)
t.deepEqual(result, {})
t.equal(txtBin.decode.bytes, 1)
t.end()
})
test('decode - exactly 256 bytes', function (t) {
var expected = { foo: '' }
var maxLength = Object.keys(expected).reduce(function (total, key) {
return total - key.length - 1 // - 1 for the equal sign used to separate the key and the value
}, 255)
for (var n = 0; n < maxLength; n++) {
expected.foo += 'x'
}
// the max case:
var encoded = txtStr.encode(expected)
t.equal(txtStr.encode.bytes, 256)
var result = txtStr.decode(encoded)
t.deepEqual(result, expected)
t.equal(txtStr.decode.bytes, encoded.length)
// go beound the max:
expected.foo += 'x'
encoded = txtStr.encode(expected)
t.equal(txtStr.encode.bytes, 257)
result = txtStr.decode(encoded)
t.notDeepEqual(result, expected)
t.ok(txtStr.decode.bytes > encoded.length)
t.end()
})