fix: 修复中介导入成功条数计算错误
问题: - 导入成功条数显示为负数 - 原因:成功数量计算使用 validRecords.size() - failures.size() - 但没有使用实际的数据库操作返回值 修复: - saveBatchWithUpsert 和 saveBatch 方法现在返回 int - 累加实际的数据库影响行数 - 使用 actualSuccessCount 变量跟踪真实成功数量 影响范围: - CcdiIntermediaryPersonImportServiceImpl - CcdiIntermediaryEntityImportServiceImpl
This commit is contained in:
13
doc/test-data/purchase_transaction/node_modules/unzipper/.circleci/config.yml
generated
vendored
Normal file
13
doc/test-data/purchase_transaction/node_modules/unzipper/.circleci/config.yml
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/node:10.15
|
||||
working_directory: ~/build
|
||||
steps:
|
||||
- checkout
|
||||
- run: npm install
|
||||
- run: npm t
|
||||
- store_artifacts:
|
||||
path: coverage/lcov-report
|
||||
destination: coverage
|
||||
1
doc/test-data/purchase_transaction/node_modules/unzipper/.gitattributes
generated
vendored
Normal file
1
doc/test-data/purchase_transaction/node_modules/unzipper/.gitattributes
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
text eol=lf
|
||||
21
doc/test-data/purchase_transaction/node_modules/unzipper/.travis.yml
generated
vendored
Normal file
21
doc/test-data/purchase_transaction/node_modules/unzipper/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "lts/*"
|
||||
- "17"
|
||||
- "16"
|
||||
- "15"
|
||||
- "14"
|
||||
- "13"
|
||||
- "12"
|
||||
- "10"
|
||||
- "8"
|
||||
- "7"
|
||||
- "6"
|
||||
- "5"
|
||||
- "4"
|
||||
- "0.11"
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
before_install:
|
||||
- if [[ `npm -v` < 5 ]]; then npm cache clean; fi
|
||||
- if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
|
||||
25
doc/test-data/purchase_transaction/node_modules/unzipper/LICENSE
generated
vendored
Normal file
25
doc/test-data/purchase_transaction/node_modules/unzipper/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2012 - 2013 Near Infinity Corporation
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Commits in this fork are (c) Ziggy Jonsson (ziggy.jonsson.nyc@gmail.com)
|
||||
and fall under same licence structure as the original repo (MIT)
|
||||
367
doc/test-data/purchase_transaction/node_modules/unzipper/README.md
generated
vendored
Normal file
367
doc/test-data/purchase_transaction/node_modules/unzipper/README.md
generated
vendored
Normal file
@@ -0,0 +1,367 @@
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Test Coverage][travis-image]][travis-url]
|
||||
[![Coverage][coverage-image]][coverage-url]
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/unzipper.svg
|
||||
[npm-url]: https://npmjs.org/package/unzipper
|
||||
[travis-image]: https://api.travis-ci.org/ZJONSSON/node-unzipper.png?branch=master
|
||||
[travis-url]: https://travis-ci.org/ZJONSSON/node-unzipper?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/unzipper.svg
|
||||
[downloads-url]: https://npmjs.org/package/unzipper
|
||||
[coverage-image]: https://3tjjj5abqi.execute-api.us-east-1.amazonaws.com/prod/node-unzipper/badge
|
||||
[coverage-url]: https://3tjjj5abqi.execute-api.us-east-1.amazonaws.com/prod/node-unzipper/url
|
||||
|
||||
# unzipper
|
||||
|
||||
This is an active fork and drop-in replacement of the [node-unzip](https://github.com/EvanOxfeld/node-unzip) and addresses the following issues:
|
||||
* finish/close events are not always triggered, particular when the input stream is slower than the receivers
|
||||
* Any files are buffered into memory before passing on to entry
|
||||
|
||||
The structure of this fork is similar to the original, but uses Promises and inherit guarantees provided by node streams to ensure low memory footprint and emits finish/close events at the end of processing. The new `Parser` will push any parsed `entries` downstream if you pipe from it, while still supporting the legacy `entry` event as well.
|
||||
|
||||
Breaking changes: The new `Parser` will not automatically drain entries if there are no listeners or pipes in place.
|
||||
|
||||
Unzipper provides simple APIs similar to [node-tar](https://github.com/isaacs/node-tar) for parsing and extracting zip files.
|
||||
There are no added compiled dependencies - inflation is handled by node.js's built in zlib support.
|
||||
|
||||
Please note: Methods that use the Central Directory instead of parsing entire file can be found under [`Open`](#open)
|
||||
|
||||
Chrome extension files (.crx) are zipfiles with an [extra header](http://www.adambarth.com/experimental/crx/docs/crx.html) at the start of the file. Unzipper will parse .crx file with the streaming methods (`Parse` and `ParseOne`). The `Open` methods will check for `crx` headers and parse crx files, but only if you provide `crx: true` in options.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install unzipper
|
||||
```
|
||||
|
||||
## Quick Examples
|
||||
|
||||
### Extract to a directory
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Extract({ path: 'output/path' }));
|
||||
```
|
||||
|
||||
Extract emits the 'close' event once the zip's contents have been fully extracted to disk. `Extract` uses [fstream.Writer](https://www.npmjs.com/package/fstream) and therefore needs need an absolute path to the destination directory. This directory will be automatically created if it doesn't already exits.
|
||||
|
||||
### Parse zip file contents
|
||||
|
||||
Process each zip file entry or pipe entries to another stream.
|
||||
|
||||
__Important__: If you do not intend to consume an entry stream's raw data, call autodrain() to dispose of the entry's
|
||||
contents. Otherwise the stream will halt. `.autodrain()` returns an empty stream that provides `error` and `finish` events.
|
||||
Additionally you can call `.autodrain().promise()` to get the promisified version of success or failure of the autodrain.
|
||||
|
||||
```js
|
||||
// If you want to handle autodrain errors you can either:
|
||||
entry.autodrain().catch(e => handleError);
|
||||
// or
|
||||
entry.autodrain().on('error' => handleError);
|
||||
```
|
||||
|
||||
Here is a quick example:
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.on('entry', function (entry) {
|
||||
const fileName = entry.path;
|
||||
const type = entry.type; // 'Directory' or 'File'
|
||||
const size = entry.vars.uncompressedSize; // There is also compressedSize;
|
||||
if (fileName === "this IS the file I'm looking for") {
|
||||
entry.pipe(fs.createWriteStream('output/path'));
|
||||
} else {
|
||||
entry.autodrain();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
and the same example using async iterators:
|
||||
|
||||
```js
|
||||
const zip = fs.createReadStream('path/to/archive.zip').pipe(unzipper.Parse({forceStream: true}));
|
||||
for await (const entry of zip) {
|
||||
const fileName = entry.path;
|
||||
const type = entry.type; // 'Directory' or 'File'
|
||||
const size = entry.vars.uncompressedSize; // There is also compressedSize;
|
||||
if (fileName === "this IS the file I'm looking for") {
|
||||
entry.pipe(fs.createWriteStream('output/path'));
|
||||
} else {
|
||||
entry.autodrain();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parse zip by piping entries downstream
|
||||
|
||||
If you `pipe` from unzipper the downstream components will receive each `entry` for further processing. This allows for clean pipelines transforming zipfiles into unzipped data.
|
||||
|
||||
Example using `stream.Transform`:
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.pipe(stream.Transform({
|
||||
objectMode: true,
|
||||
transform: function(entry,e,cb) {
|
||||
const fileName = entry.path;
|
||||
const type = entry.type; // 'Directory' or 'File'
|
||||
const size = entry.vars.uncompressedSize; // There is also compressedSize;
|
||||
if (fileName === "this IS the file I'm looking for") {
|
||||
entry.pipe(fs.createWriteStream('output/path'))
|
||||
.on('finish',cb);
|
||||
} else {
|
||||
entry.autodrain();
|
||||
cb();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
```
|
||||
|
||||
Example using [etl](https://www.npmjs.com/package/etl):
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.pipe(etl.map(entry => {
|
||||
if (entry.path == "this IS the file I'm looking for")
|
||||
return entry
|
||||
.pipe(etl.toFile('output/path'))
|
||||
.promise();
|
||||
else
|
||||
entry.autodrain();
|
||||
}))
|
||||
|
||||
```
|
||||
|
||||
### Parse a single file and pipe contents
|
||||
|
||||
`unzipper.parseOne([regex])` is a convenience method that unzips only one file from the archive and pipes the contents down (not the entry itself). If no search criteria is specified, the first file in the archive will be unzipped. Otherwise, each filename will be compared to the criteria and the first one to match will be unzipped and piped down. If no file matches then the the stream will end without any content.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.ParseOne())
|
||||
.pipe(fs.createWriteStream('firstFile.txt'));
|
||||
```
|
||||
|
||||
### Buffering the content of an entry into memory
|
||||
|
||||
While the recommended strategy of consuming the unzipped contents is using streams, it is sometimes convenient to be able to get the full buffered contents of each file . Each `entry` provides a `.buffer` function that consumes the entry by buffering the contents into memory and returning a promise to the complete buffer.
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.pipe(etl.map(async entry => {
|
||||
if (entry.path == "this IS the file I'm looking for") {
|
||||
const content = await entry.buffer();
|
||||
await fs.writeFile('output/path',content);
|
||||
}
|
||||
else {
|
||||
entry.autodrain();
|
||||
}
|
||||
}))
|
||||
```
|
||||
|
||||
### Parse.promise() syntax sugar
|
||||
|
||||
The parser emits `finish` and `error` events like any other stream. The parser additionally provides a promise wrapper around those two events to allow easy folding into existing Promise-based structures.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.on('entry', entry => entry.autodrain())
|
||||
.promise()
|
||||
.then( () => console.log('done'), e => console.log('error',e));
|
||||
```
|
||||
|
||||
### Parse zip created by DOS ZIP or Windows ZIP Folders
|
||||
|
||||
Archives created by legacy tools usually have filenames encoded with IBM PC (Windows OEM) character set.
|
||||
You can decode filenames with preferred character set:
|
||||
|
||||
```js
|
||||
const il = require('iconv-lite');
|
||||
fs.createReadStream('path/to/archive.zip')
|
||||
.pipe(unzipper.Parse())
|
||||
.on('entry', function (entry) {
|
||||
// if some legacy zip tool follow ZIP spec then this flag will be set
|
||||
const isUnicode = entry.props.flags.isUnicode;
|
||||
// decode "non-unicode" filename from OEM Cyrillic character set
|
||||
const fileName = isUnicode ? entry.path : il.decode(entry.props.pathBuffer, 'cp866');
|
||||
const type = entry.type; // 'Directory' or 'File'
|
||||
const size = entry.vars.uncompressedSize; // There is also compressedSize;
|
||||
if (fileName === "Текстовый файл.txt") {
|
||||
entry.pipe(fs.createWriteStream(fileName));
|
||||
} else {
|
||||
entry.autodrain();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Open
|
||||
Previous methods rely on the entire zipfile being received through a pipe. The Open methods load take a different approach: load the central directory first (at the end of the zipfile) and provide the ability to pick and choose which zipfiles to extract, even extracting them in parallel. The open methods return a promise on the contents of the directory, with individual `files` listed in an array. Each file element has the following methods:
|
||||
* `stream([password])` - returns a stream of the unzipped content which can be piped to any destination
|
||||
* `buffer([password])` - returns a promise on the buffered content of the file)
|
||||
If the file is encrypted you will have to supply a password to decrypt, otherwise you can leave blank.
|
||||
Unlike `adm-zip` the Open methods will never read the entire zipfile into buffer.
|
||||
|
||||
The last argument is optional `options` object where you can specify `tailSize` (default 80 bytes), i.e. how many bytes should we read at the end of the zipfile to locate the endOfCentralDirectory. This location can be variable depending on zip64 extensible data sector size. Additionally you can supply option `crx: true` which will check for a crx header and parse the file accordingly by shifting all file offsets by the length of the crx header.
|
||||
|
||||
### Open.file([path], [options])
|
||||
Returns a Promise to the central directory information with methods to extract individual files. `start` and `end` options are used to avoid reading the whole file.
|
||||
|
||||
Example:
|
||||
```js
|
||||
async function main() {
|
||||
const directory = await unzipper.Open.file('path/to/archive.zip');
|
||||
console.log('directory', directory);
|
||||
return new Promise( (resolve, reject) => {
|
||||
directory.files[0]
|
||||
.stream()
|
||||
.pipe(fs.createWriteStream('firstFile'))
|
||||
.on('error',reject)
|
||||
.on('finish',resolve)
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### Open.url([requestLibrary], [url | params], [options])
|
||||
This function will return a Promise to the central directory information from a URL point to a zipfile. Range-headers are used to avoid reading the whole file. Unzipper does not ship with a request library so you will have to provide it as the first option.
|
||||
|
||||
Live Example: (extracts a tiny xml file from the middle of a 500MB zipfile)
|
||||
|
||||
```js
|
||||
const request = require('request');
|
||||
const unzipper = require('./unzip');
|
||||
|
||||
async function main() {
|
||||
const directory = await unzipper.Open.url(request,'http://www2.census.gov/geo/tiger/TIGER2015/ZCTA5/tl_2015_us_zcta510.zip');
|
||||
const file = directory.files.find(d => d.path === 'tl_2015_us_zcta510.shp.iso.xml');
|
||||
const content = await file.buffer();
|
||||
console.log(content.toString());
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
|
||||
This function takes a second parameter which can either be a string containing the `url` to request, or an `options` object to invoke the supplied `request` library with. This can be used when other request options are required, such as custom headers or authentication to a third party service.
|
||||
|
||||
```js
|
||||
const request = require('google-oauth-jwt').requestWithJWT();
|
||||
|
||||
const googleStorageOptions = {
|
||||
url: `https://www.googleapis.com/storage/v1/b/m-bucket-name/o/my-object-name`,
|
||||
qs: { alt: 'media' },
|
||||
jwt: {
|
||||
email: google.storage.credentials.client_email,
|
||||
key: google.storage.credentials.private_key,
|
||||
scopes: ['https://www.googleapis.com/auth/devstorage.read_only']
|
||||
}
|
||||
});
|
||||
|
||||
async function getFile(req, res, next) {
|
||||
const directory = await unzipper.Open.url(request, googleStorageOptions);
|
||||
const file = zip.files.find((file) => file.path === 'my-filename');
|
||||
return file.stream().pipe(res);
|
||||
});
|
||||
```
|
||||
|
||||
### Open.s3([aws-sdk], [params], [options])
|
||||
This function will return a Promise to the central directory information from a zipfile on S3. Range-headers are used to avoid reading the whole file. Unzipper does not ship with with the aws-sdk so you have to provide an instantiated client as first arguments. The params object requires `Bucket` and `Key` to fetch the correct file.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const unzipper = require('./unzip');
|
||||
const AWS = require('aws-sdk');
|
||||
const s3Client = AWS.S3(config);
|
||||
|
||||
async function main() {
|
||||
const directory = await unzipper.Open.s3(s3Client,{Bucket: 'unzipper', Key: 'archive.zip'});
|
||||
return new Promise( (resolve, reject) => {
|
||||
directory.files[0]
|
||||
.stream()
|
||||
.pipe(fs.createWriteStream('firstFile'))
|
||||
.on('error',reject)
|
||||
.on('finish',resolve)
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### Open.buffer(buffer, [options])
|
||||
If you already have the zip file in-memory as a buffer, you can open the contents directly.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// never use readFileSync - only used here to simplify the example
|
||||
const buffer = fs.readFileSync('path/to/arhive.zip');
|
||||
|
||||
async function main() {
|
||||
const directory = await unzipper.Open.buffer(buffer);
|
||||
console.log('directory',directory);
|
||||
// ...
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### Open.custom(source, [options])
|
||||
This function can be used to provide a custom source implementation. The source parameter expects a `stream` and a `size` function to be implemented. The size function should return a `Promise` that resolves the total size of the file. The stream function should return a `Readable` stream according to the supplied offset and length parameters.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// Custom source implementation for reading a zip file from Google Cloud Storage
|
||||
const { Storage } = require('@google-cloud/storage');
|
||||
|
||||
async function main() {
|
||||
const storage = new Storage();
|
||||
const bucket = storage.bucket('my-bucket');
|
||||
const zipFile = bucket.file('my-zip-file.zip');
|
||||
|
||||
const customSource = {
|
||||
stream: function(offset, length) {
|
||||
return zipFile.createReadStream({
|
||||
start: offset,
|
||||
end: length && offset + length
|
||||
})
|
||||
},
|
||||
size: async function() {
|
||||
const objMetadata = (await zipFile.getMetadata())[0];
|
||||
return objMetadata.size;
|
||||
}
|
||||
};
|
||||
|
||||
const directory = await unzipper.Open.custom(customSource);
|
||||
console.log('directory', directory);
|
||||
// ...
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### Open.[method].extract()
|
||||
|
||||
The directory object returned from `Open.[method]` provides an `extract` method which extracts all the files to a specified `path`, with an optional `concurrency` (default: 1).
|
||||
|
||||
Example (with concurrency of 5):
|
||||
|
||||
```js
|
||||
unzip.Open.file('path/to/archive.zip')
|
||||
.then(d => d.extract({path: '/extraction/path', concurrency: 5}));
|
||||
```
|
||||
|
||||
## Licenses
|
||||
See LICENCE
|
||||
12
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Buffer.js
generated
vendored
Normal file
12
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Buffer.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
if (Buffer.from === undefined) {
|
||||
Buffer.from = function (a, b, c) {
|
||||
return new Buffer(a, b, c)
|
||||
};
|
||||
|
||||
Buffer.alloc = Buffer.from;
|
||||
}
|
||||
|
||||
module.exports = Buffer;
|
||||
25
doc/test-data/purchase_transaction/node_modules/unzipper/lib/BufferStream.js
generated
vendored
Normal file
25
doc/test-data/purchase_transaction/node_modules/unzipper/lib/BufferStream.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
var Promise = require('bluebird');
|
||||
var Stream = require('stream');
|
||||
var Buffer = require('./Buffer');
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
||||
Stream = require('readable-stream');
|
||||
|
||||
module.exports = function(entry) {
|
||||
return new Promise(function(resolve,reject) {
|
||||
var chunks = [];
|
||||
var bufferStream = Stream.Transform()
|
||||
.on('finish',function() {
|
||||
resolve(Buffer.concat(chunks));
|
||||
})
|
||||
.on('error',reject);
|
||||
|
||||
bufferStream._transform = function(d,e,cb) {
|
||||
chunks.push(d);
|
||||
cb();
|
||||
};
|
||||
entry.on('error',reject)
|
||||
.pipe(bufferStream);
|
||||
});
|
||||
};
|
||||
72
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Decrypt.js
generated
vendored
Normal file
72
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Decrypt.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
var bigInt = require('big-integer');
|
||||
var Stream = require('stream');
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
||||
Stream = require('readable-stream');
|
||||
|
||||
var table;
|
||||
|
||||
function generateTable() {
|
||||
var poly = 0xEDB88320,c,n,k;
|
||||
table = [];
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = n;
|
||||
for (k = 0; k < 8; k++)
|
||||
c = (c & 1) ? poly ^ (c >>> 1) : c = c >>> 1;
|
||||
table[n] = c >>> 0;
|
||||
}
|
||||
}
|
||||
|
||||
function crc(ch,crc) {
|
||||
if (!table)
|
||||
generateTable();
|
||||
|
||||
if (ch.charCodeAt)
|
||||
ch = ch.charCodeAt(0);
|
||||
|
||||
return (bigInt(crc).shiftRight(8).and(0xffffff)).xor(table[bigInt(crc).xor(ch).and(0xff)]).value;
|
||||
}
|
||||
|
||||
function Decrypt() {
|
||||
if (!(this instanceof Decrypt))
|
||||
return new Decrypt();
|
||||
|
||||
this.key0 = 305419896;
|
||||
this.key1 = 591751049;
|
||||
this.key2 = 878082192;
|
||||
}
|
||||
|
||||
Decrypt.prototype.update = function(h) {
|
||||
this.key0 = crc(h,this.key0);
|
||||
this.key1 = bigInt(this.key0).and(255).and(4294967295).add(this.key1)
|
||||
this.key1 = bigInt(this.key1).multiply(134775813).add(1).and(4294967295).value;
|
||||
this.key2 = crc(bigInt(this.key1).shiftRight(24).and(255), this.key2);
|
||||
}
|
||||
|
||||
|
||||
Decrypt.prototype.decryptByte = function(c) {
|
||||
var k = bigInt(this.key2).or(2);
|
||||
c = c ^ bigInt(k).multiply(bigInt(k^1)).shiftRight(8).and(255);
|
||||
this.update(c);
|
||||
return c;
|
||||
};
|
||||
|
||||
Decrypt.prototype.stream = function() {
|
||||
var stream = Stream.Transform(),
|
||||
self = this;
|
||||
|
||||
stream._transform = function(d,e,cb) {
|
||||
for (var i = 0; i<d.length;i++) {
|
||||
d[i] = self.decryptByte(d[i]);
|
||||
}
|
||||
this.push(d);
|
||||
cb();
|
||||
};
|
||||
return stream;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = Decrypt;
|
||||
19
doc/test-data/purchase_transaction/node_modules/unzipper/lib/NoopStream.js
generated
vendored
Normal file
19
doc/test-data/purchase_transaction/node_modules/unzipper/lib/NoopStream.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var Stream = require('stream');
|
||||
var util = require('util');
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
||||
Stream = require('readable-stream');
|
||||
|
||||
function NoopStream() {
|
||||
if (!(this instanceof NoopStream)) {
|
||||
return new NoopStream();
|
||||
}
|
||||
Stream.Transform.call(this);
|
||||
}
|
||||
|
||||
util.inherits(NoopStream,Stream.Transform);
|
||||
|
||||
NoopStream.prototype._transform = function(d,e,cb) { cb() ;};
|
||||
|
||||
module.exports = NoopStream;
|
||||
231
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Open/directory.js
generated
vendored
Normal file
231
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Open/directory.js
generated
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
var binary = require('binary');
|
||||
var PullStream = require('../PullStream');
|
||||
var unzip = require('./unzip');
|
||||
var Promise = require('bluebird');
|
||||
var BufferStream = require('../BufferStream');
|
||||
var parseExtraField = require('../parseExtraField');
|
||||
var Buffer = require('../Buffer');
|
||||
var path = require('path');
|
||||
var Writer = require('fstream').Writer;
|
||||
var parseDateTime = require('../parseDateTime');
|
||||
|
||||
var signature = Buffer.alloc(4);
|
||||
signature.writeUInt32LE(0x06054b50,0);
|
||||
|
||||
function getCrxHeader(source) {
|
||||
var sourceStream = source.stream(0).pipe(PullStream());
|
||||
|
||||
return sourceStream.pull(4).then(function(data) {
|
||||
var signature = data.readUInt32LE(0);
|
||||
if (signature === 0x34327243) {
|
||||
var crxHeader;
|
||||
return sourceStream.pull(12).then(function(data) {
|
||||
crxHeader = binary.parse(data)
|
||||
.word32lu('version')
|
||||
.word32lu('pubKeyLength')
|
||||
.word32lu('signatureLength')
|
||||
.vars;
|
||||
}).then(function() {
|
||||
return sourceStream.pull(crxHeader.pubKeyLength +crxHeader.signatureLength);
|
||||
}).then(function(data) {
|
||||
crxHeader.publicKey = data.slice(0,crxHeader.pubKeyLength);
|
||||
crxHeader.signature = data.slice(crxHeader.pubKeyLength);
|
||||
crxHeader.size = 16 + crxHeader.pubKeyLength +crxHeader.signatureLength;
|
||||
return crxHeader;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Zip64 File Format Notes: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
|
||||
function getZip64CentralDirectory(source, zip64CDL) {
|
||||
var d64loc = binary.parse(zip64CDL)
|
||||
.word32lu('signature')
|
||||
.word32lu('diskNumber')
|
||||
.word64lu('offsetToStartOfCentralDirectory')
|
||||
.word32lu('numberOfDisks')
|
||||
.vars;
|
||||
|
||||
if (d64loc.signature != 0x07064b50) {
|
||||
throw new Error('invalid zip64 end of central dir locator signature (0x07064b50): 0x' + d64loc.signature.toString(16));
|
||||
}
|
||||
|
||||
var dir64 = PullStream();
|
||||
source.stream(d64loc.offsetToStartOfCentralDirectory).pipe(dir64);
|
||||
|
||||
return dir64.pull(56)
|
||||
}
|
||||
|
||||
// Zip64 File Format Notes: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
|
||||
function parseZip64DirRecord (dir64record) {
|
||||
var vars = binary.parse(dir64record)
|
||||
.word32lu('signature')
|
||||
.word64lu('sizeOfCentralDirectory')
|
||||
.word16lu('version')
|
||||
.word16lu('versionsNeededToExtract')
|
||||
.word32lu('diskNumber')
|
||||
.word32lu('diskStart')
|
||||
.word64lu('numberOfRecordsOnDisk')
|
||||
.word64lu('numberOfRecords')
|
||||
.word64lu('sizeOfCentralDirectory')
|
||||
.word64lu('offsetToStartOfCentralDirectory')
|
||||
.vars;
|
||||
|
||||
if (vars.signature != 0x06064b50) {
|
||||
throw new Error('invalid zip64 end of central dir locator signature (0x06064b50): 0x0' + vars.signature.toString(16));
|
||||
}
|
||||
|
||||
return vars
|
||||
}
|
||||
|
||||
module.exports = function centralDirectory(source, options) {
|
||||
var endDir = PullStream(),
|
||||
records = PullStream(),
|
||||
tailSize = (options && options.tailSize) || 80,
|
||||
sourceSize,
|
||||
crxHeader,
|
||||
startOffset,
|
||||
vars;
|
||||
|
||||
if (options && options.crx)
|
||||
crxHeader = getCrxHeader(source);
|
||||
|
||||
return source.size()
|
||||
.then(function(size) {
|
||||
sourceSize = size;
|
||||
|
||||
source.stream(Math.max(0,size-tailSize))
|
||||
.on('error', function (error) { endDir.emit('error', error) })
|
||||
.pipe(endDir);
|
||||
|
||||
return endDir.pull(signature);
|
||||
})
|
||||
.then(function() {
|
||||
return Promise.props({directory: endDir.pull(22), crxHeader: crxHeader});
|
||||
})
|
||||
.then(function(d) {
|
||||
var data = d.directory;
|
||||
startOffset = d.crxHeader && d.crxHeader.size || 0;
|
||||
|
||||
vars = binary.parse(data)
|
||||
.word32lu('signature')
|
||||
.word16lu('diskNumber')
|
||||
.word16lu('diskStart')
|
||||
.word16lu('numberOfRecordsOnDisk')
|
||||
.word16lu('numberOfRecords')
|
||||
.word32lu('sizeOfCentralDirectory')
|
||||
.word32lu('offsetToStartOfCentralDirectory')
|
||||
.word16lu('commentLength')
|
||||
.vars;
|
||||
|
||||
// Is this zip file using zip64 format? Use same check as Go:
|
||||
// https://github.com/golang/go/blob/master/src/archive/zip/reader.go#L503
|
||||
// For zip64 files, need to find zip64 central directory locator header to extract
|
||||
// relative offset for zip64 central directory record.
|
||||
if (vars.numberOfRecords == 0xffff|| vars.numberOfRecords == 0xffff ||
|
||||
vars.offsetToStartOfCentralDirectory == 0xffffffff) {
|
||||
|
||||
// Offset to zip64 CDL is 20 bytes before normal CDR
|
||||
const zip64CDLSize = 20
|
||||
const zip64CDLOffset = sourceSize - (tailSize - endDir.match + zip64CDLSize)
|
||||
const zip64CDLStream = PullStream();
|
||||
|
||||
source.stream(zip64CDLOffset).pipe(zip64CDLStream);
|
||||
|
||||
return zip64CDLStream.pull(zip64CDLSize)
|
||||
.then(function (d) { return getZip64CentralDirectory(source, d) })
|
||||
.then(function (dir64record) {
|
||||
vars = parseZip64DirRecord(dir64record)
|
||||
})
|
||||
} else {
|
||||
vars.offsetToStartOfCentralDirectory += startOffset;
|
||||
}
|
||||
})
|
||||
.then(function() {
|
||||
if (vars.commentLength) return endDir.pull(vars.commentLength).then(function(comment) {
|
||||
vars.comment = comment.toString('utf8');
|
||||
});
|
||||
})
|
||||
.then(function() {
|
||||
source.stream(vars.offsetToStartOfCentralDirectory).pipe(records);
|
||||
|
||||
vars.extract = function(opts) {
|
||||
if (!opts || !opts.path) throw new Error('PATH_MISSING');
|
||||
// make sure path is normalized before using it
|
||||
opts.path = path.resolve(path.normalize(opts.path));
|
||||
return vars.files.then(function(files) {
|
||||
return Promise.map(files, function(entry) {
|
||||
if (entry.type == 'Directory') return;
|
||||
|
||||
// to avoid zip slip (writing outside of the destination), we resolve
|
||||
// the target path, and make sure it's nested in the intended
|
||||
// destination, or not extract it otherwise.
|
||||
var extractPath = path.join(opts.path, entry.path);
|
||||
if (extractPath.indexOf(opts.path) != 0) {
|
||||
return;
|
||||
}
|
||||
var writer = opts.getWriter ? opts.getWriter({path: extractPath}) : Writer({ path: extractPath });
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
entry.stream(opts.password)
|
||||
.on('error',reject)
|
||||
.pipe(writer)
|
||||
.on('close',resolve)
|
||||
.on('error',reject);
|
||||
});
|
||||
}, { concurrency: opts.concurrency > 1 ? opts.concurrency : 1 });
|
||||
});
|
||||
};
|
||||
|
||||
vars.files = Promise.mapSeries(Array(vars.numberOfRecords),function() {
|
||||
return records.pull(46).then(function(data) {
|
||||
var vars = binary.parse(data)
|
||||
.word32lu('signature')
|
||||
.word16lu('versionMadeBy')
|
||||
.word16lu('versionsNeededToExtract')
|
||||
.word16lu('flags')
|
||||
.word16lu('compressionMethod')
|
||||
.word16lu('lastModifiedTime')
|
||||
.word16lu('lastModifiedDate')
|
||||
.word32lu('crc32')
|
||||
.word32lu('compressedSize')
|
||||
.word32lu('uncompressedSize')
|
||||
.word16lu('fileNameLength')
|
||||
.word16lu('extraFieldLength')
|
||||
.word16lu('fileCommentLength')
|
||||
.word16lu('diskNumber')
|
||||
.word16lu('internalFileAttributes')
|
||||
.word32lu('externalFileAttributes')
|
||||
.word32lu('offsetToLocalFileHeader')
|
||||
.vars;
|
||||
|
||||
vars.offsetToLocalFileHeader += startOffset;
|
||||
vars.lastModifiedDateTime = parseDateTime(vars.lastModifiedDate, vars.lastModifiedTime);
|
||||
|
||||
return records.pull(vars.fileNameLength).then(function(fileNameBuffer) {
|
||||
vars.pathBuffer = fileNameBuffer;
|
||||
vars.path = fileNameBuffer.toString('utf8');
|
||||
vars.isUnicode = (vars.flags & 0x800) != 0;
|
||||
return records.pull(vars.extraFieldLength);
|
||||
})
|
||||
.then(function(extraField) {
|
||||
vars.extra = parseExtraField(extraField, vars);
|
||||
return records.pull(vars.fileCommentLength);
|
||||
})
|
||||
.then(function(comment) {
|
||||
vars.comment = comment;
|
||||
vars.type = (vars.uncompressedSize === 0 && /[\/\\]$/.test(vars.path)) ? 'Directory' : 'File';
|
||||
vars.stream = function(_password) {
|
||||
return unzip(source, vars.offsetToLocalFileHeader,_password, vars);
|
||||
};
|
||||
vars.buffer = function(_password) {
|
||||
return BufferStream(vars.stream(_password));
|
||||
};
|
||||
return vars;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.props(vars);
|
||||
});
|
||||
};
|
||||
101
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Open/index.js
generated
vendored
Normal file
101
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Open/index.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
var fs = require('graceful-fs');
|
||||
var Promise = require('bluebird');
|
||||
var directory = require('./directory');
|
||||
var Stream = require('stream');
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
||||
Stream = require('readable-stream');
|
||||
|
||||
module.exports = {
|
||||
buffer: function(buffer, options) {
|
||||
var source = {
|
||||
stream: function(offset, length) {
|
||||
var stream = Stream.PassThrough();
|
||||
stream.end(buffer.slice(offset, length));
|
||||
return stream;
|
||||
},
|
||||
size: function() {
|
||||
return Promise.resolve(buffer.length);
|
||||
}
|
||||
};
|
||||
return directory(source, options);
|
||||
},
|
||||
file: function(filename, options) {
|
||||
var source = {
|
||||
stream: function(offset,length) {
|
||||
return fs.createReadStream(filename,{start: offset, end: length && offset+length});
|
||||
},
|
||||
size: function() {
|
||||
return new Promise(function(resolve,reject) {
|
||||
fs.stat(filename,function(err,d) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
resolve(d.size);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
return directory(source, options);
|
||||
},
|
||||
|
||||
url: function(request, params, options) {
|
||||
if (typeof params === 'string')
|
||||
params = {url: params};
|
||||
if (!params.url)
|
||||
throw 'URL missing';
|
||||
params.headers = params.headers || {};
|
||||
|
||||
var source = {
|
||||
stream : function(offset,length) {
|
||||
var options = Object.create(params);
|
||||
options.headers = Object.create(params.headers);
|
||||
options.headers.range = 'bytes='+offset+'-' + (length ? length : '');
|
||||
return request(options);
|
||||
},
|
||||
size: function() {
|
||||
return new Promise(function(resolve,reject) {
|
||||
var req = request(params);
|
||||
req.on('response',function(d) {
|
||||
req.abort();
|
||||
if (!d.headers['content-length'])
|
||||
reject(new Error('Missing content length header'));
|
||||
else
|
||||
resolve(d.headers['content-length']);
|
||||
}).on('error',reject);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return directory(source, options);
|
||||
},
|
||||
|
||||
s3 : function(client,params, options) {
|
||||
var source = {
|
||||
size: function() {
|
||||
return new Promise(function(resolve,reject) {
|
||||
client.headObject(params, function(err,d) {
|
||||
if (err)
|
||||
reject(err);
|
||||
else
|
||||
resolve(d.ContentLength);
|
||||
});
|
||||
});
|
||||
},
|
||||
stream: function(offset,length) {
|
||||
var d = {};
|
||||
for (var key in params)
|
||||
d[key] = params[key];
|
||||
d.Range = 'bytes='+offset+'-' + (length ? length : '');
|
||||
return client.getObject(d).createReadStream();
|
||||
}
|
||||
};
|
||||
|
||||
return directory(source, options);
|
||||
},
|
||||
|
||||
custom: function(source, options) {
|
||||
return directory(source, options);
|
||||
}
|
||||
};
|
||||
126
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Open/unzip.js
generated
vendored
Normal file
126
doc/test-data/purchase_transaction/node_modules/unzipper/lib/Open/unzip.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
var Promise = require('bluebird');
|
||||
var Decrypt = require('../Decrypt');
|
||||
var PullStream = require('../PullStream');
|
||||
var Stream = require('stream');
|
||||
var binary = require('binary');
|
||||
var zlib = require('zlib');
|
||||
var parseExtraField = require('../parseExtraField');
|
||||
var Buffer = require('../Buffer');
|
||||
var parseDateTime = require('../parseDateTime');
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
||||
Stream = require('readable-stream');
|
||||
|
||||
module.exports = function unzip(source,offset,_password, directoryVars) {
|
||||
var file = PullStream(),
|
||||
entry = Stream.PassThrough();
|
||||
|
||||
var req = source.stream(offset);
|
||||
req.pipe(file).on('error', function(e) {
|
||||
entry.emit('error', e);
|
||||
});
|
||||
|
||||
entry.vars = file.pull(30)
|
||||
.then(function(data) {
|
||||
var vars = binary.parse(data)
|
||||
.word32lu('signature')
|
||||
.word16lu('versionsNeededToExtract')
|
||||
.word16lu('flags')
|
||||
.word16lu('compressionMethod')
|
||||
.word16lu('lastModifiedTime')
|
||||
.word16lu('lastModifiedDate')
|
||||
.word32lu('crc32')
|
||||
.word32lu('compressedSize')
|
||||
.word32lu('uncompressedSize')
|
||||
.word16lu('fileNameLength')
|
||||
.word16lu('extraFieldLength')
|
||||
.vars;
|
||||
|
||||
vars.lastModifiedDateTime = parseDateTime(vars.lastModifiedDate, vars.lastModifiedTime);
|
||||
|
||||
return file.pull(vars.fileNameLength)
|
||||
.then(function(fileName) {
|
||||
vars.fileName = fileName.toString('utf8');
|
||||
return file.pull(vars.extraFieldLength);
|
||||
})
|
||||
.then(function(extraField) {
|
||||
var checkEncryption;
|
||||
vars.extra = parseExtraField(extraField, vars);
|
||||
// Ignore logal file header vars if the directory vars are available
|
||||
if (directoryVars && directoryVars.compressedSize) vars = directoryVars;
|
||||
|
||||
if (vars.flags & 0x01) checkEncryption = file.pull(12)
|
||||
.then(function(header) {
|
||||
if (!_password)
|
||||
throw new Error('MISSING_PASSWORD');
|
||||
|
||||
var decrypt = Decrypt();
|
||||
|
||||
String(_password).split('').forEach(function(d) {
|
||||
decrypt.update(d);
|
||||
});
|
||||
|
||||
for (var i=0; i < header.length; i++)
|
||||
header[i] = decrypt.decryptByte(header[i]);
|
||||
|
||||
vars.decrypt = decrypt;
|
||||
vars.compressedSize -= 12;
|
||||
|
||||
var check = (vars.flags & 0x8) ? (vars.lastModifiedTime >> 8) & 0xff : (vars.crc32 >> 24) & 0xff;
|
||||
if (header[11] !== check)
|
||||
throw new Error('BAD_PASSWORD');
|
||||
|
||||
return vars;
|
||||
});
|
||||
|
||||
return Promise.resolve(checkEncryption)
|
||||
.then(function() {
|
||||
entry.emit('vars',vars);
|
||||
return vars;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
entry.vars.then(function(vars) {
|
||||
var fileSizeKnown = !(vars.flags & 0x08) || vars.compressedSize > 0,
|
||||
eof;
|
||||
|
||||
var inflater = vars.compressionMethod ? zlib.createInflateRaw() : Stream.PassThrough();
|
||||
|
||||
if (fileSizeKnown) {
|
||||
entry.size = vars.uncompressedSize;
|
||||
eof = vars.compressedSize;
|
||||
} else {
|
||||
eof = Buffer.alloc(4);
|
||||
eof.writeUInt32LE(0x08074b50, 0);
|
||||
}
|
||||
|
||||
var stream = file.stream(eof);
|
||||
|
||||
if (vars.decrypt)
|
||||
stream = stream.pipe(vars.decrypt.stream());
|
||||
|
||||
stream
|
||||
.pipe(inflater)
|
||||
.on('error',function(err) { entry.emit('error',err);})
|
||||
.pipe(entry)
|
||||
.on('finish', function() {
|
||||
if(req.destroy)
|
||||
req.destroy()
|
||||
else if (req.abort)
|
||||
req.abort();
|
||||
else if (req.close)
|
||||
req.close();
|
||||
else if (req.push)
|
||||
req.push();
|
||||
else
|
||||
console.log('warning - unable to close stream');
|
||||
});
|
||||
})
|
||||
.catch(function(e) {
|
||||
entry.emit('error',e);
|
||||
});
|
||||
|
||||
return entry;
|
||||
};
|
||||
144
doc/test-data/purchase_transaction/node_modules/unzipper/lib/PullStream.js
generated
vendored
Normal file
144
doc/test-data/purchase_transaction/node_modules/unzipper/lib/PullStream.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
var Stream = require('stream');
|
||||
var Promise = require('bluebird');
|
||||
var util = require('util');
|
||||
var Buffer = require('./Buffer');
|
||||
var strFunction = 'function';
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
||||
Stream = require('readable-stream');
|
||||
|
||||
function PullStream() {
|
||||
if (!(this instanceof PullStream))
|
||||
return new PullStream();
|
||||
|
||||
Stream.Duplex.call(this,{decodeStrings:false, objectMode:true});
|
||||
this.buffer = Buffer.from('');
|
||||
var self = this;
|
||||
self.on('finish',function() {
|
||||
self.finished = true;
|
||||
self.emit('chunk',false);
|
||||
});
|
||||
}
|
||||
|
||||
util.inherits(PullStream,Stream.Duplex);
|
||||
|
||||
PullStream.prototype._write = function(chunk,e,cb) {
|
||||
this.buffer = Buffer.concat([this.buffer,chunk]);
|
||||
this.cb = cb;
|
||||
this.emit('chunk');
|
||||
};
|
||||
|
||||
|
||||
// The `eof` parameter is interpreted as `file_length` if the type is number
|
||||
// otherwise (i.e. buffer) it is interpreted as a pattern signaling end of stream
|
||||
PullStream.prototype.stream = function(eof,includeEof) {
|
||||
var p = Stream.PassThrough();
|
||||
var done,self= this;
|
||||
|
||||
function cb() {
|
||||
if (typeof self.cb === strFunction) {
|
||||
var callback = self.cb;
|
||||
self.cb = undefined;
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
|
||||
function pull() {
|
||||
var packet;
|
||||
if (self.buffer && self.buffer.length) {
|
||||
if (typeof eof === 'number') {
|
||||
packet = self.buffer.slice(0,eof);
|
||||
self.buffer = self.buffer.slice(eof);
|
||||
eof -= packet.length;
|
||||
done = !eof;
|
||||
} else {
|
||||
var match = self.buffer.indexOf(eof);
|
||||
if (match !== -1) {
|
||||
// store signature match byte offset to allow us to reference
|
||||
// this for zip64 offset
|
||||
self.match = match
|
||||
if (includeEof) match = match + eof.length;
|
||||
packet = self.buffer.slice(0,match);
|
||||
self.buffer = self.buffer.slice(match);
|
||||
done = true;
|
||||
} else {
|
||||
var len = self.buffer.length - eof.length;
|
||||
if (len <= 0) {
|
||||
cb();
|
||||
} else {
|
||||
packet = self.buffer.slice(0,len);
|
||||
self.buffer = self.buffer.slice(len);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (packet) p.write(packet,function() {
|
||||
if (self.buffer.length === 0 || (eof.length && self.buffer.length <= eof.length)) cb();
|
||||
});
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
if (self.finished) {
|
||||
self.removeListener('chunk',pull);
|
||||
self.emit('error', new Error('FILE_ENDED'));
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
self.removeListener('chunk',pull);
|
||||
p.end();
|
||||
}
|
||||
}
|
||||
|
||||
self.on('chunk',pull);
|
||||
pull();
|
||||
return p;
|
||||
};
|
||||
|
||||
PullStream.prototype.pull = function(eof,includeEof) {
|
||||
if (eof === 0) return Promise.resolve('');
|
||||
|
||||
// If we already have the required data in buffer
|
||||
// we can resolve the request immediately
|
||||
if (!isNaN(eof) && this.buffer.length > eof) {
|
||||
var data = this.buffer.slice(0,eof);
|
||||
this.buffer = this.buffer.slice(eof);
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
|
||||
// Otherwise we stream until we have it
|
||||
var buffer = Buffer.from(''),
|
||||
self = this;
|
||||
|
||||
var concatStream = Stream.Transform();
|
||||
concatStream._transform = function(d,e,cb) {
|
||||
buffer = Buffer.concat([buffer,d]);
|
||||
cb();
|
||||
};
|
||||
|
||||
var rejectHandler;
|
||||
var pullStreamRejectHandler;
|
||||
return new Promise(function(resolve,reject) {
|
||||
rejectHandler = reject;
|
||||
pullStreamRejectHandler = function(e) {
|
||||
self.__emittedError = e;
|
||||
reject(e);
|
||||
}
|
||||
if (self.finished)
|
||||
return reject(new Error('FILE_ENDED'));
|
||||
self.once('error',pullStreamRejectHandler); // reject any errors from pullstream itself
|
||||
self.stream(eof,includeEof)
|
||||
.on('error',reject)
|
||||
.pipe(concatStream)
|
||||
.on('finish',function() {resolve(buffer);})
|
||||
.on('error',reject);
|
||||
})
|
||||
.finally(function() {
|
||||
self.removeListener('error',rejectHandler);
|
||||
self.removeListener('error',pullStreamRejectHandler);
|
||||
});
|
||||
};
|
||||
|
||||
PullStream.prototype._read = function(){};
|
||||
|
||||
module.exports = PullStream;
|
||||
55
doc/test-data/purchase_transaction/node_modules/unzipper/lib/extract.js
generated
vendored
Normal file
55
doc/test-data/purchase_transaction/node_modules/unzipper/lib/extract.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
module.exports = Extract;
|
||||
|
||||
var Parse = require('./parse');
|
||||
var Writer = require('fstream').Writer;
|
||||
var path = require('path');
|
||||
var stream = require('stream');
|
||||
var duplexer2 = require('duplexer2');
|
||||
var Promise = require('bluebird');
|
||||
|
||||
function Extract (opts) {
|
||||
// make sure path is normalized before using it
|
||||
opts.path = path.resolve(path.normalize(opts.path));
|
||||
|
||||
var parser = new Parse(opts);
|
||||
|
||||
var outStream = new stream.Writable({objectMode: true});
|
||||
outStream._write = function(entry, encoding, cb) {
|
||||
|
||||
if (entry.type == 'Directory') return cb();
|
||||
|
||||
// to avoid zip slip (writing outside of the destination), we resolve
|
||||
// the target path, and make sure it's nested in the intended
|
||||
// destination, or not extract it otherwise.
|
||||
var extractPath = path.join(opts.path, entry.path);
|
||||
if (extractPath.indexOf(opts.path) != 0) {
|
||||
return cb();
|
||||
}
|
||||
|
||||
const writer = opts.getWriter ? opts.getWriter({path: extractPath}) : Writer({ path: extractPath });
|
||||
|
||||
entry.pipe(writer)
|
||||
.on('error', cb)
|
||||
.on('close', cb);
|
||||
};
|
||||
|
||||
var extract = duplexer2(parser,outStream);
|
||||
parser.once('crx-header', function(crxHeader) {
|
||||
extract.crxHeader = crxHeader;
|
||||
});
|
||||
|
||||
parser
|
||||
.pipe(outStream)
|
||||
.on('finish',function() {
|
||||
extract.emit('close');
|
||||
});
|
||||
|
||||
extract.promise = function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
extract.on('close', resolve);
|
||||
extract.on('error',reject);
|
||||
});
|
||||
};
|
||||
|
||||
return extract;
|
||||
}
|
||||
287
doc/test-data/purchase_transaction/node_modules/unzipper/lib/parse.js
generated
vendored
Normal file
287
doc/test-data/purchase_transaction/node_modules/unzipper/lib/parse.js
generated
vendored
Normal file
@@ -0,0 +1,287 @@
|
||||
var util = require('util');
|
||||
var zlib = require('zlib');
|
||||
var Stream = require('stream');
|
||||
var binary = require('binary');
|
||||
var Promise = require('bluebird');
|
||||
var PullStream = require('./PullStream');
|
||||
var NoopStream = require('./NoopStream');
|
||||
var BufferStream = require('./BufferStream');
|
||||
var parseExtraField = require('./parseExtraField');
|
||||
var Buffer = require('./Buffer');
|
||||
var parseDateTime = require('./parseDateTime');
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
||||
Stream = require('readable-stream');
|
||||
|
||||
var endDirectorySignature = Buffer.alloc(4);
|
||||
endDirectorySignature.writeUInt32LE(0x06054b50, 0);
|
||||
|
||||
function Parse(opts) {
|
||||
if (!(this instanceof Parse)) {
|
||||
return new Parse(opts);
|
||||
}
|
||||
var self = this;
|
||||
self._opts = opts || { verbose: false };
|
||||
|
||||
PullStream.call(self, self._opts);
|
||||
self.on('finish',function() {
|
||||
self.emit('end');
|
||||
self.emit('close');
|
||||
});
|
||||
self._readRecord().catch(function(e) {
|
||||
if (!self.__emittedError || self.__emittedError !== e)
|
||||
self.emit('error',e);
|
||||
});
|
||||
}
|
||||
|
||||
util.inherits(Parse, PullStream);
|
||||
|
||||
Parse.prototype._readRecord = function () {
|
||||
var self = this;
|
||||
return self.pull(4).then(function(data) {
|
||||
if (data.length === 0)
|
||||
return;
|
||||
|
||||
var signature = data.readUInt32LE(0);
|
||||
|
||||
if (signature === 0x34327243) {
|
||||
return self._readCrxHeader();
|
||||
}
|
||||
if (signature === 0x04034b50) {
|
||||
return self._readFile();
|
||||
}
|
||||
else if (signature === 0x02014b50) {
|
||||
self.reachedCD = true;
|
||||
return self._readCentralDirectoryFileHeader();
|
||||
}
|
||||
else if (signature === 0x06054b50) {
|
||||
return self._readEndOfCentralDirectoryRecord();
|
||||
}
|
||||
else if (self.reachedCD) {
|
||||
// _readEndOfCentralDirectoryRecord expects the EOCD
|
||||
// signature to be consumed so set includeEof=true
|
||||
var includeEof = true;
|
||||
return self.pull(endDirectorySignature, includeEof).then(function() {
|
||||
return self._readEndOfCentralDirectoryRecord();
|
||||
});
|
||||
}
|
||||
else
|
||||
self.emit('error', new Error('invalid signature: 0x' + signature.toString(16)));
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype._readCrxHeader = function() {
|
||||
var self = this;
|
||||
return self.pull(12).then(function(data) {
|
||||
self.crxHeader = binary.parse(data)
|
||||
.word32lu('version')
|
||||
.word32lu('pubKeyLength')
|
||||
.word32lu('signatureLength')
|
||||
.vars;
|
||||
return self.pull(self.crxHeader.pubKeyLength + self.crxHeader.signatureLength);
|
||||
}).then(function(data) {
|
||||
self.crxHeader.publicKey = data.slice(0,self.crxHeader.pubKeyLength);
|
||||
self.crxHeader.signature = data.slice(self.crxHeader.pubKeyLength);
|
||||
self.emit('crx-header',self.crxHeader);
|
||||
return self._readRecord();
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype._readFile = function () {
|
||||
var self = this;
|
||||
return self.pull(26).then(function(data) {
|
||||
var vars = binary.parse(data)
|
||||
.word16lu('versionsNeededToExtract')
|
||||
.word16lu('flags')
|
||||
.word16lu('compressionMethod')
|
||||
.word16lu('lastModifiedTime')
|
||||
.word16lu('lastModifiedDate')
|
||||
.word32lu('crc32')
|
||||
.word32lu('compressedSize')
|
||||
.word32lu('uncompressedSize')
|
||||
.word16lu('fileNameLength')
|
||||
.word16lu('extraFieldLength')
|
||||
.vars;
|
||||
|
||||
vars.lastModifiedDateTime = parseDateTime(vars.lastModifiedDate, vars.lastModifiedTime);
|
||||
|
||||
if (self.crxHeader) vars.crxHeader = self.crxHeader;
|
||||
|
||||
return self.pull(vars.fileNameLength).then(function(fileNameBuffer) {
|
||||
var fileName = fileNameBuffer.toString('utf8');
|
||||
var entry = Stream.PassThrough();
|
||||
var __autodraining = false;
|
||||
|
||||
entry.autodrain = function() {
|
||||
__autodraining = true;
|
||||
var draining = entry.pipe(NoopStream());
|
||||
draining.promise = function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
draining.on('finish',resolve);
|
||||
draining.on('error',reject);
|
||||
});
|
||||
};
|
||||
return draining;
|
||||
};
|
||||
|
||||
entry.buffer = function() {
|
||||
return BufferStream(entry);
|
||||
};
|
||||
|
||||
entry.path = fileName;
|
||||
entry.props = {};
|
||||
entry.props.path = fileName;
|
||||
entry.props.pathBuffer = fileNameBuffer;
|
||||
entry.props.flags = {
|
||||
"isUnicode": (vars.flags & 0x800) != 0
|
||||
};
|
||||
entry.type = (vars.uncompressedSize === 0 && /[\/\\]$/.test(fileName)) ? 'Directory' : 'File';
|
||||
|
||||
if (self._opts.verbose) {
|
||||
if (entry.type === 'Directory') {
|
||||
console.log(' creating:', fileName);
|
||||
} else if (entry.type === 'File') {
|
||||
if (vars.compressionMethod === 0) {
|
||||
console.log(' extracting:', fileName);
|
||||
} else {
|
||||
console.log(' inflating:', fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self.pull(vars.extraFieldLength).then(function(extraField) {
|
||||
var extra = parseExtraField(extraField, vars);
|
||||
|
||||
entry.vars = vars;
|
||||
entry.extra = extra;
|
||||
|
||||
if (self._opts.forceStream) {
|
||||
self.push(entry);
|
||||
} else {
|
||||
self.emit('entry', entry);
|
||||
|
||||
if (self._readableState.pipesCount || (self._readableState.pipes && self._readableState.pipes.length))
|
||||
self.push(entry);
|
||||
}
|
||||
|
||||
if (self._opts.verbose)
|
||||
console.log({
|
||||
filename:fileName,
|
||||
vars: vars,
|
||||
extra: extra
|
||||
});
|
||||
|
||||
var fileSizeKnown = !(vars.flags & 0x08) || vars.compressedSize > 0,
|
||||
eof;
|
||||
|
||||
entry.__autodraining = __autodraining; // expose __autodraining for test purposes
|
||||
var inflater = (vars.compressionMethod && !__autodraining) ? zlib.createInflateRaw() : Stream.PassThrough();
|
||||
|
||||
if (fileSizeKnown) {
|
||||
entry.size = vars.uncompressedSize;
|
||||
eof = vars.compressedSize;
|
||||
} else {
|
||||
eof = Buffer.alloc(4);
|
||||
eof.writeUInt32LE(0x08074b50, 0);
|
||||
}
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
self.stream(eof)
|
||||
.pipe(inflater)
|
||||
.on('error',function(err) { self.emit('error',err);})
|
||||
.pipe(entry)
|
||||
.on('finish', function() {
|
||||
return fileSizeKnown ?
|
||||
self._readRecord().then(resolve).catch(reject) :
|
||||
self._processDataDescriptor(entry).then(resolve).catch(reject);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype._processDataDescriptor = function (entry) {
|
||||
var self = this;
|
||||
return self.pull(16).then(function(data) {
|
||||
var vars = binary.parse(data)
|
||||
.word32lu('dataDescriptorSignature')
|
||||
.word32lu('crc32')
|
||||
.word32lu('compressedSize')
|
||||
.word32lu('uncompressedSize')
|
||||
.vars;
|
||||
|
||||
entry.size = vars.uncompressedSize;
|
||||
return self._readRecord();
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype._readCentralDirectoryFileHeader = function () {
|
||||
var self = this;
|
||||
return self.pull(42).then(function(data) {
|
||||
|
||||
var vars = binary.parse(data)
|
||||
.word16lu('versionMadeBy')
|
||||
.word16lu('versionsNeededToExtract')
|
||||
.word16lu('flags')
|
||||
.word16lu('compressionMethod')
|
||||
.word16lu('lastModifiedTime')
|
||||
.word16lu('lastModifiedDate')
|
||||
.word32lu('crc32')
|
||||
.word32lu('compressedSize')
|
||||
.word32lu('uncompressedSize')
|
||||
.word16lu('fileNameLength')
|
||||
.word16lu('extraFieldLength')
|
||||
.word16lu('fileCommentLength')
|
||||
.word16lu('diskNumber')
|
||||
.word16lu('internalFileAttributes')
|
||||
.word32lu('externalFileAttributes')
|
||||
.word32lu('offsetToLocalFileHeader')
|
||||
.vars;
|
||||
|
||||
return self.pull(vars.fileNameLength).then(function(fileName) {
|
||||
vars.fileName = fileName.toString('utf8');
|
||||
return self.pull(vars.extraFieldLength);
|
||||
})
|
||||
.then(function(extraField) {
|
||||
return self.pull(vars.fileCommentLength);
|
||||
})
|
||||
.then(function(fileComment) {
|
||||
return self._readRecord();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype._readEndOfCentralDirectoryRecord = function() {
|
||||
var self = this;
|
||||
return self.pull(18).then(function(data) {
|
||||
|
||||
var vars = binary.parse(data)
|
||||
.word16lu('diskNumber')
|
||||
.word16lu('diskStart')
|
||||
.word16lu('numberOfRecordsOnDisk')
|
||||
.word16lu('numberOfRecords')
|
||||
.word32lu('sizeOfCentralDirectory')
|
||||
.word32lu('offsetToStartOfCentralDirectory')
|
||||
.word16lu('commentLength')
|
||||
.vars;
|
||||
|
||||
return self.pull(vars.commentLength).then(function(comment) {
|
||||
comment = comment.toString('utf8');
|
||||
self.end();
|
||||
self.push(null);
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
Parse.prototype.promise = function() {
|
||||
var self = this;
|
||||
return new Promise(function(resolve,reject) {
|
||||
self.on('finish',resolve);
|
||||
self.on('error',reject);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = Parse;
|
||||
13
doc/test-data/purchase_transaction/node_modules/unzipper/lib/parseDateTime.js
generated
vendored
Normal file
13
doc/test-data/purchase_transaction/node_modules/unzipper/lib/parseDateTime.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Dates in zip file entries are stored as DosDateTime
|
||||
// Spec is here: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime
|
||||
|
||||
module.exports = function parseDateTime(date, time) {
|
||||
const day = date & 0x1F;
|
||||
const month = date >> 5 & 0x0F;
|
||||
const year = (date >> 9 & 0x7F) + 1980;
|
||||
const seconds = time ? (time & 0x1F) * 2 : 0;
|
||||
const minutes = time ? (time >> 5) & 0x3F : 0;
|
||||
const hours = time ? (time >> 11): 0;
|
||||
|
||||
return new Date(Date.UTC(year, month-1, day, hours, minutes, seconds));
|
||||
};
|
||||
37
doc/test-data/purchase_transaction/node_modules/unzipper/lib/parseExtraField.js
generated
vendored
Normal file
37
doc/test-data/purchase_transaction/node_modules/unzipper/lib/parseExtraField.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var binary = require('binary');
|
||||
|
||||
module.exports = function(extraField, vars) {
|
||||
var extra;
|
||||
// Find the ZIP64 header, if present.
|
||||
while(!extra && extraField && extraField.length) {
|
||||
var candidateExtra = binary.parse(extraField)
|
||||
.word16lu('signature')
|
||||
.word16lu('partsize')
|
||||
.word64lu('uncompressedSize')
|
||||
.word64lu('compressedSize')
|
||||
.word64lu('offset')
|
||||
.word64lu('disknum')
|
||||
.vars;
|
||||
|
||||
if(candidateExtra.signature === 0x0001) {
|
||||
extra = candidateExtra;
|
||||
} else {
|
||||
// Advance the buffer to the next part.
|
||||
// The total size of this part is the 4 byte header + partsize.
|
||||
extraField = extraField.slice(candidateExtra.partsize + 4);
|
||||
}
|
||||
}
|
||||
|
||||
extra = extra || {};
|
||||
|
||||
if (vars.compressedSize === 0xffffffff)
|
||||
vars.compressedSize = extra.compressedSize;
|
||||
|
||||
if (vars.uncompressedSize === 0xffffffff)
|
||||
vars.uncompressedSize= extra.uncompressedSize;
|
||||
|
||||
if (vars.offsetToLocalFileHeader === 0xffffffff)
|
||||
vars.offsetToLocalFileHeader= extra.offset;
|
||||
|
||||
return extra;
|
||||
};
|
||||
58
doc/test-data/purchase_transaction/node_modules/unzipper/lib/parseOne.js
generated
vendored
Normal file
58
doc/test-data/purchase_transaction/node_modules/unzipper/lib/parseOne.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
var Stream = require('stream');
|
||||
var Parse = require('./parse');
|
||||
var duplexer2 = require('duplexer2');
|
||||
var BufferStream = require('./BufferStream');
|
||||
|
||||
// Backwards compatibility for node versions < 8
|
||||
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
||||
Stream = require('readable-stream');
|
||||
|
||||
function parseOne(match,opts) {
|
||||
var inStream = Stream.PassThrough({objectMode:true});
|
||||
var outStream = Stream.PassThrough();
|
||||
var transform = Stream.Transform({objectMode:true});
|
||||
var re = match instanceof RegExp ? match : (match && new RegExp(match));
|
||||
var found;
|
||||
|
||||
transform._transform = function(entry,e,cb) {
|
||||
if (found || (re && !re.exec(entry.path))) {
|
||||
entry.autodrain();
|
||||
return cb();
|
||||
} else {
|
||||
found = true;
|
||||
out.emit('entry',entry);
|
||||
entry.on('error',function(e) {
|
||||
outStream.emit('error',e);
|
||||
});
|
||||
entry.pipe(outStream)
|
||||
.on('error',function(err) {
|
||||
cb(err);
|
||||
})
|
||||
.on('finish',function(d) {
|
||||
cb(null,d);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
inStream.pipe(Parse(opts))
|
||||
.on('error',function(err) {
|
||||
outStream.emit('error',err);
|
||||
})
|
||||
.pipe(transform)
|
||||
.on('error',Object) // Silence error as its already addressed in transform
|
||||
.on('finish',function() {
|
||||
if (!found)
|
||||
outStream.emit('error',new Error('PATTERN_NOT_FOUND'));
|
||||
else
|
||||
outStream.end();
|
||||
});
|
||||
|
||||
var out = duplexer2(inStream,outStream);
|
||||
out.buffer = function() {
|
||||
return BufferStream(outStream);
|
||||
};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
module.exports = parseOne;
|
||||
34
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
34
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
before_install:
|
||||
- (test $NPM_LEGACY && npm install -g npm@2 && npm install -g npm@3) || true
|
||||
notifications:
|
||||
email: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- node_js: '0.8'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: '0.10'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: '0.11'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: '0.12'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 1
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 2
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 3
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 4
|
||||
- node_js: 5
|
||||
- node_js: 6
|
||||
- node_js: 7
|
||||
- node_js: 8
|
||||
- node_js: 9
|
||||
script: "npm run test"
|
||||
env:
|
||||
global:
|
||||
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
|
||||
- secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=
|
||||
38
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/CONTRIBUTING.md
generated
vendored
Normal file
38
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
* (a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
* (b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
* (c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
* (d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
## Moderation Policy
|
||||
|
||||
The [Node.js Moderation Policy] applies to this WG.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
The [Node.js Code of Conduct][] applies to this WG.
|
||||
|
||||
[Node.js Code of Conduct]:
|
||||
https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
|
||||
[Node.js Moderation Policy]:
|
||||
https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md
|
||||
136
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/GOVERNANCE.md
generated
vendored
Normal file
136
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/GOVERNANCE.md
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
### Streams Working Group
|
||||
|
||||
The Node.js Streams is jointly governed by a Working Group
|
||||
(WG)
|
||||
that is responsible for high-level guidance of the project.
|
||||
|
||||
The WG has final authority over this project including:
|
||||
|
||||
* Technical direction
|
||||
* Project governance and process (including this policy)
|
||||
* Contribution policy
|
||||
* GitHub repository hosting
|
||||
* Conduct guidelines
|
||||
* Maintaining the list of additional Collaborators
|
||||
|
||||
For the current list of WG members, see the project
|
||||
[README.md](./README.md#current-project-team-members).
|
||||
|
||||
### Collaborators
|
||||
|
||||
The readable-stream GitHub repository is
|
||||
maintained by the WG and additional Collaborators who are added by the
|
||||
WG on an ongoing basis.
|
||||
|
||||
Individuals making significant and valuable contributions are made
|
||||
Collaborators and given commit-access to the project. These
|
||||
individuals are identified by the WG and their addition as
|
||||
Collaborators is discussed during the WG meeting.
|
||||
|
||||
_Note:_ If you make a significant contribution and are not considered
|
||||
for commit-access log an issue or contact a WG member directly and it
|
||||
will be brought up in the next WG meeting.
|
||||
|
||||
Modifications of the contents of the readable-stream repository are
|
||||
made on
|
||||
a collaborative basis. Anybody with a GitHub account may propose a
|
||||
modification via pull request and it will be considered by the project
|
||||
Collaborators. All pull requests must be reviewed and accepted by a
|
||||
Collaborator with sufficient expertise who is able to take full
|
||||
responsibility for the change. In the case of pull requests proposed
|
||||
by an existing Collaborator, an additional Collaborator is required
|
||||
for sign-off. Consensus should be sought if additional Collaborators
|
||||
participate and there is disagreement around a particular
|
||||
modification. See _Consensus Seeking Process_ below for further detail
|
||||
on the consensus model used for governance.
|
||||
|
||||
Collaborators may opt to elevate significant or controversial
|
||||
modifications, or modifications that have not found consensus to the
|
||||
WG for discussion by assigning the ***WG-agenda*** tag to a pull
|
||||
request or issue. The WG should serve as the final arbiter where
|
||||
required.
|
||||
|
||||
For the current list of Collaborators, see the project
|
||||
[README.md](./README.md#members).
|
||||
|
||||
### WG Membership
|
||||
|
||||
WG seats are not time-limited. There is no fixed size of the WG.
|
||||
However, the expected target is between 6 and 12, to ensure adequate
|
||||
coverage of important areas of expertise, balanced with the ability to
|
||||
make decisions efficiently.
|
||||
|
||||
There is no specific set of requirements or qualifications for WG
|
||||
membership beyond these rules.
|
||||
|
||||
The WG may add additional members to the WG by unanimous consensus.
|
||||
|
||||
A WG member may be removed from the WG by voluntary resignation, or by
|
||||
unanimous consensus of all other WG members.
|
||||
|
||||
Changes to WG membership should be posted in the agenda, and may be
|
||||
suggested as any other agenda item (see "WG Meetings" below).
|
||||
|
||||
If an addition or removal is proposed during a meeting, and the full
|
||||
WG is not in attendance to participate, then the addition or removal
|
||||
is added to the agenda for the subsequent meeting. This is to ensure
|
||||
that all members are given the opportunity to participate in all
|
||||
membership decisions. If a WG member is unable to attend a meeting
|
||||
where a planned membership decision is being made, then their consent
|
||||
is assumed.
|
||||
|
||||
No more than 1/3 of the WG members may be affiliated with the same
|
||||
employer. If removal or resignation of a WG member, or a change of
|
||||
employment by a WG member, creates a situation where more than 1/3 of
|
||||
the WG membership shares an employer, then the situation must be
|
||||
immediately remedied by the resignation or removal of one or more WG
|
||||
members affiliated with the over-represented employer(s).
|
||||
|
||||
### WG Meetings
|
||||
|
||||
The WG meets occasionally on a Google Hangout On Air. A designated moderator
|
||||
approved by the WG runs the meeting. Each meeting should be
|
||||
published to YouTube.
|
||||
|
||||
Items are added to the WG agenda that are considered contentious or
|
||||
are modifications of governance, contribution policy, WG membership,
|
||||
or release process.
|
||||
|
||||
The intention of the agenda is not to approve or review all patches;
|
||||
that should happen continuously on GitHub and be handled by the larger
|
||||
group of Collaborators.
|
||||
|
||||
Any community member or contributor can ask that something be added to
|
||||
the next meeting's agenda by logging a GitHub Issue. Any Collaborator,
|
||||
WG member or the moderator can add the item to the agenda by adding
|
||||
the ***WG-agenda*** tag to the issue.
|
||||
|
||||
Prior to each WG meeting the moderator will share the Agenda with
|
||||
members of the WG. WG members can add any items they like to the
|
||||
agenda at the beginning of each meeting. The moderator and the WG
|
||||
cannot veto or remove items.
|
||||
|
||||
The WG may invite persons or representatives from certain projects to
|
||||
participate in a non-voting capacity.
|
||||
|
||||
The moderator is responsible for summarizing the discussion of each
|
||||
agenda item and sends it as a pull request after the meeting.
|
||||
|
||||
### Consensus Seeking Process
|
||||
|
||||
The WG follows a
|
||||
[Consensus
|
||||
Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making)
|
||||
decision-making model.
|
||||
|
||||
When an agenda item has appeared to reach a consensus the moderator
|
||||
will ask "Does anyone object?" as a final call for dissent from the
|
||||
consensus.
|
||||
|
||||
If an agenda item cannot reach a consensus a WG member can call for
|
||||
either a closing vote or a vote to table the issue to the next
|
||||
meeting. The call for a vote must be seconded by a majority of the WG
|
||||
or else the discussion will continue. Simple majority wins.
|
||||
|
||||
Note that changes to WG membership require a majority consensus. See
|
||||
"WG Membership" above.
|
||||
47
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
47
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
Node.js is licensed for use as follows:
|
||||
|
||||
"""
|
||||
Copyright Node.js contributors. All rights reserved.
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
This license applies to parts of Node.js originating from the
|
||||
https://github.com/joyent/node repository:
|
||||
|
||||
"""
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
||||
"""
|
||||
58
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/README.md
generated
vendored
Normal file
58
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/README.md
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# readable-stream
|
||||
|
||||
***Node-core v8.17.0 streams for userland*** [](https://travis-ci.org/nodejs/readable-stream)
|
||||
|
||||
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
|
||||
|
||||
[](https://saucelabs.com/u/readable-stream)
|
||||
|
||||
```bash
|
||||
npm install --save readable-stream
|
||||
```
|
||||
|
||||
***Node-core streams for userland***
|
||||
|
||||
This package is a mirror of the Streams2 and Streams3 implementations in
|
||||
Node-core.
|
||||
|
||||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.17.0/docs/api/stream.html).
|
||||
|
||||
If you want to guarantee a stable streams base, regardless of what version of
|
||||
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
|
||||
|
||||
As of version 2.0.0 **readable-stream** uses semantic versioning.
|
||||
|
||||
# Streams Working Group
|
||||
|
||||
`readable-stream` is maintained by the Streams Working Group, which
|
||||
oversees the development and maintenance of the Streams API within
|
||||
Node.js. The responsibilities of the Streams Working Group include:
|
||||
|
||||
* Addressing stream issues on the Node.js issue tracker.
|
||||
* Authoring and editing stream documentation within the Node.js project.
|
||||
* Reviewing changes to stream subclasses within the Node.js project.
|
||||
* Redirecting changes to streams from the Node.js project to this
|
||||
project.
|
||||
* Assisting in the implementation of stream providers within Node.js.
|
||||
* Recommending versions of `readable-stream` to be included in Node.js.
|
||||
* Messaging about the future of streams to give the community advance
|
||||
notice of changes.
|
||||
|
||||
<a name="members"></a>
|
||||
## Team Members
|
||||
|
||||
* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com>
|
||||
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
|
||||
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com>
|
||||
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
|
||||
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) <rod@vagg.org>
|
||||
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
|
||||
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com>
|
||||
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com>
|
||||
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me>
|
||||
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <matteo.collina@gmail.com>
|
||||
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
|
||||
* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) <shestak.irina@gmail.com>
|
||||
60
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
60
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# streams WG Meeting 2015-01-30
|
||||
|
||||
## Links
|
||||
|
||||
* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
|
||||
* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
|
||||
* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
|
||||
|
||||
## Agenda
|
||||
|
||||
Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
|
||||
|
||||
* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
|
||||
* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
|
||||
* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
|
||||
* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
|
||||
|
||||
## Minutes
|
||||
|
||||
### adopt a charter
|
||||
|
||||
* group: +1's all around
|
||||
|
||||
### What versioning scheme should be adopted?
|
||||
* group: +1’s 3.0.0
|
||||
* domenic+group: pulling in patches from other sources where appropriate
|
||||
* mikeal: version independently, suggesting versions for io.js
|
||||
* mikeal+domenic: work with TC to notify in advance of changes
|
||||
simpler stream creation
|
||||
|
||||
### streamline creation of streams
|
||||
* sam: streamline creation of streams
|
||||
* domenic: nice simple solution posted
|
||||
but, we lose the opportunity to change the model
|
||||
may not be backwards incompatible (double check keys)
|
||||
|
||||
**action item:** domenic will check
|
||||
|
||||
### remove implicit flowing of streams on(‘data’)
|
||||
* add isFlowing / isPaused
|
||||
* mikeal: worrying that we’re documenting polyfill methods – confuses users
|
||||
* domenic: more reflective API is probably good, with warning labels for users
|
||||
* new section for mad scientists (reflective stream access)
|
||||
* calvin: name the “third state”
|
||||
* mikeal: maybe borrow the name from whatwg?
|
||||
* domenic: we’re missing the “third state”
|
||||
* consensus: kind of difficult to name the third state
|
||||
* mikeal: figure out differences in states / compat
|
||||
* mathias: always flow on data – eliminates third state
|
||||
* explore what it breaks
|
||||
|
||||
**action items:**
|
||||
* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
|
||||
* ask rod/build for infrastructure
|
||||
* **chris**: explore the “flow on data” approach
|
||||
* add isPaused/isFlowing
|
||||
* add new docs section
|
||||
* move isPaused to that section
|
||||
|
||||
|
||||
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/duplex-browser.js
generated
vendored
Normal file
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/duplex-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/_stream_duplex.js');
|
||||
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./readable').Duplex
|
||||
131
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
131
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// a duplex stream is just a stream that is both readable and writable.
|
||||
// Since JS doesn't have multiple prototypal inheritance, this class
|
||||
// prototypally inherits from Readable, and then parasitically from
|
||||
// Writable.
|
||||
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var pna = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var objectKeys = Object.keys || function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) {
|
||||
keys.push(key);
|
||||
}return keys;
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
module.exports = Duplex;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var Readable = require('./_stream_readable');
|
||||
var Writable = require('./_stream_writable');
|
||||
|
||||
util.inherits(Duplex, Readable);
|
||||
|
||||
{
|
||||
// avoid scope creep, the keys array can then be collected
|
||||
var keys = objectKeys(Writable.prototype);
|
||||
for (var v = 0; v < keys.length; v++) {
|
||||
var method = keys[v];
|
||||
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
||||
}
|
||||
}
|
||||
|
||||
function Duplex(options) {
|
||||
if (!(this instanceof Duplex)) return new Duplex(options);
|
||||
|
||||
Readable.call(this, options);
|
||||
Writable.call(this, options);
|
||||
|
||||
if (options && options.readable === false) this.readable = false;
|
||||
|
||||
if (options && options.writable === false) this.writable = false;
|
||||
|
||||
this.allowHalfOpen = true;
|
||||
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
||||
|
||||
this.once('end', onend);
|
||||
}
|
||||
|
||||
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
||||
// making it explicit this property is not enumerable
|
||||
// because otherwise some prototype manipulation in
|
||||
// userland will fail
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
return this._writableState.highWaterMark;
|
||||
}
|
||||
});
|
||||
|
||||
// the no-half-open enforcer
|
||||
function onend() {
|
||||
// if we allow half-open state, or if the writable side ended,
|
||||
// then we're ok.
|
||||
if (this.allowHalfOpen || this._writableState.ended) return;
|
||||
|
||||
// no more data can be written.
|
||||
// But allow more writes to happen in this tick.
|
||||
pna.nextTick(onEndNT, this);
|
||||
}
|
||||
|
||||
function onEndNT(self) {
|
||||
self.end();
|
||||
}
|
||||
|
||||
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
||||
get: function () {
|
||||
if (this._readableState === undefined || this._writableState === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this._readableState.destroyed && this._writableState.destroyed;
|
||||
},
|
||||
set: function (value) {
|
||||
// we ignore the value if the stream
|
||||
// has not been initialized yet
|
||||
if (this._readableState === undefined || this._writableState === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
// backward compatibility, the user is explicitly
|
||||
// managing destroyed
|
||||
this._readableState.destroyed = value;
|
||||
this._writableState.destroyed = value;
|
||||
}
|
||||
});
|
||||
|
||||
Duplex.prototype._destroy = function (err, cb) {
|
||||
this.push(null);
|
||||
this.end();
|
||||
|
||||
pna.nextTick(cb, err);
|
||||
};
|
||||
47
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
47
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// a passthrough stream.
|
||||
// basically just the most minimal sort of Transform stream.
|
||||
// Every written chunk gets output as-is.
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = PassThrough;
|
||||
|
||||
var Transform = require('./_stream_transform');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(PassThrough, Transform);
|
||||
|
||||
function PassThrough(options) {
|
||||
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
||||
|
||||
Transform.call(this, options);
|
||||
}
|
||||
|
||||
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
||||
cb(null, chunk);
|
||||
};
|
||||
1019
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
1019
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
214
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
214
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// a transform stream is a readable/writable stream where you do
|
||||
// something with the data. Sometimes it's called a "filter",
|
||||
// but that's not a great name for it, since that implies a thing where
|
||||
// some bits pass through, and others are simply ignored. (That would
|
||||
// be a valid example of a transform, of course.)
|
||||
//
|
||||
// While the output is causally related to the input, it's not a
|
||||
// necessarily symmetric or synchronous transformation. For example,
|
||||
// a zlib stream might take multiple plain-text writes(), and then
|
||||
// emit a single compressed chunk some time in the future.
|
||||
//
|
||||
// Here's how this works:
|
||||
//
|
||||
// The Transform stream has all the aspects of the readable and writable
|
||||
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
||||
// internally, and returns false if there's a lot of pending writes
|
||||
// buffered up. When you call read(), that calls _read(n) until
|
||||
// there's enough pending readable data buffered up.
|
||||
//
|
||||
// In a transform stream, the written data is placed in a buffer. When
|
||||
// _read(n) is called, it transforms the queued up data, calling the
|
||||
// buffered _write cb's as it consumes chunks. If consuming a single
|
||||
// written chunk would result in multiple output chunks, then the first
|
||||
// outputted bit calls the readcb, and subsequent chunks just go into
|
||||
// the read buffer, and will cause it to emit 'readable' if necessary.
|
||||
//
|
||||
// This way, back-pressure is actually determined by the reading side,
|
||||
// since _read has to be called to start processing a new chunk. However,
|
||||
// a pathological inflate type of transform can cause excessive buffering
|
||||
// here. For example, imagine a stream where every byte of input is
|
||||
// interpreted as an integer from 0-255, and then results in that many
|
||||
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
||||
// 1kb of data being output. In this case, you could write a very small
|
||||
// amount of input, and end up with a very large amount of output. In
|
||||
// such a pathological inflating mechanism, there'd be no way to tell
|
||||
// the system to stop doing the transform. A single 4MB write could
|
||||
// cause the system to run out of memory.
|
||||
//
|
||||
// However, even in such a pathological case, only a single written chunk
|
||||
// would be consumed, and then the rest would wait (un-transformed) until
|
||||
// the results of the previous transformed chunk were consumed.
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = Transform;
|
||||
|
||||
var Duplex = require('./_stream_duplex');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(Transform, Duplex);
|
||||
|
||||
function afterTransform(er, data) {
|
||||
var ts = this._transformState;
|
||||
ts.transforming = false;
|
||||
|
||||
var cb = ts.writecb;
|
||||
|
||||
if (!cb) {
|
||||
return this.emit('error', new Error('write callback called multiple times'));
|
||||
}
|
||||
|
||||
ts.writechunk = null;
|
||||
ts.writecb = null;
|
||||
|
||||
if (data != null) // single equals check for both `null` and `undefined`
|
||||
this.push(data);
|
||||
|
||||
cb(er);
|
||||
|
||||
var rs = this._readableState;
|
||||
rs.reading = false;
|
||||
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
||||
this._read(rs.highWaterMark);
|
||||
}
|
||||
}
|
||||
|
||||
function Transform(options) {
|
||||
if (!(this instanceof Transform)) return new Transform(options);
|
||||
|
||||
Duplex.call(this, options);
|
||||
|
||||
this._transformState = {
|
||||
afterTransform: afterTransform.bind(this),
|
||||
needTransform: false,
|
||||
transforming: false,
|
||||
writecb: null,
|
||||
writechunk: null,
|
||||
writeencoding: null
|
||||
};
|
||||
|
||||
// start out asking for a readable event once data is transformed.
|
||||
this._readableState.needReadable = true;
|
||||
|
||||
// we have implemented the _read method, and done the other things
|
||||
// that Readable wants before the first _read call, so unset the
|
||||
// sync guard flag.
|
||||
this._readableState.sync = false;
|
||||
|
||||
if (options) {
|
||||
if (typeof options.transform === 'function') this._transform = options.transform;
|
||||
|
||||
if (typeof options.flush === 'function') this._flush = options.flush;
|
||||
}
|
||||
|
||||
// When the writable side finishes, then flush out anything remaining.
|
||||
this.on('prefinish', prefinish);
|
||||
}
|
||||
|
||||
function prefinish() {
|
||||
var _this = this;
|
||||
|
||||
if (typeof this._flush === 'function') {
|
||||
this._flush(function (er, data) {
|
||||
done(_this, er, data);
|
||||
});
|
||||
} else {
|
||||
done(this, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
Transform.prototype.push = function (chunk, encoding) {
|
||||
this._transformState.needTransform = false;
|
||||
return Duplex.prototype.push.call(this, chunk, encoding);
|
||||
};
|
||||
|
||||
// This is the part where you do stuff!
|
||||
// override this function in implementation classes.
|
||||
// 'chunk' is an input chunk.
|
||||
//
|
||||
// Call `push(newChunk)` to pass along transformed output
|
||||
// to the readable side. You may call 'push' zero or more times.
|
||||
//
|
||||
// Call `cb(err)` when you are done with this chunk. If you pass
|
||||
// an error, then that'll put the hurt on the whole operation. If you
|
||||
// never call cb(), then you'll never get another chunk.
|
||||
Transform.prototype._transform = function (chunk, encoding, cb) {
|
||||
throw new Error('_transform() is not implemented');
|
||||
};
|
||||
|
||||
Transform.prototype._write = function (chunk, encoding, cb) {
|
||||
var ts = this._transformState;
|
||||
ts.writecb = cb;
|
||||
ts.writechunk = chunk;
|
||||
ts.writeencoding = encoding;
|
||||
if (!ts.transforming) {
|
||||
var rs = this._readableState;
|
||||
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
||||
}
|
||||
};
|
||||
|
||||
// Doesn't matter what the args are here.
|
||||
// _transform does all the work.
|
||||
// That we got here means that the readable side wants more data.
|
||||
Transform.prototype._read = function (n) {
|
||||
var ts = this._transformState;
|
||||
|
||||
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
||||
ts.transforming = true;
|
||||
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
||||
} else {
|
||||
// mark that we need a transform, so that any data that comes in
|
||||
// will get processed, now that we've asked for it.
|
||||
ts.needTransform = true;
|
||||
}
|
||||
};
|
||||
|
||||
Transform.prototype._destroy = function (err, cb) {
|
||||
var _this2 = this;
|
||||
|
||||
Duplex.prototype._destroy.call(this, err, function (err2) {
|
||||
cb(err2);
|
||||
_this2.emit('close');
|
||||
});
|
||||
};
|
||||
|
||||
function done(stream, er, data) {
|
||||
if (er) return stream.emit('error', er);
|
||||
|
||||
if (data != null) // single equals check for both `null` and `undefined`
|
||||
stream.push(data);
|
||||
|
||||
// if there's nothing in the write buffer, then that means
|
||||
// that nothing more will ever be provided
|
||||
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
|
||||
|
||||
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
|
||||
|
||||
return stream.push(null);
|
||||
}
|
||||
685
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
685
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
@@ -0,0 +1,685 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// A bit simpler than readable streams.
|
||||
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
|
||||
// the drain event emission and buffering.
|
||||
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var pna = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
module.exports = Writable;
|
||||
|
||||
/* <replacement> */
|
||||
function WriteReq(chunk, encoding, cb) {
|
||||
this.chunk = chunk;
|
||||
this.encoding = encoding;
|
||||
this.callback = cb;
|
||||
this.next = null;
|
||||
}
|
||||
|
||||
// It seems a linked list but it is not
|
||||
// there will be only 2 of these for each stream
|
||||
function CorkedRequest(state) {
|
||||
var _this = this;
|
||||
|
||||
this.next = null;
|
||||
this.entry = null;
|
||||
this.finish = function () {
|
||||
onCorkedFinish(_this, state);
|
||||
};
|
||||
}
|
||||
/* </replacement> */
|
||||
|
||||
/*<replacement>*/
|
||||
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Duplex;
|
||||
/*</replacement>*/
|
||||
|
||||
Writable.WritableState = WritableState;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var internalUtil = {
|
||||
deprecate: require('util-deprecate')
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Stream = require('./internal/streams/stream');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
||||
function _uint8ArrayToBuffer(chunk) {
|
||||
return Buffer.from(chunk);
|
||||
}
|
||||
function _isUint8Array(obj) {
|
||||
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
||||
}
|
||||
|
||||
/*</replacement>*/
|
||||
|
||||
var destroyImpl = require('./internal/streams/destroy');
|
||||
|
||||
util.inherits(Writable, Stream);
|
||||
|
||||
function nop() {}
|
||||
|
||||
function WritableState(options, stream) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Duplex streams are both readable and writable, but share
|
||||
// the same options object.
|
||||
// However, some cases require setting options to different
|
||||
// values for the readable and the writable sides of the duplex stream.
|
||||
// These options can be provided separately as readableXXX and writableXXX.
|
||||
var isDuplex = stream instanceof Duplex;
|
||||
|
||||
// object stream flag to indicate whether or not this stream
|
||||
// contains buffers or objects.
|
||||
this.objectMode = !!options.objectMode;
|
||||
|
||||
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
||||
|
||||
// the point at which write() starts returning false
|
||||
// Note: 0 is a valid value, means that we always return false if
|
||||
// the entire buffer is not flushed immediately on write()
|
||||
var hwm = options.highWaterMark;
|
||||
var writableHwm = options.writableHighWaterMark;
|
||||
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
||||
|
||||
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = Math.floor(this.highWaterMark);
|
||||
|
||||
// if _final has been called
|
||||
this.finalCalled = false;
|
||||
|
||||
// drain event flag.
|
||||
this.needDrain = false;
|
||||
// at the start of calling end()
|
||||
this.ending = false;
|
||||
// when end() has been called, and returned
|
||||
this.ended = false;
|
||||
// when 'finish' is emitted
|
||||
this.finished = false;
|
||||
|
||||
// has it been destroyed
|
||||
this.destroyed = false;
|
||||
|
||||
// should we decode strings into buffers before passing to _write?
|
||||
// this is here so that some node-core streams can optimize string
|
||||
// handling at a lower level.
|
||||
var noDecode = options.decodeStrings === false;
|
||||
this.decodeStrings = !noDecode;
|
||||
|
||||
// Crypto is kind of old and crusty. Historically, its default string
|
||||
// encoding is 'binary' so we have to make this configurable.
|
||||
// Everything else in the universe uses 'utf8', though.
|
||||
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
||||
|
||||
// not an actual buffer we keep track of, but a measurement
|
||||
// of how much we're waiting to get pushed to some underlying
|
||||
// socket or file.
|
||||
this.length = 0;
|
||||
|
||||
// a flag to see when we're in the middle of a write.
|
||||
this.writing = false;
|
||||
|
||||
// when true all writes will be buffered until .uncork() call
|
||||
this.corked = 0;
|
||||
|
||||
// a flag to be able to tell if the onwrite cb is called immediately,
|
||||
// or on a later tick. We set this to true at first, because any
|
||||
// actions that shouldn't happen until "later" should generally also
|
||||
// not happen before the first write call.
|
||||
this.sync = true;
|
||||
|
||||
// a flag to know if we're processing previously buffered items, which
|
||||
// may call the _write() callback in the same tick, so that we don't
|
||||
// end up in an overlapped onwrite situation.
|
||||
this.bufferProcessing = false;
|
||||
|
||||
// the callback that's passed to _write(chunk,cb)
|
||||
this.onwrite = function (er) {
|
||||
onwrite(stream, er);
|
||||
};
|
||||
|
||||
// the callback that the user supplies to write(chunk,encoding,cb)
|
||||
this.writecb = null;
|
||||
|
||||
// the amount that is being written when _write is called.
|
||||
this.writelen = 0;
|
||||
|
||||
this.bufferedRequest = null;
|
||||
this.lastBufferedRequest = null;
|
||||
|
||||
// number of pending user-supplied write callbacks
|
||||
// this must be 0 before 'finish' can be emitted
|
||||
this.pendingcb = 0;
|
||||
|
||||
// emit prefinish if the only thing we're waiting for is _write cbs
|
||||
// This is relevant for synchronous Transform streams
|
||||
this.prefinished = false;
|
||||
|
||||
// True if the error was already emitted and should not be thrown again
|
||||
this.errorEmitted = false;
|
||||
|
||||
// count buffered requests
|
||||
this.bufferedRequestCount = 0;
|
||||
|
||||
// allocate the first CorkedRequest, there is always
|
||||
// one allocated and free to use, and we maintain at most two
|
||||
this.corkedRequestsFree = new CorkedRequest(this);
|
||||
}
|
||||
|
||||
WritableState.prototype.getBuffer = function getBuffer() {
|
||||
var current = this.bufferedRequest;
|
||||
var out = [];
|
||||
while (current) {
|
||||
out.push(current);
|
||||
current = current.next;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
(function () {
|
||||
try {
|
||||
Object.defineProperty(WritableState.prototype, 'buffer', {
|
||||
get: internalUtil.deprecate(function () {
|
||||
return this.getBuffer();
|
||||
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
||||
});
|
||||
} catch (_) {}
|
||||
})();
|
||||
|
||||
// Test _writableState for inheritance to account for Duplex streams,
|
||||
// whose prototype chain only points to Readable.
|
||||
var realHasInstance;
|
||||
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
||||
realHasInstance = Function.prototype[Symbol.hasInstance];
|
||||
Object.defineProperty(Writable, Symbol.hasInstance, {
|
||||
value: function (object) {
|
||||
if (realHasInstance.call(this, object)) return true;
|
||||
if (this !== Writable) return false;
|
||||
|
||||
return object && object._writableState instanceof WritableState;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
realHasInstance = function (object) {
|
||||
return object instanceof this;
|
||||
};
|
||||
}
|
||||
|
||||
function Writable(options) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
// Writable ctor is applied to Duplexes, too.
|
||||
// `realHasInstance` is necessary because using plain `instanceof`
|
||||
// would return false, as no `_writableState` property is attached.
|
||||
|
||||
// Trying to use the custom `instanceof` for Writable here will also break the
|
||||
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
||||
// `_writableState` that would lead to infinite recursion.
|
||||
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
||||
return new Writable(options);
|
||||
}
|
||||
|
||||
this._writableState = new WritableState(options, this);
|
||||
|
||||
// legacy.
|
||||
this.writable = true;
|
||||
|
||||
if (options) {
|
||||
if (typeof options.write === 'function') this._write = options.write;
|
||||
|
||||
if (typeof options.writev === 'function') this._writev = options.writev;
|
||||
|
||||
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
||||
|
||||
if (typeof options.final === 'function') this._final = options.final;
|
||||
}
|
||||
|
||||
Stream.call(this);
|
||||
}
|
||||
|
||||
// Otherwise people can pipe Writable streams, which is just wrong.
|
||||
Writable.prototype.pipe = function () {
|
||||
this.emit('error', new Error('Cannot pipe, not readable'));
|
||||
};
|
||||
|
||||
function writeAfterEnd(stream, cb) {
|
||||
var er = new Error('write after end');
|
||||
// TODO: defer error events consistently everywhere, not just the cb
|
||||
stream.emit('error', er);
|
||||
pna.nextTick(cb, er);
|
||||
}
|
||||
|
||||
// Checks that a user-supplied chunk is valid, especially for the particular
|
||||
// mode the stream is in. Currently this means that `null` is never accepted
|
||||
// and undefined/non-string values are only allowed in object mode.
|
||||
function validChunk(stream, state, chunk, cb) {
|
||||
var valid = true;
|
||||
var er = false;
|
||||
|
||||
if (chunk === null) {
|
||||
er = new TypeError('May not write null values to stream');
|
||||
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
||||
er = new TypeError('Invalid non-string/buffer chunk');
|
||||
}
|
||||
if (er) {
|
||||
stream.emit('error', er);
|
||||
pna.nextTick(cb, er);
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
Writable.prototype.write = function (chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
var ret = false;
|
||||
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
||||
|
||||
if (isBuf && !Buffer.isBuffer(chunk)) {
|
||||
chunk = _uint8ArrayToBuffer(chunk);
|
||||
}
|
||||
|
||||
if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
||||
|
||||
if (typeof cb !== 'function') cb = nop;
|
||||
|
||||
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
||||
state.pendingcb++;
|
||||
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
Writable.prototype.cork = function () {
|
||||
var state = this._writableState;
|
||||
|
||||
state.corked++;
|
||||
};
|
||||
|
||||
Writable.prototype.uncork = function () {
|
||||
var state = this._writableState;
|
||||
|
||||
if (state.corked) {
|
||||
state.corked--;
|
||||
|
||||
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
||||
}
|
||||
};
|
||||
|
||||
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
||||
// node::ParseEncoding() requires lower case.
|
||||
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
||||
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
|
||||
this._writableState.defaultEncoding = encoding;
|
||||
return this;
|
||||
};
|
||||
|
||||
function decodeChunk(state, chunk, encoding) {
|
||||
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
||||
chunk = Buffer.from(chunk, encoding);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
||||
// making it explicit this property is not enumerable
|
||||
// because otherwise some prototype manipulation in
|
||||
// userland will fail
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
return this._writableState.highWaterMark;
|
||||
}
|
||||
});
|
||||
|
||||
// if we're already writing something, then just put this
|
||||
// in the queue, and wait our turn. Otherwise, call _write
|
||||
// If we return false, then we need a drain event, so set that flag.
|
||||
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
||||
if (!isBuf) {
|
||||
var newChunk = decodeChunk(state, chunk, encoding);
|
||||
if (chunk !== newChunk) {
|
||||
isBuf = true;
|
||||
encoding = 'buffer';
|
||||
chunk = newChunk;
|
||||
}
|
||||
}
|
||||
var len = state.objectMode ? 1 : chunk.length;
|
||||
|
||||
state.length += len;
|
||||
|
||||
var ret = state.length < state.highWaterMark;
|
||||
// we must ensure that previous needDrain will not be reset to false.
|
||||
if (!ret) state.needDrain = true;
|
||||
|
||||
if (state.writing || state.corked) {
|
||||
var last = state.lastBufferedRequest;
|
||||
state.lastBufferedRequest = {
|
||||
chunk: chunk,
|
||||
encoding: encoding,
|
||||
isBuf: isBuf,
|
||||
callback: cb,
|
||||
next: null
|
||||
};
|
||||
if (last) {
|
||||
last.next = state.lastBufferedRequest;
|
||||
} else {
|
||||
state.bufferedRequest = state.lastBufferedRequest;
|
||||
}
|
||||
state.bufferedRequestCount += 1;
|
||||
} else {
|
||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
||||
state.writelen = len;
|
||||
state.writecb = cb;
|
||||
state.writing = true;
|
||||
state.sync = true;
|
||||
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
||||
state.sync = false;
|
||||
}
|
||||
|
||||
function onwriteError(stream, state, sync, er, cb) {
|
||||
--state.pendingcb;
|
||||
|
||||
if (sync) {
|
||||
// defer the callback if we are being called synchronously
|
||||
// to avoid piling up things on the stack
|
||||
pna.nextTick(cb, er);
|
||||
// this can emit finish, and it will always happen
|
||||
// after error
|
||||
pna.nextTick(finishMaybe, stream, state);
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
} else {
|
||||
// the caller expect this to happen before if
|
||||
// it is async
|
||||
cb(er);
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
// this can emit finish, but finish must
|
||||
// always follow error
|
||||
finishMaybe(stream, state);
|
||||
}
|
||||
}
|
||||
|
||||
function onwriteStateUpdate(state) {
|
||||
state.writing = false;
|
||||
state.writecb = null;
|
||||
state.length -= state.writelen;
|
||||
state.writelen = 0;
|
||||
}
|
||||
|
||||
function onwrite(stream, er) {
|
||||
var state = stream._writableState;
|
||||
var sync = state.sync;
|
||||
var cb = state.writecb;
|
||||
|
||||
onwriteStateUpdate(state);
|
||||
|
||||
if (er) onwriteError(stream, state, sync, er, cb);else {
|
||||
// Check if we're actually ready to finish, but don't emit yet
|
||||
var finished = needFinish(state);
|
||||
|
||||
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
||||
clearBuffer(stream, state);
|
||||
}
|
||||
|
||||
if (sync) {
|
||||
/*<replacement>*/
|
||||
asyncWrite(afterWrite, stream, state, finished, cb);
|
||||
/*</replacement>*/
|
||||
} else {
|
||||
afterWrite(stream, state, finished, cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function afterWrite(stream, state, finished, cb) {
|
||||
if (!finished) onwriteDrain(stream, state);
|
||||
state.pendingcb--;
|
||||
cb();
|
||||
finishMaybe(stream, state);
|
||||
}
|
||||
|
||||
// Must force callback to be called on nextTick, so that we don't
|
||||
// emit 'drain' before the write() consumer gets the 'false' return
|
||||
// value, and has a chance to attach a 'drain' listener.
|
||||
function onwriteDrain(stream, state) {
|
||||
if (state.length === 0 && state.needDrain) {
|
||||
state.needDrain = false;
|
||||
stream.emit('drain');
|
||||
}
|
||||
}
|
||||
|
||||
// if there's something in the buffer waiting, then process it
|
||||
function clearBuffer(stream, state) {
|
||||
state.bufferProcessing = true;
|
||||
var entry = state.bufferedRequest;
|
||||
|
||||
if (stream._writev && entry && entry.next) {
|
||||
// Fast case, write everything using _writev()
|
||||
var l = state.bufferedRequestCount;
|
||||
var buffer = new Array(l);
|
||||
var holder = state.corkedRequestsFree;
|
||||
holder.entry = entry;
|
||||
|
||||
var count = 0;
|
||||
var allBuffers = true;
|
||||
while (entry) {
|
||||
buffer[count] = entry;
|
||||
if (!entry.isBuf) allBuffers = false;
|
||||
entry = entry.next;
|
||||
count += 1;
|
||||
}
|
||||
buffer.allBuffers = allBuffers;
|
||||
|
||||
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
||||
|
||||
// doWrite is almost always async, defer these to save a bit of time
|
||||
// as the hot path ends with doWrite
|
||||
state.pendingcb++;
|
||||
state.lastBufferedRequest = null;
|
||||
if (holder.next) {
|
||||
state.corkedRequestsFree = holder.next;
|
||||
holder.next = null;
|
||||
} else {
|
||||
state.corkedRequestsFree = new CorkedRequest(state);
|
||||
}
|
||||
state.bufferedRequestCount = 0;
|
||||
} else {
|
||||
// Slow case, write chunks one-by-one
|
||||
while (entry) {
|
||||
var chunk = entry.chunk;
|
||||
var encoding = entry.encoding;
|
||||
var cb = entry.callback;
|
||||
var len = state.objectMode ? 1 : chunk.length;
|
||||
|
||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||
entry = entry.next;
|
||||
state.bufferedRequestCount--;
|
||||
// if we didn't call the onwrite immediately, then
|
||||
// it means that we need to wait until it does.
|
||||
// also, that means that the chunk and cb are currently
|
||||
// being processed, so move the buffer counter past them.
|
||||
if (state.writing) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (entry === null) state.lastBufferedRequest = null;
|
||||
}
|
||||
|
||||
state.bufferedRequest = entry;
|
||||
state.bufferProcessing = false;
|
||||
}
|
||||
|
||||
Writable.prototype._write = function (chunk, encoding, cb) {
|
||||
cb(new Error('_write() is not implemented'));
|
||||
};
|
||||
|
||||
Writable.prototype._writev = null;
|
||||
|
||||
Writable.prototype.end = function (chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
|
||||
if (typeof chunk === 'function') {
|
||||
cb = chunk;
|
||||
chunk = null;
|
||||
encoding = null;
|
||||
} else if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
||||
|
||||
// .end() fully uncorks
|
||||
if (state.corked) {
|
||||
state.corked = 1;
|
||||
this.uncork();
|
||||
}
|
||||
|
||||
// ignore unnecessary end() calls.
|
||||
if (!state.ending) endWritable(this, state, cb);
|
||||
};
|
||||
|
||||
function needFinish(state) {
|
||||
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
||||
}
|
||||
function callFinal(stream, state) {
|
||||
stream._final(function (err) {
|
||||
state.pendingcb--;
|
||||
if (err) {
|
||||
stream.emit('error', err);
|
||||
}
|
||||
state.prefinished = true;
|
||||
stream.emit('prefinish');
|
||||
finishMaybe(stream, state);
|
||||
});
|
||||
}
|
||||
function prefinish(stream, state) {
|
||||
if (!state.prefinished && !state.finalCalled) {
|
||||
if (typeof stream._final === 'function') {
|
||||
state.pendingcb++;
|
||||
state.finalCalled = true;
|
||||
pna.nextTick(callFinal, stream, state);
|
||||
} else {
|
||||
state.prefinished = true;
|
||||
stream.emit('prefinish');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function finishMaybe(stream, state) {
|
||||
var need = needFinish(state);
|
||||
if (need) {
|
||||
prefinish(stream, state);
|
||||
if (state.pendingcb === 0) {
|
||||
state.finished = true;
|
||||
stream.emit('finish');
|
||||
}
|
||||
}
|
||||
return need;
|
||||
}
|
||||
|
||||
function endWritable(stream, state, cb) {
|
||||
state.ending = true;
|
||||
finishMaybe(stream, state);
|
||||
if (cb) {
|
||||
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
|
||||
}
|
||||
state.ended = true;
|
||||
stream.writable = false;
|
||||
}
|
||||
|
||||
function onCorkedFinish(corkReq, state, err) {
|
||||
var entry = corkReq.entry;
|
||||
corkReq.entry = null;
|
||||
while (entry) {
|
||||
var cb = entry.callback;
|
||||
state.pendingcb--;
|
||||
cb(err);
|
||||
entry = entry.next;
|
||||
}
|
||||
|
||||
// reuse the free corkReq.
|
||||
state.corkedRequestsFree.next = corkReq;
|
||||
}
|
||||
|
||||
Object.defineProperty(Writable.prototype, 'destroyed', {
|
||||
get: function () {
|
||||
if (this._writableState === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this._writableState.destroyed;
|
||||
},
|
||||
set: function (value) {
|
||||
// we ignore the value if the stream
|
||||
// has not been initialized yet
|
||||
if (!this._writableState) {
|
||||
return;
|
||||
}
|
||||
|
||||
// backward compatibility, the user is explicitly
|
||||
// managing destroyed
|
||||
this._writableState.destroyed = value;
|
||||
}
|
||||
});
|
||||
|
||||
Writable.prototype.destroy = destroyImpl.destroy;
|
||||
Writable.prototype._undestroy = destroyImpl.undestroy;
|
||||
Writable.prototype._destroy = function (err, cb) {
|
||||
this.end();
|
||||
cb(err);
|
||||
};
|
||||
78
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
Normal file
78
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
'use strict';
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var util = require('util');
|
||||
|
||||
function copyBuffer(src, target, offset) {
|
||||
src.copy(target, offset);
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
function BufferList() {
|
||||
_classCallCheck(this, BufferList);
|
||||
|
||||
this.head = null;
|
||||
this.tail = null;
|
||||
this.length = 0;
|
||||
}
|
||||
|
||||
BufferList.prototype.push = function push(v) {
|
||||
var entry = { data: v, next: null };
|
||||
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
||||
this.tail = entry;
|
||||
++this.length;
|
||||
};
|
||||
|
||||
BufferList.prototype.unshift = function unshift(v) {
|
||||
var entry = { data: v, next: this.head };
|
||||
if (this.length === 0) this.tail = entry;
|
||||
this.head = entry;
|
||||
++this.length;
|
||||
};
|
||||
|
||||
BufferList.prototype.shift = function shift() {
|
||||
if (this.length === 0) return;
|
||||
var ret = this.head.data;
|
||||
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
||||
--this.length;
|
||||
return ret;
|
||||
};
|
||||
|
||||
BufferList.prototype.clear = function clear() {
|
||||
this.head = this.tail = null;
|
||||
this.length = 0;
|
||||
};
|
||||
|
||||
BufferList.prototype.join = function join(s) {
|
||||
if (this.length === 0) return '';
|
||||
var p = this.head;
|
||||
var ret = '' + p.data;
|
||||
while (p = p.next) {
|
||||
ret += s + p.data;
|
||||
}return ret;
|
||||
};
|
||||
|
||||
BufferList.prototype.concat = function concat(n) {
|
||||
if (this.length === 0) return Buffer.alloc(0);
|
||||
var ret = Buffer.allocUnsafe(n >>> 0);
|
||||
var p = this.head;
|
||||
var i = 0;
|
||||
while (p) {
|
||||
copyBuffer(p.data, ret, i);
|
||||
i += p.data.length;
|
||||
p = p.next;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
return BufferList;
|
||||
}();
|
||||
|
||||
if (util && util.inspect && util.inspect.custom) {
|
||||
module.exports.prototype[util.inspect.custom] = function () {
|
||||
var obj = util.inspect({ length: this.length });
|
||||
return this.constructor.name + ' ' + obj;
|
||||
};
|
||||
}
|
||||
84
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
Normal file
84
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var pna = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
// undocumented cb() API, needed for core, not for public API
|
||||
function destroy(err, cb) {
|
||||
var _this = this;
|
||||
|
||||
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
||||
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
||||
|
||||
if (readableDestroyed || writableDestroyed) {
|
||||
if (cb) {
|
||||
cb(err);
|
||||
} else if (err) {
|
||||
if (!this._writableState) {
|
||||
pna.nextTick(emitErrorNT, this, err);
|
||||
} else if (!this._writableState.errorEmitted) {
|
||||
this._writableState.errorEmitted = true;
|
||||
pna.nextTick(emitErrorNT, this, err);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// we set destroyed to true before firing error callbacks in order
|
||||
// to make it re-entrance safe in case destroy() is called within callbacks
|
||||
|
||||
if (this._readableState) {
|
||||
this._readableState.destroyed = true;
|
||||
}
|
||||
|
||||
// if this is a duplex stream mark the writable part as destroyed as well
|
||||
if (this._writableState) {
|
||||
this._writableState.destroyed = true;
|
||||
}
|
||||
|
||||
this._destroy(err || null, function (err) {
|
||||
if (!cb && err) {
|
||||
if (!_this._writableState) {
|
||||
pna.nextTick(emitErrorNT, _this, err);
|
||||
} else if (!_this._writableState.errorEmitted) {
|
||||
_this._writableState.errorEmitted = true;
|
||||
pna.nextTick(emitErrorNT, _this, err);
|
||||
}
|
||||
} else if (cb) {
|
||||
cb(err);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function undestroy() {
|
||||
if (this._readableState) {
|
||||
this._readableState.destroyed = false;
|
||||
this._readableState.reading = false;
|
||||
this._readableState.ended = false;
|
||||
this._readableState.endEmitted = false;
|
||||
}
|
||||
|
||||
if (this._writableState) {
|
||||
this._writableState.destroyed = false;
|
||||
this._writableState.ended = false;
|
||||
this._writableState.ending = false;
|
||||
this._writableState.finalCalled = false;
|
||||
this._writableState.prefinished = false;
|
||||
this._writableState.finished = false;
|
||||
this._writableState.errorEmitted = false;
|
||||
}
|
||||
}
|
||||
|
||||
function emitErrorNT(self, err) {
|
||||
self.emit('error', err);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
destroy: destroy,
|
||||
undestroy: undestroy
|
||||
};
|
||||
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/stream-browser.js
generated
vendored
Normal file
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/stream-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('events').EventEmitter;
|
||||
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/stream.js
generated
vendored
Normal file
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/lib/internal/streams/stream.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('stream');
|
||||
52
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/package.json
generated
vendored
Normal file
52
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "readable-stream",
|
||||
"version": "2.3.8",
|
||||
"description": "Streams3, a user-land copy of the stream library from Node.js",
|
||||
"main": "readable.js",
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"assert": "^1.4.0",
|
||||
"babel-polyfill": "^6.9.1",
|
||||
"buffer": "^4.9.0",
|
||||
"lolex": "^2.3.2",
|
||||
"nyc": "^6.4.0",
|
||||
"tap": "^0.7.0",
|
||||
"tape": "^4.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/parallel/*.js test/ours/*.js && node test/verify-dependencies.js",
|
||||
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js",
|
||||
"cover": "nyc npm test",
|
||||
"report": "nyc report --reporter=lcov"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/readable-stream"
|
||||
},
|
||||
"keywords": [
|
||||
"readable",
|
||||
"stream",
|
||||
"pipe"
|
||||
],
|
||||
"browser": {
|
||||
"util": false,
|
||||
"./readable.js": "./readable-browser.js",
|
||||
"./writable.js": "./writable-browser.js",
|
||||
"./duplex.js": "./duplex-browser.js",
|
||||
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
|
||||
},
|
||||
"nyc": {
|
||||
"include": [
|
||||
"lib/**.js"
|
||||
]
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./readable').PassThrough
|
||||
7
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/readable-browser.js
generated
vendored
Normal file
7
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/readable-browser.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
exports = module.exports = require('./lib/_stream_readable.js');
|
||||
exports.Stream = exports;
|
||||
exports.Readable = exports;
|
||||
exports.Writable = require('./lib/_stream_writable.js');
|
||||
exports.Duplex = require('./lib/_stream_duplex.js');
|
||||
exports.Transform = require('./lib/_stream_transform.js');
|
||||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
||||
19
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/readable.js
generated
vendored
Normal file
19
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/readable.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var Stream = require('stream');
|
||||
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
||||
module.exports = Stream;
|
||||
exports = module.exports = Stream.Readable;
|
||||
exports.Readable = Stream.Readable;
|
||||
exports.Writable = Stream.Writable;
|
||||
exports.Duplex = Stream.Duplex;
|
||||
exports.Transform = Stream.Transform;
|
||||
exports.PassThrough = Stream.PassThrough;
|
||||
exports.Stream = Stream;
|
||||
} else {
|
||||
exports = module.exports = require('./lib/_stream_readable.js');
|
||||
exports.Stream = Stream || exports;
|
||||
exports.Readable = exports;
|
||||
exports.Writable = require('./lib/_stream_writable.js');
|
||||
exports.Duplex = require('./lib/_stream_duplex.js');
|
||||
exports.Transform = require('./lib/_stream_transform.js');
|
||||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
||||
}
|
||||
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/transform.js
generated
vendored
Normal file
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/transform.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./readable').Transform
|
||||
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/writable-browser.js
generated
vendored
Normal file
1
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/writable-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/_stream_writable.js');
|
||||
8
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/writable.js
generated
vendored
Normal file
8
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/readable-stream/writable.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
var Stream = require("stream")
|
||||
var Writable = require("./lib/_stream_writable.js")
|
||||
|
||||
if (process.env.READABLE_STREAM === 'disable') {
|
||||
module.exports = Stream && Stream.Writable || Writable
|
||||
} else {
|
||||
module.exports = Writable
|
||||
}
|
||||
21
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/LICENSE
generated
vendored
Normal file
21
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Feross Aboukhadijeh
|
||||
|
||||
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.
|
||||
584
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/README.md
generated
vendored
Normal file
584
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/README.md
generated
vendored
Normal file
@@ -0,0 +1,584 @@
|
||||
# safe-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/feross/safe-buffer/master.svg
|
||||
[travis-url]: https://travis-ci.org/feross/safe-buffer
|
||||
[npm-image]: https://img.shields.io/npm/v/safe-buffer.svg
|
||||
[npm-url]: https://npmjs.org/package/safe-buffer
|
||||
[downloads-image]: https://img.shields.io/npm/dm/safe-buffer.svg
|
||||
[downloads-url]: https://npmjs.org/package/safe-buffer
|
||||
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
||||
[standard-url]: https://standardjs.com
|
||||
|
||||
#### Safer Node.js Buffer API
|
||||
|
||||
**Use the new Node.js Buffer APIs (`Buffer.from`, `Buffer.alloc`,
|
||||
`Buffer.allocUnsafe`, `Buffer.allocUnsafeSlow`) in all versions of Node.js.**
|
||||
|
||||
**Uses the built-in implementation when available.**
|
||||
|
||||
## install
|
||||
|
||||
```
|
||||
npm install safe-buffer
|
||||
```
|
||||
|
||||
## usage
|
||||
|
||||
The goal of this package is to provide a safe replacement for the node.js `Buffer`.
|
||||
|
||||
It's a drop-in replacement for `Buffer`. You can use it by adding one `require` line to
|
||||
the top of your node.js modules:
|
||||
|
||||
```js
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
// Existing buffer code will continue to work without issues:
|
||||
|
||||
new Buffer('hey', 'utf8')
|
||||
new Buffer([1, 2, 3], 'utf8')
|
||||
new Buffer(obj)
|
||||
new Buffer(16) // create an uninitialized buffer (potentially unsafe)
|
||||
|
||||
// But you can use these new explicit APIs to make clear what you want:
|
||||
|
||||
Buffer.from('hey', 'utf8') // convert from many types to a Buffer
|
||||
Buffer.alloc(16) // create a zero-filled buffer (safe)
|
||||
Buffer.allocUnsafe(16) // create an uninitialized buffer (potentially unsafe)
|
||||
```
|
||||
|
||||
## api
|
||||
|
||||
### Class Method: Buffer.from(array)
|
||||
<!-- YAML
|
||||
added: v3.0.0
|
||||
-->
|
||||
|
||||
* `array` {Array}
|
||||
|
||||
Allocates a new `Buffer` using an `array` of octets.
|
||||
|
||||
```js
|
||||
const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
|
||||
// creates a new Buffer containing ASCII bytes
|
||||
// ['b','u','f','f','e','r']
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `array` is not an `Array`.
|
||||
|
||||
### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or
|
||||
a `new ArrayBuffer()`
|
||||
* `byteOffset` {Number} Default: `0`
|
||||
* `length` {Number} Default: `arrayBuffer.length - byteOffset`
|
||||
|
||||
When passed a reference to the `.buffer` property of a `TypedArray` instance,
|
||||
the newly created `Buffer` will share the same allocated memory as the
|
||||
TypedArray.
|
||||
|
||||
```js
|
||||
const arr = new Uint16Array(2);
|
||||
arr[0] = 5000;
|
||||
arr[1] = 4000;
|
||||
|
||||
const buf = Buffer.from(arr.buffer); // shares the memory with arr;
|
||||
|
||||
console.log(buf);
|
||||
// Prints: <Buffer 88 13 a0 0f>
|
||||
|
||||
// changing the TypedArray changes the Buffer also
|
||||
arr[1] = 6000;
|
||||
|
||||
console.log(buf);
|
||||
// Prints: <Buffer 88 13 70 17>
|
||||
```
|
||||
|
||||
The optional `byteOffset` and `length` arguments specify a memory range within
|
||||
the `arrayBuffer` that will be shared by the `Buffer`.
|
||||
|
||||
```js
|
||||
const ab = new ArrayBuffer(10);
|
||||
const buf = Buffer.from(ab, 0, 2);
|
||||
console.log(buf.length);
|
||||
// Prints: 2
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`.
|
||||
|
||||
### Class Method: Buffer.from(buffer)
|
||||
<!-- YAML
|
||||
added: v3.0.0
|
||||
-->
|
||||
|
||||
* `buffer` {Buffer}
|
||||
|
||||
Copies the passed `buffer` data onto a new `Buffer` instance.
|
||||
|
||||
```js
|
||||
const buf1 = Buffer.from('buffer');
|
||||
const buf2 = Buffer.from(buf1);
|
||||
|
||||
buf1[0] = 0x61;
|
||||
console.log(buf1.toString());
|
||||
// 'auffer'
|
||||
console.log(buf2.toString());
|
||||
// 'buffer' (copy is not changed)
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `buffer` is not a `Buffer`.
|
||||
|
||||
### Class Method: Buffer.from(str[, encoding])
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `str` {String} String to encode.
|
||||
* `encoding` {String} Encoding to use, Default: `'utf8'`
|
||||
|
||||
Creates a new `Buffer` containing the given JavaScript string `str`. If
|
||||
provided, the `encoding` parameter identifies the character encoding.
|
||||
If not provided, `encoding` defaults to `'utf8'`.
|
||||
|
||||
```js
|
||||
const buf1 = Buffer.from('this is a tést');
|
||||
console.log(buf1.toString());
|
||||
// prints: this is a tést
|
||||
console.log(buf1.toString('ascii'));
|
||||
// prints: this is a tC)st
|
||||
|
||||
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
|
||||
console.log(buf2.toString());
|
||||
// prints: this is a tést
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `str` is not a string.
|
||||
|
||||
### Class Method: Buffer.alloc(size[, fill[, encoding]])
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `size` {Number}
|
||||
* `fill` {Value} Default: `undefined`
|
||||
* `encoding` {String} Default: `utf8`
|
||||
|
||||
Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the
|
||||
`Buffer` will be *zero-filled*.
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc(5);
|
||||
console.log(buf);
|
||||
// <Buffer 00 00 00 00 00>
|
||||
```
|
||||
|
||||
The `size` must be less than or equal to the value of
|
||||
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
|
||||
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
|
||||
be created if a `size` less than or equal to 0 is specified.
|
||||
|
||||
If `fill` is specified, the allocated `Buffer` will be initialized by calling
|
||||
`buf.fill(fill)`. See [`buf.fill()`][] for more information.
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc(5, 'a');
|
||||
console.log(buf);
|
||||
// <Buffer 61 61 61 61 61>
|
||||
```
|
||||
|
||||
If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
||||
initialized by calling `buf.fill(fill, encoding)`. For example:
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
||||
console.log(buf);
|
||||
// <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
||||
```
|
||||
|
||||
Calling `Buffer.alloc(size)` can be significantly slower than the alternative
|
||||
`Buffer.allocUnsafe(size)` but ensures that the newly created `Buffer` instance
|
||||
contents will *never contain sensitive data*.
|
||||
|
||||
A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
### Class Method: Buffer.allocUnsafe(size)
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `size` {Number}
|
||||
|
||||
Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must
|
||||
be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit
|
||||
architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is
|
||||
thrown. A zero-length Buffer will be created if a `size` less than or equal to
|
||||
0 is specified.
|
||||
|
||||
The underlying memory for `Buffer` instances created in this way is *not
|
||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
||||
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
|
||||
`Buffer` instances to zeroes.
|
||||
|
||||
```js
|
||||
const buf = Buffer.allocUnsafe(5);
|
||||
console.log(buf);
|
||||
// <Buffer 78 e0 82 02 01>
|
||||
// (octets will be different, every time)
|
||||
buf.fill(0);
|
||||
console.log(buf);
|
||||
// <Buffer 00 00 00 00 00>
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
Note that the `Buffer` module pre-allocates an internal `Buffer` instance of
|
||||
size `Buffer.poolSize` that is used as a pool for the fast allocation of new
|
||||
`Buffer` instances created using `Buffer.allocUnsafe(size)` (and the deprecated
|
||||
`new Buffer(size)` constructor) only when `size` is less than or equal to
|
||||
`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). The default
|
||||
value of `Buffer.poolSize` is `8192` but can be modified.
|
||||
|
||||
Use of this pre-allocated internal memory pool is a key difference between
|
||||
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
||||
Specifically, `Buffer.alloc(size, fill)` will *never* use the internal Buffer
|
||||
pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal
|
||||
Buffer pool if `size` is less than or equal to half `Buffer.poolSize`. The
|
||||
difference is subtle but can be important when an application requires the
|
||||
additional performance that `Buffer.allocUnsafe(size)` provides.
|
||||
|
||||
### Class Method: Buffer.allocUnsafeSlow(size)
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `size` {Number}
|
||||
|
||||
Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The
|
||||
`size` must be less than or equal to the value of
|
||||
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
|
||||
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
|
||||
be created if a `size` less than or equal to 0 is specified.
|
||||
|
||||
The underlying memory for `Buffer` instances created in this way is *not
|
||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
||||
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
|
||||
`Buffer` instances to zeroes.
|
||||
|
||||
When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
||||
allocations under 4KB are, by default, sliced from a single pre-allocated
|
||||
`Buffer`. This allows applications to avoid the garbage collection overhead of
|
||||
creating many individually allocated Buffers. This approach improves both
|
||||
performance and memory usage by eliminating the need to track and cleanup as
|
||||
many `Persistent` objects.
|
||||
|
||||
However, in the case where a developer may need to retain a small chunk of
|
||||
memory from a pool for an indeterminate amount of time, it may be appropriate
|
||||
to create an un-pooled Buffer instance using `Buffer.allocUnsafeSlow()` then
|
||||
copy out the relevant bits.
|
||||
|
||||
```js
|
||||
// need to keep around a few small chunks of memory
|
||||
const store = [];
|
||||
|
||||
socket.on('readable', () => {
|
||||
const data = socket.read();
|
||||
// allocate for retained data
|
||||
const sb = Buffer.allocUnsafeSlow(10);
|
||||
// copy the data into the new allocation
|
||||
data.copy(sb, 0, 0, 10);
|
||||
store.push(sb);
|
||||
});
|
||||
```
|
||||
|
||||
Use of `Buffer.allocUnsafeSlow()` should be used only as a last resort *after*
|
||||
a developer has observed undue memory retention in their applications.
|
||||
|
||||
A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
### All the Rest
|
||||
|
||||
The rest of the `Buffer` API is exactly the same as in node.js.
|
||||
[See the docs](https://nodejs.org/api/buffer.html).
|
||||
|
||||
|
||||
## Related links
|
||||
|
||||
- [Node.js issue: Buffer(number) is unsafe](https://github.com/nodejs/node/issues/4660)
|
||||
- [Node.js Enhancement Proposal: Buffer.from/Buffer.alloc/Buffer.zalloc/Buffer() soft-deprecate](https://github.com/nodejs/node-eps/pull/4)
|
||||
|
||||
## Why is `Buffer` unsafe?
|
||||
|
||||
Today, the node.js `Buffer` constructor is overloaded to handle many different argument
|
||||
types like `String`, `Array`, `Object`, `TypedArrayView` (`Uint8Array`, etc.),
|
||||
`ArrayBuffer`, and also `Number`.
|
||||
|
||||
The API is optimized for convenience: you can throw any type at it, and it will try to do
|
||||
what you want.
|
||||
|
||||
Because the Buffer constructor is so powerful, you often see code like this:
|
||||
|
||||
```js
|
||||
// Convert UTF-8 strings to hex
|
||||
function toHex (str) {
|
||||
return new Buffer(str).toString('hex')
|
||||
}
|
||||
```
|
||||
|
||||
***But what happens if `toHex` is called with a `Number` argument?***
|
||||
|
||||
### Remote Memory Disclosure
|
||||
|
||||
If an attacker can make your program call the `Buffer` constructor with a `Number`
|
||||
argument, then they can make it allocate uninitialized memory from the node.js process.
|
||||
This could potentially disclose TLS private keys, user data, or database passwords.
|
||||
|
||||
When the `Buffer` constructor is passed a `Number` argument, it returns an
|
||||
**UNINITIALIZED** block of memory of the specified `size`. When you create a `Buffer` like
|
||||
this, you **MUST** overwrite the contents before returning it to the user.
|
||||
|
||||
From the [node.js docs](https://nodejs.org/api/buffer.html#buffer_new_buffer_size):
|
||||
|
||||
> `new Buffer(size)`
|
||||
>
|
||||
> - `size` Number
|
||||
>
|
||||
> The underlying memory for `Buffer` instances created in this way is not initialized.
|
||||
> **The contents of a newly created `Buffer` are unknown and could contain sensitive
|
||||
> data.** Use `buf.fill(0)` to initialize a Buffer to zeroes.
|
||||
|
||||
(Emphasis our own.)
|
||||
|
||||
Whenever the programmer intended to create an uninitialized `Buffer` you often see code
|
||||
like this:
|
||||
|
||||
```js
|
||||
var buf = new Buffer(16)
|
||||
|
||||
// Immediately overwrite the uninitialized buffer with data from another buffer
|
||||
for (var i = 0; i < buf.length; i++) {
|
||||
buf[i] = otherBuf[i]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Would this ever be a problem in real code?
|
||||
|
||||
Yes. It's surprisingly common to forget to check the type of your variables in a
|
||||
dynamically-typed language like JavaScript.
|
||||
|
||||
Usually the consequences of assuming the wrong type is that your program crashes with an
|
||||
uncaught exception. But the failure mode for forgetting to check the type of arguments to
|
||||
the `Buffer` constructor is more catastrophic.
|
||||
|
||||
Here's an example of a vulnerable service that takes a JSON payload and converts it to
|
||||
hex:
|
||||
|
||||
```js
|
||||
// Take a JSON payload {str: "some string"} and convert it to hex
|
||||
var server = http.createServer(function (req, res) {
|
||||
var data = ''
|
||||
req.setEncoding('utf8')
|
||||
req.on('data', function (chunk) {
|
||||
data += chunk
|
||||
})
|
||||
req.on('end', function () {
|
||||
var body = JSON.parse(data)
|
||||
res.end(new Buffer(body.str).toString('hex'))
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(8080)
|
||||
```
|
||||
|
||||
In this example, an http client just has to send:
|
||||
|
||||
```json
|
||||
{
|
||||
"str": 1000
|
||||
}
|
||||
```
|
||||
|
||||
and it will get back 1,000 bytes of uninitialized memory from the server.
|
||||
|
||||
This is a very serious bug. It's similar in severity to the
|
||||
[the Heartbleed bug](http://heartbleed.com/) that allowed disclosure of OpenSSL process
|
||||
memory by remote attackers.
|
||||
|
||||
|
||||
### Which real-world packages were vulnerable?
|
||||
|
||||
#### [`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht)
|
||||
|
||||
[Mathias Buus](https://github.com/mafintosh) and I
|
||||
([Feross Aboukhadijeh](http://feross.org/)) found this issue in one of our own packages,
|
||||
[`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht). The bug would allow
|
||||
anyone on the internet to send a series of messages to a user of `bittorrent-dht` and get
|
||||
them to reveal 20 bytes at a time of uninitialized memory from the node.js process.
|
||||
|
||||
Here's
|
||||
[the commit](https://github.com/feross/bittorrent-dht/commit/6c7da04025d5633699800a99ec3fbadf70ad35b8)
|
||||
that fixed it. We released a new fixed version, created a
|
||||
[Node Security Project disclosure](https://nodesecurity.io/advisories/68), and deprecated all
|
||||
vulnerable versions on npm so users will get a warning to upgrade to a newer version.
|
||||
|
||||
#### [`ws`](https://www.npmjs.com/package/ws)
|
||||
|
||||
That got us wondering if there were other vulnerable packages. Sure enough, within a short
|
||||
period of time, we found the same issue in [`ws`](https://www.npmjs.com/package/ws), the
|
||||
most popular WebSocket implementation in node.js.
|
||||
|
||||
If certain APIs were called with `Number` parameters instead of `String` or `Buffer` as
|
||||
expected, then uninitialized server memory would be disclosed to the remote peer.
|
||||
|
||||
These were the vulnerable methods:
|
||||
|
||||
```js
|
||||
socket.send(number)
|
||||
socket.ping(number)
|
||||
socket.pong(number)
|
||||
```
|
||||
|
||||
Here's a vulnerable socket server with some echo functionality:
|
||||
|
||||
```js
|
||||
server.on('connection', function (socket) {
|
||||
socket.on('message', function (message) {
|
||||
message = JSON.parse(message)
|
||||
if (message.type === 'echo') {
|
||||
socket.send(message.data) // send back the user's message
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
`socket.send(number)` called on the server, will disclose server memory.
|
||||
|
||||
Here's [the release](https://github.com/websockets/ws/releases/tag/1.0.1) where the issue
|
||||
was fixed, with a more detailed explanation. Props to
|
||||
[Arnout Kazemier](https://github.com/3rd-Eden) for the quick fix. Here's the
|
||||
[Node Security Project disclosure](https://nodesecurity.io/advisories/67).
|
||||
|
||||
|
||||
### What's the solution?
|
||||
|
||||
It's important that node.js offers a fast way to get memory otherwise performance-critical
|
||||
applications would needlessly get a lot slower.
|
||||
|
||||
But we need a better way to *signal our intent* as programmers. **When we want
|
||||
uninitialized memory, we should request it explicitly.**
|
||||
|
||||
Sensitive functionality should not be packed into a developer-friendly API that loosely
|
||||
accepts many different types. This type of API encourages the lazy practice of passing
|
||||
variables in without checking the type very carefully.
|
||||
|
||||
#### A new API: `Buffer.allocUnsafe(number)`
|
||||
|
||||
The functionality of creating buffers with uninitialized memory should be part of another
|
||||
API. We propose `Buffer.allocUnsafe(number)`. This way, it's not part of an API that
|
||||
frequently gets user input of all sorts of different types passed into it.
|
||||
|
||||
```js
|
||||
var buf = Buffer.allocUnsafe(16) // careful, uninitialized memory!
|
||||
|
||||
// Immediately overwrite the uninitialized buffer with data from another buffer
|
||||
for (var i = 0; i < buf.length; i++) {
|
||||
buf[i] = otherBuf[i]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### How do we fix node.js core?
|
||||
|
||||
We sent [a PR to node.js core](https://github.com/nodejs/node/pull/4514) (merged as
|
||||
`semver-major`) which defends against one case:
|
||||
|
||||
```js
|
||||
var str = 16
|
||||
new Buffer(str, 'utf8')
|
||||
```
|
||||
|
||||
In this situation, it's implied that the programmer intended the first argument to be a
|
||||
string, since they passed an encoding as a second argument. Today, node.js will allocate
|
||||
uninitialized memory in the case of `new Buffer(number, encoding)`, which is probably not
|
||||
what the programmer intended.
|
||||
|
||||
But this is only a partial solution, since if the programmer does `new Buffer(variable)`
|
||||
(without an `encoding` parameter) there's no way to know what they intended. If `variable`
|
||||
is sometimes a number, then uninitialized memory will sometimes be returned.
|
||||
|
||||
### What's the real long-term fix?
|
||||
|
||||
We could deprecate and remove `new Buffer(number)` and use `Buffer.allocUnsafe(number)` when
|
||||
we need uninitialized memory. But that would break 1000s of packages.
|
||||
|
||||
~~We believe the best solution is to:~~
|
||||
|
||||
~~1. Change `new Buffer(number)` to return safe, zeroed-out memory~~
|
||||
|
||||
~~2. Create a new API for creating uninitialized Buffers. We propose: `Buffer.allocUnsafe(number)`~~
|
||||
|
||||
#### Update
|
||||
|
||||
We now support adding three new APIs:
|
||||
|
||||
- `Buffer.from(value)` - convert from any type to a buffer
|
||||
- `Buffer.alloc(size)` - create a zero-filled buffer
|
||||
- `Buffer.allocUnsafe(size)` - create an uninitialized buffer with given size
|
||||
|
||||
This solves the core problem that affected `ws` and `bittorrent-dht` which is
|
||||
`Buffer(variable)` getting tricked into taking a number argument.
|
||||
|
||||
This way, existing code continues working and the impact on the npm ecosystem will be
|
||||
minimal. Over time, npm maintainers can migrate performance-critical code to use
|
||||
`Buffer.allocUnsafe(number)` instead of `new Buffer(number)`.
|
||||
|
||||
|
||||
### Conclusion
|
||||
|
||||
We think there's a serious design issue with the `Buffer` API as it exists today. It
|
||||
promotes insecure software by putting high-risk functionality into a convenient API
|
||||
with friendly "developer ergonomics".
|
||||
|
||||
This wasn't merely a theoretical exercise because we found the issue in some of the
|
||||
most popular npm packages.
|
||||
|
||||
Fortunately, there's an easy fix that can be applied today. Use `safe-buffer` in place of
|
||||
`buffer`.
|
||||
|
||||
```js
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
```
|
||||
|
||||
Eventually, we hope that node.js core can switch to this new, safer behavior. We believe
|
||||
the impact on the ecosystem would be minimal since it's not a breaking change.
|
||||
Well-maintained, popular packages would be updated to use `Buffer.alloc` quickly, while
|
||||
older, insecure packages would magically become safe from this attack vector.
|
||||
|
||||
|
||||
## links
|
||||
|
||||
- [Node.js PR: buffer: throw if both length and enc are passed](https://github.com/nodejs/node/pull/4514)
|
||||
- [Node Security Project disclosure for `ws`](https://nodesecurity.io/advisories/67)
|
||||
- [Node Security Project disclosure for`bittorrent-dht`](https://nodesecurity.io/advisories/68)
|
||||
|
||||
|
||||
## credit
|
||||
|
||||
The original issues in `bittorrent-dht`
|
||||
([disclosure](https://nodesecurity.io/advisories/68)) and
|
||||
`ws` ([disclosure](https://nodesecurity.io/advisories/67)) were discovered by
|
||||
[Mathias Buus](https://github.com/mafintosh) and
|
||||
[Feross Aboukhadijeh](http://feross.org/).
|
||||
|
||||
Thanks to [Adam Baldwin](https://github.com/evilpacket) for helping disclose these issues
|
||||
and for his work running the [Node Security Project](https://nodesecurity.io/).
|
||||
|
||||
Thanks to [John Hiesey](https://github.com/jhiesey) for proofreading this README and
|
||||
auditing the code.
|
||||
|
||||
|
||||
## license
|
||||
|
||||
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org)
|
||||
187
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/index.d.ts
generated
vendored
Normal file
187
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
declare module "safe-buffer" {
|
||||
export class Buffer {
|
||||
length: number
|
||||
write(string: string, offset?: number, length?: number, encoding?: string): number;
|
||||
toString(encoding?: string, start?: number, end?: number): string;
|
||||
toJSON(): { type: 'Buffer', data: any[] };
|
||||
equals(otherBuffer: Buffer): boolean;
|
||||
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
slice(start?: number, end?: number): Buffer;
|
||||
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUInt8(offset: number, noAssert?: boolean): number;
|
||||
readUInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readInt8(offset: number, noAssert?: boolean): number;
|
||||
readInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readFloatLE(offset: number, noAssert?: boolean): number;
|
||||
readFloatBE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleLE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleBE(offset: number, noAssert?: boolean): number;
|
||||
swap16(): Buffer;
|
||||
swap32(): Buffer;
|
||||
swap64(): Buffer;
|
||||
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt8(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
fill(value: any, offset?: number, end?: number): this;
|
||||
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
||||
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
||||
includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
|
||||
|
||||
/**
|
||||
* Allocates a new buffer containing the given {str}.
|
||||
*
|
||||
* @param str String to store in buffer.
|
||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||
*/
|
||||
constructor (str: string, encoding?: string);
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
*/
|
||||
constructor (size: number);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
*/
|
||||
constructor (array: Uint8Array);
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}.
|
||||
*
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
*/
|
||||
constructor (arrayBuffer: ArrayBuffer);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
*/
|
||||
constructor (array: any[]);
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
||||
*
|
||||
* @param buffer The buffer to copy.
|
||||
*/
|
||||
constructor (buffer: Buffer);
|
||||
prototype: Buffer;
|
||||
/**
|
||||
* Allocates a new Buffer using an {array} of octets.
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
static from(array: any[]): Buffer;
|
||||
/**
|
||||
* When passed a reference to the .buffer property of a TypedArray instance,
|
||||
* the newly created Buffer will share the same allocated memory as the TypedArray.
|
||||
* The optional {byteOffset} and {length} arguments specify a memory range
|
||||
* within the {arrayBuffer} that will be shared by the Buffer.
|
||||
*
|
||||
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
|
||||
* @param byteOffset
|
||||
* @param length
|
||||
*/
|
||||
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new Buffer instance.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
static from(buffer: Buffer): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer containing the given JavaScript string {str}.
|
||||
* If provided, the {encoding} parameter identifies the character encoding.
|
||||
* If not provided, {encoding} defaults to 'utf8'.
|
||||
*
|
||||
* @param str
|
||||
*/
|
||||
static from(str: string, encoding?: string): Buffer;
|
||||
/**
|
||||
* Returns true if {obj} is a Buffer
|
||||
*
|
||||
* @param obj object to test.
|
||||
*/
|
||||
static isBuffer(obj: any): obj is Buffer;
|
||||
/**
|
||||
* Returns true if {encoding} is a valid encoding argument.
|
||||
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
||||
*
|
||||
* @param encoding string to test.
|
||||
*/
|
||||
static isEncoding(encoding: string): boolean;
|
||||
/**
|
||||
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
|
||||
* This is not the same as String.prototype.length since that returns the number of characters in a string.
|
||||
*
|
||||
* @param string string to test.
|
||||
* @param encoding encoding used to evaluate (defaults to 'utf8')
|
||||
*/
|
||||
static byteLength(string: string, encoding?: string): number;
|
||||
/**
|
||||
* Returns a buffer which is the result of concatenating all the buffers in the list together.
|
||||
*
|
||||
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
|
||||
* If the list has exactly one item, then the first item of the list is returned.
|
||||
* If the list has more than one item, then a new Buffer is created.
|
||||
*
|
||||
* @param list An array of Buffer objects to concatenate
|
||||
* @param totalLength Total length of the buffers when concatenated.
|
||||
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
|
||||
*/
|
||||
static concat(list: Buffer[], totalLength?: number): Buffer;
|
||||
/**
|
||||
* The same as buf1.compare(buf2).
|
||||
*/
|
||||
static compare(buf1: Buffer, buf2: Buffer): number;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
|
||||
* If parameter is omitted, buffer will be filled with zeros.
|
||||
* @param encoding encoding used for call to buf.fill while initalizing
|
||||
*/
|
||||
static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafe(size: number): Buffer;
|
||||
/**
|
||||
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafeSlow(size: number): Buffer;
|
||||
}
|
||||
}
|
||||
62
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/index.js
generated
vendored
Normal file
62
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/index.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/* eslint-disable node/no-deprecated-api */
|
||||
var buffer = require('buffer')
|
||||
var Buffer = buffer.Buffer
|
||||
|
||||
// alternative to using Object.keys for old browsers
|
||||
function copyProps (src, dst) {
|
||||
for (var key in src) {
|
||||
dst[key] = src[key]
|
||||
}
|
||||
}
|
||||
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
||||
module.exports = buffer
|
||||
} else {
|
||||
// Copy properties from require('buffer')
|
||||
copyProps(buffer, exports)
|
||||
exports.Buffer = SafeBuffer
|
||||
}
|
||||
|
||||
function SafeBuffer (arg, encodingOrOffset, length) {
|
||||
return Buffer(arg, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
// Copy static methods from Buffer
|
||||
copyProps(Buffer, SafeBuffer)
|
||||
|
||||
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
||||
if (typeof arg === 'number') {
|
||||
throw new TypeError('Argument must not be a number')
|
||||
}
|
||||
return Buffer(arg, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
SafeBuffer.alloc = function (size, fill, encoding) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('Argument must be a number')
|
||||
}
|
||||
var buf = Buffer(size)
|
||||
if (fill !== undefined) {
|
||||
if (typeof encoding === 'string') {
|
||||
buf.fill(fill, encoding)
|
||||
} else {
|
||||
buf.fill(fill)
|
||||
}
|
||||
} else {
|
||||
buf.fill(0)
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
SafeBuffer.allocUnsafe = function (size) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('Argument must be a number')
|
||||
}
|
||||
return Buffer(size)
|
||||
}
|
||||
|
||||
SafeBuffer.allocUnsafeSlow = function (size) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('Argument must be a number')
|
||||
}
|
||||
return buffer.SlowBuffer(size)
|
||||
}
|
||||
37
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/package.json
generated
vendored
Normal file
37
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/safe-buffer/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "safe-buffer",
|
||||
"description": "Safer Node.js Buffer API",
|
||||
"version": "5.1.2",
|
||||
"author": {
|
||||
"name": "Feross Aboukhadijeh",
|
||||
"email": "feross@feross.org",
|
||||
"url": "http://feross.org"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/feross/safe-buffer/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "*",
|
||||
"tape": "^4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/feross/safe-buffer",
|
||||
"keywords": [
|
||||
"buffer",
|
||||
"buffer allocate",
|
||||
"node security",
|
||||
"safe",
|
||||
"safe-buffer",
|
||||
"security",
|
||||
"uninitialized"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/feross/safe-buffer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && tape test/*.js"
|
||||
}
|
||||
}
|
||||
50
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/.travis.yml
generated
vendored
Normal file
50
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
before_install:
|
||||
- npm install -g npm@2
|
||||
- test $NPM_LEGACY && npm install -g npm@latest-3 || npm install npm -g
|
||||
notifications:
|
||||
email: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- node_js: '0.8'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: '0.10'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: '0.11'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: '0.12'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 1
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 2
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 3
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 4
|
||||
env: TASK=test
|
||||
- node_js: 5
|
||||
env: TASK=test
|
||||
- node_js: 6
|
||||
env: TASK=test
|
||||
- node_js: 7
|
||||
env: TASK=test
|
||||
- node_js: 8
|
||||
env: TASK=test
|
||||
- node_js: 9
|
||||
env: TASK=test
|
||||
48
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/LICENSE
generated
vendored
Normal file
48
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
Node.js is licensed for use as follows:
|
||||
|
||||
"""
|
||||
Copyright Node.js contributors. All rights reserved.
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
This license applies to parts of Node.js originating from the
|
||||
https://github.com/joyent/node repository:
|
||||
|
||||
"""
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
||||
"""
|
||||
|
||||
47
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/README.md
generated
vendored
Normal file
47
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/README.md
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# string_decoder
|
||||
|
||||
***Node-core v8.9.4 string_decoder for userland***
|
||||
|
||||
|
||||
[](https://nodei.co/npm/string_decoder/)
|
||||
[](https://nodei.co/npm/string_decoder/)
|
||||
|
||||
|
||||
```bash
|
||||
npm install --save string_decoder
|
||||
```
|
||||
|
||||
***Node-core string_decoder for userland***
|
||||
|
||||
This package is a mirror of the string_decoder implementation in Node-core.
|
||||
|
||||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.9.4/docs/api/).
|
||||
|
||||
As of version 1.0.0 **string_decoder** uses semantic versioning.
|
||||
|
||||
## Previous versions
|
||||
|
||||
Previous version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10.
|
||||
|
||||
## Update
|
||||
|
||||
The *build/* directory contains a build script that will scrape the source from the [nodejs/node](https://github.com/nodejs/node) repo given a specific Node version.
|
||||
|
||||
## Streams Working Group
|
||||
|
||||
`string_decoder` is maintained by the Streams Working Group, which
|
||||
oversees the development and maintenance of the Streams API within
|
||||
Node.js. The responsibilities of the Streams Working Group include:
|
||||
|
||||
* Addressing stream issues on the Node.js issue tracker.
|
||||
* Authoring and editing stream documentation within the Node.js project.
|
||||
* Reviewing changes to stream subclasses within the Node.js project.
|
||||
* Redirecting changes to streams from the Node.js project to this
|
||||
project.
|
||||
* Assisting in the implementation of stream providers within Node.js.
|
||||
* Recommending versions of `readable-stream` to be included in Node.js.
|
||||
* Messaging about the future of streams to give the community advance
|
||||
notice of changes.
|
||||
|
||||
See [readable-stream](https://github.com/nodejs/readable-stream) for
|
||||
more details.
|
||||
296
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/lib/string_decoder.js
generated
vendored
Normal file
296
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/lib/string_decoder.js
generated
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
/*</replacement>*/
|
||||
|
||||
var isEncoding = Buffer.isEncoding || function (encoding) {
|
||||
encoding = '' + encoding;
|
||||
switch (encoding && encoding.toLowerCase()) {
|
||||
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
function _normalizeEncoding(enc) {
|
||||
if (!enc) return 'utf8';
|
||||
var retried;
|
||||
while (true) {
|
||||
switch (enc) {
|
||||
case 'utf8':
|
||||
case 'utf-8':
|
||||
return 'utf8';
|
||||
case 'ucs2':
|
||||
case 'ucs-2':
|
||||
case 'utf16le':
|
||||
case 'utf-16le':
|
||||
return 'utf16le';
|
||||
case 'latin1':
|
||||
case 'binary':
|
||||
return 'latin1';
|
||||
case 'base64':
|
||||
case 'ascii':
|
||||
case 'hex':
|
||||
return enc;
|
||||
default:
|
||||
if (retried) return; // undefined
|
||||
enc = ('' + enc).toLowerCase();
|
||||
retried = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Do not cache `Buffer.isEncoding` when checking encoding names as some
|
||||
// modules monkey-patch it to support additional encodings
|
||||
function normalizeEncoding(enc) {
|
||||
var nenc = _normalizeEncoding(enc);
|
||||
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
|
||||
return nenc || enc;
|
||||
}
|
||||
|
||||
// StringDecoder provides an interface for efficiently splitting a series of
|
||||
// buffers into a series of JS strings without breaking apart multi-byte
|
||||
// characters.
|
||||
exports.StringDecoder = StringDecoder;
|
||||
function StringDecoder(encoding) {
|
||||
this.encoding = normalizeEncoding(encoding);
|
||||
var nb;
|
||||
switch (this.encoding) {
|
||||
case 'utf16le':
|
||||
this.text = utf16Text;
|
||||
this.end = utf16End;
|
||||
nb = 4;
|
||||
break;
|
||||
case 'utf8':
|
||||
this.fillLast = utf8FillLast;
|
||||
nb = 4;
|
||||
break;
|
||||
case 'base64':
|
||||
this.text = base64Text;
|
||||
this.end = base64End;
|
||||
nb = 3;
|
||||
break;
|
||||
default:
|
||||
this.write = simpleWrite;
|
||||
this.end = simpleEnd;
|
||||
return;
|
||||
}
|
||||
this.lastNeed = 0;
|
||||
this.lastTotal = 0;
|
||||
this.lastChar = Buffer.allocUnsafe(nb);
|
||||
}
|
||||
|
||||
StringDecoder.prototype.write = function (buf) {
|
||||
if (buf.length === 0) return '';
|
||||
var r;
|
||||
var i;
|
||||
if (this.lastNeed) {
|
||||
r = this.fillLast(buf);
|
||||
if (r === undefined) return '';
|
||||
i = this.lastNeed;
|
||||
this.lastNeed = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
|
||||
return r || '';
|
||||
};
|
||||
|
||||
StringDecoder.prototype.end = utf8End;
|
||||
|
||||
// Returns only complete characters in a Buffer
|
||||
StringDecoder.prototype.text = utf8Text;
|
||||
|
||||
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
|
||||
StringDecoder.prototype.fillLast = function (buf) {
|
||||
if (this.lastNeed <= buf.length) {
|
||||
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
||||
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
||||
}
|
||||
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
||||
this.lastNeed -= buf.length;
|
||||
};
|
||||
|
||||
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
|
||||
// continuation byte. If an invalid byte is detected, -2 is returned.
|
||||
function utf8CheckByte(byte) {
|
||||
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
|
||||
return byte >> 6 === 0x02 ? -1 : -2;
|
||||
}
|
||||
|
||||
// Checks at most 3 bytes at the end of a Buffer in order to detect an
|
||||
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
|
||||
// needed to complete the UTF-8 character (if applicable) are returned.
|
||||
function utf8CheckIncomplete(self, buf, i) {
|
||||
var j = buf.length - 1;
|
||||
if (j < i) return 0;
|
||||
var nb = utf8CheckByte(buf[j]);
|
||||
if (nb >= 0) {
|
||||
if (nb > 0) self.lastNeed = nb - 1;
|
||||
return nb;
|
||||
}
|
||||
if (--j < i || nb === -2) return 0;
|
||||
nb = utf8CheckByte(buf[j]);
|
||||
if (nb >= 0) {
|
||||
if (nb > 0) self.lastNeed = nb - 2;
|
||||
return nb;
|
||||
}
|
||||
if (--j < i || nb === -2) return 0;
|
||||
nb = utf8CheckByte(buf[j]);
|
||||
if (nb >= 0) {
|
||||
if (nb > 0) {
|
||||
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
|
||||
}
|
||||
return nb;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Validates as many continuation bytes for a multi-byte UTF-8 character as
|
||||
// needed or are available. If we see a non-continuation byte where we expect
|
||||
// one, we "replace" the validated continuation bytes we've seen so far with
|
||||
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
|
||||
// behavior. The continuation byte check is included three times in the case
|
||||
// where all of the continuation bytes for a character exist in the same buffer.
|
||||
// It is also done this way as a slight performance increase instead of using a
|
||||
// loop.
|
||||
function utf8CheckExtraBytes(self, buf, p) {
|
||||
if ((buf[0] & 0xC0) !== 0x80) {
|
||||
self.lastNeed = 0;
|
||||
return '\ufffd';
|
||||
}
|
||||
if (self.lastNeed > 1 && buf.length > 1) {
|
||||
if ((buf[1] & 0xC0) !== 0x80) {
|
||||
self.lastNeed = 1;
|
||||
return '\ufffd';
|
||||
}
|
||||
if (self.lastNeed > 2 && buf.length > 2) {
|
||||
if ((buf[2] & 0xC0) !== 0x80) {
|
||||
self.lastNeed = 2;
|
||||
return '\ufffd';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
|
||||
function utf8FillLast(buf) {
|
||||
var p = this.lastTotal - this.lastNeed;
|
||||
var r = utf8CheckExtraBytes(this, buf, p);
|
||||
if (r !== undefined) return r;
|
||||
if (this.lastNeed <= buf.length) {
|
||||
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
||||
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
||||
}
|
||||
buf.copy(this.lastChar, p, 0, buf.length);
|
||||
this.lastNeed -= buf.length;
|
||||
}
|
||||
|
||||
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
|
||||
// partial character, the character's bytes are buffered until the required
|
||||
// number of bytes are available.
|
||||
function utf8Text(buf, i) {
|
||||
var total = utf8CheckIncomplete(this, buf, i);
|
||||
if (!this.lastNeed) return buf.toString('utf8', i);
|
||||
this.lastTotal = total;
|
||||
var end = buf.length - (total - this.lastNeed);
|
||||
buf.copy(this.lastChar, 0, end);
|
||||
return buf.toString('utf8', i, end);
|
||||
}
|
||||
|
||||
// For UTF-8, a replacement character is added when ending on a partial
|
||||
// character.
|
||||
function utf8End(buf) {
|
||||
var r = buf && buf.length ? this.write(buf) : '';
|
||||
if (this.lastNeed) return r + '\ufffd';
|
||||
return r;
|
||||
}
|
||||
|
||||
// UTF-16LE typically needs two bytes per character, but even if we have an even
|
||||
// number of bytes available, we need to check if we end on a leading/high
|
||||
// surrogate. In that case, we need to wait for the next two bytes in order to
|
||||
// decode the last character properly.
|
||||
function utf16Text(buf, i) {
|
||||
if ((buf.length - i) % 2 === 0) {
|
||||
var r = buf.toString('utf16le', i);
|
||||
if (r) {
|
||||
var c = r.charCodeAt(r.length - 1);
|
||||
if (c >= 0xD800 && c <= 0xDBFF) {
|
||||
this.lastNeed = 2;
|
||||
this.lastTotal = 4;
|
||||
this.lastChar[0] = buf[buf.length - 2];
|
||||
this.lastChar[1] = buf[buf.length - 1];
|
||||
return r.slice(0, -1);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
this.lastNeed = 1;
|
||||
this.lastTotal = 2;
|
||||
this.lastChar[0] = buf[buf.length - 1];
|
||||
return buf.toString('utf16le', i, buf.length - 1);
|
||||
}
|
||||
|
||||
// For UTF-16LE we do not explicitly append special replacement characters if we
|
||||
// end on a partial character, we simply let v8 handle that.
|
||||
function utf16End(buf) {
|
||||
var r = buf && buf.length ? this.write(buf) : '';
|
||||
if (this.lastNeed) {
|
||||
var end = this.lastTotal - this.lastNeed;
|
||||
return r + this.lastChar.toString('utf16le', 0, end);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function base64Text(buf, i) {
|
||||
var n = (buf.length - i) % 3;
|
||||
if (n === 0) return buf.toString('base64', i);
|
||||
this.lastNeed = 3 - n;
|
||||
this.lastTotal = 3;
|
||||
if (n === 1) {
|
||||
this.lastChar[0] = buf[buf.length - 1];
|
||||
} else {
|
||||
this.lastChar[0] = buf[buf.length - 2];
|
||||
this.lastChar[1] = buf[buf.length - 1];
|
||||
}
|
||||
return buf.toString('base64', i, buf.length - n);
|
||||
}
|
||||
|
||||
function base64End(buf) {
|
||||
var r = buf && buf.length ? this.write(buf) : '';
|
||||
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
|
||||
return r;
|
||||
}
|
||||
|
||||
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
|
||||
function simpleWrite(buf) {
|
||||
return buf.toString(this.encoding);
|
||||
}
|
||||
|
||||
function simpleEnd(buf) {
|
||||
return buf && buf.length ? this.write(buf) : '';
|
||||
}
|
||||
31
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/package.json
generated
vendored
Normal file
31
doc/test-data/purchase_transaction/node_modules/unzipper/node_modules/string_decoder/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "string_decoder",
|
||||
"version": "1.1.1",
|
||||
"description": "The string_decoder module from Node core",
|
||||
"main": "lib/string_decoder.js",
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"core-util-is": "^1.0.2",
|
||||
"inherits": "^2.0.3",
|
||||
"tap": "~0.4.8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/parallel/*.js && node test/verify-dependencies",
|
||||
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/string_decoder.git"
|
||||
},
|
||||
"homepage": "https://github.com/nodejs/string_decoder",
|
||||
"keywords": [
|
||||
"string",
|
||||
"decoder",
|
||||
"browser",
|
||||
"browserify"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
63
doc/test-data/purchase_transaction/node_modules/unzipper/package.json
generated
vendored
Normal file
63
doc/test-data/purchase_transaction/node_modules/unzipper/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "unzipper",
|
||||
"version": "0.10.14",
|
||||
"description": "Unzip cross-platform streaming API ",
|
||||
"author": "Evan Oxfeld <eoxfeld@gmail.com>",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Ziggy Jonsson",
|
||||
"email": "ziggy.jonsson.nyc@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Evan Oxfeld",
|
||||
"email": "eoxfeld@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Joe Ferner",
|
||||
"email": "joe.ferner@nearinfinity.com"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ZJONSSON/node-unzipper.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"big-integer": "^1.6.17",
|
||||
"binary": "~0.3.0",
|
||||
"bluebird": "~3.4.1",
|
||||
"buffer-indexof-polyfill": "~1.0.0",
|
||||
"duplexer2": "~0.1.4",
|
||||
"fstream": "^1.0.12",
|
||||
"graceful-fs": "^4.2.2",
|
||||
"listenercount": "~1.0.1",
|
||||
"readable-stream": "~2.3.6",
|
||||
"setimmediate": "~1.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"aws-sdk": "^2.77.0",
|
||||
"dirdiff": ">= 0.0.1 < 1",
|
||||
"iconv-lite": "^0.4.24",
|
||||
"request": "^2.88.0",
|
||||
"stream-buffers": ">= 0.2.5 < 1",
|
||||
"tap": ">= 0.3.0 < 1",
|
||||
"temp": ">= 0.4.0 < 1"
|
||||
},
|
||||
"directories": {
|
||||
"example": "examples",
|
||||
"test": "test"
|
||||
},
|
||||
"keywords": [
|
||||
"zip",
|
||||
"unzip",
|
||||
"zlib",
|
||||
"uncompress",
|
||||
"archive",
|
||||
"stream",
|
||||
"extract"
|
||||
],
|
||||
"main": "unzip.js",
|
||||
"scripts": {
|
||||
"test": "tap test/*.js --jobs=10 --coverage-report=html --no-browser"
|
||||
}
|
||||
}
|
||||
11
doc/test-data/purchase_transaction/node_modules/unzipper/unzip.js
generated
vendored
Normal file
11
doc/test-data/purchase_transaction/node_modules/unzipper/unzip.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
// Polyfills for node 0.8
|
||||
require('listenercount');
|
||||
require('buffer-indexof-polyfill');
|
||||
require('setimmediate');
|
||||
|
||||
|
||||
exports.Parse = require('./lib/parse');
|
||||
exports.ParseOne = require('./lib/parseOne');
|
||||
exports.Extract = require('./lib/extract');
|
||||
exports.Open = require('./lib/Open');
|
||||
Reference in New Issue
Block a user