gennadysht před 1 rokem
revize
546a9cacdd
100 změnil soubory, kde provedl 36625 přidání a 0 odebrání
  1. 0 0
      README.md
  2. 191 0
      index.js
  3. binární
      libssl1.1_1.1.1f-1ubuntu2_amd64.deb
  4. 261 0
      models.js
  5. binární
      mongodb-compass_1.26.1_amd64.deb
  6. binární
      mongodb-compass_1.35.0_amd64.deb
  7. 1 0
      node_modules/.bin/mime
  8. 1 0
      node_modules/.bin/mkdirp
  9. 1 0
      node_modules/.bin/semver
  10. 1099 0
      node_modules/.package-lock.json
  11. 243 0
      node_modules/accepts/HISTORY.md
  12. 23 0
      node_modules/accepts/LICENSE
  13. 140 0
      node_modules/accepts/README.md
  14. 238 0
      node_modules/accepts/index.js
  15. 47 0
      node_modules/accepts/package.json
  16. 1 0
      node_modules/append-field/.npmignore
  17. 21 0
      node_modules/append-field/LICENSE
  18. 44 0
      node_modules/append-field/README.md
  19. 12 0
      node_modules/append-field/index.js
  20. 53 0
      node_modules/append-field/lib/parse-path.js
  21. 64 0
      node_modules/append-field/lib/set-value.js
  22. 19 0
      node_modules/append-field/package.json
  23. 19 0
      node_modules/append-field/test/forms.js
  24. 21 0
      node_modules/array-flatten/LICENSE
  25. 43 0
      node_modules/array-flatten/README.md
  26. 64 0
      node_modules/array-flatten/array-flatten.js
  27. 39 0
      node_modules/array-flatten/package.json
  28. 60 0
      node_modules/bl/.jshintrc
  29. 15 0
      node_modules/bl/.travis.yml
  30. 13 0
      node_modules/bl/LICENSE.md
  31. 218 0
      node_modules/bl/README.md
  32. 392 0
      node_modules/bl/bl.js
  33. 35 0
      node_modules/bl/package.json
  34. 463 0
      node_modules/bl/test/indexOf.js
  35. 782 0
      node_modules/bl/test/test.js
  36. 657 0
      node_modules/body-parser/HISTORY.md
  37. 23 0
      node_modules/body-parser/LICENSE
  38. 464 0
      node_modules/body-parser/README.md
  39. 25 0
      node_modules/body-parser/SECURITY.md
  40. 156 0
      node_modules/body-parser/index.js
  41. 205 0
      node_modules/body-parser/lib/read.js
  42. 236 0
      node_modules/body-parser/lib/types/json.js
  43. 101 0
      node_modules/body-parser/lib/types/raw.js
  44. 121 0
      node_modules/body-parser/lib/types/text.js
  45. 284 0
      node_modules/body-parser/lib/types/urlencoded.js
  46. 56 0
      node_modules/body-parser/package.json
  47. 301 0
      node_modules/bson/HISTORY.md
  48. 201 0
      node_modules/bson/LICENSE.md
  49. 170 0
      node_modules/bson/README.md
  50. 26 0
      node_modules/bson/bower.json
  51. 18218 0
      node_modules/bson/browser_build/bson.js
  52. 8 0
      node_modules/bson/browser_build/package.json
  53. 46 0
      node_modules/bson/index.js
  54. 384 0
      node_modules/bson/lib/bson/binary.js
  55. 386 0
      node_modules/bson/lib/bson/bson.js
  56. 24 0
      node_modules/bson/lib/bson/code.js
  57. 32 0
      node_modules/bson/lib/bson/db_ref.js
  58. 820 0
      node_modules/bson/lib/bson/decimal128.js
  59. 33 0
      node_modules/bson/lib/bson/double.js
  60. 124 0
      node_modules/bson/lib/bson/float_parser.js
  61. 33 0
      node_modules/bson/lib/bson/int_32.js
  62. 865 0
      node_modules/bson/lib/bson/long.js
  63. 128 0
      node_modules/bson/lib/bson/map.js
  64. 14 0
      node_modules/bson/lib/bson/max_key.js
  65. 14 0
      node_modules/bson/lib/bson/min_key.js
  66. 392 0
      node_modules/bson/lib/bson/objectid.js
  67. 255 0
      node_modules/bson/lib/bson/parser/calculate_size.js
  68. 782 0
      node_modules/bson/lib/bson/parser/deserializer.js
  69. 1194 0
      node_modules/bson/lib/bson/parser/serializer.js
  70. 28 0
      node_modules/bson/lib/bson/parser/utils.js
  71. 33 0
      node_modules/bson/lib/bson/regexp.js
  72. 50 0
      node_modules/bson/lib/bson/symbol.js
  73. 854 0
      node_modules/bson/lib/bson/timestamp.js
  74. 58 0
      node_modules/bson/package.json
  75. 2 0
      node_modules/buffer-equal-constant-time/.npmignore
  76. 4 0
      node_modules/buffer-equal-constant-time/.travis.yml
  77. 12 0
      node_modules/buffer-equal-constant-time/LICENSE.txt
  78. 50 0
      node_modules/buffer-equal-constant-time/README.md
  79. 41 0
      node_modules/buffer-equal-constant-time/index.js
  80. 21 0
      node_modules/buffer-equal-constant-time/package.json
  81. 42 0
      node_modules/buffer-equal-constant-time/test.js
  82. 21 0
      node_modules/buffer-from/LICENSE
  83. 72 0
      node_modules/buffer-from/index.js
  84. 19 0
      node_modules/buffer-from/package.json
  85. 69 0
      node_modules/buffer-from/readme.md
  86. 17 0
      node_modules/busboy/.travis.yml
  87. 19 0
      node_modules/busboy/LICENSE
  88. 225 0
      node_modules/busboy/README.md
  89. 73 0
      node_modules/busboy/deps/encoding/encoding-indexes.js
  90. 2391 0
      node_modules/busboy/deps/encoding/encoding.js
  91. 89 0
      node_modules/busboy/lib/main.js
  92. 324 0
      node_modules/busboy/lib/types/multipart.js
  93. 214 0
      node_modules/busboy/lib/types/urlencoded.js
  94. 186 0
      node_modules/busboy/lib/utils.js
  95. 54 0
      node_modules/busboy/node_modules/isarray/README.md
  96. 209 0
      node_modules/busboy/node_modules/isarray/build/build.js
  97. 19 0
      node_modules/busboy/node_modules/isarray/component.json
  98. 3 0
      node_modules/busboy/node_modules/isarray/index.js
  99. 25 0
      node_modules/busboy/node_modules/isarray/package.json
  100. 0 0
      node_modules/busboy/node_modules/readable-stream/.npmignore

+ 0 - 0
README.md


+ 191 - 0
index.js

@@ -0,0 +1,191 @@
+const jwtSecret   = 'AjnjLhjxM'
+const jwt         = require('jsonwebtoken')
+
+const express           = require('express');
+const express_graphql   = require('express-graphql');
+
+const { buildSchema, printSchema, GraphQLString } = require('graphql');
+const expand = require('mm-graphql/expand')
+const fs     = require('fs')
+const uploadPath = `${__dirname}/public/images/`;
+const upload  = require('multer')({ dest: uploadPath })
+
+
+;(async () => {
+
+    const {Savable, slice, getModels} = await require('./models.js')()
+    const { jwtGQLAnon, jwtCheck } = require('mm-graphql/jwt')
+
+    let schema = buildSchema(`
+        type User {
+             _id: String
+             createdAt: String
+             login: String
+             nick : String
+             avatar: Image
+             acl: [String]
+        }
+
+        input UserInput {
+             _id: String
+             login: String
+             nick : String
+             password: String
+             acl: [String]
+             avatar: ImageInput
+        }
+
+        type Image {
+            _id: ID,
+            createdAt: String
+            text: String,
+            url: String,
+            originalFileName: String,
+            userAvatar: User,
+            good: Good
+            category: Category
+            owner: User
+        }
+
+        input ImageInput {
+            _id: ID,
+            text: String,
+            userAvatar: UserInput,
+            good: GoodInput
+            category: CategoryInput
+        }
+
+        type Category {
+            _id: ID,
+             createdAt: String
+            name: String,
+            goods: [Good]
+            image: Image
+            owner: User
+            parent: Category
+            subCategories: [Category]
+        }
+
+        input CategoryInput {
+            _id: ID,
+            name: String!,
+            goods: [GoodInput]
+            image: ImageInput
+
+            parent: CategoryInput
+            subCategories: [CategoryInput]
+        }
+
+        type Good {
+            _id: ID,
+            createdAt: String
+            name: String,
+            description: String
+            price: Float
+            orderGoods: [OrderGood]
+            categories: [Category]
+            images: [Image]
+            owner: User
+        }
+
+        input GoodInput {
+            _id: ID,
+            name: String,
+            description: String
+            price: Float
+            categories: [CategoryInput]
+            images: [ImageInput]
+        }
+
+        type OrderGood {
+            _id: ID,
+            createdAt: String
+            price: Float,
+            count: Float,
+            good: Good,
+            order: Order
+            owner: User
+            total: Float
+        }
+
+        input OrderGoodInput {
+            _id: ID,
+            count: Int!,
+            good: GoodInput,
+            order: OrderInput
+        }
+
+        type Order {
+            _id: ID
+            createdAt: String
+            total: Float
+            orderGoods: [OrderGood]
+            owner: User
+        }
+
+        input OrderInput {
+            _id: ID
+            orderGoods: [OrderGoodInput]
+        }
+    `);
+
+    schema = expand(schema, {
+        login:{
+            type: GraphQLString,
+            args: {login:    {type: GraphQLString},
+                   password: {type: GraphQLString},
+            },
+            async resolve(root, {login, password}, context, info){
+                const Savable =  context.models.Savable 
+                if (!login || !password) return null;
+                const user    =  await Savable.m.User.findOne({login, password})
+                console.log(user, {login, password})
+                if (!user)
+                    return null;
+
+                const token = jwt.sign({ sub: {id: user._id, login, acl: user.acl}}, jwtSecret); //подписывам токен нашим ключем
+                return token
+            }
+        }
+    })
+    console.log(printSchema(schema))
+
+    const app = express();
+    app.use(require('cors')())
+    app.use(express.static('public'));
+    app.use('/graphql', express_graphql(jwtGQLAnon({schema, createContext: getModels, graphiql: true, secret: jwtSecret})))
+
+
+    app.post('/upload', upload.single('photo'), async (req, res, next) => {
+        let decoded;
+        if (decoded = jwtCheck(req, jwtSecret)){
+            console.log('SOME UPLOAD', decoded, req.file)
+
+            let {models: {Image }} = await getModels(decoded.sub)
+		if (req.file){
+			let image = await Image.fromFileData(req.file)
+			res.end(JSON.stringify({_id: image._id, url: image.url}))
+		}
+		else {
+			res.end('дичь')
+		}
+        }
+        else {
+            res.status(503).send('permission denied')
+        }
+    })
+
+    app.use(express.static('public'));
+
+
+    let socketPath = 3030
+    app.listen(socketPath, () => {
+        console.log(`Express GraphQL Server Now Running On ${socketPath}/graphql`);
+        //fs.chmodSync(socketPath, '777');
+    });
+})()
+
+process.on('uncaughtException', (error) => {
+	console.log('UNCAUGHT EXCEPTION', error)
+})
+

binární
libssl1.1_1.1.1f-1ubuntu2_amd64.deb


+ 261 - 0
models.js

@@ -0,0 +1,261 @@
+const ObjectID    = require("mongodb").ObjectID;
+const {connect}   = require('mm')
+
+module.exports = async (dbName='shop-roles') => {
+    const {Savable, slice} = await connect(dbName)
+
+    async function getModels({id, acl}){
+        const SlicedSavable = slice(id === 'anon' ? [id] : [...acl])
+
+        class User extends SlicedSavable {
+            constructor(...params){
+                super(...params)
+
+                this.originalACL = this.acl && [...this.acl]
+            }
+
+            async save(...params){
+                console.log(this)
+                let otherUserWithThisLogin = this.login && await Savable.m.User.findOne({login: this.login})
+                if (this._id){
+                    if (otherUserWithThisLogin && otherUserWithThisLogin._id.toString() !== this._id.toString()){
+                        throw new ReferenceError(`User ${this.login} already exists`)
+                    }
+                    if (!acl.includes('admin') && this.originalACL.toString() !== this.acl.toString())
+                        throw new ReferenceError(`Not enough permissions for changing acl on ${this.login}`)
+                    else return await super.save(...params)
+                }
+                else {
+                    if (otherUserWithThisLogin){
+                        throw new ReferenceError(`User ${this.login} already exists`)
+                    }
+                    await super.save(...params)
+                    this.___owner = this._id.toString()
+                    this.acl      = [this.___owner, "user"]
+                    return await Savable.prototype.save.call(this, ...params)
+                }
+            }
+
+            static get relations(){ //don't needed due to ___owner in most cases
+                return {
+                    avatar : "userAvatar",
+                }
+            }
+
+            static get defaultPermissions(){
+                return {
+                    create: ['anon'],
+                    read: ['owner', 'user', 'admin'],
+                    write: ['owner', 'admin'],
+                    delete: []
+                }
+            }
+
+            async getACL(){
+                return [this._id.toString(), "user"]
+            }
+        }
+        SlicedSavable.addClass(User)
+
+        class OwnerSlicedSavable extends SlicedSavable {
+            get owner(){
+                if (!this.___owner) return this.___owner
+
+                return SlicedSavable.m.User.findOne({_id: ObjectID(this.___owner)})
+            }
+        }
+
+
+        class Image extends OwnerSlicedSavable {
+            constructor(...params){
+                super(...params)
+            }
+
+
+            static async fromFileData(fileData){
+		    if (!fileData) return
+                let image  = new Image({})
+                image.fileData = fileData
+                image.url      = `images/${fileData.filename}`
+                image.originalFileName = fileData.originalname
+                await image.save()
+                return image;
+            }
+
+            async save(...params){
+                if (this.userAvatar){
+                    if (this.userAvatar._id.toString() !== id){
+                        throw new ReferenceError(`You can't set ava for other user`)
+                    }
+                }
+
+                return await super.save(...params)
+            }
+
+            static get relations(){
+                return {
+                    userAvatar: "avatar", //if it is ava
+                    good: ["images"], //if it is ava
+                    category: "image", //if it is ava
+                }
+            }
+
+            static get defaultPermissions(){
+                return {
+                    create: ['user', 'admin'],
+                    read: ['anon', 'user', 'admin'],
+                    write: ['admin'],
+                    delete: ['admin']
+                }
+            }
+
+        }
+        SlicedSavable.addClass(Image)
+
+        class Good extends OwnerSlicedSavable {
+            constructor(...params){
+                super(...params)
+            }
+
+            static get relations(){
+                return {
+                    categories: ["goods"],
+                    orderGoods: "good",
+                    images: "good"
+                }
+            }
+
+            static get defaultPermissions(){
+                return {
+                    create: ['admin'],
+                    read: ['anon', 'user', 'admin'],
+                    write: ['admin'],
+                    delete: ['admin']
+                }
+            }
+
+            static get guestRelations(){
+                return ['orderGoods']
+            }
+        }
+        SlicedSavable.addClass(Good)
+
+        class Category extends SlicedSavable {
+            constructor(...params){
+                super(...params)
+            }
+
+            static get relations(){
+                return {
+                    goods: ["categories"],
+                    image: "category",
+                    parent: ["subCategories"],
+                    subCategories: "parent"
+                }
+            }
+
+            static get defaultPermissions(){
+                return {
+                    create: ['admin'],
+                    read: ['anon', 'user', 'admin'],
+                    write: ['admin'],
+                    delete: ['admin']
+                }
+            }
+        }
+        SlicedSavable.addClass(Category)
+
+        class Order extends OwnerSlicedSavable {
+            constructor(...params){
+                super(...params)
+            }
+
+            get total(){
+                return (async() => (await Promise.all(this.orderGoods)).reduce((a,b) => (a.total || a) + b.total, 0))()
+            }
+
+            static get relations(){
+                return {
+                    orderGoods: "order"
+                }
+            }
+
+
+            static get defaultPermissions(){
+                return {
+                    //savable refs, objectid's, words like 'tags' or 'roles'
+                    read:   ['owner', 'admin'],
+                    write:  ['owner', 'admin'],
+                    create: ['user'],
+                    delete: [],
+
+                    /*permission
+                     * TODO: permissions for read and write permissions
+                     *
+                     */
+                }
+            }
+        }
+        SlicedSavable.addClass(Order)
+
+        class OrderGood extends OwnerSlicedSavable {
+            constructor(...params){
+                super(...params)
+            }
+
+            get total(){
+                return this.price*this.count
+            }
+
+            async save(...params){
+                if (!this.price && this.good && this.good.price){
+                    this.price = this.good.price
+                }
+                return await super.save(...params)
+            }
+
+            static get relations(){
+                return {
+                    good: ["orderGoods"],
+                    order: ["orderGoods"]
+                }
+            }
+
+
+            static get defaultPermissions(){
+                return {
+                    //savable refs, objectid's, words like 'tags' or 'roles'
+                    read:   ['owner', 'admin'],
+                    write:  ['owner', 'admin'],
+                    create: ['user'],
+                    delete: [],
+
+                    /*permission
+                     * TODO: permissions for read and write permissions
+                     *
+                     */
+                }
+            }
+        }
+        SlicedSavable.addClass(OrderGood)
+
+
+
+        const thisUser = id !== 'anon' && await Savable.m.User.findOne({_id: ObjectID(id)})
+
+
+
+        return {models: {
+                            SlicedSavable, ...SlicedSavable.classes
+                        }, 
+                thisUser}
+    }
+
+    return {
+        Savable, 
+        slice,
+        getModels
+    }
+}
+
+

binární
mongodb-compass_1.26.1_amd64.deb


binární
mongodb-compass_1.35.0_amd64.deb


+ 1 - 0
node_modules/.bin/mime

@@ -0,0 +1 @@
+../mime/cli.js

+ 1 - 0
node_modules/.bin/mkdirp

@@ -0,0 +1 @@
+../mkdirp/bin/cmd.js

+ 1 - 0
node_modules/.bin/semver

@@ -0,0 +1 @@
+../semver/bin/semver

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1099 - 0
node_modules/.package-lock.json


+ 243 - 0
node_modules/accepts/HISTORY.md

@@ -0,0 +1,243 @@
+1.3.8 / 2022-02-02
+==================
+
+  * deps: mime-types@~2.1.34
+    - deps: mime-db@~1.51.0
+  * deps: negotiator@0.6.3
+
+1.3.7 / 2019-04-29
+==================
+
+  * deps: negotiator@0.6.2
+    - Fix sorting charset, encoding, and language with extra parameters
+
+1.3.6 / 2019-04-28
+==================
+
+  * deps: mime-types@~2.1.24
+    - deps: mime-db@~1.40.0
+
+1.3.5 / 2018-02-28
+==================
+
+  * deps: mime-types@~2.1.18
+    - deps: mime-db@~1.33.0
+
+1.3.4 / 2017-08-22
+==================
+
+  * deps: mime-types@~2.1.16
+    - deps: mime-db@~1.29.0
+
+1.3.3 / 2016-05-02
+==================
+
+  * deps: mime-types@~2.1.11
+    - deps: mime-db@~1.23.0
+  * deps: negotiator@0.6.1
+    - perf: improve `Accept` parsing speed
+    - perf: improve `Accept-Charset` parsing speed
+    - perf: improve `Accept-Encoding` parsing speed
+    - perf: improve `Accept-Language` parsing speed
+
+1.3.2 / 2016-03-08
+==================
+
+  * deps: mime-types@~2.1.10
+    - Fix extension of `application/dash+xml`
+    - Update primary extension for `audio/mp4`
+    - deps: mime-db@~1.22.0
+
+1.3.1 / 2016-01-19
+==================
+
+  * deps: mime-types@~2.1.9
+    - deps: mime-db@~1.21.0
+
+1.3.0 / 2015-09-29
+==================
+
+  * deps: mime-types@~2.1.7
+    - deps: mime-db@~1.19.0
+  * deps: negotiator@0.6.0
+    - Fix including type extensions in parameters in `Accept` parsing
+    - Fix parsing `Accept` parameters with quoted equals
+    - Fix parsing `Accept` parameters with quoted semicolons
+    - Lazy-load modules from main entry point
+    - perf: delay type concatenation until needed
+    - perf: enable strict mode
+    - perf: hoist regular expressions
+    - perf: remove closures getting spec properties
+    - perf: remove a closure from media type parsing
+    - perf: remove property delete from media type parsing
+
+1.2.13 / 2015-09-06
+===================
+
+  * deps: mime-types@~2.1.6
+    - deps: mime-db@~1.18.0
+
+1.2.12 / 2015-07-30
+===================
+
+  * deps: mime-types@~2.1.4
+    - deps: mime-db@~1.16.0
+
+1.2.11 / 2015-07-16
+===================
+
+  * deps: mime-types@~2.1.3
+    - deps: mime-db@~1.15.0
+
+1.2.10 / 2015-07-01
+===================
+
+  * deps: mime-types@~2.1.2
+    - deps: mime-db@~1.14.0
+
+1.2.9 / 2015-06-08
+==================
+
+  * deps: mime-types@~2.1.1
+    - perf: fix deopt during mapping
+
+1.2.8 / 2015-06-07
+==================
+
+  * deps: mime-types@~2.1.0
+    - deps: mime-db@~1.13.0
+  * perf: avoid argument reassignment & argument slice
+  * perf: avoid negotiator recursive construction
+  * perf: enable strict mode
+  * perf: remove unnecessary bitwise operator
+
+1.2.7 / 2015-05-10
+==================
+
+  * deps: negotiator@0.5.3
+    - Fix media type parameter matching to be case-insensitive
+
+1.2.6 / 2015-05-07
+==================
+
+  * deps: mime-types@~2.0.11
+    - deps: mime-db@~1.9.1
+  * deps: negotiator@0.5.2
+    - Fix comparing media types with quoted values
+    - Fix splitting media types with quoted commas
+
+1.2.5 / 2015-03-13
+==================
+
+  * deps: mime-types@~2.0.10
+    - deps: mime-db@~1.8.0
+
+1.2.4 / 2015-02-14
+==================
+
+  * Support Node.js 0.6
+  * deps: mime-types@~2.0.9
+    - deps: mime-db@~1.7.0
+  * deps: negotiator@0.5.1
+    - Fix preference sorting to be stable for long acceptable lists
+
+1.2.3 / 2015-01-31
+==================
+
+  * deps: mime-types@~2.0.8
+    - deps: mime-db@~1.6.0
+
+1.2.2 / 2014-12-30
+==================
+
+  * deps: mime-types@~2.0.7
+    - deps: mime-db@~1.5.0
+
+1.2.1 / 2014-12-30
+==================
+
+  * deps: mime-types@~2.0.5
+    - deps: mime-db@~1.3.1
+
+1.2.0 / 2014-12-19
+==================
+
+  * deps: negotiator@0.5.0
+    - Fix list return order when large accepted list
+    - Fix missing identity encoding when q=0 exists
+    - Remove dynamic building of Negotiator class
+
+1.1.4 / 2014-12-10
+==================
+
+  * deps: mime-types@~2.0.4
+    - deps: mime-db@~1.3.0
+
+1.1.3 / 2014-11-09
+==================
+
+  * deps: mime-types@~2.0.3
+    - deps: mime-db@~1.2.0
+
+1.1.2 / 2014-10-14
+==================
+
+  * deps: negotiator@0.4.9
+    - Fix error when media type has invalid parameter
+
+1.1.1 / 2014-09-28
+==================
+
+  * deps: mime-types@~2.0.2
+    - deps: mime-db@~1.1.0
+  * deps: negotiator@0.4.8
+    - Fix all negotiations to be case-insensitive
+    - Stable sort preferences of same quality according to client order
+
+1.1.0 / 2014-09-02
+==================
+
+  * update `mime-types`
+
+1.0.7 / 2014-07-04
+==================
+
+  * Fix wrong type returned from `type` when match after unknown extension
+
+1.0.6 / 2014-06-24
+==================
+
+  * deps: negotiator@0.4.7
+
+1.0.5 / 2014-06-20
+==================
+
+ * fix crash when unknown extension given
+
+1.0.4 / 2014-06-19
+==================
+
+  * use `mime-types`
+
+1.0.3 / 2014-06-11
+==================
+
+  * deps: negotiator@0.4.6
+    - Order by specificity when quality is the same
+
+1.0.2 / 2014-05-29
+==================
+
+  * Fix interpretation when header not in request
+  * deps: pin negotiator@0.4.5
+
+1.0.1 / 2014-01-18
+==================
+
+  * Identity encoding isn't always acceptable
+  * deps: negotiator@~0.4.0
+
+1.0.0 / 2013-12-27
+==================
+
+  * Genesis

+ 23 - 0
node_modules/accepts/LICENSE

@@ -0,0 +1,23 @@
+(The MIT License)
+
+Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
+Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
+
+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.

+ 140 - 0
node_modules/accepts/README.md

@@ -0,0 +1,140 @@
+# accepts
+
+[![NPM Version][npm-version-image]][npm-url]
+[![NPM Downloads][npm-downloads-image]][npm-url]
+[![Node.js Version][node-version-image]][node-version-url]
+[![Build Status][github-actions-ci-image]][github-actions-ci-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
+
+Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
+Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
+
+In addition to negotiator, it allows:
+
+- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
+  as well as `('text/html', 'application/json')`.
+- Allows type shorthands such as `json`.
+- Returns `false` when no types match
+- Treats non-existent headers as `*`
+
+## Installation
+
+This is a [Node.js](https://nodejs.org/en/) module available through the
+[npm registry](https://www.npmjs.com/). Installation is done using the
+[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
+
+```sh
+$ npm install accepts
+```
+
+## API
+
+```js
+var accepts = require('accepts')
+```
+
+### accepts(req)
+
+Create a new `Accepts` object for the given `req`.
+
+#### .charset(charsets)
+
+Return the first accepted charset. If nothing in `charsets` is accepted,
+then `false` is returned.
+
+#### .charsets()
+
+Return the charsets that the request accepts, in the order of the client's
+preference (most preferred first).
+
+#### .encoding(encodings)
+
+Return the first accepted encoding. If nothing in `encodings` is accepted,
+then `false` is returned.
+
+#### .encodings()
+
+Return the encodings that the request accepts, in the order of the client's
+preference (most preferred first).
+
+#### .language(languages)
+
+Return the first accepted language. If nothing in `languages` is accepted,
+then `false` is returned.
+
+#### .languages()
+
+Return the languages that the request accepts, in the order of the client's
+preference (most preferred first).
+
+#### .type(types)
+
+Return the first accepted type (and it is returned as the same text as what
+appears in the `types` array). If nothing in `types` is accepted, then `false`
+is returned.
+
+The `types` array can contain full MIME types or file extensions. Any value
+that is not a full MIME types is passed to `require('mime-types').lookup`.
+
+#### .types()
+
+Return the types that the request accepts, in the order of the client's
+preference (most preferred first).
+
+## Examples
+
+### Simple type negotiation
+
+This simple example shows how to use `accepts` to return a different typed
+respond body based on what the client wants to accept. The server lists it's
+preferences in order and will get back the best match between the client and
+server.
+
+```js
+var accepts = require('accepts')
+var http = require('http')
+
+function app (req, res) {
+  var accept = accepts(req)
+
+  // the order of this list is significant; should be server preferred order
+  switch (accept.type(['json', 'html'])) {
+    case 'json':
+      res.setHeader('Content-Type', 'application/json')
+      res.write('{"hello":"world!"}')
+      break
+    case 'html':
+      res.setHeader('Content-Type', 'text/html')
+      res.write('<b>hello, world!</b>')
+      break
+    default:
+      // the fallback is text/plain, so no need to specify it above
+      res.setHeader('Content-Type', 'text/plain')
+      res.write('hello, world!')
+      break
+  }
+
+  res.end()
+}
+
+http.createServer(app).listen(3000)
+```
+
+You can test this out with the cURL program:
+```sh
+curl -I -H'Accept: text/html' http://localhost:3000/
+```
+
+## License
+
+[MIT](LICENSE)
+
+[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
+[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
+[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci
+[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml
+[node-version-image]: https://badgen.net/npm/node/accepts
+[node-version-url]: https://nodejs.org/en/download
+[npm-downloads-image]: https://badgen.net/npm/dm/accepts
+[npm-url]: https://npmjs.org/package/accepts
+[npm-version-image]: https://badgen.net/npm/v/accepts

+ 238 - 0
node_modules/accepts/index.js

@@ -0,0 +1,238 @@
+/*!
+ * accepts
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var Negotiator = require('negotiator')
+var mime = require('mime-types')
+
+/**
+ * Module exports.
+ * @public
+ */
+
+module.exports = Accepts
+
+/**
+ * Create a new Accepts object for the given req.
+ *
+ * @param {object} req
+ * @public
+ */
+
+function Accepts (req) {
+  if (!(this instanceof Accepts)) {
+    return new Accepts(req)
+  }
+
+  this.headers = req.headers
+  this.negotiator = new Negotiator(req)
+}
+
+/**
+ * Check if the given `type(s)` is acceptable, returning
+ * the best match when true, otherwise `undefined`, in which
+ * case you should respond with 406 "Not Acceptable".
+ *
+ * The `type` value may be a single mime type string
+ * such as "application/json", the extension name
+ * such as "json" or an array `["json", "html", "text/plain"]`. When a list
+ * or array is given the _best_ match, if any is returned.
+ *
+ * Examples:
+ *
+ *     // Accept: text/html
+ *     this.types('html');
+ *     // => "html"
+ *
+ *     // Accept: text/*, application/json
+ *     this.types('html');
+ *     // => "html"
+ *     this.types('text/html');
+ *     // => "text/html"
+ *     this.types('json', 'text');
+ *     // => "json"
+ *     this.types('application/json');
+ *     // => "application/json"
+ *
+ *     // Accept: text/*, application/json
+ *     this.types('image/png');
+ *     this.types('png');
+ *     // => undefined
+ *
+ *     // Accept: text/*;q=.5, application/json
+ *     this.types(['html', 'json']);
+ *     this.types('html', 'json');
+ *     // => "json"
+ *
+ * @param {String|Array} types...
+ * @return {String|Array|Boolean}
+ * @public
+ */
+
+Accepts.prototype.type =
+Accepts.prototype.types = function (types_) {
+  var types = types_
+
+  // support flattened arguments
+  if (types && !Array.isArray(types)) {
+    types = new Array(arguments.length)
+    for (var i = 0; i < types.length; i++) {
+      types[i] = arguments[i]
+    }
+  }
+
+  // no types, return all requested types
+  if (!types || types.length === 0) {
+    return this.negotiator.mediaTypes()
+  }
+
+  // no accept header, return first given type
+  if (!this.headers.accept) {
+    return types[0]
+  }
+
+  var mimes = types.map(extToMime)
+  var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
+  var first = accepts[0]
+
+  return first
+    ? types[mimes.indexOf(first)]
+    : false
+}
+
+/**
+ * Return accepted encodings or best fit based on `encodings`.
+ *
+ * Given `Accept-Encoding: gzip, deflate`
+ * an array sorted by quality is returned:
+ *
+ *     ['gzip', 'deflate']
+ *
+ * @param {String|Array} encodings...
+ * @return {String|Array}
+ * @public
+ */
+
+Accepts.prototype.encoding =
+Accepts.prototype.encodings = function (encodings_) {
+  var encodings = encodings_
+
+  // support flattened arguments
+  if (encodings && !Array.isArray(encodings)) {
+    encodings = new Array(arguments.length)
+    for (var i = 0; i < encodings.length; i++) {
+      encodings[i] = arguments[i]
+    }
+  }
+
+  // no encodings, return all requested encodings
+  if (!encodings || encodings.length === 0) {
+    return this.negotiator.encodings()
+  }
+
+  return this.negotiator.encodings(encodings)[0] || false
+}
+
+/**
+ * Return accepted charsets or best fit based on `charsets`.
+ *
+ * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
+ * an array sorted by quality is returned:
+ *
+ *     ['utf-8', 'utf-7', 'iso-8859-1']
+ *
+ * @param {String|Array} charsets...
+ * @return {String|Array}
+ * @public
+ */
+
+Accepts.prototype.charset =
+Accepts.prototype.charsets = function (charsets_) {
+  var charsets = charsets_
+
+  // support flattened arguments
+  if (charsets && !Array.isArray(charsets)) {
+    charsets = new Array(arguments.length)
+    for (var i = 0; i < charsets.length; i++) {
+      charsets[i] = arguments[i]
+    }
+  }
+
+  // no charsets, return all requested charsets
+  if (!charsets || charsets.length === 0) {
+    return this.negotiator.charsets()
+  }
+
+  return this.negotiator.charsets(charsets)[0] || false
+}
+
+/**
+ * Return accepted languages or best fit based on `langs`.
+ *
+ * Given `Accept-Language: en;q=0.8, es, pt`
+ * an array sorted by quality is returned:
+ *
+ *     ['es', 'pt', 'en']
+ *
+ * @param {String|Array} langs...
+ * @return {Array|String}
+ * @public
+ */
+
+Accepts.prototype.lang =
+Accepts.prototype.langs =
+Accepts.prototype.language =
+Accepts.prototype.languages = function (languages_) {
+  var languages = languages_
+
+  // support flattened arguments
+  if (languages && !Array.isArray(languages)) {
+    languages = new Array(arguments.length)
+    for (var i = 0; i < languages.length; i++) {
+      languages[i] = arguments[i]
+    }
+  }
+
+  // no languages, return all requested languages
+  if (!languages || languages.length === 0) {
+    return this.negotiator.languages()
+  }
+
+  return this.negotiator.languages(languages)[0] || false
+}
+
+/**
+ * Convert extnames to mime.
+ *
+ * @param {String} type
+ * @return {String}
+ * @private
+ */
+
+function extToMime (type) {
+  return type.indexOf('/') === -1
+    ? mime.lookup(type)
+    : type
+}
+
+/**
+ * Check if mime is valid.
+ *
+ * @param {String} type
+ * @return {String}
+ * @private
+ */
+
+function validMime (type) {
+  return typeof type === 'string'
+}

+ 47 - 0
node_modules/accepts/package.json

@@ -0,0 +1,47 @@
+{
+  "name": "accepts",
+  "description": "Higher-level content negotiation",
+  "version": "1.3.8",
+  "contributors": [
+    "Douglas Christopher Wilson <doug@somethingdoug.com>",
+    "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
+  ],
+  "license": "MIT",
+  "repository": "jshttp/accepts",
+  "dependencies": {
+    "mime-types": "~2.1.34",
+    "negotiator": "0.6.3"
+  },
+  "devDependencies": {
+    "deep-equal": "1.0.1",
+    "eslint": "7.32.0",
+    "eslint-config-standard": "14.1.1",
+    "eslint-plugin-import": "2.25.4",
+    "eslint-plugin-markdown": "2.2.1",
+    "eslint-plugin-node": "11.1.0",
+    "eslint-plugin-promise": "4.3.1",
+    "eslint-plugin-standard": "4.1.0",
+    "mocha": "9.2.0",
+    "nyc": "15.1.0"
+  },
+  "files": [
+    "LICENSE",
+    "HISTORY.md",
+    "index.js"
+  ],
+  "engines": {
+    "node": ">= 0.6"
+  },
+  "scripts": {
+    "lint": "eslint .",
+    "test": "mocha --reporter spec --check-leaks --bail test/",
+    "test-ci": "nyc --reporter=lcov --reporter=text npm test",
+    "test-cov": "nyc --reporter=html --reporter=text npm test"
+  },
+  "keywords": [
+    "content",
+    "negotiation",
+    "accept",
+    "accepts"
+  ]
+}

+ 1 - 0
node_modules/append-field/.npmignore

@@ -0,0 +1 @@
+node_modules/

+ 21 - 0
node_modules/append-field/LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Linus Unnebäck
+
+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.

+ 44 - 0
node_modules/append-field/README.md

@@ -0,0 +1,44 @@
+# `append-field`
+
+A [W3C HTML JSON forms spec](http://www.w3.org/TR/html-json-forms/) compliant
+field appender (for lack of a better name). Useful for people implementing
+`application/x-www-form-urlencoded` and `multipart/form-data` parsers.
+
+It works best on objects created with `Object.create(null)`. Otherwise it might
+conflict with variables from the prototype (e.g. `hasOwnProperty`).
+
+## Installation
+
+```sh
+npm install --save append-field
+```
+
+## Usage
+
+```javascript
+var appendField = require('append-field')
+var obj = Object.create(null)
+
+appendField(obj, 'pets[0][species]', 'Dahut')
+appendField(obj, 'pets[0][name]', 'Hypatia')
+appendField(obj, 'pets[1][species]', 'Felis Stultus')
+appendField(obj, 'pets[1][name]', 'Billie')
+
+console.log(obj)
+```
+
+```text
+{ pets:
+   [ { species: 'Dahut', name: 'Hypatia' },
+     { species: 'Felis Stultus', name: 'Billie' } ] }
+```
+
+## API
+
+### `appendField(store, key, value)`
+
+Adds the field named `key` with the value `value` to the object `store`.
+
+## License
+
+MIT

+ 12 - 0
node_modules/append-field/index.js

@@ -0,0 +1,12 @@
+var parsePath = require('./lib/parse-path')
+var setValue = require('./lib/set-value')
+
+function appendField (store, key, value) {
+  var steps = parsePath(key)
+
+  steps.reduce(function (context, step) {
+    return setValue(context, step, context[step.key], value)
+  }, store)
+}
+
+module.exports = appendField

+ 53 - 0
node_modules/append-field/lib/parse-path.js

@@ -0,0 +1,53 @@
+var reFirstKey = /^[^\[]*/
+var reDigitPath = /^\[(\d+)\]/
+var reNormalPath = /^\[([^\]]+)\]/
+
+function parsePath (key) {
+  function failure () {
+    return [{ type: 'object', key: key, last: true }]
+  }
+
+  var firstKey = reFirstKey.exec(key)[0]
+  if (!firstKey) return failure()
+
+  var len = key.length
+  var pos = firstKey.length
+  var tail = { type: 'object', key: firstKey }
+  var steps = [tail]
+
+  while (pos < len) {
+    var m
+
+    if (key[pos] === '[' && key[pos + 1] === ']') {
+      pos += 2
+      tail.append = true
+      if (pos !== len) return failure()
+      continue
+    }
+
+    m = reDigitPath.exec(key.substring(pos))
+    if (m !== null) {
+      pos += m[0].length
+      tail.nextType = 'array'
+      tail = { type: 'array', key: parseInt(m[1], 10) }
+      steps.push(tail)
+      continue
+    }
+
+    m = reNormalPath.exec(key.substring(pos))
+    if (m !== null) {
+      pos += m[0].length
+      tail.nextType = 'object'
+      tail = { type: 'object', key: m[1] }
+      steps.push(tail)
+      continue
+    }
+
+    return failure()
+  }
+
+  tail.last = true
+  return steps
+}
+
+module.exports = parsePath

+ 64 - 0
node_modules/append-field/lib/set-value.js

@@ -0,0 +1,64 @@
+function valueType (value) {
+  if (value === undefined) return 'undefined'
+  if (Array.isArray(value)) return 'array'
+  if (typeof value === 'object') return 'object'
+  return 'scalar'
+}
+
+function setLastValue (context, step, currentValue, entryValue) {
+  switch (valueType(currentValue)) {
+    case 'undefined':
+      if (step.append) {
+        context[step.key] = [entryValue]
+      } else {
+        context[step.key] = entryValue
+      }
+      break
+    case 'array':
+      context[step.key].push(entryValue)
+      break
+    case 'object':
+      return setLastValue(currentValue, { type: 'object', key: '', last: true }, currentValue[''], entryValue)
+    case 'scalar':
+      context[step.key] = [context[step.key], entryValue]
+      break
+  }
+
+  return context
+}
+
+function setValue (context, step, currentValue, entryValue) {
+  if (step.last) return setLastValue(context, step, currentValue, entryValue)
+
+  var obj
+  switch (valueType(currentValue)) {
+    case 'undefined':
+      if (step.nextType === 'array') {
+        context[step.key] = []
+      } else {
+        context[step.key] = Object.create(null)
+      }
+      return context[step.key]
+    case 'object':
+      return context[step.key]
+    case 'array':
+      if (step.nextType === 'array') {
+        return currentValue
+      }
+
+      obj = Object.create(null)
+      context[step.key] = obj
+      currentValue.forEach(function (item, i) {
+        if (item !== undefined) obj['' + i] = item
+      })
+
+      return obj
+    case 'scalar':
+      obj = Object.create(null)
+      obj[''] = currentValue
+      context[step.key] = obj
+      return obj
+  }
+}
+
+module.exports = setValue

+ 19 - 0
node_modules/append-field/package.json

@@ -0,0 +1,19 @@
+{
+  "name": "append-field",
+  "version": "1.0.0",
+  "license": "MIT",
+  "author": "Linus Unnebäck <linus@folkdatorn.se>",
+  "main": "index.js",
+  "devDependencies": {
+    "mocha": "^2.2.4",
+    "standard": "^6.0.5",
+    "testdata-w3c-json-form": "^0.2.0"
+  },
+  "scripts": {
+    "test": "standard && mocha"
+  },
+  "repository": {
+    "type": "git",
+    "url": "http://github.com/LinusU/node-append-field.git"
+  }
+}

+ 19 - 0
node_modules/append-field/test/forms.js

@@ -0,0 +1,19 @@
+/* eslint-env mocha */
+
+var assert = require('assert')
+var appendField = require('../')
+var testData = require('testdata-w3c-json-form')
+
+describe('Append Field', function () {
+  for (var test of testData) {
+    it('handles ' + test.name, function () {
+      var store = Object.create(null)
+
+      for (var field of test.fields) {
+        appendField(store, field.key, field.value)
+      }
+
+      assert.deepEqual(store, test.expected)
+    })
+  }
+})

+ 21 - 0
node_modules/array-flatten/LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
+
+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.

+ 43 - 0
node_modules/array-flatten/README.md

@@ -0,0 +1,43 @@
+# Array Flatten
+
+[![NPM version][npm-image]][npm-url]
+[![NPM downloads][downloads-image]][downloads-url]
+[![Build status][travis-image]][travis-url]
+[![Test coverage][coveralls-image]][coveralls-url]
+
+> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
+
+## Installation
+
+```
+npm install array-flatten --save
+```
+
+## Usage
+
+```javascript
+var flatten = require('array-flatten')
+
+flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
+//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
+
+flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
+//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
+
+(function () {
+  flatten(arguments) //=> [1, 2, 3]
+})(1, [2, 3])
+```
+
+## License
+
+MIT
+
+[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
+[npm-url]: https://npmjs.org/package/array-flatten
+[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
+[downloads-url]: https://npmjs.org/package/array-flatten
+[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
+[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
+[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
+[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master

+ 64 - 0
node_modules/array-flatten/array-flatten.js

@@ -0,0 +1,64 @@
+'use strict'
+
+/**
+ * Expose `arrayFlatten`.
+ */
+module.exports = arrayFlatten
+
+/**
+ * Recursive flatten function with depth.
+ *
+ * @param  {Array}  array
+ * @param  {Array}  result
+ * @param  {Number} depth
+ * @return {Array}
+ */
+function flattenWithDepth (array, result, depth) {
+  for (var i = 0; i < array.length; i++) {
+    var value = array[i]
+
+    if (depth > 0 && Array.isArray(value)) {
+      flattenWithDepth(value, result, depth - 1)
+    } else {
+      result.push(value)
+    }
+  }
+
+  return result
+}
+
+/**
+ * Recursive flatten function. Omitting depth is slightly faster.
+ *
+ * @param  {Array} array
+ * @param  {Array} result
+ * @return {Array}
+ */
+function flattenForever (array, result) {
+  for (var i = 0; i < array.length; i++) {
+    var value = array[i]
+
+    if (Array.isArray(value)) {
+      flattenForever(value, result)
+    } else {
+      result.push(value)
+    }
+  }
+
+  return result
+}
+
+/**
+ * Flatten an array, with the ability to define a depth.
+ *
+ * @param  {Array}  array
+ * @param  {Number} depth
+ * @return {Array}
+ */
+function arrayFlatten (array, depth) {
+  if (depth == null) {
+    return flattenForever(array, [])
+  }
+
+  return flattenWithDepth(array, [], depth)
+}

+ 39 - 0
node_modules/array-flatten/package.json

@@ -0,0 +1,39 @@
+{
+  "name": "array-flatten",
+  "version": "1.1.1",
+  "description": "Flatten an array of nested arrays into a single flat array",
+  "main": "array-flatten.js",
+  "files": [
+    "array-flatten.js",
+    "LICENSE"
+  ],
+  "scripts": {
+    "test": "istanbul cover _mocha -- -R spec"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/blakeembrey/array-flatten.git"
+  },
+  "keywords": [
+    "array",
+    "flatten",
+    "arguments",
+    "depth"
+  ],
+  "author": {
+    "name": "Blake Embrey",
+    "email": "hello@blakeembrey.com",
+    "url": "http://blakeembrey.me"
+  },
+  "license": "MIT",
+  "bugs": {
+    "url": "https://github.com/blakeembrey/array-flatten/issues"
+  },
+  "homepage": "https://github.com/blakeembrey/array-flatten",
+  "devDependencies": {
+    "istanbul": "^0.3.13",
+    "mocha": "^2.2.4",
+    "pre-commit": "^1.0.7",
+    "standard": "^3.7.3"
+  }
+}

+ 60 - 0
node_modules/bl/.jshintrc

@@ -0,0 +1,60 @@
+{
+    "predef": [ ]
+  , "bitwise": false
+  , "camelcase": false
+  , "curly": false
+  , "eqeqeq": false
+  , "forin": false
+  , "immed": false
+  , "latedef": false
+  , "noarg": true
+  , "noempty": true
+  , "nonew": true
+  , "plusplus": false
+  , "quotmark": true
+  , "regexp": false
+  , "undef": true
+  , "unused": true
+  , "strict": false
+  , "trailing": true
+  , "maxlen": 120
+  , "asi": true
+  , "boss": true
+  , "debug": true
+  , "eqnull": true
+  , "esnext": false
+  , "evil": true
+  , "expr": true
+  , "funcscope": false
+  , "globalstrict": false
+  , "iterator": false
+  , "lastsemic": true
+  , "laxbreak": true
+  , "laxcomma": true
+  , "loopfunc": true
+  , "multistr": false
+  , "onecase": false
+  , "proto": false
+  , "regexdash": false
+  , "scripturl": true
+  , "smarttabs": false
+  , "shadow": false
+  , "sub": true
+  , "supernew": false
+  , "validthis": true
+  , "browser": true
+  , "couch": false
+  , "devel": false
+  , "dojo": false
+  , "mootools": false
+  , "node": true
+  , "nonstandard": true
+  , "prototypejs": false
+  , "rhino": false
+  , "worker": true
+  , "wsh": false
+  , "nomen": false
+  , "onevar": false
+  , "passfail": false
+  , "esversion": 3
+}

+ 15 - 0
node_modules/bl/.travis.yml

@@ -0,0 +1,15 @@
+sudo: false
+language: node_js
+node_js:
+  - '4'
+  - '6'
+  - '8'
+  - '9'
+  - '10'
+branches:
+  only:
+    - master
+notifications:
+  email:
+    - rod@vagg.org
+    - matteo.collina@gmail.com

+ 13 - 0
node_modules/bl/LICENSE.md

@@ -0,0 +1,13 @@
+The MIT License (MIT)
+=====================
+
+Copyright (c) 2013-2018 bl contributors
+----------------------------------
+
+*bl contributors listed at <https://github.com/rvagg/bl#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.

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 218 - 0
node_modules/bl/README.md


+ 392 - 0
node_modules/bl/bl.js

@@ -0,0 +1,392 @@
+'use strict'
+var DuplexStream = require('readable-stream').Duplex
+  , util         = require('util')
+  , Buffer       = require('safe-buffer').Buffer
+
+function BufferList (callback) {
+  if (!(this instanceof BufferList))
+    return new BufferList(callback)
+
+  this._bufs  = []
+  this.length = 0
+
+  if (typeof callback == 'function') {
+    this._callback = callback
+
+    var piper = function piper (err) {
+      if (this._callback) {
+        this._callback(err)
+        this._callback = null
+      }
+    }.bind(this)
+
+    this.on('pipe', function onPipe (src) {
+      src.on('error', piper)
+    })
+    this.on('unpipe', function onUnpipe (src) {
+      src.removeListener('error', piper)
+    })
+  } else {
+    this.append(callback)
+  }
+
+  DuplexStream.call(this)
+}
+
+
+util.inherits(BufferList, DuplexStream)
+
+
+BufferList.prototype._offset = function _offset (offset) {
+  var tot = 0, i = 0, _t
+  if (offset === 0) return [ 0, 0 ]
+  for (; i < this._bufs.length; i++) {
+    _t = tot + this._bufs[i].length
+    if (offset < _t || i == this._bufs.length - 1) {
+      return [ i, offset - tot ]
+    }
+    tot = _t
+  }
+}
+
+BufferList.prototype._reverseOffset = function (blOffset) {
+  var bufferId = blOffset[0]
+  var offset = blOffset[1]
+  for (var i = 0; i < bufferId; i++) {
+    offset += this._bufs[i].length
+  }
+  return offset
+}
+
+BufferList.prototype.append = function append (buf) {
+  var i = 0
+
+  if (Buffer.isBuffer(buf)) {
+    this._appendBuffer(buf)
+  } else if (Array.isArray(buf)) {
+    for (; i < buf.length; i++)
+      this.append(buf[i])
+  } else if (buf instanceof BufferList) {
+    // unwrap argument into individual BufferLists
+    for (; i < buf._bufs.length; i++)
+      this.append(buf._bufs[i])
+  } else if (buf != null) {
+    // coerce number arguments to strings, since Buffer(number) does
+    // uninitialized memory allocation
+    if (typeof buf == 'number')
+      buf = buf.toString()
+
+    this._appendBuffer(Buffer.from(buf))
+  }
+
+  return this
+}
+
+
+BufferList.prototype._appendBuffer = function appendBuffer (buf) {
+  this._bufs.push(buf)
+  this.length += buf.length
+}
+
+
+BufferList.prototype._write = function _write (buf, encoding, callback) {
+  this._appendBuffer(buf)
+
+  if (typeof callback == 'function')
+    callback()
+}
+
+
+BufferList.prototype._read = function _read (size) {
+  if (!this.length)
+    return this.push(null)
+
+  size = Math.min(size, this.length)
+  this.push(this.slice(0, size))
+  this.consume(size)
+}
+
+
+BufferList.prototype.end = function end (chunk) {
+  DuplexStream.prototype.end.call(this, chunk)
+
+  if (this._callback) {
+    this._callback(null, this.slice())
+    this._callback = null
+  }
+}
+
+
+BufferList.prototype.get = function get (index) {
+  if (index > this.length || index < 0) {
+    return undefined
+  }
+  var offset = this._offset(index)
+  return this._bufs[offset[0]][offset[1]]
+}
+
+
+BufferList.prototype.slice = function slice (start, end) {
+  if (typeof start == 'number' && start < 0)
+    start += this.length
+  if (typeof end == 'number' && end < 0)
+    end += this.length
+  return this.copy(null, 0, start, end)
+}
+
+
+BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
+  if (typeof srcStart != 'number' || srcStart < 0)
+    srcStart = 0
+  if (typeof srcEnd != 'number' || srcEnd > this.length)
+    srcEnd = this.length
+  if (srcStart >= this.length)
+    return dst || Buffer.alloc(0)
+  if (srcEnd <= 0)
+    return dst || Buffer.alloc(0)
+
+  var copy   = !!dst
+    , off    = this._offset(srcStart)
+    , len    = srcEnd - srcStart
+    , bytes  = len
+    , bufoff = (copy && dstStart) || 0
+    , start  = off[1]
+    , l
+    , i
+
+  // copy/slice everything
+  if (srcStart === 0 && srcEnd == this.length) {
+    if (!copy) { // slice, but full concat if multiple buffers
+      return this._bufs.length === 1
+        ? this._bufs[0]
+        : Buffer.concat(this._bufs, this.length)
+    }
+
+    // copy, need to copy individual buffers
+    for (i = 0; i < this._bufs.length; i++) {
+      this._bufs[i].copy(dst, bufoff)
+      bufoff += this._bufs[i].length
+    }
+
+    return dst
+  }
+
+  // easy, cheap case where it's a subset of one of the buffers
+  if (bytes <= this._bufs[off[0]].length - start) {
+    return copy
+      ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
+      : this._bufs[off[0]].slice(start, start + bytes)
+  }
+
+  if (!copy) // a slice, we need something to copy in to
+    dst = Buffer.allocUnsafe(len)
+
+  for (i = off[0]; i < this._bufs.length; i++) {
+    l = this._bufs[i].length - start
+
+    if (bytes > l) {
+      this._bufs[i].copy(dst, bufoff, start)
+      bufoff += l
+    } else {
+      this._bufs[i].copy(dst, bufoff, start, start + bytes)
+      bufoff += l
+      break
+    }
+
+    bytes -= l
+
+    if (start)
+      start = 0
+  }
+
+  // safeguard so that we don't return uninitialized memory
+  if (dst.length > bufoff) return dst.slice(0, bufoff)
+
+  return dst
+}
+
+BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
+  start = start || 0
+  end = typeof end !== 'number' ? this.length : end
+
+  if (start < 0)
+    start += this.length
+  if (end < 0)
+    end += this.length
+
+  if (start === end) {
+    return new BufferList()
+  }
+  var startOffset = this._offset(start)
+    , endOffset = this._offset(end)
+    , buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
+
+  if (endOffset[1] == 0)
+    buffers.pop()
+  else
+    buffers[buffers.length-1] = buffers[buffers.length-1].slice(0, endOffset[1])
+
+  if (startOffset[1] != 0)
+    buffers[0] = buffers[0].slice(startOffset[1])
+
+  return new BufferList(buffers)
+}
+
+BufferList.prototype.toString = function toString (encoding, start, end) {
+  return this.slice(start, end).toString(encoding)
+}
+
+BufferList.prototype.consume = function consume (bytes) {
+  // first, normalize the argument, in accordance with how Buffer does it
+  bytes = Math.trunc(bytes)
+  // do nothing if not a positive number
+  if (Number.isNaN(bytes) || bytes <= 0) return this
+
+  while (this._bufs.length) {
+    if (bytes >= this._bufs[0].length) {
+      bytes -= this._bufs[0].length
+      this.length -= this._bufs[0].length
+      this._bufs.shift()
+    } else {
+      this._bufs[0] = this._bufs[0].slice(bytes)
+      this.length -= bytes
+      break
+    }
+  }
+  return this
+}
+
+
+BufferList.prototype.duplicate = function duplicate () {
+  var i = 0
+    , copy = new BufferList()
+
+  for (; i < this._bufs.length; i++)
+    copy.append(this._bufs[i])
+
+  return copy
+}
+
+
+BufferList.prototype.destroy = function destroy () {
+  this._bufs.length = 0
+  this.length = 0
+  this.push(null)
+}
+
+
+BufferList.prototype.indexOf = function (search, offset, encoding) {
+  if (encoding === undefined && typeof offset === 'string') {
+    encoding = offset
+    offset = undefined
+  }
+  if (typeof search === 'function' || Array.isArray(search)) {
+    throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.')
+  } else if (typeof search === 'number') {
+      search = Buffer.from([search])
+  } else if (typeof search === 'string') {
+    search = Buffer.from(search, encoding)
+  } else if (search instanceof BufferList) {
+    search = search.slice()
+  } else if (!Buffer.isBuffer(search)) {
+    search = Buffer.from(search)
+  }
+
+  offset = Number(offset || 0)
+  if (isNaN(offset)) {
+    offset = 0
+  }
+
+  if (offset < 0) {
+    offset = this.length + offset
+  }
+
+  if (offset < 0) {
+    offset = 0
+  }
+
+  if (search.length === 0) {
+    return offset > this.length ? this.length : offset
+  }
+
+  var blOffset = this._offset(offset)
+  var blIndex = blOffset[0] // index of which internal buffer we're working on
+  var buffOffset = blOffset[1] // offset of the internal buffer we're working on
+
+  // scan over each buffer
+  for (blIndex; blIndex < this._bufs.length; blIndex++) {
+    var buff = this._bufs[blIndex]
+    while(buffOffset < buff.length) {
+      var availableWindow = buff.length - buffOffset
+      if (availableWindow >= search.length) {
+        var nativeSearchResult = buff.indexOf(search, buffOffset)
+        if (nativeSearchResult !== -1) {
+          return this._reverseOffset([blIndex, nativeSearchResult])
+        }
+        buffOffset = buff.length - search.length + 1 // end of native search window
+      } else {
+        var revOffset = this._reverseOffset([blIndex, buffOffset])
+        if (this._match(revOffset, search)) {
+          return revOffset
+        }
+        buffOffset++
+      }
+    }
+    buffOffset = 0
+  }
+  return -1
+}
+
+BufferList.prototype._match = function(offset, search) {
+  if (this.length - offset < search.length) {
+    return false
+  }
+  for (var searchOffset = 0; searchOffset < search.length ; searchOffset++) {
+    if(this.get(offset + searchOffset) !== search[searchOffset]){
+      return false
+    }
+  }
+  return true
+}
+
+
+;(function () {
+  var methods = {
+      'readDoubleBE' : 8
+    , 'readDoubleLE' : 8
+    , 'readFloatBE'  : 4
+    , 'readFloatLE'  : 4
+    , 'readInt32BE'  : 4
+    , 'readInt32LE'  : 4
+    , 'readUInt32BE' : 4
+    , 'readUInt32LE' : 4
+    , 'readInt16BE'  : 2
+    , 'readInt16LE'  : 2
+    , 'readUInt16BE' : 2
+    , 'readUInt16LE' : 2
+    , 'readInt8'     : 1
+    , 'readUInt8'    : 1
+    , 'readIntBE'    : null
+    , 'readIntLE'    : null
+    , 'readUIntBE'   : null
+    , 'readUIntLE'   : null
+  }
+
+  for (var m in methods) {
+    (function (m) {
+      if (methods[m] === null) {
+        BufferList.prototype[m] = function (offset, byteLength) {
+          return this.slice(offset, offset + byteLength)[m](0, byteLength)
+        }
+      }
+      else {
+        BufferList.prototype[m] = function (offset) {
+          return this.slice(offset, offset + methods[m])[m](0)
+        }
+      }
+    }(m))
+  }
+}())
+
+
+module.exports = BufferList

+ 35 - 0
node_modules/bl/package.json

@@ -0,0 +1,35 @@
+{
+  "name": "bl",
+  "version": "2.2.1",
+  "description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
+  "main": "bl.js",
+  "scripts": {
+    "test": "node test/test.js | faucet"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/rvagg/bl.git"
+  },
+  "homepage": "https://github.com/rvagg/bl",
+  "authors": [
+    "Rod Vagg <rod@vagg.org> (https://github.com/rvagg)",
+    "Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
+    "Jarett Cruger <jcrugzz@gmail.com> (https://github.com/jcrugzz)"
+  ],
+  "keywords": [
+    "buffer",
+    "buffers",
+    "stream",
+    "awesomesauce"
+  ],
+  "license": "MIT",
+  "dependencies": {
+    "readable-stream": "^2.3.5",
+    "safe-buffer": "^5.1.1"
+  },
+  "devDependencies": {
+    "faucet": "0.0.1",
+    "hash_file": "~0.1.1",
+    "tape": "~4.9.0"
+  }
+}

+ 463 - 0
node_modules/bl/test/indexOf.js

@@ -0,0 +1,463 @@
+'use strict'
+
+var tape       = require('tape')
+  , BufferList = require('../')
+  , Buffer     = require('safe-buffer').Buffer
+
+tape('indexOf single byte needle', t => {
+  const bl = new BufferList(['abcdefg', 'abcdefg', '12345'])
+  t.equal(bl.indexOf('e'), 4)
+  t.equal(bl.indexOf('e', 5), 11)
+  t.equal(bl.indexOf('e', 12), -1)
+  t.equal(bl.indexOf('5'), 18)
+  t.end()
+})
+
+tape('indexOf multiple byte needle', t => {
+  const bl = new BufferList(['abcdefg', 'abcdefg'])
+  t.equal(bl.indexOf('ef'), 4)
+  t.equal(bl.indexOf('ef', 5), 11)
+  t.end()
+})
+
+tape('indexOf multiple byte needles across buffer boundaries', t => {
+  const bl = new BufferList(['abcdefg', 'abcdefg'])
+  t.equal(bl.indexOf('fgabc'), 5)
+  t.end()
+})
+
+tape('indexOf takes a buffer list search', t => {
+  const bl = new BufferList(['abcdefg', 'abcdefg'])
+  const search = new BufferList('fgabc')
+  t.equal(bl.indexOf(search), 5)
+  t.end()
+})
+
+tape('indexOf a zero byte needle', t => {
+  const b = new BufferList('abcdef')
+  const buf_empty = Buffer.from('')
+  t.equal(b.indexOf(''), 0)
+  t.equal(b.indexOf('', 1), 1)
+  t.equal(b.indexOf('', b.length + 1), b.length)
+  t.equal(b.indexOf('', Infinity), b.length)
+  t.equal(b.indexOf(buf_empty), 0)
+  t.equal(b.indexOf(buf_empty, 1), 1)
+  t.equal(b.indexOf(buf_empty, b.length + 1), b.length)
+  t.equal(b.indexOf(buf_empty, Infinity), b.length)
+  t.end()
+})
+
+tape('indexOf buffers smaller and larger than the needle', t => {
+  const bl = new BufferList(['abcdefg', 'a', 'bcdefg', 'a', 'bcfgab'])
+  t.equal(bl.indexOf('fgabc'), 5)
+  t.equal(bl.indexOf('fgabc', 6), 12)
+  t.equal(bl.indexOf('fgabc', 13), -1)
+  t.end()
+})
+
+// only present in node 6+
+;(process.version.substr(1).split('.')[0] >= 6) && tape('indexOf latin1 and binary encoding', t => {
+  const b = new BufferList('abcdef')
+
+  // test latin1 encoding
+  t.equal(
+    new BufferList(Buffer.from(b.toString('latin1'), 'latin1'))
+      .indexOf('d', 0, 'latin1'),
+    3
+  )
+  t.equal(
+    new BufferList(Buffer.from(b.toString('latin1'), 'latin1'))
+      .indexOf(Buffer.from('d', 'latin1'), 0, 'latin1'),
+    3
+  )
+  t.equal(
+    new BufferList(Buffer.from('aa\u00e8aa', 'latin1'))
+      .indexOf('\u00e8', 'latin1'),
+    2
+  )
+  t.equal(
+    new BufferList(Buffer.from('\u00e8', 'latin1'))
+      .indexOf('\u00e8', 'latin1'),
+    0
+  )
+  t.equal(
+    new BufferList(Buffer.from('\u00e8', 'latin1'))
+      .indexOf(Buffer.from('\u00e8', 'latin1'), 'latin1'),
+    0
+  )
+
+  // test binary encoding
+  t.equal(
+    new BufferList(Buffer.from(b.toString('binary'), 'binary'))
+      .indexOf('d', 0, 'binary'),
+    3
+  )
+  t.equal(
+    new BufferList(Buffer.from(b.toString('binary'), 'binary'))
+      .indexOf(Buffer.from('d', 'binary'), 0, 'binary'),
+    3
+  )
+  t.equal(
+    new BufferList(Buffer.from('aa\u00e8aa', 'binary'))
+      .indexOf('\u00e8', 'binary'),
+    2
+  )
+  t.equal(
+    new BufferList(Buffer.from('\u00e8', 'binary'))
+      .indexOf('\u00e8', 'binary'),
+    0
+  )
+  t.equal(
+    new BufferList(Buffer.from('\u00e8', 'binary'))
+      .indexOf(Buffer.from('\u00e8', 'binary'), 'binary'),
+    0
+  )
+  t.end()
+})
+
+tape('indexOf the entire nodejs10 buffer test suite', t => {
+  const b = new BufferList('abcdef')
+  const buf_a = Buffer.from('a')
+  const buf_bc = Buffer.from('bc')
+  const buf_f = Buffer.from('f')
+  const buf_z = Buffer.from('z')
+
+  const stringComparison = 'abcdef'
+
+  t.equal(b.indexOf('a'), 0)
+  t.equal(b.indexOf('a', 1), -1)
+  t.equal(b.indexOf('a', -1), -1)
+  t.equal(b.indexOf('a', -4), -1)
+  t.equal(b.indexOf('a', -b.length), 0)
+  t.equal(b.indexOf('a', NaN), 0)
+  t.equal(b.indexOf('a', -Infinity), 0)
+  t.equal(b.indexOf('a', Infinity), -1)
+  t.equal(b.indexOf('bc'), 1)
+  t.equal(b.indexOf('bc', 2), -1)
+  t.equal(b.indexOf('bc', -1), -1)
+  t.equal(b.indexOf('bc', -3), -1)
+  t.equal(b.indexOf('bc', -5), 1)
+  t.equal(b.indexOf('bc', NaN), 1)
+  t.equal(b.indexOf('bc', -Infinity), 1)
+  t.equal(b.indexOf('bc', Infinity), -1)
+  t.equal(b.indexOf('f'), b.length - 1)
+  t.equal(b.indexOf('z'), -1)
+  // empty search tests
+  t.equal(b.indexOf(buf_a), 0)
+  t.equal(b.indexOf(buf_a, 1), -1)
+  t.equal(b.indexOf(buf_a, -1), -1)
+  t.equal(b.indexOf(buf_a, -4), -1)
+  t.equal(b.indexOf(buf_a, -b.length), 0)
+  t.equal(b.indexOf(buf_a, NaN), 0)
+  t.equal(b.indexOf(buf_a, -Infinity), 0)
+  t.equal(b.indexOf(buf_a, Infinity), -1)
+  t.equal(b.indexOf(buf_bc), 1)
+  t.equal(b.indexOf(buf_bc, 2), -1)
+  t.equal(b.indexOf(buf_bc, -1), -1)
+  t.equal(b.indexOf(buf_bc, -3), -1)
+  t.equal(b.indexOf(buf_bc, -5), 1)
+  t.equal(b.indexOf(buf_bc, NaN), 1)
+  t.equal(b.indexOf(buf_bc, -Infinity), 1)
+  t.equal(b.indexOf(buf_bc, Infinity), -1)
+  t.equal(b.indexOf(buf_f), b.length - 1)
+  t.equal(b.indexOf(buf_z), -1)
+  t.equal(b.indexOf(0x61), 0)
+  t.equal(b.indexOf(0x61, 1), -1)
+  t.equal(b.indexOf(0x61, -1), -1)
+  t.equal(b.indexOf(0x61, -4), -1)
+  t.equal(b.indexOf(0x61, -b.length), 0)
+  t.equal(b.indexOf(0x61, NaN), 0)
+  t.equal(b.indexOf(0x61, -Infinity), 0)
+  t.equal(b.indexOf(0x61, Infinity), -1)
+  t.equal(b.indexOf(0x0), -1)
+
+  // test offsets
+  t.equal(b.indexOf('d', 2), 3)
+  t.equal(b.indexOf('f', 5), 5)
+  t.equal(b.indexOf('f', -1), 5)
+  t.equal(b.indexOf('f', 6), -1)
+
+  t.equal(b.indexOf(Buffer.from('d'), 2), 3)
+  t.equal(b.indexOf(Buffer.from('f'), 5), 5)
+  t.equal(b.indexOf(Buffer.from('f'), -1), 5)
+  t.equal(b.indexOf(Buffer.from('f'), 6), -1)
+
+  t.equal(Buffer.from('ff').indexOf(Buffer.from('f'), 1, 'ucs2'), -1)
+
+  // test invalid and uppercase encoding
+  t.equal(b.indexOf('b', 'utf8'), 1)
+  t.equal(b.indexOf('b', 'UTF8'), 1)
+  t.equal(b.indexOf('62', 'HEX'), 1)
+  t.throws(() => b.indexOf('bad', 'enc'), TypeError)
+
+  // test hex encoding
+  t.equal(
+    Buffer.from(b.toString('hex'), 'hex')
+      .indexOf('64', 0, 'hex'),
+    3
+  )
+  t.equal(
+    Buffer.from(b.toString('hex'), 'hex')
+      .indexOf(Buffer.from('64', 'hex'), 0, 'hex'),
+    3
+  )
+
+  // test base64 encoding
+  t.equal(
+    Buffer.from(b.toString('base64'), 'base64')
+      .indexOf('ZA==', 0, 'base64'),
+    3
+  )
+  t.equal(
+    Buffer.from(b.toString('base64'), 'base64')
+      .indexOf(Buffer.from('ZA==', 'base64'), 0, 'base64'),
+    3
+  )
+
+  // test ascii encoding
+  t.equal(
+    Buffer.from(b.toString('ascii'), 'ascii')
+      .indexOf('d', 0, 'ascii'),
+    3
+  )
+  t.equal(
+    Buffer.from(b.toString('ascii'), 'ascii')
+      .indexOf(Buffer.from('d', 'ascii'), 0, 'ascii'),
+    3
+  )
+
+  // test optional offset with passed encoding
+  t.equal(Buffer.from('aaaa0').indexOf('30', 'hex'), 4)
+  t.equal(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4)
+
+  {
+    // test usc2 encoding
+    const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2')
+
+    t.equal(8, twoByteString.indexOf('\u0395', 4, 'ucs2'))
+    t.equal(6, twoByteString.indexOf('\u03a3', -4, 'ucs2'))
+    t.equal(4, twoByteString.indexOf('\u03a3', -6, 'ucs2'))
+    t.equal(4, twoByteString.indexOf(
+      Buffer.from('\u03a3', 'ucs2'), -6, 'ucs2'))
+    t.equal(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2'))
+  }
+
+  const mixedByteStringUcs2 =
+      Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395', 'ucs2')
+  t.equal(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2'))
+  t.equal(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2'))
+  t.equal(-1, mixedByteStringUcs2.indexOf('\u0396', 0, 'ucs2'))
+
+  t.equal(
+    6, mixedByteStringUcs2.indexOf(Buffer.from('bc', 'ucs2'), 0, 'ucs2'))
+  t.equal(
+    10, mixedByteStringUcs2.indexOf(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2'))
+  t.equal(
+    -1, mixedByteStringUcs2.indexOf(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2'))
+
+  {
+    const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2')
+
+    // Test single char pattern
+    t.equal(0, twoByteString.indexOf('\u039a', 0, 'ucs2'))
+    let index = twoByteString.indexOf('\u0391', 0, 'ucs2')
+    t.equal(2, index, `Alpha - at index ${index}`)
+    index = twoByteString.indexOf('\u03a3', 0, 'ucs2')
+    t.equal(4, index, `First Sigma - at index ${index}`)
+    index = twoByteString.indexOf('\u03a3', 6, 'ucs2')
+    t.equal(6, index, `Second Sigma - at index ${index}`)
+    index = twoByteString.indexOf('\u0395', 0, 'ucs2')
+    t.equal(8, index, `Epsilon - at index ${index}`)
+    index = twoByteString.indexOf('\u0392', 0, 'ucs2')
+    t.equal(-1, index, `Not beta - at index ${index}`)
+
+    // Test multi-char pattern
+    index = twoByteString.indexOf('\u039a\u0391', 0, 'ucs2')
+    t.equal(0, index, `Lambda Alpha - at index ${index}`)
+    index = twoByteString.indexOf('\u0391\u03a3', 0, 'ucs2')
+    t.equal(2, index, `Alpha Sigma - at index ${index}`)
+    index = twoByteString.indexOf('\u03a3\u03a3', 0, 'ucs2')
+    t.equal(4, index, `Sigma Sigma - at index ${index}`)
+    index = twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2')
+    t.equal(6, index, `Sigma Epsilon - at index ${index}`)
+  }
+
+  const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395')
+  t.equal(5, mixedByteStringUtf8.indexOf('bc'))
+  t.equal(5, mixedByteStringUtf8.indexOf('bc', 5))
+  t.equal(5, mixedByteStringUtf8.indexOf('bc', -8))
+  t.equal(7, mixedByteStringUtf8.indexOf('\u03a3'))
+  t.equal(-1, mixedByteStringUtf8.indexOf('\u0396'))
+
+
+  // Test complex string indexOf algorithms. Only trigger for long strings.
+  // Long string that isn't a simple repeat of a shorter string.
+  let longString = 'A'
+  for (let i = 66; i < 76; i++) {  // from 'B' to 'K'
+    longString = longString + String.fromCharCode(i) + longString
+  }
+
+  const longBufferString = Buffer.from(longString)
+
+  // pattern of 15 chars, repeated every 16 chars in long
+  let pattern = 'ABACABADABACABA'
+  for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {
+    const index = longBufferString.indexOf(pattern, i)
+    t.equal((i + 15) & ~0xf, index,
+                      `Long ABACABA...-string at index ${i}`)
+  }
+
+  let index = longBufferString.indexOf('AJABACA')
+  t.equal(510, index, `Long AJABACA, First J - at index ${index}`)
+  index = longBufferString.indexOf('AJABACA', 511)
+  t.equal(1534, index, `Long AJABACA, Second J - at index ${index}`)
+
+  pattern = 'JABACABADABACABA'
+  index = longBufferString.indexOf(pattern)
+  t.equal(511, index, `Long JABACABA..., First J - at index ${index}`)
+  index = longBufferString.indexOf(pattern, 512)
+  t.equal(
+    1535, index, `Long JABACABA..., Second J - at index ${index}`)
+
+  // Search for a non-ASCII string in a pure ASCII string.
+  const asciiString = Buffer.from(
+    'arglebargleglopglyfarglebargleglopglyfarglebargleglopglyf')
+  t.equal(-1, asciiString.indexOf('\x2061'))
+  t.equal(3, asciiString.indexOf('leb', 0))
+
+  // Search in string containing many non-ASCII chars.
+  const allCodePoints = []
+  for (let i = 0; i < 65536; i++) allCodePoints[i] = i
+  const allCharsString = String.fromCharCode.apply(String, allCodePoints)
+  const allCharsBufferUtf8 = Buffer.from(allCharsString)
+  const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2')
+
+  // Search for string long enough to trigger complex search with ASCII pattern
+  // and UC16 subject.
+  t.equal(-1, allCharsBufferUtf8.indexOf('notfound'))
+  t.equal(-1, allCharsBufferUcs2.indexOf('notfound'))
+
+  // Needle is longer than haystack, but only because it's encoded as UTF-16
+  t.equal(Buffer.from('aaaa').indexOf('a'.repeat(4), 'ucs2'), -1)
+
+  t.equal(Buffer.from('aaaa').indexOf('a'.repeat(4), 'utf8'), 0)
+  t.equal(Buffer.from('aaaa').indexOf('你好', 'ucs2'), -1)
+
+  // Haystack has odd length, but the needle is UCS2.
+  t.equal(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1)
+
+  {
+    // Find substrings in Utf8.
+    const lengths = [1, 3, 15];  // Single char, simple and complex.
+    const indices = [0x5, 0x60, 0x400, 0x680, 0x7ee, 0xFF02, 0x16610, 0x2f77b]
+    for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
+      for (let i = 0; i < indices.length; i++) {
+        const index = indices[i]
+        let length = lengths[lengthIndex]
+
+        if (index + length > 0x7F) {
+          length = 2 * length
+        }
+
+        if (index + length > 0x7FF) {
+          length = 3 * length
+        }
+
+        if (index + length > 0xFFFF) {
+          length = 4 * length
+        }
+
+        const patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length)
+        t.equal(index, allCharsBufferUtf8.indexOf(patternBufferUtf8))
+
+        const patternStringUtf8 = patternBufferUtf8.toString()
+        t.equal(index, allCharsBufferUtf8.indexOf(patternStringUtf8))
+      }
+    }
+  }
+
+  {
+    // Find substrings in Usc2.
+    const lengths = [2, 4, 16];  // Single char, simple and complex.
+    const indices = [0x5, 0x65, 0x105, 0x205, 0x285, 0x2005, 0x2085, 0xfff0]
+    for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
+      for (let i = 0; i < indices.length; i++) {
+        const index = indices[i] * 2
+        const length = lengths[lengthIndex]
+
+        const patternBufferUcs2 =
+            allCharsBufferUcs2.slice(index, index + length)
+        t.equal(
+          index, allCharsBufferUcs2.indexOf(patternBufferUcs2, 0, 'ucs2'))
+
+        const patternStringUcs2 = patternBufferUcs2.toString('ucs2')
+        t.equal(
+          index, allCharsBufferUcs2.indexOf(patternStringUcs2, 0, 'ucs2'))
+      }
+    }
+  }
+
+  [
+    () => {},
+    {},
+    []
+  ].forEach(val => {
+    debugger
+    t.throws(() => b.indexOf(val), TypeError, `"${JSON.stringify(val)}" should throw`)
+  })
+
+  // Test weird offset arguments.
+  // The following offsets coerce to NaN or 0, searching the whole Buffer
+  t.equal(b.indexOf('b', undefined), 1)
+  t.equal(b.indexOf('b', {}), 1)
+  t.equal(b.indexOf('b', 0), 1)
+  t.equal(b.indexOf('b', null), 1)
+  t.equal(b.indexOf('b', []), 1)
+
+  // The following offset coerces to 2, in other words +[2] === 2
+  t.equal(b.indexOf('b', [2]), -1)
+
+  // Behavior should match String.indexOf()
+  t.equal(
+    b.indexOf('b', undefined),
+    stringComparison.indexOf('b', undefined))
+  t.equal(
+    b.indexOf('b', {}),
+    stringComparison.indexOf('b', {}))
+  t.equal(
+    b.indexOf('b', 0),
+    stringComparison.indexOf('b', 0))
+  t.equal(
+    b.indexOf('b', null),
+    stringComparison.indexOf('b', null))
+  t.equal(
+    b.indexOf('b', []),
+    stringComparison.indexOf('b', []))
+  t.equal(
+    b.indexOf('b', [2]),
+    stringComparison.indexOf('b', [2]))
+
+  // test truncation of Number arguments to uint8
+  {
+    const buf = Buffer.from('this is a test')
+    t.equal(buf.indexOf(0x6973), 3)
+    t.equal(buf.indexOf(0x697320), 4)
+    t.equal(buf.indexOf(0x69732069), 2)
+    t.equal(buf.indexOf(0x697374657374), 0)
+    t.equal(buf.indexOf(0x69737374), 0)
+    t.equal(buf.indexOf(0x69737465), 11)
+    t.equal(buf.indexOf(0x69737465), 11)
+    t.equal(buf.indexOf(-140), 0)
+    t.equal(buf.indexOf(-152), 1)
+    t.equal(buf.indexOf(0xff), -1)
+    t.equal(buf.indexOf(0xffff), -1)
+  }
+
+  // Test that Uint8Array arguments are okay.
+  {
+    const needle = new Uint8Array([ 0x66, 0x6f, 0x6f ])
+    const haystack = new BufferList(Buffer.from('a foo b foo'))
+    t.equal(haystack.indexOf(needle), 2)
+  }
+  t.end()
+})

+ 782 - 0
node_modules/bl/test/test.js

@@ -0,0 +1,782 @@
+'use strict'
+
+var tape       = require('tape')
+  , crypto     = require('crypto')
+  , fs         = require('fs')
+  , hash       = require('hash_file')
+  , BufferList = require('../')
+  , Buffer     = require('safe-buffer').Buffer
+
+  , encodings  =
+      ('hex utf8 utf-8 ascii binary base64'
+          + (process.browser ? '' : ' ucs2 ucs-2 utf16le utf-16le')).split(' ')
+
+// run the indexOf tests
+require('./indexOf')
+
+tape('single bytes from single buffer', function (t) {
+  var bl = new BufferList()
+  bl.append(Buffer.from('abcd'))
+
+  t.equal(bl.length, 4)
+  t.equal(bl.get(-1), undefined)
+  t.equal(bl.get(0), 97)
+  t.equal(bl.get(1), 98)
+  t.equal(bl.get(2), 99)
+  t.equal(bl.get(3), 100)
+  t.equal(bl.get(4), undefined)
+
+  t.end()
+})
+
+tape('single bytes from multiple buffers', function (t) {
+  var bl = new BufferList()
+  bl.append(Buffer.from('abcd'))
+  bl.append(Buffer.from('efg'))
+  bl.append(Buffer.from('hi'))
+  bl.append(Buffer.from('j'))
+
+  t.equal(bl.length, 10)
+
+  t.equal(bl.get(0), 97)
+  t.equal(bl.get(1), 98)
+  t.equal(bl.get(2), 99)
+  t.equal(bl.get(3), 100)
+  t.equal(bl.get(4), 101)
+  t.equal(bl.get(5), 102)
+  t.equal(bl.get(6), 103)
+  t.equal(bl.get(7), 104)
+  t.equal(bl.get(8), 105)
+  t.equal(bl.get(9), 106)
+  t.end()
+})
+
+tape('multi bytes from single buffer', function (t) {
+  var bl = new BufferList()
+  bl.append(Buffer.from('abcd'))
+
+  t.equal(bl.length, 4)
+
+  t.equal(bl.slice(0, 4).toString('ascii'), 'abcd')
+  t.equal(bl.slice(0, 3).toString('ascii'), 'abc')
+  t.equal(bl.slice(1, 4).toString('ascii'), 'bcd')
+  t.equal(bl.slice(-4, -1).toString('ascii'), 'abc')
+
+  t.end()
+})
+
+tape('multi bytes from single buffer (negative indexes)', function (t) {
+  var bl = new BufferList()
+  bl.append(Buffer.from('buffer'))
+
+  t.equal(bl.length, 6)
+
+  t.equal(bl.slice(-6, -1).toString('ascii'), 'buffe')
+  t.equal(bl.slice(-6, -2).toString('ascii'), 'buff')
+  t.equal(bl.slice(-5, -2).toString('ascii'), 'uff')
+
+  t.end()
+})
+
+tape('multiple bytes from multiple buffers', function (t) {
+  var bl = new BufferList()
+
+  bl.append(Buffer.from('abcd'))
+  bl.append(Buffer.from('efg'))
+  bl.append(Buffer.from('hi'))
+  bl.append(Buffer.from('j'))
+
+  t.equal(bl.length, 10)
+
+  t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
+  t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
+  t.equal(bl.slice(3, 6).toString('ascii'), 'def')
+  t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
+  t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
+  t.equal(bl.slice(-7, -4).toString('ascii'), 'def')
+
+  t.end()
+})
+
+tape('multiple bytes from multiple buffer lists', function (t) {
+  var bl = new BufferList()
+
+  bl.append(new BufferList([ Buffer.from('abcd'), Buffer.from('efg') ]))
+  bl.append(new BufferList([ Buffer.from('hi'), Buffer.from('j') ]))
+
+  t.equal(bl.length, 10)
+
+  t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
+
+  t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
+  t.equal(bl.slice(3, 6).toString('ascii'), 'def')
+  t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
+  t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
+
+  t.end()
+})
+
+// same data as previous test, just using nested constructors
+tape('multiple bytes from crazy nested buffer lists', function (t) {
+  var bl = new BufferList()
+
+  bl.append(new BufferList([
+      new BufferList([
+          new BufferList(Buffer.from('abc'))
+        , Buffer.from('d')
+        , new BufferList(Buffer.from('efg'))
+      ])
+    , new BufferList([ Buffer.from('hi') ])
+    , new BufferList(Buffer.from('j'))
+  ]))
+
+  t.equal(bl.length, 10)
+
+  t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
+
+  t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
+  t.equal(bl.slice(3, 6).toString('ascii'), 'def')
+  t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
+  t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
+
+  t.end()
+})
+
+tape('append accepts arrays of Buffers', function (t) {
+  var bl = new BufferList()
+  bl.append(Buffer.from('abc'))
+  bl.append([ Buffer.from('def') ])
+  bl.append([ Buffer.from('ghi'), Buffer.from('jkl') ])
+  bl.append([ Buffer.from('mnop'), Buffer.from('qrstu'), Buffer.from('vwxyz') ])
+  t.equal(bl.length, 26)
+  t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
+  t.end()
+})
+
+tape('append accepts arrays of BufferLists', function (t) {
+  var bl = new BufferList()
+  bl.append(Buffer.from('abc'))
+  bl.append([ new BufferList('def') ])
+  bl.append(new BufferList([ Buffer.from('ghi'), new BufferList('jkl') ]))
+  bl.append([ Buffer.from('mnop'), new BufferList([ Buffer.from('qrstu'), Buffer.from('vwxyz') ]) ])
+  t.equal(bl.length, 26)
+  t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
+  t.end()
+})
+
+tape('append chainable', function (t) {
+  var bl = new BufferList()
+  t.ok(bl.append(Buffer.from('abcd')) === bl)
+  t.ok(bl.append([ Buffer.from('abcd') ]) === bl)
+  t.ok(bl.append(new BufferList(Buffer.from('abcd'))) === bl)
+  t.ok(bl.append([ new BufferList(Buffer.from('abcd')) ]) === bl)
+  t.end()
+})
+
+tape('append chainable (test results)', function (t) {
+  var bl = new BufferList('abc')
+    .append([ new BufferList('def') ])
+    .append(new BufferList([ Buffer.from('ghi'), new BufferList('jkl') ]))
+    .append([ Buffer.from('mnop'), new BufferList([ Buffer.from('qrstu'), Buffer.from('vwxyz') ]) ])
+
+  t.equal(bl.length, 26)
+  t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
+  t.end()
+})
+
+tape('consuming from multiple buffers', function (t) {
+  var bl = new BufferList()
+
+  bl.append(Buffer.from('abcd'))
+  bl.append(Buffer.from('efg'))
+  bl.append(Buffer.from('hi'))
+  bl.append(Buffer.from('j'))
+
+  t.equal(bl.length, 10)
+
+  t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
+
+  bl.consume(3)
+  t.equal(bl.length, 7)
+  t.equal(bl.slice(0, 7).toString('ascii'), 'defghij')
+
+  bl.consume(2)
+  t.equal(bl.length, 5)
+  t.equal(bl.slice(0, 5).toString('ascii'), 'fghij')
+
+  bl.consume(1)
+  t.equal(bl.length, 4)
+  t.equal(bl.slice(0, 4).toString('ascii'), 'ghij')
+
+  bl.consume(1)
+  t.equal(bl.length, 3)
+  t.equal(bl.slice(0, 3).toString('ascii'), 'hij')
+
+  bl.consume(2)
+  t.equal(bl.length, 1)
+  t.equal(bl.slice(0, 1).toString('ascii'), 'j')
+
+  t.end()
+})
+
+tape('complete consumption', function (t) {
+  var bl = new BufferList()
+
+  bl.append(Buffer.from('a'))
+  bl.append(Buffer.from('b'))
+
+  bl.consume(2)
+
+  t.equal(bl.length, 0)
+  t.equal(bl._bufs.length, 0)
+
+  t.end()
+})
+
+tape('test readUInt8 / readInt8', function (t) {
+  var buf1 = Buffer.alloc(1)
+    , buf2 = Buffer.alloc(3)
+    , buf3 = Buffer.alloc(3)
+    , bl  = new BufferList()
+
+  buf2[1] = 0x3
+  buf2[2] = 0x4
+  buf3[0] = 0x23
+  buf3[1] = 0x42
+
+  bl.append(buf1)
+  bl.append(buf2)
+  bl.append(buf3)
+
+  t.equal(bl.readUInt8(2), 0x3)
+  t.equal(bl.readInt8(2), 0x3)
+  t.equal(bl.readUInt8(3), 0x4)
+  t.equal(bl.readInt8(3), 0x4)
+  t.equal(bl.readUInt8(4), 0x23)
+  t.equal(bl.readInt8(4), 0x23)
+  t.equal(bl.readUInt8(5), 0x42)
+  t.equal(bl.readInt8(5), 0x42)
+  t.end()
+})
+
+tape('test readUInt16LE / readUInt16BE / readInt16LE / readInt16BE', function (t) {
+  var buf1 = Buffer.alloc(1)
+    , buf2 = Buffer.alloc(3)
+    , buf3 = Buffer.alloc(3)
+    , bl   = new BufferList()
+
+  buf2[1] = 0x3
+  buf2[2] = 0x4
+  buf3[0] = 0x23
+  buf3[1] = 0x42
+
+  bl.append(buf1)
+  bl.append(buf2)
+  bl.append(buf3)
+
+  t.equal(bl.readUInt16BE(2), 0x0304)
+  t.equal(bl.readUInt16LE(2), 0x0403)
+  t.equal(bl.readInt16BE(2), 0x0304)
+  t.equal(bl.readInt16LE(2), 0x0403)
+  t.equal(bl.readUInt16BE(3), 0x0423)
+  t.equal(bl.readUInt16LE(3), 0x2304)
+  t.equal(bl.readInt16BE(3), 0x0423)
+  t.equal(bl.readInt16LE(3), 0x2304)
+  t.equal(bl.readUInt16BE(4), 0x2342)
+  t.equal(bl.readUInt16LE(4), 0x4223)
+  t.equal(bl.readInt16BE(4), 0x2342)
+  t.equal(bl.readInt16LE(4), 0x4223)
+  t.end()
+})
+
+tape('test readUInt32LE / readUInt32BE / readInt32LE / readInt32BE', function (t) {
+  var buf1 = Buffer.alloc(1)
+    , buf2 = Buffer.alloc(3)
+    , buf3 = Buffer.alloc(3)
+    , bl   = new BufferList()
+
+  buf2[1] = 0x3
+  buf2[2] = 0x4
+  buf3[0] = 0x23
+  buf3[1] = 0x42
+
+  bl.append(buf1)
+  bl.append(buf2)
+  bl.append(buf3)
+
+  t.equal(bl.readUInt32BE(2), 0x03042342)
+  t.equal(bl.readUInt32LE(2), 0x42230403)
+  t.equal(bl.readInt32BE(2), 0x03042342)
+  t.equal(bl.readInt32LE(2), 0x42230403)
+  t.end()
+})
+
+tape('test readUIntLE / readUIntBE / readIntLE / readIntBE', function (t) {
+  var buf1 = Buffer.alloc(1)
+    , buf2 = Buffer.alloc(3)
+    , buf3 = Buffer.alloc(3)
+    , bl   = new BufferList()
+
+  buf2[0] = 0x2
+  buf2[1] = 0x3
+  buf2[2] = 0x4
+  buf3[0] = 0x23
+  buf3[1] = 0x42
+  buf3[2] = 0x61
+
+  bl.append(buf1)
+  bl.append(buf2)
+  bl.append(buf3)
+
+  t.equal(bl.readUIntBE(1, 1), 0x02)
+  t.equal(bl.readUIntBE(1, 2), 0x0203)
+  t.equal(bl.readUIntBE(1, 3), 0x020304)
+  t.equal(bl.readUIntBE(1, 4), 0x02030423)
+  t.equal(bl.readUIntBE(1, 5), 0x0203042342)
+  t.equal(bl.readUIntBE(1, 6), 0x020304234261)
+  t.equal(bl.readUIntLE(1, 1), 0x02)
+  t.equal(bl.readUIntLE(1, 2), 0x0302)
+  t.equal(bl.readUIntLE(1, 3), 0x040302)
+  t.equal(bl.readUIntLE(1, 4), 0x23040302)
+  t.equal(bl.readUIntLE(1, 5), 0x4223040302)
+  t.equal(bl.readUIntLE(1, 6), 0x614223040302)
+  t.equal(bl.readIntBE(1, 1), 0x02)
+  t.equal(bl.readIntBE(1, 2), 0x0203)
+  t.equal(bl.readIntBE(1, 3), 0x020304)
+  t.equal(bl.readIntBE(1, 4), 0x02030423)
+  t.equal(bl.readIntBE(1, 5), 0x0203042342)
+  t.equal(bl.readIntBE(1, 6), 0x020304234261)
+  t.equal(bl.readIntLE(1, 1), 0x02)
+  t.equal(bl.readIntLE(1, 2), 0x0302)
+  t.equal(bl.readIntLE(1, 3), 0x040302)
+  t.equal(bl.readIntLE(1, 4), 0x23040302)
+  t.equal(bl.readIntLE(1, 5), 0x4223040302)
+  t.equal(bl.readIntLE(1, 6), 0x614223040302)
+  t.end()
+})
+
+tape('test readFloatLE / readFloatBE', function (t) {
+  var buf1 = Buffer.alloc(1)
+    , buf2 = Buffer.alloc(3)
+    , buf3 = Buffer.alloc(3)
+    , bl   = new BufferList()
+
+  buf2[1] = 0x00
+  buf2[2] = 0x00
+  buf3[0] = 0x80
+  buf3[1] = 0x3f
+
+  bl.append(buf1)
+  bl.append(buf2)
+  bl.append(buf3)
+
+  t.equal(bl.readFloatLE(2), 0x01)
+  t.end()
+})
+
+tape('test readDoubleLE / readDoubleBE', function (t) {
+  var buf1 = Buffer.alloc(1)
+    , buf2 = Buffer.alloc(3)
+    , buf3 = Buffer.alloc(10)
+    , bl   = new BufferList()
+
+  buf2[1] = 0x55
+  buf2[2] = 0x55
+  buf3[0] = 0x55
+  buf3[1] = 0x55
+  buf3[2] = 0x55
+  buf3[3] = 0x55
+  buf3[4] = 0xd5
+  buf3[5] = 0x3f
+
+  bl.append(buf1)
+  bl.append(buf2)
+  bl.append(buf3)
+
+  t.equal(bl.readDoubleLE(2), 0.3333333333333333)
+  t.end()
+})
+
+tape('test toString', function (t) {
+  var bl = new BufferList()
+
+  bl.append(Buffer.from('abcd'))
+  bl.append(Buffer.from('efg'))
+  bl.append(Buffer.from('hi'))
+  bl.append(Buffer.from('j'))
+
+  t.equal(bl.toString('ascii', 0, 10), 'abcdefghij')
+  t.equal(bl.toString('ascii', 3, 10), 'defghij')
+  t.equal(bl.toString('ascii', 3, 6), 'def')
+  t.equal(bl.toString('ascii', 3, 8), 'defgh')
+  t.equal(bl.toString('ascii', 5, 10), 'fghij')
+
+  t.end()
+})
+
+tape('test toString encoding', function (t) {
+  var bl = new BufferList()
+    , b  = Buffer.from('abcdefghij\xff\x00')
+
+  bl.append(Buffer.from('abcd'))
+  bl.append(Buffer.from('efg'))
+  bl.append(Buffer.from('hi'))
+  bl.append(Buffer.from('j'))
+  bl.append(Buffer.from('\xff\x00'))
+
+  encodings.forEach(function (enc) {
+      t.equal(bl.toString(enc), b.toString(enc), enc)
+    })
+
+  t.end()
+})
+
+tape('uninitialized memory', function (t) {
+  const secret = crypto.randomBytes(256)
+  for (let i = 0; i < 1e6; i++) {
+    const clone = Buffer.from(secret)
+    const bl = new BufferList()
+    bl.append(Buffer.from('a'))
+    bl.consume(-1024)
+    const buf = bl.slice(1)
+    if (buf.indexOf(clone) !== -1) {
+      t.fail(`Match (at ${i})`)
+      break
+    }
+  }
+  t.end()
+})
+
+!process.browser && tape('test stream', function (t) {
+  var random = crypto.randomBytes(65534)
+    , rndhash = hash(random, 'md5')
+    , md5sum = crypto.createHash('md5')
+    , bl     = new BufferList(function (err, buf) {
+        t.ok(Buffer.isBuffer(buf))
+        t.ok(err === null)
+        t.equal(rndhash, hash(bl.slice(), 'md5'))
+        t.equal(rndhash, hash(buf, 'md5'))
+
+        bl.pipe(fs.createWriteStream('/tmp/bl_test_rnd_out.dat'))
+          .on('close', function () {
+            var s = fs.createReadStream('/tmp/bl_test_rnd_out.dat')
+            s.on('data', md5sum.update.bind(md5sum))
+            s.on('end', function() {
+              t.equal(rndhash, md5sum.digest('hex'), 'woohoo! correct hash!')
+              t.end()
+            })
+          })
+
+      })
+
+  fs.writeFileSync('/tmp/bl_test_rnd.dat', random)
+  fs.createReadStream('/tmp/bl_test_rnd.dat').pipe(bl)
+})
+
+tape('instantiation with Buffer', function (t) {
+  var buf  = crypto.randomBytes(1024)
+    , buf2 = crypto.randomBytes(1024)
+    , b    = BufferList(buf)
+
+  t.equal(buf.toString('hex'), b.slice().toString('hex'), 'same buffer')
+  b = BufferList([ buf, buf2 ])
+  t.equal(b.slice().toString('hex'), Buffer.concat([ buf, buf2 ]).toString('hex'), 'same buffer')
+  t.end()
+})
+
+tape('test String appendage', function (t) {
+  var bl = new BufferList()
+    , b  = Buffer.from('abcdefghij\xff\x00')
+
+  bl.append('abcd')
+  bl.append('efg')
+  bl.append('hi')
+  bl.append('j')
+  bl.append('\xff\x00')
+
+  encodings.forEach(function (enc) {
+      t.equal(bl.toString(enc), b.toString(enc))
+    })
+
+  t.end()
+})
+
+tape('test Number appendage', function (t) {
+  var bl = new BufferList()
+    , b  = Buffer.from('1234567890')
+
+  bl.append(1234)
+  bl.append(567)
+  bl.append(89)
+  bl.append(0)
+
+  encodings.forEach(function (enc) {
+      t.equal(bl.toString(enc), b.toString(enc))
+    })
+
+  t.end()
+})
+
+tape('write nothing, should get empty buffer', function (t) {
+  t.plan(3)
+  BufferList(function (err, data) {
+    t.notOk(err, 'no error')
+    t.ok(Buffer.isBuffer(data), 'got a buffer')
+    t.equal(0, data.length, 'got a zero-length buffer')
+    t.end()
+  }).end()
+})
+
+tape('unicode string', function (t) {
+  t.plan(2)
+  var inp1 = '\u2600'
+    , inp2 = '\u2603'
+    , exp = inp1 + ' and ' + inp2
+    , bl = BufferList()
+  bl.write(inp1)
+  bl.write(' and ')
+  bl.write(inp2)
+  t.equal(exp, bl.toString())
+  t.equal(Buffer.from(exp).toString('hex'), bl.toString('hex'))
+})
+
+tape('should emit finish', function (t) {
+  var source = BufferList()
+    , dest = BufferList()
+
+  source.write('hello')
+  source.pipe(dest)
+
+  dest.on('finish', function () {
+    t.equal(dest.toString('utf8'), 'hello')
+    t.end()
+  })
+})
+
+tape('basic copy', function (t) {
+  var buf  = crypto.randomBytes(1024)
+    , buf2 = Buffer.alloc(1024)
+    , b    = BufferList(buf)
+
+  b.copy(buf2)
+  t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
+  t.end()
+})
+
+tape('copy after many appends', function (t) {
+  var buf  = crypto.randomBytes(512)
+    , buf2 = Buffer.alloc(1024)
+    , b    = BufferList(buf)
+
+  b.append(buf)
+  b.copy(buf2)
+  t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
+  t.end()
+})
+
+tape('copy at a precise position', function (t) {
+  var buf  = crypto.randomBytes(1004)
+    , buf2 = Buffer.alloc(1024)
+    , b    = BufferList(buf)
+
+  b.copy(buf2, 20)
+  t.equal(b.slice().toString('hex'), buf2.slice(20).toString('hex'), 'same buffer')
+  t.end()
+})
+
+tape('copy starting from a precise location', function (t) {
+  var buf  = crypto.randomBytes(10)
+    , buf2 = Buffer.alloc(5)
+    , b    = BufferList(buf)
+
+  b.copy(buf2, 0, 5)
+  t.equal(b.slice(5).toString('hex'), buf2.toString('hex'), 'same buffer')
+  t.end()
+})
+
+tape('copy in an interval', function (t) {
+  var rnd      = crypto.randomBytes(10)
+    , b        = BufferList(rnd) // put the random bytes there
+    , actual   = Buffer.alloc(3)
+    , expected = Buffer.alloc(3)
+
+  rnd.copy(expected, 0, 5, 8)
+  b.copy(actual, 0, 5, 8)
+
+  t.equal(actual.toString('hex'), expected.toString('hex'), 'same buffer')
+  t.end()
+})
+
+tape('copy an interval between two buffers', function (t) {
+  var buf      = crypto.randomBytes(10)
+    , buf2     = Buffer.alloc(10)
+    , b        = BufferList(buf)
+
+  b.append(buf)
+  b.copy(buf2, 0, 5, 15)
+
+  t.equal(b.slice(5, 15).toString('hex'), buf2.toString('hex'), 'same buffer')
+  t.end()
+})
+
+tape('shallow slice across buffer boundaries', function (t) {
+  var bl = new BufferList(['First', 'Second', 'Third'])
+
+  t.equal(bl.shallowSlice(3, 13).toString(), 'stSecondTh')
+  t.end()
+})
+
+tape('shallow slice within single buffer', function (t) {
+  t.plan(2)
+  var bl = new BufferList(['First', 'Second', 'Third'])
+
+  t.equal(bl.shallowSlice(5, 10).toString(), 'Secon')
+  t.equal(bl.shallowSlice(7, 10).toString(), 'con')
+  t.end()
+})
+
+tape('shallow slice single buffer', function (t) {
+  t.plan(3)
+  var bl = new BufferList(['First', 'Second', 'Third'])
+
+  t.equal(bl.shallowSlice(0, 5).toString(), 'First')
+  t.equal(bl.shallowSlice(5, 11).toString(), 'Second')
+  t.equal(bl.shallowSlice(11, 16).toString(), 'Third')
+})
+
+tape('shallow slice with negative or omitted indices', function (t) {
+  t.plan(4)
+  var bl = new BufferList(['First', 'Second', 'Third'])
+
+  t.equal(bl.shallowSlice().toString(), 'FirstSecondThird')
+  t.equal(bl.shallowSlice(5).toString(), 'SecondThird')
+  t.equal(bl.shallowSlice(5, -3).toString(), 'SecondTh')
+  t.equal(bl.shallowSlice(-8).toString(), 'ondThird')
+})
+
+tape('shallow slice does not make a copy', function (t) {
+  t.plan(1)
+  var buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
+  var bl = (new BufferList(buffers)).shallowSlice(5, -3)
+
+  buffers[1].fill('h')
+  buffers[2].fill('h')
+
+  t.equal(bl.toString(), 'hhhhhhhh')
+})
+
+tape('shallow slice with 0 length', function (t) {
+  t.plan(1)
+  var buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
+  var bl = (new BufferList(buffers)).shallowSlice(0, 0)
+  t.equal(bl.length, 0)
+})
+
+tape('shallow slice with 0 length from middle', function (t) {
+  t.plan(1)
+  var buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
+  var bl = (new BufferList(buffers)).shallowSlice(10, 10)
+  t.equal(bl.length, 0)
+})
+
+tape('duplicate', function (t) {
+  t.plan(2)
+
+  var bl = new BufferList('abcdefghij\xff\x00')
+    , dup = bl.duplicate()
+
+  t.equal(bl.prototype, dup.prototype)
+  t.equal(bl.toString('hex'), dup.toString('hex'))
+})
+
+tape('destroy no pipe', function (t) {
+  t.plan(2)
+
+  var bl = new BufferList('alsdkfja;lsdkfja;lsdk')
+  bl.destroy()
+
+  t.equal(bl._bufs.length, 0)
+  t.equal(bl.length, 0)
+})
+
+!process.browser && tape('destroy with pipe before read end', function (t) {
+  t.plan(2)
+
+  var bl = new BufferList()
+  fs.createReadStream(__dirname + '/test.js')
+    .pipe(bl)
+
+  bl.destroy()
+
+  t.equal(bl._bufs.length, 0)
+  t.equal(bl.length, 0)
+
+})
+
+!process.browser && tape('destroy with pipe before read end with race', function (t) {
+  t.plan(2)
+
+  var bl = new BufferList()
+  fs.createReadStream(__dirname + '/test.js')
+    .pipe(bl)
+
+  setTimeout(function () {
+    bl.destroy()
+    setTimeout(function () {
+      t.equal(bl._bufs.length, 0)
+      t.equal(bl.length, 0)
+    }, 500)
+  }, 500)
+})
+
+!process.browser && tape('destroy with pipe after read end', function (t) {
+  t.plan(2)
+
+  var bl = new BufferList()
+  fs.createReadStream(__dirname + '/test.js')
+    .on('end', onEnd)
+    .pipe(bl)
+
+  function onEnd () {
+    bl.destroy()
+
+    t.equal(bl._bufs.length, 0)
+    t.equal(bl.length, 0)
+  }
+})
+
+!process.browser && tape('destroy with pipe while writing to a destination', function (t) {
+  t.plan(4)
+
+  var bl = new BufferList()
+    , ds = new BufferList()
+
+  fs.createReadStream(__dirname + '/test.js')
+    .on('end', onEnd)
+    .pipe(bl)
+
+  function onEnd () {
+    bl.pipe(ds)
+
+    setTimeout(function () {
+      bl.destroy()
+
+      t.equals(bl._bufs.length, 0)
+      t.equals(bl.length, 0)
+
+      ds.destroy()
+
+      t.equals(bl._bufs.length, 0)
+      t.equals(bl.length, 0)
+
+    }, 100)
+  }
+})
+
+!process.browser && tape('handle error', function (t) {
+  t.plan(2)
+  fs.createReadStream('/does/not/exist').pipe(BufferList(function (err, data) {
+    t.ok(err instanceof Error, 'has error')
+    t.notOk(data, 'no data')
+  }))
+})

+ 657 - 0
node_modules/body-parser/HISTORY.md

@@ -0,0 +1,657 @@
+1.20.1 / 2022-10-06
+===================
+
+  * deps: qs@6.11.0
+  * perf: remove unnecessary object clone
+
+1.20.0 / 2022-04-02
+===================
+
+  * Fix error message for json parse whitespace in `strict`
+  * Fix internal error when inflated body exceeds limit
+  * Prevent loss of async hooks context
+  * Prevent hanging when request already read
+  * deps: depd@2.0.0
+    - Replace internal `eval` usage with `Function` constructor
+    - Use instance methods on `process` to check for listeners
+  * deps: http-errors@2.0.0
+    - deps: depd@2.0.0
+    - deps: statuses@2.0.1
+  * deps: on-finished@2.4.1
+  * deps: qs@6.10.3
+  * deps: raw-body@2.5.1
+    - deps: http-errors@2.0.0
+
+1.19.2 / 2022-02-15
+===================
+
+  * deps: bytes@3.1.2
+  * deps: qs@6.9.7
+    * Fix handling of `__proto__` keys
+  * deps: raw-body@2.4.3
+    - deps: bytes@3.1.2
+
+1.19.1 / 2021-12-10
+===================
+
+  * deps: bytes@3.1.1
+  * deps: http-errors@1.8.1
+    - deps: inherits@2.0.4
+    - deps: toidentifier@1.0.1
+    - deps: setprototypeof@1.2.0
+  * deps: qs@6.9.6
+  * deps: raw-body@2.4.2
+    - deps: bytes@3.1.1
+    - deps: http-errors@1.8.1
+  * deps: safe-buffer@5.2.1
+  * deps: type-is@~1.6.18
+
+1.19.0 / 2019-04-25
+===================
+
+  * deps: bytes@3.1.0
+    - Add petabyte (`pb`) support
+  * deps: http-errors@1.7.2
+    - Set constructor name when possible
+    - deps: setprototypeof@1.1.1
+    - deps: statuses@'>= 1.5.0 < 2'
+  * deps: iconv-lite@0.4.24
+    - Added encoding MIK
+  * deps: qs@6.7.0
+    - Fix parsing array brackets after index
+  * deps: raw-body@2.4.0
+    - deps: bytes@3.1.0
+    - deps: http-errors@1.7.2
+    - deps: iconv-lite@0.4.24
+  * deps: type-is@~1.6.17
+    - deps: mime-types@~2.1.24
+    - perf: prevent internal `throw` on invalid type
+
+1.18.3 / 2018-05-14
+===================
+
+  * Fix stack trace for strict json parse error
+  * deps: depd@~1.1.2
+    - perf: remove argument reassignment
+  * deps: http-errors@~1.6.3
+    - deps: depd@~1.1.2
+    - deps: setprototypeof@1.1.0
+    - deps: statuses@'>= 1.3.1 < 2'
+  * deps: iconv-lite@0.4.23
+    - Fix loading encoding with year appended
+    - Fix deprecation warnings on Node.js 10+
+  * deps: qs@6.5.2
+  * deps: raw-body@2.3.3
+    - deps: http-errors@1.6.3
+    - deps: iconv-lite@0.4.23
+  * deps: type-is@~1.6.16
+    - deps: mime-types@~2.1.18
+
+1.18.2 / 2017-09-22
+===================
+
+  * deps: debug@2.6.9
+  * perf: remove argument reassignment
+
+1.18.1 / 2017-09-12
+===================
+
+  * deps: content-type@~1.0.4
+    - perf: remove argument reassignment
+    - perf: skip parameter parsing when no parameters
+  * deps: iconv-lite@0.4.19
+    - Fix ISO-8859-1 regression
+    - Update Windows-1255
+  * deps: qs@6.5.1
+    - Fix parsing & compacting very deep objects
+  * deps: raw-body@2.3.2
+    - deps: iconv-lite@0.4.19
+
+1.18.0 / 2017-09-08
+===================
+
+  * Fix JSON strict violation error to match native parse error
+  * Include the `body` property on verify errors
+  * Include the `type` property on all generated errors
+  * Use `http-errors` to set status code on errors
+  * deps: bytes@3.0.0
+  * deps: debug@2.6.8
+  * deps: depd@~1.1.1
+    - Remove unnecessary `Buffer` loading
+  * deps: http-errors@~1.6.2
+    - deps: depd@1.1.1
+  * deps: iconv-lite@0.4.18
+    - Add support for React Native
+    - Add a warning if not loaded as utf-8
+    - Fix CESU-8 decoding in Node.js 8
+    - Improve speed of ISO-8859-1 encoding
+  * deps: qs@6.5.0
+  * deps: raw-body@2.3.1
+    - Use `http-errors` for standard emitted errors
+    - deps: bytes@3.0.0
+    - deps: iconv-lite@0.4.18
+    - perf: skip buffer decoding on overage chunk
+  * perf: prevent internal `throw` when missing charset
+
+1.17.2 / 2017-05-17
+===================
+
+  * deps: debug@2.6.7
+    - Fix `DEBUG_MAX_ARRAY_LENGTH`
+    - deps: ms@2.0.0
+  * deps: type-is@~1.6.15
+    - deps: mime-types@~2.1.15
+
+1.17.1 / 2017-03-06
+===================
+
+  * deps: qs@6.4.0
+    - Fix regression parsing keys starting with `[`
+
+1.17.0 / 2017-03-01
+===================
+
+  * deps: http-errors@~1.6.1
+    - Make `message` property enumerable for `HttpError`s
+    - deps: setprototypeof@1.0.3
+  * deps: qs@6.3.1
+    - Fix compacting nested arrays
+
+1.16.1 / 2017-02-10
+===================
+
+  * deps: debug@2.6.1
+    - Fix deprecation messages in WebStorm and other editors
+    - Undeprecate `DEBUG_FD` set to `1` or `2`
+
+1.16.0 / 2017-01-17
+===================
+
+  * deps: debug@2.6.0
+    - Allow colors in workers
+    - Deprecated `DEBUG_FD` environment variable
+    - Fix error when running under React Native
+    - Use same color for same namespace
+    - deps: ms@0.7.2
+  * deps: http-errors@~1.5.1
+    - deps: inherits@2.0.3
+    - deps: setprototypeof@1.0.2
+    - deps: statuses@'>= 1.3.1 < 2'
+  * deps: iconv-lite@0.4.15
+    - Added encoding MS-31J
+    - Added encoding MS-932
+    - Added encoding MS-936
+    - Added encoding MS-949
+    - Added encoding MS-950
+    - Fix GBK/GB18030 handling of Euro character
+  * deps: qs@6.2.1
+    - Fix array parsing from skipping empty values
+  * deps: raw-body@~2.2.0
+    - deps: iconv-lite@0.4.15
+  * deps: type-is@~1.6.14
+    - deps: mime-types@~2.1.13
+
+1.15.2 / 2016-06-19
+===================
+
+  * deps: bytes@2.4.0
+  * deps: content-type@~1.0.2
+    - perf: enable strict mode
+  * deps: http-errors@~1.5.0
+    - Use `setprototypeof` module to replace `__proto__` setting
+    - deps: statuses@'>= 1.3.0 < 2'
+    - perf: enable strict mode
+  * deps: qs@6.2.0
+  * deps: raw-body@~2.1.7
+    - deps: bytes@2.4.0
+    - perf: remove double-cleanup on happy path
+  * deps: type-is@~1.6.13
+    - deps: mime-types@~2.1.11
+
+1.15.1 / 2016-05-05
+===================
+
+  * deps: bytes@2.3.0
+    - Drop partial bytes on all parsed units
+    - Fix parsing byte string that looks like hex
+  * deps: raw-body@~2.1.6
+    - deps: bytes@2.3.0
+  * deps: type-is@~1.6.12
+    - deps: mime-types@~2.1.10
+
+1.15.0 / 2016-02-10
+===================
+
+  * deps: http-errors@~1.4.0
+    - Add `HttpError` export, for `err instanceof createError.HttpError`
+    - deps: inherits@2.0.1
+    - deps: statuses@'>= 1.2.1 < 2'
+  * deps: qs@6.1.0
+  * deps: type-is@~1.6.11
+    - deps: mime-types@~2.1.9
+
+1.14.2 / 2015-12-16
+===================
+
+  * deps: bytes@2.2.0
+  * deps: iconv-lite@0.4.13
+  * deps: qs@5.2.0
+  * deps: raw-body@~2.1.5
+    - deps: bytes@2.2.0
+    - deps: iconv-lite@0.4.13
+  * deps: type-is@~1.6.10
+    - deps: mime-types@~2.1.8
+
+1.14.1 / 2015-09-27
+===================
+
+  * Fix issue where invalid charset results in 400 when `verify` used
+  * deps: iconv-lite@0.4.12
+    - Fix CESU-8 decoding in Node.js 4.x
+  * deps: raw-body@~2.1.4
+    - Fix masking critical errors from `iconv-lite`
+    - deps: iconv-lite@0.4.12
+  * deps: type-is@~1.6.9
+    - deps: mime-types@~2.1.7
+
+1.14.0 / 2015-09-16
+===================
+
+  * Fix JSON strict parse error to match syntax errors
+  * Provide static `require` analysis in `urlencoded` parser
+  * deps: depd@~1.1.0
+    - Support web browser loading
+  * deps: qs@5.1.0
+  * deps: raw-body@~2.1.3
+    - Fix sync callback when attaching data listener causes sync read
+  * deps: type-is@~1.6.8
+    - Fix type error when given invalid type to match against
+    - deps: mime-types@~2.1.6
+
+1.13.3 / 2015-07-31
+===================
+
+  * deps: type-is@~1.6.6
+    - deps: mime-types@~2.1.4
+
+1.13.2 / 2015-07-05
+===================
+
+  * deps: iconv-lite@0.4.11
+  * deps: qs@4.0.0
+    - Fix dropping parameters like `hasOwnProperty`
+    - Fix user-visible incompatibilities from 3.1.0
+    - Fix various parsing edge cases
+  * deps: raw-body@~2.1.2
+    - Fix error stack traces to skip `makeError`
+    - deps: iconv-lite@0.4.11
+  * deps: type-is@~1.6.4
+    - deps: mime-types@~2.1.2
+    - perf: enable strict mode
+    - perf: remove argument reassignment
+
+1.13.1 / 2015-06-16
+===================
+
+  * deps: qs@2.4.2
+    - Downgraded from 3.1.0 because of user-visible incompatibilities
+
+1.13.0 / 2015-06-14
+===================
+
+  * Add `statusCode` property on `Error`s, in addition to `status`
+  * Change `type` default to `application/json` for JSON parser
+  * Change `type` default to `application/x-www-form-urlencoded` for urlencoded parser
+  * Provide static `require` analysis
+  * Use the `http-errors` module to generate errors
+  * deps: bytes@2.1.0
+    - Slight optimizations
+  * deps: iconv-lite@0.4.10
+    - The encoding UTF-16 without BOM now defaults to UTF-16LE when detection fails
+    - Leading BOM is now removed when decoding
+  * deps: on-finished@~2.3.0
+    - Add defined behavior for HTTP `CONNECT` requests
+    - Add defined behavior for HTTP `Upgrade` requests
+    - deps: ee-first@1.1.1
+  * deps: qs@3.1.0
+    - Fix dropping parameters like `hasOwnProperty`
+    - Fix various parsing edge cases
+    - Parsed object now has `null` prototype
+  * deps: raw-body@~2.1.1
+    - Use `unpipe` module for unpiping requests
+    - deps: iconv-lite@0.4.10
+  * deps: type-is@~1.6.3
+    - deps: mime-types@~2.1.1
+    - perf: reduce try block size
+    - perf: remove bitwise operations
+  * perf: enable strict mode
+  * perf: remove argument reassignment
+  * perf: remove delete call
+
+1.12.4 / 2015-05-10
+===================
+
+  * deps: debug@~2.2.0
+  * deps: qs@2.4.2
+    - Fix allowing parameters like `constructor`
+  * deps: on-finished@~2.2.1
+  * deps: raw-body@~2.0.1
+    - Fix a false-positive when unpiping in Node.js 0.8
+    - deps: bytes@2.0.1
+  * deps: type-is@~1.6.2
+    - deps: mime-types@~2.0.11
+
+1.12.3 / 2015-04-15
+===================
+
+  * Slight efficiency improvement when not debugging
+  * deps: depd@~1.0.1
+  * deps: iconv-lite@0.4.8
+    - Add encoding alias UNICODE-1-1-UTF-7
+  * deps: raw-body@1.3.4
+    - Fix hanging callback if request aborts during read
+    - deps: iconv-lite@0.4.8
+
+1.12.2 / 2015-03-16
+===================
+
+  * deps: qs@2.4.1
+    - Fix error when parameter `hasOwnProperty` is present
+
+1.12.1 / 2015-03-15
+===================
+
+  * deps: debug@~2.1.3
+    - Fix high intensity foreground color for bold
+    - deps: ms@0.7.0
+  * deps: type-is@~1.6.1
+    - deps: mime-types@~2.0.10
+
+1.12.0 / 2015-02-13
+===================
+
+  * add `debug` messages
+  * accept a function for the `type` option
+  * use `content-type` to parse `Content-Type` headers
+  * deps: iconv-lite@0.4.7
+    - Gracefully support enumerables on `Object.prototype`
+  * deps: raw-body@1.3.3
+    - deps: iconv-lite@0.4.7
+  * deps: type-is@~1.6.0
+    - fix argument reassignment
+    - fix false-positives in `hasBody` `Transfer-Encoding` check
+    - support wildcard for both type and subtype (`*/*`)
+    - deps: mime-types@~2.0.9
+
+1.11.0 / 2015-01-30
+===================
+
+  * make internal `extended: true` depth limit infinity
+  * deps: type-is@~1.5.6
+    - deps: mime-types@~2.0.8
+
+1.10.2 / 2015-01-20
+===================
+
+  * deps: iconv-lite@0.4.6
+    - Fix rare aliases of single-byte encodings
+  * deps: raw-body@1.3.2
+    - deps: iconv-lite@0.4.6
+
+1.10.1 / 2015-01-01
+===================
+
+  * deps: on-finished@~2.2.0
+  * deps: type-is@~1.5.5
+    - deps: mime-types@~2.0.7
+
+1.10.0 / 2014-12-02
+===================
+
+  * make internal `extended: true` array limit dynamic
+
+1.9.3 / 2014-11-21
+==================
+
+  * deps: iconv-lite@0.4.5
+    - Fix Windows-31J and X-SJIS encoding support
+  * deps: qs@2.3.3
+    - Fix `arrayLimit` behavior
+  * deps: raw-body@1.3.1
+    - deps: iconv-lite@0.4.5
+  * deps: type-is@~1.5.3
+    - deps: mime-types@~2.0.3
+
+1.9.2 / 2014-10-27
+==================
+
+  * deps: qs@2.3.2
+    - Fix parsing of mixed objects and values
+
+1.9.1 / 2014-10-22
+==================
+
+  * deps: on-finished@~2.1.1
+    - Fix handling of pipelined requests
+  * deps: qs@2.3.0
+    - Fix parsing of mixed implicit and explicit arrays
+  * deps: type-is@~1.5.2
+    - deps: mime-types@~2.0.2
+
+1.9.0 / 2014-09-24
+==================
+
+  * include the charset in "unsupported charset" error message
+  * include the encoding in "unsupported content encoding" error message
+  * deps: depd@~1.0.0
+
+1.8.4 / 2014-09-23
+==================
+
+  * fix content encoding to be case-insensitive
+
+1.8.3 / 2014-09-19
+==================
+
+  * deps: qs@2.2.4
+    - Fix issue with object keys starting with numbers truncated
+
+1.8.2 / 2014-09-15
+==================
+
+  * deps: depd@0.4.5
+
+1.8.1 / 2014-09-07
+==================
+
+  * deps: media-typer@0.3.0
+  * deps: type-is@~1.5.1
+
+1.8.0 / 2014-09-05
+==================
+
+  * make empty-body-handling consistent between chunked requests
+    - empty `json` produces `{}`
+    - empty `raw` produces `new Buffer(0)`
+    - empty `text` produces `''`
+    - empty `urlencoded` produces `{}`
+  * deps: qs@2.2.3
+    - Fix issue where first empty value in array is discarded
+  * deps: type-is@~1.5.0
+    - fix `hasbody` to be true for `content-length: 0`
+
+1.7.0 / 2014-09-01
+==================
+
+  * add `parameterLimit` option to `urlencoded` parser
+  * change `urlencoded` extended array limit to 100
+  * respond with 413 when over `parameterLimit` in `urlencoded`
+
+1.6.7 / 2014-08-29
+==================
+
+  * deps: qs@2.2.2
+    - Remove unnecessary cloning
+
+1.6.6 / 2014-08-27
+==================
+
+  * deps: qs@2.2.0
+    - Array parsing fix
+    - Performance improvements
+
+1.6.5 / 2014-08-16
+==================
+
+  * deps: on-finished@2.1.0
+
+1.6.4 / 2014-08-14
+==================
+
+  * deps: qs@1.2.2
+
+1.6.3 / 2014-08-10
+==================
+
+  * deps: qs@1.2.1
+
+1.6.2 / 2014-08-07
+==================
+
+  * deps: qs@1.2.0
+    - Fix parsing array of objects
+
+1.6.1 / 2014-08-06
+==================
+
+  * deps: qs@1.1.0
+    - Accept urlencoded square brackets
+    - Accept empty values in implicit array notation
+
+1.6.0 / 2014-08-05
+==================
+
+  * deps: qs@1.0.2
+    - Complete rewrite
+    - Limits array length to 20
+    - Limits object depth to 5
+    - Limits parameters to 1,000
+
+1.5.2 / 2014-07-27
+==================
+
+  * deps: depd@0.4.4
+    - Work-around v8 generating empty stack traces
+
+1.5.1 / 2014-07-26
+==================
+
+  * deps: depd@0.4.3
+    - Fix exception when global `Error.stackTraceLimit` is too low
+
+1.5.0 / 2014-07-20
+==================
+
+  * deps: depd@0.4.2
+    - Add `TRACE_DEPRECATION` environment variable
+    - Remove non-standard grey color from color output
+    - Support `--no-deprecation` argument
+    - Support `--trace-deprecation` argument
+  * deps: iconv-lite@0.4.4
+    - Added encoding UTF-7
+  * deps: raw-body@1.3.0
+    - deps: iconv-lite@0.4.4
+    - Added encoding UTF-7
+    - Fix `Cannot switch to old mode now` error on Node.js 0.10+
+  * deps: type-is@~1.3.2
+
+1.4.3 / 2014-06-19
+==================
+
+  * deps: type-is@1.3.1
+    - fix global variable leak
+
+1.4.2 / 2014-06-19
+==================
+
+  * deps: type-is@1.3.0
+    - improve type parsing
+
+1.4.1 / 2014-06-19
+==================
+
+  * fix urlencoded extended deprecation message
+
+1.4.0 / 2014-06-19
+==================
+
+  * add `text` parser
+  * add `raw` parser
+  * check accepted charset in content-type (accepts utf-8)
+  * check accepted encoding in content-encoding (accepts identity)
+  * deprecate `bodyParser()` middleware; use `.json()` and `.urlencoded()` as needed
+  * deprecate `urlencoded()` without provided `extended` option
+  * lazy-load urlencoded parsers
+  * parsers split into files for reduced mem usage
+  * support gzip and deflate bodies
+    - set `inflate: false` to turn off
+  * deps: raw-body@1.2.2
+    - Support all encodings from `iconv-lite`
+
+1.3.1 / 2014-06-11
+==================
+
+  * deps: type-is@1.2.1
+    - Switch dependency from mime to mime-types@1.0.0
+
+1.3.0 / 2014-05-31
+==================
+
+  * add `extended` option to urlencoded parser
+
+1.2.2 / 2014-05-27
+==================
+
+  * deps: raw-body@1.1.6
+    - assert stream encoding on node.js 0.8
+    - assert stream encoding on node.js < 0.10.6
+    - deps: bytes@1
+
+1.2.1 / 2014-05-26
+==================
+
+  * invoke `next(err)` after request fully read
+    - prevents hung responses and socket hang ups
+
+1.2.0 / 2014-05-11
+==================
+
+  * add `verify` option
+  * deps: type-is@1.2.0
+    - support suffix matching
+
+1.1.2 / 2014-05-11
+==================
+
+  * improve json parser speed
+
+1.1.1 / 2014-05-11
+==================
+
+  * fix repeated limit parsing with every request
+
+1.1.0 / 2014-05-10
+==================
+
+  * add `type` option
+  * deps: pin for safety and consistency
+
+1.0.2 / 2014-04-14
+==================
+
+  * use `type-is` module
+
+1.0.1 / 2014-03-20
+==================
+
+  * lower default limits to 100kb

+ 23 - 0
node_modules/body-parser/LICENSE

@@ -0,0 +1,23 @@
+(The MIT License)
+
+Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
+Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
+
+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.

+ 464 - 0
node_modules/body-parser/README.md

@@ -0,0 +1,464 @@
+# body-parser
+
+[![NPM Version][npm-image]][npm-url]
+[![NPM Downloads][downloads-image]][downloads-url]
+[![Build Status][github-actions-ci-image]][github-actions-ci-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
+
+Node.js body parsing middleware.
+
+Parse incoming request bodies in a middleware before your handlers, available
+under the `req.body` property.
+
+**Note** As `req.body`'s shape is based on user-controlled input, all
+properties and values in this object are untrusted and should be validated
+before trusting. For example, `req.body.foo.toString()` may fail in multiple
+ways, for example the `foo` property may not be there or may not be a string,
+and `toString` may not be a function and instead a string or other user input.
+
+[Learn about the anatomy of an HTTP transaction in Node.js](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/).
+
+_This does not handle multipart bodies_, due to their complex and typically
+large nature. For multipart bodies, you may be interested in the following
+modules:
+
+  * [busboy](https://www.npmjs.org/package/busboy#readme) and
+    [connect-busboy](https://www.npmjs.org/package/connect-busboy#readme)
+  * [multiparty](https://www.npmjs.org/package/multiparty#readme) and
+    [connect-multiparty](https://www.npmjs.org/package/connect-multiparty#readme)
+  * [formidable](https://www.npmjs.org/package/formidable#readme)
+  * [multer](https://www.npmjs.org/package/multer#readme)
+
+This module provides the following parsers:
+
+  * [JSON body parser](#bodyparserjsonoptions)
+  * [Raw body parser](#bodyparserrawoptions)
+  * [Text body parser](#bodyparsertextoptions)
+  * [URL-encoded form body parser](#bodyparserurlencodedoptions)
+
+Other body parsers you might be interested in:
+
+- [body](https://www.npmjs.org/package/body#readme)
+- [co-body](https://www.npmjs.org/package/co-body#readme)
+
+## Installation
+
+```sh
+$ npm install body-parser
+```
+
+## API
+
+```js
+var bodyParser = require('body-parser')
+```
+
+The `bodyParser` object exposes various factories to create middlewares. All
+middlewares will populate the `req.body` property with the parsed body when
+the `Content-Type` request header matches the `type` option, or an empty
+object (`{}`) if there was no body to parse, the `Content-Type` was not matched,
+or an error occurred.
+
+The various errors returned by this module are described in the
+[errors section](#errors).
+
+### bodyParser.json([options])
+
+Returns middleware that only parses `json` and only looks at requests where
+the `Content-Type` header matches the `type` option. This parser accepts any
+Unicode encoding of the body and supports automatic inflation of `gzip` and
+`deflate` encodings.
+
+A new `body` object containing the parsed data is populated on the `request`
+object after the middleware (i.e. `req.body`).
+
+#### Options
+
+The `json` function takes an optional `options` object that may contain any of
+the following keys:
+
+##### inflate
+
+When set to `true`, then deflated (compressed) bodies will be inflated; when
+`false`, deflated bodies are rejected. Defaults to `true`.
+
+##### limit
+
+Controls the maximum request body size. If this is a number, then the value
+specifies the number of bytes; if it is a string, the value is passed to the
+[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
+to `'100kb'`.
+
+##### reviver
+
+The `reviver` option is passed directly to `JSON.parse` as the second
+argument. You can find more information on this argument
+[in the MDN documentation about JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter).
+
+##### strict
+
+When set to `true`, will only accept arrays and objects; when `false` will
+accept anything `JSON.parse` accepts. Defaults to `true`.
+
+##### type
+
+The `type` option is used to determine what media type the middleware will
+parse. This option can be a string, array of strings, or a function. If not a
+function, `type` option is passed directly to the
+[type-is](https://www.npmjs.org/package/type-is#readme) library and this can
+be an extension name (like `json`), a mime type (like `application/json`), or
+a mime type with a wildcard (like `*/*` or `*/json`). If a function, the `type`
+option is called as `fn(req)` and the request is parsed if it returns a truthy
+value. Defaults to `application/json`.
+
+##### verify
+
+The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
+where `buf` is a `Buffer` of the raw request body and `encoding` is the
+encoding of the request. The parsing can be aborted by throwing an error.
+
+### bodyParser.raw([options])
+
+Returns middleware that parses all bodies as a `Buffer` and only looks at
+requests where the `Content-Type` header matches the `type` option. This
+parser supports automatic inflation of `gzip` and `deflate` encodings.
+
+A new `body` object containing the parsed data is populated on the `request`
+object after the middleware (i.e. `req.body`). This will be a `Buffer` object
+of the body.
+
+#### Options
+
+The `raw` function takes an optional `options` object that may contain any of
+the following keys:
+
+##### inflate
+
+When set to `true`, then deflated (compressed) bodies will be inflated; when
+`false`, deflated bodies are rejected. Defaults to `true`.
+
+##### limit
+
+Controls the maximum request body size. If this is a number, then the value
+specifies the number of bytes; if it is a string, the value is passed to the
+[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
+to `'100kb'`.
+
+##### type
+
+The `type` option is used to determine what media type the middleware will
+parse. This option can be a string, array of strings, or a function.
+If not a function, `type` option is passed directly to the
+[type-is](https://www.npmjs.org/package/type-is#readme) library and this
+can be an extension name (like `bin`), a mime type (like
+`application/octet-stream`), or a mime type with a wildcard (like `*/*` or
+`application/*`). If a function, the `type` option is called as `fn(req)`
+and the request is parsed if it returns a truthy value. Defaults to
+`application/octet-stream`.
+
+##### verify
+
+The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
+where `buf` is a `Buffer` of the raw request body and `encoding` is the
+encoding of the request. The parsing can be aborted by throwing an error.
+
+### bodyParser.text([options])
+
+Returns middleware that parses all bodies as a string and only looks at
+requests where the `Content-Type` header matches the `type` option. This
+parser supports automatic inflation of `gzip` and `deflate` encodings.
+
+A new `body` string containing the parsed data is populated on the `request`
+object after the middleware (i.e. `req.body`). This will be a string of the
+body.
+
+#### Options
+
+The `text` function takes an optional `options` object that may contain any of
+the following keys:
+
+##### defaultCharset
+
+Specify the default character set for the text content if the charset is not
+specified in the `Content-Type` header of the request. Defaults to `utf-8`.
+
+##### inflate
+
+When set to `true`, then deflated (compressed) bodies will be inflated; when
+`false`, deflated bodies are rejected. Defaults to `true`.
+
+##### limit
+
+Controls the maximum request body size. If this is a number, then the value
+specifies the number of bytes; if it is a string, the value is passed to the
+[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
+to `'100kb'`.
+
+##### type
+
+The `type` option is used to determine what media type the middleware will
+parse. This option can be a string, array of strings, or a function. If not
+a function, `type` option is passed directly to the
+[type-is](https://www.npmjs.org/package/type-is#readme) library and this can
+be an extension name (like `txt`), a mime type (like `text/plain`), or a mime
+type with a wildcard (like `*/*` or `text/*`). If a function, the `type`
+option is called as `fn(req)` and the request is parsed if it returns a
+truthy value. Defaults to `text/plain`.
+
+##### verify
+
+The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
+where `buf` is a `Buffer` of the raw request body and `encoding` is the
+encoding of the request. The parsing can be aborted by throwing an error.
+
+### bodyParser.urlencoded([options])
+
+Returns middleware that only parses `urlencoded` bodies and only looks at
+requests where the `Content-Type` header matches the `type` option. This
+parser accepts only UTF-8 encoding of the body and supports automatic
+inflation of `gzip` and `deflate` encodings.
+
+A new `body` object containing the parsed data is populated on the `request`
+object after the middleware (i.e. `req.body`). This object will contain
+key-value pairs, where the value can be a string or array (when `extended` is
+`false`), or any type (when `extended` is `true`).
+
+#### Options
+
+The `urlencoded` function takes an optional `options` object that may contain
+any of the following keys:
+
+##### extended
+
+The `extended` option allows to choose between parsing the URL-encoded data
+with the `querystring` library (when `false`) or the `qs` library (when
+`true`). The "extended" syntax allows for rich objects and arrays to be
+encoded into the URL-encoded format, allowing for a JSON-like experience
+with URL-encoded. For more information, please
+[see the qs library](https://www.npmjs.org/package/qs#readme).
+
+Defaults to `true`, but using the default has been deprecated. Please
+research into the difference between `qs` and `querystring` and choose the
+appropriate setting.
+
+##### inflate
+
+When set to `true`, then deflated (compressed) bodies will be inflated; when
+`false`, deflated bodies are rejected. Defaults to `true`.
+
+##### limit
+
+Controls the maximum request body size. If this is a number, then the value
+specifies the number of bytes; if it is a string, the value is passed to the
+[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
+to `'100kb'`.
+
+##### parameterLimit
+
+The `parameterLimit` option controls the maximum number of parameters that
+are allowed in the URL-encoded data. If a request contains more parameters
+than this value, a 413 will be returned to the client. Defaults to `1000`.
+
+##### type
+
+The `type` option is used to determine what media type the middleware will
+parse. This option can be a string, array of strings, or a function. If not
+a function, `type` option is passed directly to the
+[type-is](https://www.npmjs.org/package/type-is#readme) library and this can
+be an extension name (like `urlencoded`), a mime type (like
+`application/x-www-form-urlencoded`), or a mime type with a wildcard (like
+`*/x-www-form-urlencoded`). If a function, the `type` option is called as
+`fn(req)` and the request is parsed if it returns a truthy value. Defaults
+to `application/x-www-form-urlencoded`.
+
+##### verify
+
+The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
+where `buf` is a `Buffer` of the raw request body and `encoding` is the
+encoding of the request. The parsing can be aborted by throwing an error.
+
+## Errors
+
+The middlewares provided by this module create errors using the
+[`http-errors` module](https://www.npmjs.com/package/http-errors). The errors
+will typically have a `status`/`statusCode` property that contains the suggested
+HTTP response code, an `expose` property to determine if the `message` property
+should be displayed to the client, a `type` property to determine the type of
+error without matching against the `message`, and a `body` property containing
+the read body, if available.
+
+The following are the common errors created, though any error can come through
+for various reasons.
+
+### content encoding unsupported
+
+This error will occur when the request had a `Content-Encoding` header that
+contained an encoding but the "inflation" option was set to `false`. The
+`status` property is set to `415`, the `type` property is set to
+`'encoding.unsupported'`, and the `charset` property will be set to the
+encoding that is unsupported.
+
+### entity parse failed
+
+This error will occur when the request contained an entity that could not be
+parsed by the middleware. The `status` property is set to `400`, the `type`
+property is set to `'entity.parse.failed'`, and the `body` property is set to
+the entity value that failed parsing.
+
+### entity verify failed
+
+This error will occur when the request contained an entity that could not be
+failed verification by the defined `verify` option. The `status` property is
+set to `403`, the `type` property is set to `'entity.verify.failed'`, and the
+`body` property is set to the entity value that failed verification.
+
+### request aborted
+
+This error will occur when the request is aborted by the client before reading
+the body has finished. The `received` property will be set to the number of
+bytes received before the request was aborted and the `expected` property is
+set to the number of expected bytes. The `status` property is set to `400`
+and `type` property is set to `'request.aborted'`.
+
+### request entity too large
+
+This error will occur when the request body's size is larger than the "limit"
+option. The `limit` property will be set to the byte limit and the `length`
+property will be set to the request body's length. The `status` property is
+set to `413` and the `type` property is set to `'entity.too.large'`.
+
+### request size did not match content length
+
+This error will occur when the request's length did not match the length from
+the `Content-Length` header. This typically occurs when the request is malformed,
+typically when the `Content-Length` header was calculated based on characters
+instead of bytes. The `status` property is set to `400` and the `type` property
+is set to `'request.size.invalid'`.
+
+### stream encoding should not be set
+
+This error will occur when something called the `req.setEncoding` method prior
+to this middleware. This module operates directly on bytes only and you cannot
+call `req.setEncoding` when using this module. The `status` property is set to
+`500` and the `type` property is set to `'stream.encoding.set'`.
+
+### stream is not readable
+
+This error will occur when the request is no longer readable when this middleware
+attempts to read it. This typically means something other than a middleware from
+this module read the request body already and the middleware was also configured to
+read the same request. The `status` property is set to `500` and the `type`
+property is set to `'stream.not.readable'`.
+
+### too many parameters
+
+This error will occur when the content of the request exceeds the configured
+`parameterLimit` for the `urlencoded` parser. The `status` property is set to
+`413` and the `type` property is set to `'parameters.too.many'`.
+
+### unsupported charset "BOGUS"
+
+This error will occur when the request had a charset parameter in the
+`Content-Type` header, but the `iconv-lite` module does not support it OR the
+parser does not support it. The charset is contained in the message as well
+as in the `charset` property. The `status` property is set to `415`, the
+`type` property is set to `'charset.unsupported'`, and the `charset` property
+is set to the charset that is unsupported.
+
+### unsupported content encoding "bogus"
+
+This error will occur when the request had a `Content-Encoding` header that
+contained an unsupported encoding. The encoding is contained in the message
+as well as in the `encoding` property. The `status` property is set to `415`,
+the `type` property is set to `'encoding.unsupported'`, and the `encoding`
+property is set to the encoding that is unsupported.
+
+## Examples
+
+### Express/Connect top-level generic
+
+This example demonstrates adding a generic JSON and URL-encoded parser as a
+top-level middleware, which will parse the bodies of all incoming requests.
+This is the simplest setup.
+
+```js
+var express = require('express')
+var bodyParser = require('body-parser')
+
+var app = express()
+
+// parse application/x-www-form-urlencoded
+app.use(bodyParser.urlencoded({ extended: false }))
+
+// parse application/json
+app.use(bodyParser.json())
+
+app.use(function (req, res) {
+  res.setHeader('Content-Type', 'text/plain')
+  res.write('you posted:\n')
+  res.end(JSON.stringify(req.body, null, 2))
+})
+```
+
+### Express route-specific
+
+This example demonstrates adding body parsers specifically to the routes that
+need them. In general, this is the most recommended way to use body-parser with
+Express.
+
+```js
+var express = require('express')
+var bodyParser = require('body-parser')
+
+var app = express()
+
+// create application/json parser
+var jsonParser = bodyParser.json()
+
+// create application/x-www-form-urlencoded parser
+var urlencodedParser = bodyParser.urlencoded({ extended: false })
+
+// POST /login gets urlencoded bodies
+app.post('/login', urlencodedParser, function (req, res) {
+  res.send('welcome, ' + req.body.username)
+})
+
+// POST /api/users gets JSON bodies
+app.post('/api/users', jsonParser, function (req, res) {
+  // create user in req.body
+})
+```
+
+### Change accepted type for parsers
+
+All the parsers accept a `type` option which allows you to change the
+`Content-Type` that the middleware will parse.
+
+```js
+var express = require('express')
+var bodyParser = require('body-parser')
+
+var app = express()
+
+// parse various different custom JSON types as JSON
+app.use(bodyParser.json({ type: 'application/*+json' }))
+
+// parse some custom thing into a Buffer
+app.use(bodyParser.raw({ type: 'application/vnd.custom-type' }))
+
+// parse an HTML body into a string
+app.use(bodyParser.text({ type: 'text/html' }))
+```
+
+## License
+
+[MIT](LICENSE)
+
+[npm-image]: https://img.shields.io/npm/v/body-parser.svg
+[npm-url]: https://npmjs.org/package/body-parser
+[coveralls-image]: https://img.shields.io/coveralls/expressjs/body-parser/master.svg
+[coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master
+[downloads-image]: https://img.shields.io/npm/dm/body-parser.svg
+[downloads-url]: https://npmjs.org/package/body-parser
+[github-actions-ci-image]: https://img.shields.io/github/workflow/status/expressjs/body-parser/ci/master?label=ci
+[github-actions-ci-url]: https://github.com/expressjs/body-parser/actions/workflows/ci.yml

+ 25 - 0
node_modules/body-parser/SECURITY.md

@@ -0,0 +1,25 @@
+# Security Policies and Procedures
+
+## Reporting a Bug
+
+The Express team and community take all security bugs seriously. Thank you
+for improving the security of Express. We appreciate your efforts and
+responsible disclosure and will make every effort to acknowledge your
+contributions.
+
+Report security bugs by emailing the current owner(s) of `body-parser`. This
+information can be found in the npm registry using the command
+`npm owner ls body-parser`.
+If unsure or unable to get the information from the above, open an issue
+in the [project issue tracker](https://github.com/expressjs/body-parser/issues)
+asking for the current contact information.
+
+To ensure the timely response to your report, please ensure that the entirety
+of the report is contained within the email body and not solely behind a web
+link or an attachment.
+
+At least one owner will acknowledge your email within 48 hours, and will send a
+more detailed response within 48 hours indicating the next steps in handling
+your report. After the initial reply to your report, the owners will
+endeavor to keep you informed of the progress towards a fix and full
+announcement, and may ask for additional information or guidance.

+ 156 - 0
node_modules/body-parser/index.js

@@ -0,0 +1,156 @@
+/*!
+ * body-parser
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var deprecate = require('depd')('body-parser')
+
+/**
+ * Cache of loaded parsers.
+ * @private
+ */
+
+var parsers = Object.create(null)
+
+/**
+ * @typedef Parsers
+ * @type {function}
+ * @property {function} json
+ * @property {function} raw
+ * @property {function} text
+ * @property {function} urlencoded
+ */
+
+/**
+ * Module exports.
+ * @type {Parsers}
+ */
+
+exports = module.exports = deprecate.function(bodyParser,
+  'bodyParser: use individual json/urlencoded middlewares')
+
+/**
+ * JSON parser.
+ * @public
+ */
+
+Object.defineProperty(exports, 'json', {
+  configurable: true,
+  enumerable: true,
+  get: createParserGetter('json')
+})
+
+/**
+ * Raw parser.
+ * @public
+ */
+
+Object.defineProperty(exports, 'raw', {
+  configurable: true,
+  enumerable: true,
+  get: createParserGetter('raw')
+})
+
+/**
+ * Text parser.
+ * @public
+ */
+
+Object.defineProperty(exports, 'text', {
+  configurable: true,
+  enumerable: true,
+  get: createParserGetter('text')
+})
+
+/**
+ * URL-encoded parser.
+ * @public
+ */
+
+Object.defineProperty(exports, 'urlencoded', {
+  configurable: true,
+  enumerable: true,
+  get: createParserGetter('urlencoded')
+})
+
+/**
+ * Create a middleware to parse json and urlencoded bodies.
+ *
+ * @param {object} [options]
+ * @return {function}
+ * @deprecated
+ * @public
+ */
+
+function bodyParser (options) {
+  // use default type for parsers
+  var opts = Object.create(options || null, {
+    type: {
+      configurable: true,
+      enumerable: true,
+      value: undefined,
+      writable: true
+    }
+  })
+
+  var _urlencoded = exports.urlencoded(opts)
+  var _json = exports.json(opts)
+
+  return function bodyParser (req, res, next) {
+    _json(req, res, function (err) {
+      if (err) return next(err)
+      _urlencoded(req, res, next)
+    })
+  }
+}
+
+/**
+ * Create a getter for loading a parser.
+ * @private
+ */
+
+function createParserGetter (name) {
+  return function get () {
+    return loadParser(name)
+  }
+}
+
+/**
+ * Load a parser module.
+ * @private
+ */
+
+function loadParser (parserName) {
+  var parser = parsers[parserName]
+
+  if (parser !== undefined) {
+    return parser
+  }
+
+  // this uses a switch for static require analysis
+  switch (parserName) {
+    case 'json':
+      parser = require('./lib/types/json')
+      break
+    case 'raw':
+      parser = require('./lib/types/raw')
+      break
+    case 'text':
+      parser = require('./lib/types/text')
+      break
+    case 'urlencoded':
+      parser = require('./lib/types/urlencoded')
+      break
+  }
+
+  // store to prevent invoking require()
+  return (parsers[parserName] = parser)
+}

+ 205 - 0
node_modules/body-parser/lib/read.js

@@ -0,0 +1,205 @@
+/*!
+ * body-parser
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var createError = require('http-errors')
+var destroy = require('destroy')
+var getBody = require('raw-body')
+var iconv = require('iconv-lite')
+var onFinished = require('on-finished')
+var unpipe = require('unpipe')
+var zlib = require('zlib')
+
+/**
+ * Module exports.
+ */
+
+module.exports = read
+
+/**
+ * Read a request into a buffer and parse.
+ *
+ * @param {object} req
+ * @param {object} res
+ * @param {function} next
+ * @param {function} parse
+ * @param {function} debug
+ * @param {object} options
+ * @private
+ */
+
+function read (req, res, next, parse, debug, options) {
+  var length
+  var opts = options
+  var stream
+
+  // flag as parsed
+  req._body = true
+
+  // read options
+  var encoding = opts.encoding !== null
+    ? opts.encoding
+    : null
+  var verify = opts.verify
+
+  try {
+    // get the content stream
+    stream = contentstream(req, debug, opts.inflate)
+    length = stream.length
+    stream.length = undefined
+  } catch (err) {
+    return next(err)
+  }
+
+  // set raw-body options
+  opts.length = length
+  opts.encoding = verify
+    ? null
+    : encoding
+
+  // assert charset is supported
+  if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
+    return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
+      charset: encoding.toLowerCase(),
+      type: 'charset.unsupported'
+    }))
+  }
+
+  // read body
+  debug('read body')
+  getBody(stream, opts, function (error, body) {
+    if (error) {
+      var _error
+
+      if (error.type === 'encoding.unsupported') {
+        // echo back charset
+        _error = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
+          charset: encoding.toLowerCase(),
+          type: 'charset.unsupported'
+        })
+      } else {
+        // set status code on error
+        _error = createError(400, error)
+      }
+
+      // unpipe from stream and destroy
+      if (stream !== req) {
+        unpipe(req)
+        destroy(stream, true)
+      }
+
+      // read off entire request
+      dump(req, function onfinished () {
+        next(createError(400, _error))
+      })
+      return
+    }
+
+    // verify
+    if (verify) {
+      try {
+        debug('verify body')
+        verify(req, res, body, encoding)
+      } catch (err) {
+        next(createError(403, err, {
+          body: body,
+          type: err.type || 'entity.verify.failed'
+        }))
+        return
+      }
+    }
+
+    // parse
+    var str = body
+    try {
+      debug('parse body')
+      str = typeof body !== 'string' && encoding !== null
+        ? iconv.decode(body, encoding)
+        : body
+      req.body = parse(str)
+    } catch (err) {
+      next(createError(400, err, {
+        body: str,
+        type: err.type || 'entity.parse.failed'
+      }))
+      return
+    }
+
+    next()
+  })
+}
+
+/**
+ * Get the content stream of the request.
+ *
+ * @param {object} req
+ * @param {function} debug
+ * @param {boolean} [inflate=true]
+ * @return {object}
+ * @api private
+ */
+
+function contentstream (req, debug, inflate) {
+  var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
+  var length = req.headers['content-length']
+  var stream
+
+  debug('content-encoding "%s"', encoding)
+
+  if (inflate === false && encoding !== 'identity') {
+    throw createError(415, 'content encoding unsupported', {
+      encoding: encoding,
+      type: 'encoding.unsupported'
+    })
+  }
+
+  switch (encoding) {
+    case 'deflate':
+      stream = zlib.createInflate()
+      debug('inflate body')
+      req.pipe(stream)
+      break
+    case 'gzip':
+      stream = zlib.createGunzip()
+      debug('gunzip body')
+      req.pipe(stream)
+      break
+    case 'identity':
+      stream = req
+      stream.length = length
+      break
+    default:
+      throw createError(415, 'unsupported content encoding "' + encoding + '"', {
+        encoding: encoding,
+        type: 'encoding.unsupported'
+      })
+  }
+
+  return stream
+}
+
+/**
+ * Dump the contents of a request.
+ *
+ * @param {object} req
+ * @param {function} callback
+ * @api private
+ */
+
+function dump (req, callback) {
+  if (onFinished.isFinished(req)) {
+    callback(null)
+  } else {
+    onFinished(req, callback)
+    req.resume()
+  }
+}

+ 236 - 0
node_modules/body-parser/lib/types/json.js

@@ -0,0 +1,236 @@
+/*!
+ * body-parser
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var bytes = require('bytes')
+var contentType = require('content-type')
+var createError = require('http-errors')
+var debug = require('debug')('body-parser:json')
+var read = require('../read')
+var typeis = require('type-is')
+
+/**
+ * Module exports.
+ */
+
+module.exports = json
+
+/**
+ * RegExp to match the first non-space in a string.
+ *
+ * Allowed whitespace is defined in RFC 7159:
+ *
+ *    ws = *(
+ *            %x20 /              ; Space
+ *            %x09 /              ; Horizontal tab
+ *            %x0A /              ; Line feed or New line
+ *            %x0D )              ; Carriage return
+ */
+
+var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/ // eslint-disable-line no-control-regex
+
+/**
+ * Create a middleware to parse JSON bodies.
+ *
+ * @param {object} [options]
+ * @return {function}
+ * @public
+ */
+
+function json (options) {
+  var opts = options || {}
+
+  var limit = typeof opts.limit !== 'number'
+    ? bytes.parse(opts.limit || '100kb')
+    : opts.limit
+  var inflate = opts.inflate !== false
+  var reviver = opts.reviver
+  var strict = opts.strict !== false
+  var type = opts.type || 'application/json'
+  var verify = opts.verify || false
+
+  if (verify !== false && typeof verify !== 'function') {
+    throw new TypeError('option verify must be function')
+  }
+
+  // create the appropriate type checking function
+  var shouldParse = typeof type !== 'function'
+    ? typeChecker(type)
+    : type
+
+  function parse (body) {
+    if (body.length === 0) {
+      // special-case empty json body, as it's a common client-side mistake
+      // TODO: maybe make this configurable or part of "strict" option
+      return {}
+    }
+
+    if (strict) {
+      var first = firstchar(body)
+
+      if (first !== '{' && first !== '[') {
+        debug('strict violation')
+        throw createStrictSyntaxError(body, first)
+      }
+    }
+
+    try {
+      debug('parse json')
+      return JSON.parse(body, reviver)
+    } catch (e) {
+      throw normalizeJsonSyntaxError(e, {
+        message: e.message,
+        stack: e.stack
+      })
+    }
+  }
+
+  return function jsonParser (req, res, next) {
+    if (req._body) {
+      debug('body already parsed')
+      next()
+      return
+    }
+
+    req.body = req.body || {}
+
+    // skip requests without bodies
+    if (!typeis.hasBody(req)) {
+      debug('skip empty body')
+      next()
+      return
+    }
+
+    debug('content-type %j', req.headers['content-type'])
+
+    // determine if request should be parsed
+    if (!shouldParse(req)) {
+      debug('skip parsing')
+      next()
+      return
+    }
+
+    // assert charset per RFC 7159 sec 8.1
+    var charset = getCharset(req) || 'utf-8'
+    if (charset.slice(0, 4) !== 'utf-') {
+      debug('invalid charset')
+      next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
+        charset: charset,
+        type: 'charset.unsupported'
+      }))
+      return
+    }
+
+    // read
+    read(req, res, next, parse, debug, {
+      encoding: charset,
+      inflate: inflate,
+      limit: limit,
+      verify: verify
+    })
+  }
+}
+
+/**
+ * Create strict violation syntax error matching native error.
+ *
+ * @param {string} str
+ * @param {string} char
+ * @return {Error}
+ * @private
+ */
+
+function createStrictSyntaxError (str, char) {
+  var index = str.indexOf(char)
+  var partial = index !== -1
+    ? str.substring(0, index) + '#'
+    : ''
+
+  try {
+    JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')
+  } catch (e) {
+    return normalizeJsonSyntaxError(e, {
+      message: e.message.replace('#', char),
+      stack: e.stack
+    })
+  }
+}
+
+/**
+ * Get the first non-whitespace character in a string.
+ *
+ * @param {string} str
+ * @return {function}
+ * @private
+ */
+
+function firstchar (str) {
+  var match = FIRST_CHAR_REGEXP.exec(str)
+
+  return match
+    ? match[1]
+    : undefined
+}
+
+/**
+ * Get the charset of a request.
+ *
+ * @param {object} req
+ * @api private
+ */
+
+function getCharset (req) {
+  try {
+    return (contentType.parse(req).parameters.charset || '').toLowerCase()
+  } catch (e) {
+    return undefined
+  }
+}
+
+/**
+ * Normalize a SyntaxError for JSON.parse.
+ *
+ * @param {SyntaxError} error
+ * @param {object} obj
+ * @return {SyntaxError}
+ */
+
+function normalizeJsonSyntaxError (error, obj) {
+  var keys = Object.getOwnPropertyNames(error)
+
+  for (var i = 0; i < keys.length; i++) {
+    var key = keys[i]
+    if (key !== 'stack' && key !== 'message') {
+      delete error[key]
+    }
+  }
+
+  // replace stack before message for Node.js 0.10 and below
+  error.stack = obj.stack.replace(error.message, obj.message)
+  error.message = obj.message
+
+  return error
+}
+
+/**
+ * Get the simple type checker.
+ *
+ * @param {string} type
+ * @return {function}
+ */
+
+function typeChecker (type) {
+  return function checkType (req) {
+    return Boolean(typeis(req, type))
+  }
+}

+ 101 - 0
node_modules/body-parser/lib/types/raw.js

@@ -0,0 +1,101 @@
+/*!
+ * body-parser
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ */
+
+var bytes = require('bytes')
+var debug = require('debug')('body-parser:raw')
+var read = require('../read')
+var typeis = require('type-is')
+
+/**
+ * Module exports.
+ */
+
+module.exports = raw
+
+/**
+ * Create a middleware to parse raw bodies.
+ *
+ * @param {object} [options]
+ * @return {function}
+ * @api public
+ */
+
+function raw (options) {
+  var opts = options || {}
+
+  var inflate = opts.inflate !== false
+  var limit = typeof opts.limit !== 'number'
+    ? bytes.parse(opts.limit || '100kb')
+    : opts.limit
+  var type = opts.type || 'application/octet-stream'
+  var verify = opts.verify || false
+
+  if (verify !== false && typeof verify !== 'function') {
+    throw new TypeError('option verify must be function')
+  }
+
+  // create the appropriate type checking function
+  var shouldParse = typeof type !== 'function'
+    ? typeChecker(type)
+    : type
+
+  function parse (buf) {
+    return buf
+  }
+
+  return function rawParser (req, res, next) {
+    if (req._body) {
+      debug('body already parsed')
+      next()
+      return
+    }
+
+    req.body = req.body || {}
+
+    // skip requests without bodies
+    if (!typeis.hasBody(req)) {
+      debug('skip empty body')
+      next()
+      return
+    }
+
+    debug('content-type %j', req.headers['content-type'])
+
+    // determine if request should be parsed
+    if (!shouldParse(req)) {
+      debug('skip parsing')
+      next()
+      return
+    }
+
+    // read
+    read(req, res, next, parse, debug, {
+      encoding: null,
+      inflate: inflate,
+      limit: limit,
+      verify: verify
+    })
+  }
+}
+
+/**
+ * Get the simple type checker.
+ *
+ * @param {string} type
+ * @return {function}
+ */
+
+function typeChecker (type) {
+  return function checkType (req) {
+    return Boolean(typeis(req, type))
+  }
+}

+ 121 - 0
node_modules/body-parser/lib/types/text.js

@@ -0,0 +1,121 @@
+/*!
+ * body-parser
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ */
+
+var bytes = require('bytes')
+var contentType = require('content-type')
+var debug = require('debug')('body-parser:text')
+var read = require('../read')
+var typeis = require('type-is')
+
+/**
+ * Module exports.
+ */
+
+module.exports = text
+
+/**
+ * Create a middleware to parse text bodies.
+ *
+ * @param {object} [options]
+ * @return {function}
+ * @api public
+ */
+
+function text (options) {
+  var opts = options || {}
+
+  var defaultCharset = opts.defaultCharset || 'utf-8'
+  var inflate = opts.inflate !== false
+  var limit = typeof opts.limit !== 'number'
+    ? bytes.parse(opts.limit || '100kb')
+    : opts.limit
+  var type = opts.type || 'text/plain'
+  var verify = opts.verify || false
+
+  if (verify !== false && typeof verify !== 'function') {
+    throw new TypeError('option verify must be function')
+  }
+
+  // create the appropriate type checking function
+  var shouldParse = typeof type !== 'function'
+    ? typeChecker(type)
+    : type
+
+  function parse (buf) {
+    return buf
+  }
+
+  return function textParser (req, res, next) {
+    if (req._body) {
+      debug('body already parsed')
+      next()
+      return
+    }
+
+    req.body = req.body || {}
+
+    // skip requests without bodies
+    if (!typeis.hasBody(req)) {
+      debug('skip empty body')
+      next()
+      return
+    }
+
+    debug('content-type %j', req.headers['content-type'])
+
+    // determine if request should be parsed
+    if (!shouldParse(req)) {
+      debug('skip parsing')
+      next()
+      return
+    }
+
+    // get charset
+    var charset = getCharset(req) || defaultCharset
+
+    // read
+    read(req, res, next, parse, debug, {
+      encoding: charset,
+      inflate: inflate,
+      limit: limit,
+      verify: verify
+    })
+  }
+}
+
+/**
+ * Get the charset of a request.
+ *
+ * @param {object} req
+ * @api private
+ */
+
+function getCharset (req) {
+  try {
+    return (contentType.parse(req).parameters.charset || '').toLowerCase()
+  } catch (e) {
+    return undefined
+  }
+}
+
+/**
+ * Get the simple type checker.
+ *
+ * @param {string} type
+ * @return {function}
+ */
+
+function typeChecker (type) {
+  return function checkType (req) {
+    return Boolean(typeis(req, type))
+  }
+}

+ 284 - 0
node_modules/body-parser/lib/types/urlencoded.js

@@ -0,0 +1,284 @@
+/*!
+ * body-parser
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var bytes = require('bytes')
+var contentType = require('content-type')
+var createError = require('http-errors')
+var debug = require('debug')('body-parser:urlencoded')
+var deprecate = require('depd')('body-parser')
+var read = require('../read')
+var typeis = require('type-is')
+
+/**
+ * Module exports.
+ */
+
+module.exports = urlencoded
+
+/**
+ * Cache of parser modules.
+ */
+
+var parsers = Object.create(null)
+
+/**
+ * Create a middleware to parse urlencoded bodies.
+ *
+ * @param {object} [options]
+ * @return {function}
+ * @public
+ */
+
+function urlencoded (options) {
+  var opts = options || {}
+
+  // notice because option default will flip in next major
+  if (opts.extended === undefined) {
+    deprecate('undefined extended: provide extended option')
+  }
+
+  var extended = opts.extended !== false
+  var inflate = opts.inflate !== false
+  var limit = typeof opts.limit !== 'number'
+    ? bytes.parse(opts.limit || '100kb')
+    : opts.limit
+  var type = opts.type || 'application/x-www-form-urlencoded'
+  var verify = opts.verify || false
+
+  if (verify !== false && typeof verify !== 'function') {
+    throw new TypeError('option verify must be function')
+  }
+
+  // create the appropriate query parser
+  var queryparse = extended
+    ? extendedparser(opts)
+    : simpleparser(opts)
+
+  // create the appropriate type checking function
+  var shouldParse = typeof type !== 'function'
+    ? typeChecker(type)
+    : type
+
+  function parse (body) {
+    return body.length
+      ? queryparse(body)
+      : {}
+  }
+
+  return function urlencodedParser (req, res, next) {
+    if (req._body) {
+      debug('body already parsed')
+      next()
+      return
+    }
+
+    req.body = req.body || {}
+
+    // skip requests without bodies
+    if (!typeis.hasBody(req)) {
+      debug('skip empty body')
+      next()
+      return
+    }
+
+    debug('content-type %j', req.headers['content-type'])
+
+    // determine if request should be parsed
+    if (!shouldParse(req)) {
+      debug('skip parsing')
+      next()
+      return
+    }
+
+    // assert charset
+    var charset = getCharset(req) || 'utf-8'
+    if (charset !== 'utf-8') {
+      debug('invalid charset')
+      next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
+        charset: charset,
+        type: 'charset.unsupported'
+      }))
+      return
+    }
+
+    // read
+    read(req, res, next, parse, debug, {
+      debug: debug,
+      encoding: charset,
+      inflate: inflate,
+      limit: limit,
+      verify: verify
+    })
+  }
+}
+
+/**
+ * Get the extended query parser.
+ *
+ * @param {object} options
+ */
+
+function extendedparser (options) {
+  var parameterLimit = options.parameterLimit !== undefined
+    ? options.parameterLimit
+    : 1000
+  var parse = parser('qs')
+
+  if (isNaN(parameterLimit) || parameterLimit < 1) {
+    throw new TypeError('option parameterLimit must be a positive number')
+  }
+
+  if (isFinite(parameterLimit)) {
+    parameterLimit = parameterLimit | 0
+  }
+
+  return function queryparse (body) {
+    var paramCount = parameterCount(body, parameterLimit)
+
+    if (paramCount === undefined) {
+      debug('too many parameters')
+      throw createError(413, 'too many parameters', {
+        type: 'parameters.too.many'
+      })
+    }
+
+    var arrayLimit = Math.max(100, paramCount)
+
+    debug('parse extended urlencoding')
+    return parse(body, {
+      allowPrototypes: true,
+      arrayLimit: arrayLimit,
+      depth: Infinity,
+      parameterLimit: parameterLimit
+    })
+  }
+}
+
+/**
+ * Get the charset of a request.
+ *
+ * @param {object} req
+ * @api private
+ */
+
+function getCharset (req) {
+  try {
+    return (contentType.parse(req).parameters.charset || '').toLowerCase()
+  } catch (e) {
+    return undefined
+  }
+}
+
+/**
+ * Count the number of parameters, stopping once limit reached
+ *
+ * @param {string} body
+ * @param {number} limit
+ * @api private
+ */
+
+function parameterCount (body, limit) {
+  var count = 0
+  var index = 0
+
+  while ((index = body.indexOf('&', index)) !== -1) {
+    count++
+    index++
+
+    if (count === limit) {
+      return undefined
+    }
+  }
+
+  return count
+}
+
+/**
+ * Get parser for module name dynamically.
+ *
+ * @param {string} name
+ * @return {function}
+ * @api private
+ */
+
+function parser (name) {
+  var mod = parsers[name]
+
+  if (mod !== undefined) {
+    return mod.parse
+  }
+
+  // this uses a switch for static require analysis
+  switch (name) {
+    case 'qs':
+      mod = require('qs')
+      break
+    case 'querystring':
+      mod = require('querystring')
+      break
+  }
+
+  // store to prevent invoking require()
+  parsers[name] = mod
+
+  return mod.parse
+}
+
+/**
+ * Get the simple query parser.
+ *
+ * @param {object} options
+ */
+
+function simpleparser (options) {
+  var parameterLimit = options.parameterLimit !== undefined
+    ? options.parameterLimit
+    : 1000
+  var parse = parser('querystring')
+
+  if (isNaN(parameterLimit) || parameterLimit < 1) {
+    throw new TypeError('option parameterLimit must be a positive number')
+  }
+
+  if (isFinite(parameterLimit)) {
+    parameterLimit = parameterLimit | 0
+  }
+
+  return function queryparse (body) {
+    var paramCount = parameterCount(body, parameterLimit)
+
+    if (paramCount === undefined) {
+      debug('too many parameters')
+      throw createError(413, 'too many parameters', {
+        type: 'parameters.too.many'
+      })
+    }
+
+    debug('parse urlencoding')
+    return parse(body, undefined, undefined, { maxKeys: parameterLimit })
+  }
+}
+
+/**
+ * Get the simple type checker.
+ *
+ * @param {string} type
+ * @return {function}
+ */
+
+function typeChecker (type) {
+  return function checkType (req) {
+    return Boolean(typeis(req, type))
+  }
+}

+ 56 - 0
node_modules/body-parser/package.json

@@ -0,0 +1,56 @@
+{
+  "name": "body-parser",
+  "description": "Node.js body parsing middleware",
+  "version": "1.20.1",
+  "contributors": [
+    "Douglas Christopher Wilson <doug@somethingdoug.com>",
+    "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
+  ],
+  "license": "MIT",
+  "repository": "expressjs/body-parser",
+  "dependencies": {
+    "bytes": "3.1.2",
+    "content-type": "~1.0.4",
+    "debug": "2.6.9",
+    "depd": "2.0.0",
+    "destroy": "1.2.0",
+    "http-errors": "2.0.0",
+    "iconv-lite": "0.4.24",
+    "on-finished": "2.4.1",
+    "qs": "6.11.0",
+    "raw-body": "2.5.1",
+    "type-is": "~1.6.18",
+    "unpipe": "1.0.0"
+  },
+  "devDependencies": {
+    "eslint": "8.24.0",
+    "eslint-config-standard": "14.1.1",
+    "eslint-plugin-import": "2.26.0",
+    "eslint-plugin-markdown": "3.0.0",
+    "eslint-plugin-node": "11.1.0",
+    "eslint-plugin-promise": "6.0.1",
+    "eslint-plugin-standard": "4.1.0",
+    "methods": "1.1.2",
+    "mocha": "10.0.0",
+    "nyc": "15.1.0",
+    "safe-buffer": "5.2.1",
+    "supertest": "6.3.0"
+  },
+  "files": [
+    "lib/",
+    "LICENSE",
+    "HISTORY.md",
+    "SECURITY.md",
+    "index.js"
+  ],
+  "engines": {
+    "node": ">= 0.8",
+    "npm": "1.2.8000 || >= 1.4.16"
+  },
+  "scripts": {
+    "lint": "eslint .",
+    "test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/",
+    "test-ci": "nyc --reporter=lcov --reporter=text npm test",
+    "test-cov": "nyc --reporter=html --reporter=text npm test"
+  }
+}

+ 301 - 0
node_modules/bson/HISTORY.md

@@ -0,0 +1,301 @@
+# Changelog
+
+All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+
+### [1.1.6](https://github.com/mongodb/js-bson/compare/v1.1.5...v1.1.6) (2021-03-16)
+
+
+### Bug Fixes
+
+* Throw error on bigint usage and add helpers to Long ([#426](https://github.com/mongodb/js-bson/issues/426)) ([375f368](https://github.com/mongodb/js-bson/commit/375f368738807f2d41c7751e618fd09c8a1b94c9))
+
+### [1.1.5](https://github.com/mongodb/js-bson/compare/v1.1.4...v1.1.5) (2020-08-10)
+
+
+### Bug Fixes
+
+* **object-id:** harden the duck-typing ([b526145](https://github.com/mongodb/js-bson/commit/b5261450c3bc4abb2e2fb19b5b1a7aba27982d44))
+
+<a name="1.1.3"></a>
+## [1.1.3](https://github.com/mongodb/js-bson/compare/v1.1.2...v1.1.3) (2019-11-09)
+
+Reverts 1.1.2
+
+<a name="1.1.2"></a>
+## [1.1.2](https://github.com/mongodb/js-bson/compare/v1.1.1...v1.1.2) (2019-11-08)
+
+
+### Bug Fixes
+
+* **_bsontype:** only check bsontype if it is a prototype member. ([dd8a349](https://github.com/mongodb/js-bson/commit/dd8a349))
+
+
+
+<a name="1.1.1"></a>
+## [1.1.1](https://github.com/mongodb/js-bson/compare/v1.1.0...v1.1.1) (2019-03-08)
+
+
+### Bug Fixes
+
+* **object-id:** support 4.x->1.x interop for MinKey and ObjectId ([53419a5](https://github.com/mongodb/js-bson/commit/53419a5))
+
+
+### Features
+
+* replace new Buffer with modern versions ([24aefba](https://github.com/mongodb/js-bson/commit/24aefba))
+
+
+
+<a name="1.1.0"></a>
+# [1.1.0](https://github.com/mongodb/js-bson/compare/v1.0.9...v1.1.0) (2018-08-13)
+
+
+### Bug Fixes
+
+* **serializer:** do not use checkKeys for $clusterTime ([573e141](https://github.com/mongodb/js-bson/commit/573e141))
+
+
+
+<a name="1.0.9"></a>
+## [1.0.9](https://github.com/mongodb/js-bson/compare/v1.0.8...v1.0.9) (2018-06-07)
+
+
+### Bug Fixes
+
+* **serializer:** remove use of `const` ([5feb12f](https://github.com/mongodb/js-bson/commit/5feb12f))
+
+
+
+<a name="1.0.7"></a>
+## [1.0.7](https://github.com/mongodb/js-bson/compare/v1.0.6...v1.0.7) (2018-06-06)
+
+
+### Bug Fixes
+
+* **binary:** add type checking for buffer ([26b05b5](https://github.com/mongodb/js-bson/commit/26b05b5))
+* **bson:** fix custom inspect property ([080323b](https://github.com/mongodb/js-bson/commit/080323b))
+* **readme:** clarify documentation about deserialize methods ([20f764c](https://github.com/mongodb/js-bson/commit/20f764c))
+* **serialization:** normalize function stringification ([1320c10](https://github.com/mongodb/js-bson/commit/1320c10))
+
+
+
+<a name="1.0.6"></a>
+## [1.0.6](https://github.com/mongodb/js-bson/compare/v1.0.5...v1.0.6) (2018-03-12)
+
+
+### Features
+
+* **serialization:** support arbitrary sizes for the internal serialization buffer ([abe97bc](https://github.com/mongodb/js-bson/commit/abe97bc))
+
+
+
+<a name="1.0.5"></a>
+## 1.0.5 (2018-02-26)
+
+
+### Bug Fixes
+
+* **decimal128:** add basic guard against REDOS attacks ([bd61c45](https://github.com/mongodb/js-bson/commit/bd61c45))
+* **objectid:** if pid is 1, use random value ([e188ae6](https://github.com/mongodb/js-bson/commit/e188ae6))
+
+
+
+1.0.4 2016-01-11
+----------------
+- #204 remove Buffer.from as it's partially broken in early 4.x.x. series of node releases.
+
+1.0.3 2016-01-03
+----------------
+- Fixed toString for ObjectId so it will work with inspect.
+
+1.0.2 2016-01-02
+----------------
+- Minor optimizations for ObjectID to use Buffer.from where available.
+
+1.0.1 2016-12-06
+----------------
+- Reverse behavior for undefined to be serialized as NULL. MongoDB 3.4 does not allow for undefined comparisons.
+
+1.0.0 2016-12-06
+----------------
+- Introduced new BSON API and documentation.
+
+0.5.7 2016-11-18
+-----------------
+- NODE-848 BSON Regex flags must be alphabetically ordered.
+
+0.5.6 2016-10-19
+-----------------
+- NODE-833, Detects cyclic dependencies in documents and throws error if one is found.
+- Fix(deserializer): corrected the check for (size + index) comparison… (Issue #195, https://github.com/JoelParke).
+
+0.5.5 2016-09-15
+-----------------
+- Added DBPointer up conversion to DBRef
+
+0.5.4 2016-08-23
+-----------------
+- Added promoteValues flag (default to true) allowing user to specify if deserialization should be into wrapper classes only.
+
+0.5.3 2016-07-11
+-----------------
+- Throw error if ObjectId is not a string or a buffer.
+
+0.5.2 2016-07-11
+-----------------
+- All values encoded big-endian style for ObjectId.
+
+0.5.1 2016-07-11
+-----------------
+- Fixed encoding/decoding issue in ObjectId timestamp generation.
+- Removed BinaryParser dependency from the serializer/deserializer.
+
+0.5.0 2016-07-05
+-----------------
+- Added Decimal128 type and extended test suite to include entire bson corpus.
+
+0.4.23 2016-04-08
+-----------------
+- Allow for proper detection of ObjectId or objects that look like ObjectId, improving compatibility across third party libraries.
+- Remove one package from dependency due to having been pulled from NPM.
+
+0.4.22 2016-03-04
+-----------------
+- Fix "TypeError: data.copy is not a function" in Electron (Issue #170, https://github.com/kangas).
+- Fixed issue with undefined type on deserializing.
+
+0.4.21 2016-01-12
+-----------------
+- Minor optimizations to avoid non needed object creation.
+
+0.4.20 2015-10-15
+-----------------
+- Added bower file to repository.
+- Fixed browser pid sometimes set greater than 0xFFFF on browsers (Issue #155, https://github.com/rahatarmanahmed)
+
+0.4.19 2015-10-15
+-----------------
+- Remove all support for bson-ext.
+
+0.4.18 2015-10-15
+-----------------
+- ObjectID equality check should return boolean instead of throwing exception for invalid oid string #139
+- add option for deserializing binary into Buffer object #116
+
+0.4.17 2015-10-15
+-----------------
+- Validate regexp string for null bytes and throw if there is one.
+
+0.4.16 2015-10-07
+-----------------
+- Fixed issue with return statement in Map.js.
+
+0.4.15 2015-10-06
+-----------------
+- Exposed Map correctly via index.js file.
+
+0.4.14 2015-10-06
+-----------------
+- Exposed Map correctly via bson.js file.
+
+0.4.13 2015-10-06
+-----------------
+- Added ES6 Map type serialization as well as a polyfill for ES5.
+
+0.4.12 2015-09-18
+-----------------
+- Made ignore undefined an optional parameter.
+
+0.4.11 2015-08-06
+-----------------
+- Minor fix for invalid key checking.
+
+0.4.10 2015-08-06
+-----------------
+- NODE-38 Added new BSONRegExp type to allow direct serialization to MongoDB type.
+- Some performance improvements by in lining code.
+
+0.4.9 2015-08-06
+----------------
+- Undefined fields are omitted from serialization in objects.
+
+0.4.8 2015-07-14
+----------------
+- Fixed size validation to ensure we can deserialize from dumped files.
+
+0.4.7 2015-06-26
+----------------
+- Added ability to instruct deserializer to return raw BSON buffers for named array fields.
+- Minor deserialization optimization by moving inlined function out.
+
+0.4.6 2015-06-17
+----------------
+- Fixed serializeWithBufferAndIndex bug.
+
+0.4.5 2015-06-17
+----------------
+- Removed any references to the shared buffer to avoid non GC collectible bson instances.
+
+0.4.4 2015-06-17
+----------------
+- Fixed rethrowing of error when not RangeError.
+
+0.4.3 2015-06-17
+----------------
+- Start buffer at 64K and double as needed, meaning we keep a low memory profile until needed.
+
+0.4.2 2015-06-16
+----------------
+- More fixes for corrupt Bson
+
+0.4.1 2015-06-16
+----------------
+- More fixes for corrupt Bson
+
+0.4.0 2015-06-16
+----------------
+- New JS serializer serializing into a single buffer then copying out the new buffer. Performance is similar to current C++ parser.
+- Removed bson-ext extension dependency for now.
+
+0.3.2 2015-03-27
+----------------
+- Removed node-gyp from install script in package.json.
+
+0.3.1 2015-03-27
+----------------
+- Return pure js version on native() call if failed to initialize.
+
+0.3.0 2015-03-26
+----------------
+- Pulled out all C++ code into bson-ext and made it an optional dependency.
+
+0.2.21 2015-03-21
+-----------------
+- Updated Nan to 1.7.0 to support io.js and node 0.12.0
+
+0.2.19 2015-02-16
+-----------------
+- Updated Nan to 1.6.2 to support io.js and node 0.12.0
+
+0.2.18 2015-01-20
+-----------------
+- Updated Nan to 1.5.1 to support io.js
+
+0.2.16 2014-12-17
+-----------------
+- Made pid cycle on 0xffff to avoid weird overflows on creation of ObjectID's
+
+0.2.12 2014-08-24
+-----------------
+- Fixes for fortify review of c++ extension
+- toBSON correctly allows returns of non objects
+
+0.2.3 2013-10-01
+----------------
+- Drying of ObjectId code for generation of id (Issue #54, https://github.com/moredip)
+- Fixed issue where corrupt CString's could cause endless loop
+- Support for Node 0.11.X > (Issue #49, https://github.com/kkoopa)
+
+0.1.4 2012-09-25
+----------------
+- Added precompiled c++ native extensions for win32 ia32 and x64

+ 201 - 0
node_modules/bson/LICENSE.md

@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

+ 170 - 0
node_modules/bson/README.md

@@ -0,0 +1,170 @@
+# BSON parser
+
+BSON is short for Bin­ary JSON and is the bin­ary-en­coded seri­al­iz­a­tion of JSON-like doc­u­ments. You can learn more about it in [the specification](http://bsonspec.org).
+
+This browser version of the BSON parser is compiled using [webpack](https://webpack.js.org/) and the current version is pre-compiled in the `browser_build` directory.
+
+This is the default BSON parser, however, there is a C++ Node.js addon version as well that does not support the browser. It can be found at [mongod-js/bson-ext](https://github.com/mongodb-js/bson-ext).
+
+## Usage
+
+To build a new version perform the following operations:
+
+```
+npm install
+npm run build
+```
+
+A simple example of how to use BSON in the browser:
+
+```html
+<script src="./browser_build/bson.js"></script>
+
+<script>
+  function start() {
+    // Get the Long type
+    var Long = BSON.Long;
+    // Create a bson parser instance
+    var bson = new BSON();
+
+    // Serialize document
+    var doc = { long: Long.fromNumber(100) }
+
+    // Serialize a document
+    var data = bson.serialize(doc)
+    // De serialize it again
+    var doc_2 = bson.deserialize(data)
+  }
+</script>
+```
+
+A simple example of how to use BSON in `Node.js`:
+
+```js
+// Get BSON parser class
+var BSON = require('bson')
+// Get the Long type
+var Long = BSON.Long;
+// Create a bson parser instance
+var bson = new BSON();
+
+// Serialize document
+var doc = { long: Long.fromNumber(100) }
+
+// Serialize a document
+var data = bson.serialize(doc)
+console.log('data:', data)
+
+// Deserialize the resulting Buffer
+var doc_2 = bson.deserialize(data)
+console.log('doc_2:', doc_2)
+```
+
+## Installation
+
+`npm install bson`
+
+## API
+
+### BSON types
+
+For all BSON types documentation, please refer to the following sources:
+  * [MongoDB BSON Type Reference](https://docs.mongodb.com/manual/reference/bson-types/)
+  * [BSON Spec](https://bsonspec.org/)
+
+### BSON serialization and deserialiation
+
+**`new BSON()`** - Creates a new BSON serializer/deserializer you can use to serialize and deserialize BSON.
+
+#### BSON.serialize
+
+The BSON `serialize` method takes a JavaScript object and an optional options object and returns a Node.js Buffer.
+
+  * `BSON.serialize(object, options)`
+    * @param {Object} object the JavaScript object to serialize.
+    * @param {Boolean} [options.checkKeys=false] the serializer will check if keys are valid.
+    * @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions.
+    * @param {Boolean} [options.ignoreUndefined=true]
+    * @return {Buffer} returns a Buffer instance.
+
+#### BSON.serializeWithBufferAndIndex
+
+The BSON `serializeWithBufferAndIndex` method takes an object, a target buffer instance and an optional options object and returns the end serialization index in the final buffer.
+
+  * `BSON.serializeWithBufferAndIndex(object, buffer, options)`
+    * @param {Object} object the JavaScript object to serialize.
+    * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object.
+    * @param {Boolean} [options.checkKeys=false] the serializer will check if keys are valid.
+    * @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions.
+    * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields.
+    * @param {Number} [options.index=0] the index in the buffer where we wish to start serializing into.
+    * @return {Number} returns the index pointing to the last written byte in the buffer.
+
+#### BSON.calculateObjectSize
+
+The BSON `calculateObjectSize` method takes a JavaScript object and an optional options object and returns the size of the BSON object.
+
+  * `BSON.calculateObjectSize(object, options)`
+    * @param {Object} object the JavaScript object to serialize.
+    * @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions.
+    * @param {Boolean} [options.ignoreUndefined=true]
+    * @return {Buffer} returns a Buffer instance.
+
+#### BSON.deserialize
+
+The BSON `deserialize` method takes a Node.js Buffer and an optional options object and returns a deserialized JavaScript object.
+
+  * `BSON.deserialize(buffer, options)`
+    * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized.
+    * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.
+    * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.
+    * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+    * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a Node.js Buffer instance.
+    * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
+    * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
+    * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
+    * @return {Object} returns the deserialized Javascript Object.
+
+#### BSON.deserializeStream
+
+The BSON `deserializeStream` method takes a Node.js Buffer, `startIndex` and allow more control over deserialization of a Buffer containing concatenated BSON documents.
+
+  * `BSON.deserializeStream(buffer, startIndex, numberOfDocuments, documents, docStartIndex, options)`
+    * @param {Buffer} buffer the buffer containing the serialized set of BSON documents.
+    * @param {Number} startIndex the start index in the data Buffer where the deserialization is to start.
+    * @param {Number} numberOfDocuments number of documents to deserialize.
+    * @param {Array} documents an array where to store the deserialized documents.
+    * @param {Number} docStartIndex the index in the documents array from where to start inserting documents.
+    * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized.
+    * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.
+    * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.
+    * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+    * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a Node.js Buffer instance.
+    * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
+    * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
+    * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
+    * @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents.
+
+## FAQ
+
+#### Why does `undefined` get converted to `null`?
+
+The `undefined` BSON type has been [deprecated for many years](http://bsonspec.org/spec.html), so this library has dropped support for it. Use the `ignoreUndefined` option (for example, from the [driver](http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#connect) ) to instead remove `undefined` keys.
+
+#### How do I add custom serialization logic?
+
+This library looks for `toBSON()` functions on every path, and calls the `toBSON()` function to get the value to serialize.
+
+```javascript
+var bson = new BSON();
+
+class CustomSerialize {
+  toBSON() {
+    return 42;
+  }
+}
+
+const obj = { answer: new CustomSerialize() };
+// "{ answer: 42 }"
+console.log(bson.deserialize(bson.serialize(obj)));
+```

+ 26 - 0
node_modules/bson/bower.json

@@ -0,0 +1,26 @@
+{
+  "name": "bson",
+  "description": "A bson parser for node.js and the browser",
+  "keywords": [
+    "mongodb",
+    "bson",
+    "parser"
+  ],
+  "author": "Christian Amor Kvalheim <christkv@gmail.com>",
+  "main": "./browser_build/bson.js",
+  "license": "Apache-2.0",
+  "moduleType": [
+    "globals",
+    "node"
+  ],
+  "ignore": [
+    "**/.*",
+    "alternate_parsers",
+    "benchmarks",
+    "bower_components",
+    "node_modules",
+    "test",
+    "tools"
+  ],
+  "version": "1.1.6"
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 18218 - 0
node_modules/bson/browser_build/bson.js


+ 8 - 0
node_modules/bson/browser_build/package.json

@@ -0,0 +1,8 @@
+{ "name" :            "bson"
+, "description" :     "A bson parser for node.js and the browser"
+, "main":             "../"
+, "directories" :   { "lib" : "../lib/bson" }
+, "engines" :       { "node" : ">=0.6.0" }
+, "licenses" :    [ { "type" :  "Apache License, Version 2.0"
+                    , "url" :   "http://www.apache.org/licenses/LICENSE-2.0" } ]
+}

+ 46 - 0
node_modules/bson/index.js

@@ -0,0 +1,46 @@
+var BSON = require('./lib/bson/bson'),
+  Binary = require('./lib/bson/binary'),
+  Code = require('./lib/bson/code'),
+  DBRef = require('./lib/bson/db_ref'),
+  Decimal128 = require('./lib/bson/decimal128'),
+  Double = require('./lib/bson/double'),
+  Int32 = require('./lib/bson/int_32'),
+  Long = require('./lib/bson/long'),
+  Map = require('./lib/bson/map'),
+  MaxKey = require('./lib/bson/max_key'),
+  MinKey = require('./lib/bson/min_key'),
+  ObjectId = require('./lib/bson/objectid'),
+  BSONRegExp = require('./lib/bson/regexp'),
+  Symbol = require('./lib/bson/symbol'),
+  Timestamp = require('./lib/bson/timestamp');
+
+// BSON MAX VALUES
+BSON.BSON_INT32_MAX = 0x7fffffff;
+BSON.BSON_INT32_MIN = -0x80000000;
+
+BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1;
+BSON.BSON_INT64_MIN = -Math.pow(2, 63);
+
+// JS MAX PRECISE VALUES
+BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double.
+BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double.
+
+// Add BSON types to function creation
+BSON.Binary = Binary;
+BSON.Code = Code;
+BSON.DBRef = DBRef;
+BSON.Decimal128 = Decimal128;
+BSON.Double = Double;
+BSON.Int32 = Int32;
+BSON.Long = Long;
+BSON.Map = Map;
+BSON.MaxKey = MaxKey;
+BSON.MinKey = MinKey;
+BSON.ObjectId = ObjectId;
+BSON.ObjectID = ObjectId;
+BSON.BSONRegExp = BSONRegExp;
+BSON.Symbol = Symbol;
+BSON.Timestamp = Timestamp;
+
+// Return the BSON
+module.exports = BSON;

+ 384 - 0
node_modules/bson/lib/bson/binary.js

@@ -0,0 +1,384 @@
+/**
+ * Module dependencies.
+ * @ignore
+ */
+
+// Test if we're in Node via presence of "global" not absence of "window"
+// to support hybrid environments like Electron
+if (typeof global !== 'undefined') {
+  var Buffer = require('buffer').Buffer; // TODO just use global Buffer
+}
+
+var utils = require('./parser/utils');
+
+/**
+ * A class representation of the BSON Binary type.
+ *
+ * Sub types
+ *  - **BSON.BSON_BINARY_SUBTYPE_DEFAULT**, default BSON type.
+ *  - **BSON.BSON_BINARY_SUBTYPE_FUNCTION**, BSON function type.
+ *  - **BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY**, BSON byte array type.
+ *  - **BSON.BSON_BINARY_SUBTYPE_UUID**, BSON uuid type.
+ *  - **BSON.BSON_BINARY_SUBTYPE_MD5**, BSON md5 type.
+ *  - **BSON.BSON_BINARY_SUBTYPE_USER_DEFINED**, BSON user defined type.
+ *
+ * @class
+ * @param {Buffer} buffer a buffer object containing the binary data.
+ * @param {Number} [subType] the option binary type.
+ * @return {Binary}
+ */
+function Binary(buffer, subType) {
+  if (!(this instanceof Binary)) return new Binary(buffer, subType);
+
+  if (
+    buffer != null &&
+    !(typeof buffer === 'string') &&
+    !Buffer.isBuffer(buffer) &&
+    !(buffer instanceof Uint8Array) &&
+    !Array.isArray(buffer)
+  ) {
+    throw new Error('only String, Buffer, Uint8Array or Array accepted');
+  }
+
+  this._bsontype = 'Binary';
+
+  if (buffer instanceof Number) {
+    this.sub_type = buffer;
+    this.position = 0;
+  } else {
+    this.sub_type = subType == null ? BSON_BINARY_SUBTYPE_DEFAULT : subType;
+    this.position = 0;
+  }
+
+  if (buffer != null && !(buffer instanceof Number)) {
+    // Only accept Buffer, Uint8Array or Arrays
+    if (typeof buffer === 'string') {
+      // Different ways of writing the length of the string for the different types
+      if (typeof Buffer !== 'undefined') {
+        this.buffer = utils.toBuffer(buffer);
+      } else if (
+        typeof Uint8Array !== 'undefined' ||
+        Object.prototype.toString.call(buffer) === '[object Array]'
+      ) {
+        this.buffer = writeStringToArray(buffer);
+      } else {
+        throw new Error('only String, Buffer, Uint8Array or Array accepted');
+      }
+    } else {
+      this.buffer = buffer;
+    }
+    this.position = buffer.length;
+  } else {
+    if (typeof Buffer !== 'undefined') {
+      this.buffer = utils.allocBuffer(Binary.BUFFER_SIZE);
+    } else if (typeof Uint8Array !== 'undefined') {
+      this.buffer = new Uint8Array(new ArrayBuffer(Binary.BUFFER_SIZE));
+    } else {
+      this.buffer = new Array(Binary.BUFFER_SIZE);
+    }
+    // Set position to start of buffer
+    this.position = 0;
+  }
+}
+
+/**
+ * Updates this binary with byte_value.
+ *
+ * @method
+ * @param {string} byte_value a single byte we wish to write.
+ */
+Binary.prototype.put = function put(byte_value) {
+  // If it's a string and a has more than one character throw an error
+  if (byte_value['length'] != null && typeof byte_value !== 'number' && byte_value.length !== 1)
+    throw new Error('only accepts single character String, Uint8Array or Array');
+  if ((typeof byte_value !== 'number' && byte_value < 0) || byte_value > 255)
+    throw new Error('only accepts number in a valid unsigned byte range 0-255');
+
+  // Decode the byte value once
+  var decoded_byte = null;
+  if (typeof byte_value === 'string') {
+    decoded_byte = byte_value.charCodeAt(0);
+  } else if (byte_value['length'] != null) {
+    decoded_byte = byte_value[0];
+  } else {
+    decoded_byte = byte_value;
+  }
+
+  if (this.buffer.length > this.position) {
+    this.buffer[this.position++] = decoded_byte;
+  } else {
+    if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) {
+      // Create additional overflow buffer
+      var buffer = utils.allocBuffer(Binary.BUFFER_SIZE + this.buffer.length);
+      // Combine the two buffers together
+      this.buffer.copy(buffer, 0, 0, this.buffer.length);
+      this.buffer = buffer;
+      this.buffer[this.position++] = decoded_byte;
+    } else {
+      buffer = null;
+      // Create a new buffer (typed or normal array)
+      if (Object.prototype.toString.call(this.buffer) === '[object Uint8Array]') {
+        buffer = new Uint8Array(new ArrayBuffer(Binary.BUFFER_SIZE + this.buffer.length));
+      } else {
+        buffer = new Array(Binary.BUFFER_SIZE + this.buffer.length);
+      }
+
+      // We need to copy all the content to the new array
+      for (var i = 0; i < this.buffer.length; i++) {
+        buffer[i] = this.buffer[i];
+      }
+
+      // Reassign the buffer
+      this.buffer = buffer;
+      // Write the byte
+      this.buffer[this.position++] = decoded_byte;
+    }
+  }
+};
+
+/**
+ * Writes a buffer or string to the binary.
+ *
+ * @method
+ * @param {(Buffer|string)} string a string or buffer to be written to the Binary BSON object.
+ * @param {number} offset specify the binary of where to write the content.
+ * @return {null}
+ */
+Binary.prototype.write = function write(string, offset) {
+  offset = typeof offset === 'number' ? offset : this.position;
+
+  // If the buffer is to small let's extend the buffer
+  if (this.buffer.length < offset + string.length) {
+    var buffer = null;
+    // If we are in node.js
+    if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) {
+      buffer = utils.allocBuffer(this.buffer.length + string.length);
+      this.buffer.copy(buffer, 0, 0, this.buffer.length);
+    } else if (Object.prototype.toString.call(this.buffer) === '[object Uint8Array]') {
+      // Create a new buffer
+      buffer = new Uint8Array(new ArrayBuffer(this.buffer.length + string.length));
+      // Copy the content
+      for (var i = 0; i < this.position; i++) {
+        buffer[i] = this.buffer[i];
+      }
+    }
+
+    // Assign the new buffer
+    this.buffer = buffer;
+  }
+
+  if (typeof Buffer !== 'undefined' && Buffer.isBuffer(string) && Buffer.isBuffer(this.buffer)) {
+    string.copy(this.buffer, offset, 0, string.length);
+    this.position = offset + string.length > this.position ? offset + string.length : this.position;
+    // offset = string.length
+  } else if (
+    typeof Buffer !== 'undefined' &&
+    typeof string === 'string' &&
+    Buffer.isBuffer(this.buffer)
+  ) {
+    this.buffer.write(string, offset, 'binary');
+    this.position = offset + string.length > this.position ? offset + string.length : this.position;
+    // offset = string.length;
+  } else if (
+    Object.prototype.toString.call(string) === '[object Uint8Array]' ||
+    (Object.prototype.toString.call(string) === '[object Array]' && typeof string !== 'string')
+  ) {
+    for (i = 0; i < string.length; i++) {
+      this.buffer[offset++] = string[i];
+    }
+
+    this.position = offset > this.position ? offset : this.position;
+  } else if (typeof string === 'string') {
+    for (i = 0; i < string.length; i++) {
+      this.buffer[offset++] = string.charCodeAt(i);
+    }
+
+    this.position = offset > this.position ? offset : this.position;
+  }
+};
+
+/**
+ * Reads **length** bytes starting at **position**.
+ *
+ * @method
+ * @param {number} position read from the given position in the Binary.
+ * @param {number} length the number of bytes to read.
+ * @return {Buffer}
+ */
+Binary.prototype.read = function read(position, length) {
+  length = length && length > 0 ? length : this.position;
+
+  // Let's return the data based on the type we have
+  if (this.buffer['slice']) {
+    return this.buffer.slice(position, position + length);
+  } else {
+    // Create a buffer to keep the result
+    var buffer =
+      typeof Uint8Array !== 'undefined'
+        ? new Uint8Array(new ArrayBuffer(length))
+        : new Array(length);
+    for (var i = 0; i < length; i++) {
+      buffer[i] = this.buffer[position++];
+    }
+  }
+  // Return the buffer
+  return buffer;
+};
+
+/**
+ * Returns the value of this binary as a string.
+ *
+ * @method
+ * @return {string}
+ */
+Binary.prototype.value = function value(asRaw) {
+  asRaw = asRaw == null ? false : asRaw;
+
+  // Optimize to serialize for the situation where the data == size of buffer
+  if (
+    asRaw &&
+    typeof Buffer !== 'undefined' &&
+    Buffer.isBuffer(this.buffer) &&
+    this.buffer.length === this.position
+  )
+    return this.buffer;
+
+  // If it's a node.js buffer object
+  if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) {
+    return asRaw
+      ? this.buffer.slice(0, this.position)
+      : this.buffer.toString('binary', 0, this.position);
+  } else {
+    if (asRaw) {
+      // we support the slice command use it
+      if (this.buffer['slice'] != null) {
+        return this.buffer.slice(0, this.position);
+      } else {
+        // Create a new buffer to copy content to
+        var newBuffer =
+          Object.prototype.toString.call(this.buffer) === '[object Uint8Array]'
+            ? new Uint8Array(new ArrayBuffer(this.position))
+            : new Array(this.position);
+        // Copy content
+        for (var i = 0; i < this.position; i++) {
+          newBuffer[i] = this.buffer[i];
+        }
+        // Return the buffer
+        return newBuffer;
+      }
+    } else {
+      return convertArraytoUtf8BinaryString(this.buffer, 0, this.position);
+    }
+  }
+};
+
+/**
+ * Length.
+ *
+ * @method
+ * @return {number} the length of the binary.
+ */
+Binary.prototype.length = function length() {
+  return this.position;
+};
+
+/**
+ * @ignore
+ */
+Binary.prototype.toJSON = function() {
+  return this.buffer != null ? this.buffer.toString('base64') : '';
+};
+
+/**
+ * @ignore
+ */
+Binary.prototype.toString = function(format) {
+  return this.buffer != null ? this.buffer.slice(0, this.position).toString(format) : '';
+};
+
+/**
+ * Binary default subtype
+ * @ignore
+ */
+var BSON_BINARY_SUBTYPE_DEFAULT = 0;
+
+/**
+ * @ignore
+ */
+var writeStringToArray = function(data) {
+  // Create a buffer
+  var buffer =
+    typeof Uint8Array !== 'undefined'
+      ? new Uint8Array(new ArrayBuffer(data.length))
+      : new Array(data.length);
+  // Write the content to the buffer
+  for (var i = 0; i < data.length; i++) {
+    buffer[i] = data.charCodeAt(i);
+  }
+  // Write the string to the buffer
+  return buffer;
+};
+
+/**
+ * Convert Array ot Uint8Array to Binary String
+ *
+ * @ignore
+ */
+var convertArraytoUtf8BinaryString = function(byteArray, startIndex, endIndex) {
+  var result = '';
+  for (var i = startIndex; i < endIndex; i++) {
+    result = result + String.fromCharCode(byteArray[i]);
+  }
+  return result;
+};
+
+Binary.BUFFER_SIZE = 256;
+
+/**
+ * Default BSON type
+ *
+ * @classconstant SUBTYPE_DEFAULT
+ **/
+Binary.SUBTYPE_DEFAULT = 0;
+/**
+ * Function BSON type
+ *
+ * @classconstant SUBTYPE_DEFAULT
+ **/
+Binary.SUBTYPE_FUNCTION = 1;
+/**
+ * Byte Array BSON type
+ *
+ * @classconstant SUBTYPE_DEFAULT
+ **/
+Binary.SUBTYPE_BYTE_ARRAY = 2;
+/**
+ * OLD UUID BSON type
+ *
+ * @classconstant SUBTYPE_DEFAULT
+ **/
+Binary.SUBTYPE_UUID_OLD = 3;
+/**
+ * UUID BSON type
+ *
+ * @classconstant SUBTYPE_DEFAULT
+ **/
+Binary.SUBTYPE_UUID = 4;
+/**
+ * MD5 BSON type
+ *
+ * @classconstant SUBTYPE_DEFAULT
+ **/
+Binary.SUBTYPE_MD5 = 5;
+/**
+ * User BSON type
+ *
+ * @classconstant SUBTYPE_DEFAULT
+ **/
+Binary.SUBTYPE_USER_DEFINED = 128;
+
+/**
+ * Expose.
+ */
+module.exports = Binary;
+module.exports.Binary = Binary;

+ 386 - 0
node_modules/bson/lib/bson/bson.js

@@ -0,0 +1,386 @@
+'use strict';
+
+var Map = require('./map'),
+  Long = require('./long'),
+  Double = require('./double'),
+  Timestamp = require('./timestamp'),
+  ObjectID = require('./objectid'),
+  BSONRegExp = require('./regexp'),
+  Symbol = require('./symbol'),
+  Int32 = require('./int_32'),
+  Code = require('./code'),
+  Decimal128 = require('./decimal128'),
+  MinKey = require('./min_key'),
+  MaxKey = require('./max_key'),
+  DBRef = require('./db_ref'),
+  Binary = require('./binary');
+
+// Parts of the parser
+var deserialize = require('./parser/deserializer'),
+  serializer = require('./parser/serializer'),
+  calculateObjectSize = require('./parser/calculate_size'),
+  utils = require('./parser/utils');
+
+/**
+ * @ignore
+ * @api private
+ */
+// Default Max Size
+var MAXSIZE = 1024 * 1024 * 17;
+
+// Current Internal Temporary Serialization Buffer
+var buffer = utils.allocBuffer(MAXSIZE);
+
+var BSON = function() {};
+
+/**
+ * Serialize a Javascript object.
+ *
+ * @param {Object} object the Javascript object to serialize.
+ * @param {Boolean} [options.checkKeys] the serializer will check if keys are valid.
+ * @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions **(default:false)**.
+ * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields **(default:true)**.
+ * @param {Number} [options.minInternalBufferSize=1024*1024*17] minimum size of the internal temporary serialization buffer **(default:1024*1024*17)**.
+ * @return {Buffer} returns the Buffer object containing the serialized object.
+ * @api public
+ */
+BSON.prototype.serialize = function serialize(object, options) {
+  options = options || {};
+  // Unpack the options
+  var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
+  var serializeFunctions =
+    typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
+  var ignoreUndefined =
+    typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
+  var minInternalBufferSize =
+    typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE;
+  
+  // Resize the internal serialization buffer if needed
+  if (buffer.length < minInternalBufferSize) {
+    buffer = utils.allocBuffer(minInternalBufferSize);
+  }
+
+  // Attempt to serialize
+  var serializationIndex = serializer(
+    buffer,
+    object,
+    checkKeys,
+    0,
+    0,
+    serializeFunctions,
+    ignoreUndefined,
+    []
+  );
+  // Create the final buffer
+  var finishedBuffer = utils.allocBuffer(serializationIndex);
+  // Copy into the finished buffer
+  buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length);
+  // Return the buffer
+  return finishedBuffer;
+};
+
+/**
+ * Serialize a Javascript object using a predefined Buffer and index into the buffer, useful when pre-allocating the space for serialization.
+ *
+ * @param {Object} object the Javascript object to serialize.
+ * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object.
+ * @param {Boolean} [options.checkKeys] the serializer will check if keys are valid.
+ * @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions **(default:false)**.
+ * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields **(default:true)**.
+ * @param {Number} [options.index] the index in the buffer where we wish to start serializing into.
+ * @return {Number} returns the index pointing to the last written byte in the buffer.
+ * @api public
+ */
+BSON.prototype.serializeWithBufferAndIndex = function(object, finalBuffer, options) {
+  options = options || {};
+  // Unpack the options
+  var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
+  var serializeFunctions =
+    typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
+  var ignoreUndefined =
+    typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
+  var startIndex = typeof options.index === 'number' ? options.index : 0;
+
+  // Attempt to serialize
+  var serializationIndex = serializer(
+    finalBuffer,
+    object,
+    checkKeys,
+    startIndex || 0,
+    0,
+    serializeFunctions,
+    ignoreUndefined
+  );
+
+  // Return the index
+  return serializationIndex - 1;
+};
+
+/**
+ * Deserialize data as BSON.
+ *
+ * @param {Buffer} buffer the buffer containing the serialized set of BSON documents.
+ * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized.
+ * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.
+ * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.
+ * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+ * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance.
+ * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
+ * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
+ * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
+ * @return {Object} returns the deserialized Javascript Object.
+ * @api public
+ */
+BSON.prototype.deserialize = function(buffer, options) {
+  return deserialize(buffer, options);
+};
+
+/**
+ * Calculate the bson size for a passed in Javascript object.
+ *
+ * @param {Object} object the Javascript object to calculate the BSON byte size for.
+ * @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions **(default:false)**.
+ * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields **(default:true)**.
+ * @return {Number} returns the number of bytes the BSON object will take up.
+ * @api public
+ */
+BSON.prototype.calculateObjectSize = function(object, options) {
+  options = options || {};
+
+  var serializeFunctions =
+    typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
+  var ignoreUndefined =
+    typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
+
+  return calculateObjectSize(object, serializeFunctions, ignoreUndefined);
+};
+
+/**
+ * Deserialize stream data as BSON documents.
+ *
+ * @param {Buffer} data the buffer containing the serialized set of BSON documents.
+ * @param {Number} startIndex the start index in the data Buffer where the deserialization is to start.
+ * @param {Number} numberOfDocuments number of documents to deserialize.
+ * @param {Array} documents an array where to store the deserialized documents.
+ * @param {Number} docStartIndex the index in the documents array from where to start inserting documents.
+ * @param {Object} [options] additional options used for the deserialization.
+ * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized.
+ * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.
+ * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.
+ * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+ * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance.
+ * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
+ * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
+ * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
+ * @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents.
+ * @api public
+ */
+BSON.prototype.deserializeStream = function(
+  data,
+  startIndex,
+  numberOfDocuments,
+  documents,
+  docStartIndex,
+  options
+) {
+  options = options != null ? options : {};
+  var index = startIndex;
+  // Loop over all documents
+  for (var i = 0; i < numberOfDocuments; i++) {
+    // Find size of the document
+    var size =
+      data[index] | (data[index + 1] << 8) | (data[index + 2] << 16) | (data[index + 3] << 24);
+    // Update options with index
+    options['index'] = index;
+    // Parse the document at this point
+    documents[docStartIndex + i] = this.deserialize(data, options);
+    // Adjust index by the document size
+    index = index + size;
+  }
+
+  // Return object containing end index of parsing and list of documents
+  return index;
+};
+
+/**
+ * @ignore
+ * @api private
+ */
+// BSON MAX VALUES
+BSON.BSON_INT32_MAX = 0x7fffffff;
+BSON.BSON_INT32_MIN = -0x80000000;
+
+BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1;
+BSON.BSON_INT64_MIN = -Math.pow(2, 63);
+
+// JS MAX PRECISE VALUES
+BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double.
+BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double.
+
+// Internal long versions
+// var JS_INT_MAX_LONG = Long.fromNumber(0x20000000000000); // Any integer up to 2^53 can be precisely represented by a double.
+// var JS_INT_MIN_LONG = Long.fromNumber(-0x20000000000000); // Any integer down to -2^53 can be precisely represented by a double.
+
+/**
+ * Number BSON Type
+ *
+ * @classconstant BSON_DATA_NUMBER
+ **/
+BSON.BSON_DATA_NUMBER = 1;
+/**
+ * String BSON Type
+ *
+ * @classconstant BSON_DATA_STRING
+ **/
+BSON.BSON_DATA_STRING = 2;
+/**
+ * Object BSON Type
+ *
+ * @classconstant BSON_DATA_OBJECT
+ **/
+BSON.BSON_DATA_OBJECT = 3;
+/**
+ * Array BSON Type
+ *
+ * @classconstant BSON_DATA_ARRAY
+ **/
+BSON.BSON_DATA_ARRAY = 4;
+/**
+ * Binary BSON Type
+ *
+ * @classconstant BSON_DATA_BINARY
+ **/
+BSON.BSON_DATA_BINARY = 5;
+/**
+ * ObjectID BSON Type
+ *
+ * @classconstant BSON_DATA_OID
+ **/
+BSON.BSON_DATA_OID = 7;
+/**
+ * Boolean BSON Type
+ *
+ * @classconstant BSON_DATA_BOOLEAN
+ **/
+BSON.BSON_DATA_BOOLEAN = 8;
+/**
+ * Date BSON Type
+ *
+ * @classconstant BSON_DATA_DATE
+ **/
+BSON.BSON_DATA_DATE = 9;
+/**
+ * null BSON Type
+ *
+ * @classconstant BSON_DATA_NULL
+ **/
+BSON.BSON_DATA_NULL = 10;
+/**
+ * RegExp BSON Type
+ *
+ * @classconstant BSON_DATA_REGEXP
+ **/
+BSON.BSON_DATA_REGEXP = 11;
+/**
+ * Code BSON Type
+ *
+ * @classconstant BSON_DATA_CODE
+ **/
+BSON.BSON_DATA_CODE = 13;
+/**
+ * Symbol BSON Type
+ *
+ * @classconstant BSON_DATA_SYMBOL
+ **/
+BSON.BSON_DATA_SYMBOL = 14;
+/**
+ * Code with Scope BSON Type
+ *
+ * @classconstant BSON_DATA_CODE_W_SCOPE
+ **/
+BSON.BSON_DATA_CODE_W_SCOPE = 15;
+/**
+ * 32 bit Integer BSON Type
+ *
+ * @classconstant BSON_DATA_INT
+ **/
+BSON.BSON_DATA_INT = 16;
+/**
+ * Timestamp BSON Type
+ *
+ * @classconstant BSON_DATA_TIMESTAMP
+ **/
+BSON.BSON_DATA_TIMESTAMP = 17;
+/**
+ * Long BSON Type
+ *
+ * @classconstant BSON_DATA_LONG
+ **/
+BSON.BSON_DATA_LONG = 18;
+/**
+ * MinKey BSON Type
+ *
+ * @classconstant BSON_DATA_MIN_KEY
+ **/
+BSON.BSON_DATA_MIN_KEY = 0xff;
+/**
+ * MaxKey BSON Type
+ *
+ * @classconstant BSON_DATA_MAX_KEY
+ **/
+BSON.BSON_DATA_MAX_KEY = 0x7f;
+
+/**
+ * Binary Default Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_DEFAULT
+ **/
+BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0;
+/**
+ * Binary Function Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_FUNCTION
+ **/
+BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1;
+/**
+ * Binary Byte Array Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_BYTE_ARRAY
+ **/
+BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
+/**
+ * Binary UUID Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_UUID
+ **/
+BSON.BSON_BINARY_SUBTYPE_UUID = 3;
+/**
+ * Binary MD5 Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_MD5
+ **/
+BSON.BSON_BINARY_SUBTYPE_MD5 = 4;
+/**
+ * Binary User Defined Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_USER_DEFINED
+ **/
+BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
+
+// Return BSON
+module.exports = BSON;
+module.exports.Code = Code;
+module.exports.Map = Map;
+module.exports.Symbol = Symbol;
+module.exports.BSON = BSON;
+module.exports.DBRef = DBRef;
+module.exports.Binary = Binary;
+module.exports.ObjectID = ObjectID;
+module.exports.Long = Long;
+module.exports.Timestamp = Timestamp;
+module.exports.Double = Double;
+module.exports.Int32 = Int32;
+module.exports.MinKey = MinKey;
+module.exports.MaxKey = MaxKey;
+module.exports.BSONRegExp = BSONRegExp;
+module.exports.Decimal128 = Decimal128;

+ 24 - 0
node_modules/bson/lib/bson/code.js

@@ -0,0 +1,24 @@
+/**
+ * A class representation of the BSON Code type.
+ *
+ * @class
+ * @param {(string|function)} code a string or function.
+ * @param {Object} [scope] an optional scope for the function.
+ * @return {Code}
+ */
+var Code = function Code(code, scope) {
+  if (!(this instanceof Code)) return new Code(code, scope);
+  this._bsontype = 'Code';
+  this.code = code;
+  this.scope = scope;
+};
+
+/**
+ * @ignore
+ */
+Code.prototype.toJSON = function() {
+  return { scope: this.scope, code: this.code };
+};
+
+module.exports = Code;
+module.exports.Code = Code;

+ 32 - 0
node_modules/bson/lib/bson/db_ref.js

@@ -0,0 +1,32 @@
+/**
+ * A class representation of the BSON DBRef type.
+ *
+ * @class
+ * @param {string} namespace the collection name.
+ * @param {ObjectID} oid the reference ObjectID.
+ * @param {string} [db] optional db name, if omitted the reference is local to the current db.
+ * @return {DBRef}
+ */
+function DBRef(namespace, oid, db) {
+  if (!(this instanceof DBRef)) return new DBRef(namespace, oid, db);
+
+  this._bsontype = 'DBRef';
+  this.namespace = namespace;
+  this.oid = oid;
+  this.db = db;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+DBRef.prototype.toJSON = function() {
+  return {
+    $ref: this.namespace,
+    $id: this.oid,
+    $db: this.db == null ? '' : this.db
+  };
+};
+
+module.exports = DBRef;
+module.exports.DBRef = DBRef;

+ 820 - 0
node_modules/bson/lib/bson/decimal128.js

@@ -0,0 +1,820 @@
+'use strict';
+
+var Long = require('./long');
+
+var PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/;
+var PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i;
+var PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i;
+
+var EXPONENT_MAX = 6111;
+var EXPONENT_MIN = -6176;
+var EXPONENT_BIAS = 6176;
+var MAX_DIGITS = 34;
+
+// Nan value bits as 32 bit values (due to lack of longs)
+var NAN_BUFFER = [
+  0x7c,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00
+].reverse();
+// Infinity value bits 32 bit values (due to lack of longs)
+var INF_NEGATIVE_BUFFER = [
+  0xf8,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00
+].reverse();
+var INF_POSITIVE_BUFFER = [
+  0x78,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00,
+  0x00
+].reverse();
+
+var EXPONENT_REGEX = /^([-+])?(\d+)?$/;
+
+var utils = require('./parser/utils');
+
+// Detect if the value is a digit
+var isDigit = function(value) {
+  return !isNaN(parseInt(value, 10));
+};
+
+// Divide two uint128 values
+var divideu128 = function(value) {
+  var DIVISOR = Long.fromNumber(1000 * 1000 * 1000);
+  var _rem = Long.fromNumber(0);
+  var i = 0;
+
+  if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) {
+    return { quotient: value, rem: _rem };
+  }
+
+  for (i = 0; i <= 3; i++) {
+    // Adjust remainder to match value of next dividend
+    _rem = _rem.shiftLeft(32);
+    // Add the divided to _rem
+    _rem = _rem.add(new Long(value.parts[i], 0));
+    value.parts[i] = _rem.div(DIVISOR).low_;
+    _rem = _rem.modulo(DIVISOR);
+  }
+
+  return { quotient: value, rem: _rem };
+};
+
+// Multiply two Long values and return the 128 bit value
+var multiply64x2 = function(left, right) {
+  if (!left && !right) {
+    return { high: Long.fromNumber(0), low: Long.fromNumber(0) };
+  }
+
+  var leftHigh = left.shiftRightUnsigned(32);
+  var leftLow = new Long(left.getLowBits(), 0);
+  var rightHigh = right.shiftRightUnsigned(32);
+  var rightLow = new Long(right.getLowBits(), 0);
+
+  var productHigh = leftHigh.multiply(rightHigh);
+  var productMid = leftHigh.multiply(rightLow);
+  var productMid2 = leftLow.multiply(rightHigh);
+  var productLow = leftLow.multiply(rightLow);
+
+  productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
+  productMid = new Long(productMid.getLowBits(), 0)
+    .add(productMid2)
+    .add(productLow.shiftRightUnsigned(32));
+
+  productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
+  productLow = productMid.shiftLeft(32).add(new Long(productLow.getLowBits(), 0));
+
+  // Return the 128 bit result
+  return { high: productHigh, low: productLow };
+};
+
+var lessThan = function(left, right) {
+  // Make values unsigned
+  var uhleft = left.high_ >>> 0;
+  var uhright = right.high_ >>> 0;
+
+  // Compare high bits first
+  if (uhleft < uhright) {
+    return true;
+  } else if (uhleft === uhright) {
+    var ulleft = left.low_ >>> 0;
+    var ulright = right.low_ >>> 0;
+    if (ulleft < ulright) return true;
+  }
+
+  return false;
+};
+
+// var longtoHex = function(value) {
+//   var buffer = utils.allocBuffer(8);
+//   var index = 0;
+//   // Encode the low 64 bits of the decimal
+//   // Encode low bits
+//   buffer[index++] = value.low_ & 0xff;
+//   buffer[index++] = (value.low_ >> 8) & 0xff;
+//   buffer[index++] = (value.low_ >> 16) & 0xff;
+//   buffer[index++] = (value.low_ >> 24) & 0xff;
+//   // Encode high bits
+//   buffer[index++] = value.high_ & 0xff;
+//   buffer[index++] = (value.high_ >> 8) & 0xff;
+//   buffer[index++] = (value.high_ >> 16) & 0xff;
+//   buffer[index++] = (value.high_ >> 24) & 0xff;
+//   return buffer.reverse().toString('hex');
+// };
+
+// var int32toHex = function(value) {
+//   var buffer = utils.allocBuffer(4);
+//   var index = 0;
+//   // Encode the low 64 bits of the decimal
+//   // Encode low bits
+//   buffer[index++] = value & 0xff;
+//   buffer[index++] = (value >> 8) & 0xff;
+//   buffer[index++] = (value >> 16) & 0xff;
+//   buffer[index++] = (value >> 24) & 0xff;
+//   return buffer.reverse().toString('hex');
+// };
+
+/**
+ * A class representation of the BSON Decimal128 type.
+ *
+ * @class
+ * @param {Buffer} bytes a buffer containing the raw Decimal128 bytes.
+ * @return {Double}
+ */
+var Decimal128 = function(bytes) {
+  this._bsontype = 'Decimal128';
+  this.bytes = bytes;
+};
+
+/**
+ * Create a Decimal128 instance from a string representation
+ *
+ * @method
+ * @param {string} string a numeric string representation.
+ * @return {Decimal128} returns a Decimal128 instance.
+ */
+Decimal128.fromString = function(string) {
+  // Parse state tracking
+  var isNegative = false;
+  var sawRadix = false;
+  var foundNonZero = false;
+
+  // Total number of significant digits (no leading or trailing zero)
+  var significantDigits = 0;
+  // Total number of significand digits read
+  var nDigitsRead = 0;
+  // Total number of digits (no leading zeros)
+  var nDigits = 0;
+  // The number of the digits after radix
+  var radixPosition = 0;
+  // The index of the first non-zero in *str*
+  var firstNonZero = 0;
+
+  // Digits Array
+  var digits = [0];
+  // The number of digits in digits
+  var nDigitsStored = 0;
+  // Insertion pointer for digits
+  var digitsInsert = 0;
+  // The index of the first non-zero digit
+  var firstDigit = 0;
+  // The index of the last digit
+  var lastDigit = 0;
+
+  // Exponent
+  var exponent = 0;
+  // loop index over array
+  var i = 0;
+  // The high 17 digits of the significand
+  var significandHigh = [0, 0];
+  // The low 17 digits of the significand
+  var significandLow = [0, 0];
+  // The biased exponent
+  var biasedExponent = 0;
+
+  // Read index
+  var index = 0;
+
+  // Trim the string
+  string = string.trim();
+
+  // Naively prevent against REDOS attacks.
+  // TODO: implementing a custom parsing for this, or refactoring the regex would yield
+  //       further gains.
+  if (string.length >= 7000) {
+    throw new Error('' + string + ' not a valid Decimal128 string');
+  }
+
+  // Results
+  var stringMatch = string.match(PARSE_STRING_REGEXP);
+  var infMatch = string.match(PARSE_INF_REGEXP);
+  var nanMatch = string.match(PARSE_NAN_REGEXP);
+
+  // Validate the string
+  if ((!stringMatch && !infMatch && !nanMatch) || string.length === 0) {
+    throw new Error('' + string + ' not a valid Decimal128 string');
+  }
+
+  // Check if we have an illegal exponent format
+  if (stringMatch && stringMatch[4] && stringMatch[2] === undefined) {
+    throw new Error('' + string + ' not a valid Decimal128 string');
+  }
+
+  // Get the negative or positive sign
+  if (string[index] === '+' || string[index] === '-') {
+    isNegative = string[index++] === '-';
+  }
+
+  // Check if user passed Infinity or NaN
+  if (!isDigit(string[index]) && string[index] !== '.') {
+    if (string[index] === 'i' || string[index] === 'I') {
+      return new Decimal128(utils.toBuffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
+    } else if (string[index] === 'N') {
+      return new Decimal128(utils.toBuffer(NAN_BUFFER));
+    }
+  }
+
+  // Read all the digits
+  while (isDigit(string[index]) || string[index] === '.') {
+    if (string[index] === '.') {
+      if (sawRadix) {
+        return new Decimal128(utils.toBuffer(NAN_BUFFER));
+      }
+
+      sawRadix = true;
+      index = index + 1;
+      continue;
+    }
+
+    if (nDigitsStored < 34) {
+      if (string[index] !== '0' || foundNonZero) {
+        if (!foundNonZero) {
+          firstNonZero = nDigitsRead;
+        }
+
+        foundNonZero = true;
+
+        // Only store 34 digits
+        digits[digitsInsert++] = parseInt(string[index], 10);
+        nDigitsStored = nDigitsStored + 1;
+      }
+    }
+
+    if (foundNonZero) {
+      nDigits = nDigits + 1;
+    }
+
+    if (sawRadix) {
+      radixPosition = radixPosition + 1;
+    }
+
+    nDigitsRead = nDigitsRead + 1;
+    index = index + 1;
+  }
+
+  if (sawRadix && !nDigitsRead) {
+    throw new Error('' + string + ' not a valid Decimal128 string');
+  }
+
+  // Read exponent if exists
+  if (string[index] === 'e' || string[index] === 'E') {
+    // Read exponent digits
+    var match = string.substr(++index).match(EXPONENT_REGEX);
+
+    // No digits read
+    if (!match || !match[2]) {
+      return new Decimal128(utils.toBuffer(NAN_BUFFER));
+    }
+
+    // Get exponent
+    exponent = parseInt(match[0], 10);
+
+    // Adjust the index
+    index = index + match[0].length;
+  }
+
+  // Return not a number
+  if (string[index]) {
+    return new Decimal128(utils.toBuffer(NAN_BUFFER));
+  }
+
+  // Done reading input
+  // Find first non-zero digit in digits
+  firstDigit = 0;
+
+  if (!nDigitsStored) {
+    firstDigit = 0;
+    lastDigit = 0;
+    digits[0] = 0;
+    nDigits = 1;
+    nDigitsStored = 1;
+    significantDigits = 0;
+  } else {
+    lastDigit = nDigitsStored - 1;
+    significantDigits = nDigits;
+
+    if (exponent !== 0 && significantDigits !== 1) {
+      while (string[firstNonZero + significantDigits - 1] === '0') {
+        significantDigits = significantDigits - 1;
+      }
+    }
+  }
+
+  // Normalization of exponent
+  // Correct exponent based on radix position, and shift significand as needed
+  // to represent user input
+
+  // Overflow prevention
+  if (exponent <= radixPosition && radixPosition - exponent > 1 << 14) {
+    exponent = EXPONENT_MIN;
+  } else {
+    exponent = exponent - radixPosition;
+  }
+
+  // Attempt to normalize the exponent
+  while (exponent > EXPONENT_MAX) {
+    // Shift exponent to significand and decrease
+    lastDigit = lastDigit + 1;
+
+    if (lastDigit - firstDigit > MAX_DIGITS) {
+      // Check if we have a zero then just hard clamp, otherwise fail
+      var digitsString = digits.join('');
+      if (digitsString.match(/^0+$/)) {
+        exponent = EXPONENT_MAX;
+        break;
+      } else {
+        return new Decimal128(utils.toBuffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
+      }
+    }
+
+    exponent = exponent - 1;
+  }
+
+  while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) {
+    // Shift last digit
+    if (lastDigit === 0) {
+      exponent = EXPONENT_MIN;
+      significantDigits = 0;
+      break;
+    }
+
+    if (nDigitsStored < nDigits) {
+      // adjust to match digits not stored
+      nDigits = nDigits - 1;
+    } else {
+      // adjust to round
+      lastDigit = lastDigit - 1;
+    }
+
+    if (exponent < EXPONENT_MAX) {
+      exponent = exponent + 1;
+    } else {
+      // Check if we have a zero then just hard clamp, otherwise fail
+      digitsString = digits.join('');
+      if (digitsString.match(/^0+$/)) {
+        exponent = EXPONENT_MAX;
+        break;
+      } else {
+        return new Decimal128(utils.toBuffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
+      }
+    }
+  }
+
+  // Round
+  // We've normalized the exponent, but might still need to round.
+  if (lastDigit - firstDigit + 1 < significantDigits && string[significantDigits] !== '0') {
+    var endOfString = nDigitsRead;
+
+    // If we have seen a radix point, 'string' is 1 longer than we have
+    // documented with ndigits_read, so inc the position of the first nonzero
+    // digit and the position that digits are read to.
+    if (sawRadix && exponent === EXPONENT_MIN) {
+      firstNonZero = firstNonZero + 1;
+      endOfString = endOfString + 1;
+    }
+
+    var roundDigit = parseInt(string[firstNonZero + lastDigit + 1], 10);
+    var roundBit = 0;
+
+    if (roundDigit >= 5) {
+      roundBit = 1;
+
+      if (roundDigit === 5) {
+        roundBit = digits[lastDigit] % 2 === 1;
+
+        for (i = firstNonZero + lastDigit + 2; i < endOfString; i++) {
+          if (parseInt(string[i], 10)) {
+            roundBit = 1;
+            break;
+          }
+        }
+      }
+    }
+
+    if (roundBit) {
+      var dIdx = lastDigit;
+
+      for (; dIdx >= 0; dIdx--) {
+        if (++digits[dIdx] > 9) {
+          digits[dIdx] = 0;
+
+          // overflowed most significant digit
+          if (dIdx === 0) {
+            if (exponent < EXPONENT_MAX) {
+              exponent = exponent + 1;
+              digits[dIdx] = 1;
+            } else {
+              return new Decimal128(
+                utils.toBuffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)
+              );
+            }
+          }
+        } else {
+          break;
+        }
+      }
+    }
+  }
+
+  // Encode significand
+  // The high 17 digits of the significand
+  significandHigh = Long.fromNumber(0);
+  // The low 17 digits of the significand
+  significandLow = Long.fromNumber(0);
+
+  // read a zero
+  if (significantDigits === 0) {
+    significandHigh = Long.fromNumber(0);
+    significandLow = Long.fromNumber(0);
+  } else if (lastDigit - firstDigit < 17) {
+    dIdx = firstDigit;
+    significandLow = Long.fromNumber(digits[dIdx++]);
+    significandHigh = new Long(0, 0);
+
+    for (; dIdx <= lastDigit; dIdx++) {
+      significandLow = significandLow.multiply(Long.fromNumber(10));
+      significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
+    }
+  } else {
+    dIdx = firstDigit;
+    significandHigh = Long.fromNumber(digits[dIdx++]);
+
+    for (; dIdx <= lastDigit - 17; dIdx++) {
+      significandHigh = significandHigh.multiply(Long.fromNumber(10));
+      significandHigh = significandHigh.add(Long.fromNumber(digits[dIdx]));
+    }
+
+    significandLow = Long.fromNumber(digits[dIdx++]);
+
+    for (; dIdx <= lastDigit; dIdx++) {
+      significandLow = significandLow.multiply(Long.fromNumber(10));
+      significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
+    }
+  }
+
+  var significand = multiply64x2(significandHigh, Long.fromString('100000000000000000'));
+
+  significand.low = significand.low.add(significandLow);
+
+  if (lessThan(significand.low, significandLow)) {
+    significand.high = significand.high.add(Long.fromNumber(1));
+  }
+
+  // Biased exponent
+  biasedExponent = exponent + EXPONENT_BIAS;
+  var dec = { low: Long.fromNumber(0), high: Long.fromNumber(0) };
+
+  // Encode combination, exponent, and significand.
+  if (
+    significand.high
+      .shiftRightUnsigned(49)
+      .and(Long.fromNumber(1))
+      .equals(Long.fromNumber)
+  ) {
+    // Encode '11' into bits 1 to 3
+    dec.high = dec.high.or(Long.fromNumber(0x3).shiftLeft(61));
+    dec.high = dec.high.or(
+      Long.fromNumber(biasedExponent).and(Long.fromNumber(0x3fff).shiftLeft(47))
+    );
+    dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x7fffffffffff)));
+  } else {
+    dec.high = dec.high.or(Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49));
+    dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x1ffffffffffff)));
+  }
+
+  dec.low = significand.low;
+
+  // Encode sign
+  if (isNegative) {
+    dec.high = dec.high.or(Long.fromString('9223372036854775808'));
+  }
+
+  // Encode into a buffer
+  var buffer = utils.allocBuffer(16);
+  index = 0;
+
+  // Encode the low 64 bits of the decimal
+  // Encode low bits
+  buffer[index++] = dec.low.low_ & 0xff;
+  buffer[index++] = (dec.low.low_ >> 8) & 0xff;
+  buffer[index++] = (dec.low.low_ >> 16) & 0xff;
+  buffer[index++] = (dec.low.low_ >> 24) & 0xff;
+  // Encode high bits
+  buffer[index++] = dec.low.high_ & 0xff;
+  buffer[index++] = (dec.low.high_ >> 8) & 0xff;
+  buffer[index++] = (dec.low.high_ >> 16) & 0xff;
+  buffer[index++] = (dec.low.high_ >> 24) & 0xff;
+
+  // Encode the high 64 bits of the decimal
+  // Encode low bits
+  buffer[index++] = dec.high.low_ & 0xff;
+  buffer[index++] = (dec.high.low_ >> 8) & 0xff;
+  buffer[index++] = (dec.high.low_ >> 16) & 0xff;
+  buffer[index++] = (dec.high.low_ >> 24) & 0xff;
+  // Encode high bits
+  buffer[index++] = dec.high.high_ & 0xff;
+  buffer[index++] = (dec.high.high_ >> 8) & 0xff;
+  buffer[index++] = (dec.high.high_ >> 16) & 0xff;
+  buffer[index++] = (dec.high.high_ >> 24) & 0xff;
+
+  // Return the new Decimal128
+  return new Decimal128(buffer);
+};
+
+// Extract least significant 5 bits
+var COMBINATION_MASK = 0x1f;
+// Extract least significant 14 bits
+var EXPONENT_MASK = 0x3fff;
+// Value of combination field for Inf
+var COMBINATION_INFINITY = 30;
+// Value of combination field for NaN
+var COMBINATION_NAN = 31;
+// Value of combination field for NaN
+// var COMBINATION_SNAN = 32;
+// decimal128 exponent bias
+EXPONENT_BIAS = 6176;
+
+/**
+ * Create a string representation of the raw Decimal128 value
+ *
+ * @method
+ * @return {string} returns a Decimal128 string representation.
+ */
+Decimal128.prototype.toString = function() {
+  // Note: bits in this routine are referred to starting at 0,
+  // from the sign bit, towards the coefficient.
+
+  // bits 0 - 31
+  var high;
+  // bits 32 - 63
+  var midh;
+  // bits 64 - 95
+  var midl;
+  // bits 96 - 127
+  var low;
+  // bits 1 - 5
+  var combination;
+  // decoded biased exponent (14 bits)
+  var biased_exponent;
+  // the number of significand digits
+  var significand_digits = 0;
+  // the base-10 digits in the significand
+  var significand = new Array(36);
+  for (var i = 0; i < significand.length; i++) significand[i] = 0;
+  // read pointer into significand
+  var index = 0;
+
+  // unbiased exponent
+  var exponent;
+  // the exponent if scientific notation is used
+  var scientific_exponent;
+
+  // true if the number is zero
+  var is_zero = false;
+
+  // the most signifcant significand bits (50-46)
+  var significand_msb;
+  // temporary storage for significand decoding
+  var significand128 = { parts: new Array(4) };
+  // indexing variables
+  i;
+  var j, k;
+
+  // Output string
+  var string = [];
+
+  // Unpack index
+  index = 0;
+
+  // Buffer reference
+  var buffer = this.bytes;
+
+  // Unpack the low 64bits into a long
+  low =
+    buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
+  midl =
+    buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
+
+  // Unpack the high 64bits into a long
+  midh =
+    buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
+  high =
+    buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
+
+  // Unpack index
+  index = 0;
+
+  // Create the state of the decimal
+  var dec = {
+    low: new Long(low, midl),
+    high: new Long(midh, high)
+  };
+
+  if (dec.high.lessThan(Long.ZERO)) {
+    string.push('-');
+  }
+
+  // Decode combination field and exponent
+  combination = (high >> 26) & COMBINATION_MASK;
+
+  if (combination >> 3 === 3) {
+    // Check for 'special' values
+    if (combination === COMBINATION_INFINITY) {
+      return string.join('') + 'Infinity';
+    } else if (combination === COMBINATION_NAN) {
+      return 'NaN';
+    } else {
+      biased_exponent = (high >> 15) & EXPONENT_MASK;
+      significand_msb = 0x08 + ((high >> 14) & 0x01);
+    }
+  } else {
+    significand_msb = (high >> 14) & 0x07;
+    biased_exponent = (high >> 17) & EXPONENT_MASK;
+  }
+
+  exponent = biased_exponent - EXPONENT_BIAS;
+
+  // Create string of significand digits
+
+  // Convert the 114-bit binary number represented by
+  // (significand_high, significand_low) to at most 34 decimal
+  // digits through modulo and division.
+  significand128.parts[0] = (high & 0x3fff) + ((significand_msb & 0xf) << 14);
+  significand128.parts[1] = midh;
+  significand128.parts[2] = midl;
+  significand128.parts[3] = low;
+
+  if (
+    significand128.parts[0] === 0 &&
+    significand128.parts[1] === 0 &&
+    significand128.parts[2] === 0 &&
+    significand128.parts[3] === 0
+  ) {
+    is_zero = true;
+  } else {
+    for (k = 3; k >= 0; k--) {
+      var least_digits = 0;
+      // Peform the divide
+      var result = divideu128(significand128);
+      significand128 = result.quotient;
+      least_digits = result.rem.low_;
+
+      // We now have the 9 least significant digits (in base 2).
+      // Convert and output to string.
+      if (!least_digits) continue;
+
+      for (j = 8; j >= 0; j--) {
+        // significand[k * 9 + j] = Math.round(least_digits % 10);
+        significand[k * 9 + j] = least_digits % 10;
+        // least_digits = Math.round(least_digits / 10);
+        least_digits = Math.floor(least_digits / 10);
+      }
+    }
+  }
+
+  // Output format options:
+  // Scientific - [-]d.dddE(+/-)dd or [-]dE(+/-)dd
+  // Regular    - ddd.ddd
+
+  if (is_zero) {
+    significand_digits = 1;
+    significand[index] = 0;
+  } else {
+    significand_digits = 36;
+    i = 0;
+
+    while (!significand[index]) {
+      i++;
+      significand_digits = significand_digits - 1;
+      index = index + 1;
+    }
+  }
+
+  scientific_exponent = significand_digits - 1 + exponent;
+
+  // The scientific exponent checks are dictated by the string conversion
+  // specification and are somewhat arbitrary cutoffs.
+  //
+  // We must check exponent > 0, because if this is the case, the number
+  // has trailing zeros.  However, we *cannot* output these trailing zeros,
+  // because doing so would change the precision of the value, and would
+  // change stored data if the string converted number is round tripped.
+
+  if (scientific_exponent >= 34 || scientific_exponent <= -7 || exponent > 0) {
+    // Scientific format
+    string.push(significand[index++]);
+    significand_digits = significand_digits - 1;
+
+    if (significand_digits) {
+      string.push('.');
+    }
+
+    for (i = 0; i < significand_digits; i++) {
+      string.push(significand[index++]);
+    }
+
+    // Exponent
+    string.push('E');
+    if (scientific_exponent > 0) {
+      string.push('+' + scientific_exponent);
+    } else {
+      string.push(scientific_exponent);
+    }
+  } else {
+    // Regular format with no decimal place
+    if (exponent >= 0) {
+      for (i = 0; i < significand_digits; i++) {
+        string.push(significand[index++]);
+      }
+    } else {
+      var radix_position = significand_digits + exponent;
+
+      // non-zero digits before radix
+      if (radix_position > 0) {
+        for (i = 0; i < radix_position; i++) {
+          string.push(significand[index++]);
+        }
+      } else {
+        string.push('0');
+      }
+
+      string.push('.');
+      // add leading zeros after radix
+      while (radix_position++ < 0) {
+        string.push('0');
+      }
+
+      for (i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) {
+        string.push(significand[index++]);
+      }
+    }
+  }
+
+  return string.join('');
+};
+
+Decimal128.prototype.toJSON = function() {
+  return { $numberDecimal: this.toString() };
+};
+
+module.exports = Decimal128;
+module.exports.Decimal128 = Decimal128;

+ 33 - 0
node_modules/bson/lib/bson/double.js

@@ -0,0 +1,33 @@
+/**
+ * A class representation of the BSON Double type.
+ *
+ * @class
+ * @param {number} value the number we want to represent as a double.
+ * @return {Double}
+ */
+function Double(value) {
+  if (!(this instanceof Double)) return new Double(value);
+
+  this._bsontype = 'Double';
+  this.value = value;
+}
+
+/**
+ * Access the number value.
+ *
+ * @method
+ * @return {number} returns the wrapped double number.
+ */
+Double.prototype.valueOf = function() {
+  return this.value;
+};
+
+/**
+ * @ignore
+ */
+Double.prototype.toJSON = function() {
+  return this.value;
+};
+
+module.exports = Double;
+module.exports.Double = Double;

+ 124 - 0
node_modules/bson/lib/bson/float_parser.js

@@ -0,0 +1,124 @@
+// Copyright (c) 2008, Fair Oaks Labs, Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+//  * Redistributions of source code must retain the above copyright notice,
+//    this list of conditions and the following disclaimer.
+//
+//  * Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+//
+//  * Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors
+//    may be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+//
+// Modifications to writeIEEE754 to support negative zeroes made by Brian White
+
+var readIEEE754 = function(buffer, offset, endian, mLen, nBytes) {
+  var e,
+    m,
+    bBE = endian === 'big',
+    eLen = nBytes * 8 - mLen - 1,
+    eMax = (1 << eLen) - 1,
+    eBias = eMax >> 1,
+    nBits = -7,
+    i = bBE ? 0 : nBytes - 1,
+    d = bBE ? 1 : -1,
+    s = buffer[offset + i];
+
+  i += d;
+
+  e = s & ((1 << -nBits) - 1);
+  s >>= -nBits;
+  nBits += eLen;
+  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
+
+  m = e & ((1 << -nBits) - 1);
+  e >>= -nBits;
+  nBits += mLen;
+  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
+
+  if (e === 0) {
+    e = 1 - eBias;
+  } else if (e === eMax) {
+    return m ? NaN : (s ? -1 : 1) * Infinity;
+  } else {
+    m = m + Math.pow(2, mLen);
+    e = e - eBias;
+  }
+  return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
+};
+
+var writeIEEE754 = function(buffer, value, offset, endian, mLen, nBytes) {
+  var e,
+    m,
+    c,
+    bBE = endian === 'big',
+    eLen = nBytes * 8 - mLen - 1,
+    eMax = (1 << eLen) - 1,
+    eBias = eMax >> 1,
+    rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0,
+    i = bBE ? nBytes - 1 : 0,
+    d = bBE ? -1 : 1,
+    s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
+
+  value = Math.abs(value);
+
+  if (isNaN(value) || value === Infinity) {
+    m = isNaN(value) ? 1 : 0;
+    e = eMax;
+  } else {
+    e = Math.floor(Math.log(value) / Math.LN2);
+    if (value * (c = Math.pow(2, -e)) < 1) {
+      e--;
+      c *= 2;
+    }
+    if (e + eBias >= 1) {
+      value += rt / c;
+    } else {
+      value += rt * Math.pow(2, 1 - eBias);
+    }
+    if (value * c >= 2) {
+      e++;
+      c /= 2;
+    }
+
+    if (e + eBias >= eMax) {
+      m = 0;
+      e = eMax;
+    } else if (e + eBias >= 1) {
+      m = (value * c - 1) * Math.pow(2, mLen);
+      e = e + eBias;
+    } else {
+      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
+      e = 0;
+    }
+  }
+
+  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);
+
+  e = (e << mLen) | m;
+  eLen += mLen;
+  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);
+
+  buffer[offset + i - d] |= s * 128;
+};
+
+exports.readIEEE754 = readIEEE754;
+exports.writeIEEE754 = writeIEEE754;

+ 33 - 0
node_modules/bson/lib/bson/int_32.js

@@ -0,0 +1,33 @@
+/**
+ * A class representation of a BSON Int32 type.
+ *
+ * @class
+ * @param {number} value the number we want to represent as an int32.
+ * @return {Int32}
+ */
+var Int32 = function(value) {
+  if (!(this instanceof Int32)) return new Int32(value);
+
+  this._bsontype = 'Int32';
+  this.value = value;
+};
+
+/**
+ * Access the number value.
+ *
+ * @method
+ * @return {number} returns the wrapped int32 number.
+ */
+Int32.prototype.valueOf = function() {
+  return this.value;
+};
+
+/**
+ * @ignore
+ */
+Int32.prototype.toJSON = function() {
+  return this.value;
+};
+
+module.exports = Int32;
+module.exports.Int32 = Int32;

+ 865 - 0
node_modules/bson/lib/bson/long.js

@@ -0,0 +1,865 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Copyright 2009 Google Inc. All Rights Reserved
+
+/**
+ * Defines a Long class for representing a 64-bit two's-complement
+ * integer value, which faithfully simulates the behavior of a Java "Long". This
+ * implementation is derived from LongLib in GWT.
+ *
+ * Constructs a 64-bit two's-complement integer, given its low and high 32-bit
+ * values as *signed* integers.  See the from* functions below for more
+ * convenient ways of constructing Longs.
+ *
+ * The internal representation of a Long is the two given signed, 32-bit values.
+ * We use 32-bit pieces because these are the size of integers on which
+ * Javascript performs bit-operations.  For operations like addition and
+ * multiplication, we split each number into 16-bit pieces, which can easily be
+ * multiplied within Javascript's floating-point representation without overflow
+ * or change in sign.
+ *
+ * In the algorithms below, we frequently reduce the negative case to the
+ * positive case by negating the input(s) and then post-processing the result.
+ * Note that we must ALWAYS check specially whether those values are MIN_VALUE
+ * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
+ * a positive number, it overflows back into a negative).  Not handling this
+ * case would often result in infinite recursion.
+ *
+ * @class
+ * @param {number} low  the low (signed) 32 bits of the Long.
+ * @param {number} high the high (signed) 32 bits of the Long.
+ * @return {Long}
+ */
+function Long(low, high) {
+  if (!(this instanceof Long)) return new Long(low, high);
+
+  this._bsontype = 'Long';
+  /**
+   * @type {number}
+   * @ignore
+   */
+  this.low_ = low | 0; // force into 32 signed bits.
+
+  /**
+   * @type {number}
+   * @ignore
+   */
+  this.high_ = high | 0; // force into 32 signed bits.
+}
+
+/**
+ * Return the int value.
+ *
+ * @method
+ * @return {number} the value, assuming it is a 32-bit integer.
+ */
+Long.prototype.toInt = function() {
+  return this.low_;
+};
+
+/**
+ * Return the Number value.
+ *
+ * @method
+ * @return {number} the closest floating-point representation to this value.
+ */
+Long.prototype.toNumber = function() {
+  return this.high_ * Long.TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();
+};
+
+/** Converts the Long to a BigInt (arbitrary precision). */
+Long.prototype.toBigInt = function () {
+  return BigInt(this.toString());
+}
+
+/**
+ * Return the JSON value.
+ *
+ * @method
+ * @return {string} the JSON representation.
+ */
+Long.prototype.toJSON = function() {
+  return this.toString();
+};
+
+/**
+ * Return the String value.
+ *
+ * @method
+ * @param {number} [opt_radix] the radix in which the text should be written.
+ * @return {string} the textual representation of this value.
+ */
+Long.prototype.toString = function(opt_radix) {
+  var radix = opt_radix || 10;
+  if (radix < 2 || 36 < radix) {
+    throw Error('radix out of range: ' + radix);
+  }
+
+  if (this.isZero()) {
+    return '0';
+  }
+
+  if (this.isNegative()) {
+    if (this.equals(Long.MIN_VALUE)) {
+      // We need to change the Long value before it can be negated, so we remove
+      // the bottom-most digit in this base and then recurse to do the rest.
+      var radixLong = Long.fromNumber(radix);
+      var div = this.div(radixLong);
+      var rem = div.multiply(radixLong).subtract(this);
+      return div.toString(radix) + rem.toInt().toString(radix);
+    } else {
+      return '-' + this.negate().toString(radix);
+    }
+  }
+
+  // Do several (6) digits each time through the loop, so as to
+  // minimize the calls to the very expensive emulated div.
+  var radixToPower = Long.fromNumber(Math.pow(radix, 6));
+
+  rem = this;
+  var result = '';
+
+  while (!rem.isZero()) {
+    var remDiv = rem.div(radixToPower);
+    var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt();
+    var digits = intval.toString(radix);
+
+    rem = remDiv;
+    if (rem.isZero()) {
+      return digits + result;
+    } else {
+      while (digits.length < 6) {
+        digits = '0' + digits;
+      }
+      result = '' + digits + result;
+    }
+  }
+};
+
+/**
+ * Return the high 32-bits value.
+ *
+ * @method
+ * @return {number} the high 32-bits as a signed value.
+ */
+Long.prototype.getHighBits = function() {
+  return this.high_;
+};
+
+/**
+ * Return the low 32-bits value.
+ *
+ * @method
+ * @return {number} the low 32-bits as a signed value.
+ */
+Long.prototype.getLowBits = function() {
+  return this.low_;
+};
+
+/**
+ * Return the low unsigned 32-bits value.
+ *
+ * @method
+ * @return {number} the low 32-bits as an unsigned value.
+ */
+Long.prototype.getLowBitsUnsigned = function() {
+  return this.low_ >= 0 ? this.low_ : Long.TWO_PWR_32_DBL_ + this.low_;
+};
+
+/**
+ * Returns the number of bits needed to represent the absolute value of this Long.
+ *
+ * @method
+ * @return {number} Returns the number of bits needed to represent the absolute value of this Long.
+ */
+Long.prototype.getNumBitsAbs = function() {
+  if (this.isNegative()) {
+    if (this.equals(Long.MIN_VALUE)) {
+      return 64;
+    } else {
+      return this.negate().getNumBitsAbs();
+    }
+  } else {
+    var val = this.high_ !== 0 ? this.high_ : this.low_;
+    for (var bit = 31; bit > 0; bit--) {
+      if ((val & (1 << bit)) !== 0) {
+        break;
+      }
+    }
+    return this.high_ !== 0 ? bit + 33 : bit + 1;
+  }
+};
+
+/**
+ * Return whether this value is zero.
+ *
+ * @method
+ * @return {boolean} whether this value is zero.
+ */
+Long.prototype.isZero = function() {
+  return this.high_ === 0 && this.low_ === 0;
+};
+
+/**
+ * Return whether this value is negative.
+ *
+ * @method
+ * @return {boolean} whether this value is negative.
+ */
+Long.prototype.isNegative = function() {
+  return this.high_ < 0;
+};
+
+/**
+ * Return whether this value is odd.
+ *
+ * @method
+ * @return {boolean} whether this value is odd.
+ */
+Long.prototype.isOdd = function() {
+  return (this.low_ & 1) === 1;
+};
+
+/**
+ * Return whether this Long equals the other
+ *
+ * @method
+ * @param {Long} other Long to compare against.
+ * @return {boolean} whether this Long equals the other
+ */
+Long.prototype.equals = function(other) {
+  return this.high_ === other.high_ && this.low_ === other.low_;
+};
+
+/**
+ * Return whether this Long does not equal the other.
+ *
+ * @method
+ * @param {Long} other Long to compare against.
+ * @return {boolean} whether this Long does not equal the other.
+ */
+Long.prototype.notEquals = function(other) {
+  return this.high_ !== other.high_ || this.low_ !== other.low_;
+};
+
+/**
+ * Return whether this Long is less than the other.
+ *
+ * @method
+ * @param {Long} other Long to compare against.
+ * @return {boolean} whether this Long is less than the other.
+ */
+Long.prototype.lessThan = function(other) {
+  return this.compare(other) < 0;
+};
+
+/**
+ * Return whether this Long is less than or equal to the other.
+ *
+ * @method
+ * @param {Long} other Long to compare against.
+ * @return {boolean} whether this Long is less than or equal to the other.
+ */
+Long.prototype.lessThanOrEqual = function(other) {
+  return this.compare(other) <= 0;
+};
+
+/**
+ * Return whether this Long is greater than the other.
+ *
+ * @method
+ * @param {Long} other Long to compare against.
+ * @return {boolean} whether this Long is greater than the other.
+ */
+Long.prototype.greaterThan = function(other) {
+  return this.compare(other) > 0;
+};
+
+/**
+ * Return whether this Long is greater than or equal to the other.
+ *
+ * @method
+ * @param {Long} other Long to compare against.
+ * @return {boolean} whether this Long is greater than or equal to the other.
+ */
+Long.prototype.greaterThanOrEqual = function(other) {
+  return this.compare(other) >= 0;
+};
+
+/**
+ * Compares this Long with the given one.
+ *
+ * @method
+ * @param {Long} other Long to compare against.
+ * @return {boolean} 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater.
+ */
+Long.prototype.compare = function(other) {
+  if (this.equals(other)) {
+    return 0;
+  }
+
+  var thisNeg = this.isNegative();
+  var otherNeg = other.isNegative();
+  if (thisNeg && !otherNeg) {
+    return -1;
+  }
+  if (!thisNeg && otherNeg) {
+    return 1;
+  }
+
+  // at this point, the signs are the same, so subtraction will not overflow
+  if (this.subtract(other).isNegative()) {
+    return -1;
+  } else {
+    return 1;
+  }
+};
+
+/**
+ * The negation of this value.
+ *
+ * @method
+ * @return {Long} the negation of this value.
+ */
+Long.prototype.negate = function() {
+  if (this.equals(Long.MIN_VALUE)) {
+    return Long.MIN_VALUE;
+  } else {
+    return this.not().add(Long.ONE);
+  }
+};
+
+/**
+ * Returns the sum of this and the given Long.
+ *
+ * @method
+ * @param {Long} other Long to add to this one.
+ * @return {Long} the sum of this and the given Long.
+ */
+Long.prototype.add = function(other) {
+  // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
+
+  var a48 = this.high_ >>> 16;
+  var a32 = this.high_ & 0xffff;
+  var a16 = this.low_ >>> 16;
+  var a00 = this.low_ & 0xffff;
+
+  var b48 = other.high_ >>> 16;
+  var b32 = other.high_ & 0xffff;
+  var b16 = other.low_ >>> 16;
+  var b00 = other.low_ & 0xffff;
+
+  var c48 = 0,
+    c32 = 0,
+    c16 = 0,
+    c00 = 0;
+  c00 += a00 + b00;
+  c16 += c00 >>> 16;
+  c00 &= 0xffff;
+  c16 += a16 + b16;
+  c32 += c16 >>> 16;
+  c16 &= 0xffff;
+  c32 += a32 + b32;
+  c48 += c32 >>> 16;
+  c32 &= 0xffff;
+  c48 += a48 + b48;
+  c48 &= 0xffff;
+  return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
+};
+
+/**
+ * Returns the difference of this and the given Long.
+ *
+ * @method
+ * @param {Long} other Long to subtract from this.
+ * @return {Long} the difference of this and the given Long.
+ */
+Long.prototype.subtract = function(other) {
+  return this.add(other.negate());
+};
+
+/**
+ * Returns the product of this and the given Long.
+ *
+ * @method
+ * @param {Long} other Long to multiply with this.
+ * @return {Long} the product of this and the other.
+ */
+Long.prototype.multiply = function(other) {
+  if (this.isZero()) {
+    return Long.ZERO;
+  } else if (other.isZero()) {
+    return Long.ZERO;
+  }
+
+  if (this.equals(Long.MIN_VALUE)) {
+    return other.isOdd() ? Long.MIN_VALUE : Long.ZERO;
+  } else if (other.equals(Long.MIN_VALUE)) {
+    return this.isOdd() ? Long.MIN_VALUE : Long.ZERO;
+  }
+
+  if (this.isNegative()) {
+    if (other.isNegative()) {
+      return this.negate().multiply(other.negate());
+    } else {
+      return this.negate()
+        .multiply(other)
+        .negate();
+    }
+  } else if (other.isNegative()) {
+    return this.multiply(other.negate()).negate();
+  }
+
+  // If both Longs are small, use float multiplication
+  if (this.lessThan(Long.TWO_PWR_24_) && other.lessThan(Long.TWO_PWR_24_)) {
+    return Long.fromNumber(this.toNumber() * other.toNumber());
+  }
+
+  // Divide each Long into 4 chunks of 16 bits, and then add up 4x4 products.
+  // We can skip products that would overflow.
+
+  var a48 = this.high_ >>> 16;
+  var a32 = this.high_ & 0xffff;
+  var a16 = this.low_ >>> 16;
+  var a00 = this.low_ & 0xffff;
+
+  var b48 = other.high_ >>> 16;
+  var b32 = other.high_ & 0xffff;
+  var b16 = other.low_ >>> 16;
+  var b00 = other.low_ & 0xffff;
+
+  var c48 = 0,
+    c32 = 0,
+    c16 = 0,
+    c00 = 0;
+  c00 += a00 * b00;
+  c16 += c00 >>> 16;
+  c00 &= 0xffff;
+  c16 += a16 * b00;
+  c32 += c16 >>> 16;
+  c16 &= 0xffff;
+  c16 += a00 * b16;
+  c32 += c16 >>> 16;
+  c16 &= 0xffff;
+  c32 += a32 * b00;
+  c48 += c32 >>> 16;
+  c32 &= 0xffff;
+  c32 += a16 * b16;
+  c48 += c32 >>> 16;
+  c32 &= 0xffff;
+  c32 += a00 * b32;
+  c48 += c32 >>> 16;
+  c32 &= 0xffff;
+  c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
+  c48 &= 0xffff;
+  return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
+};
+
+/**
+ * Returns this Long divided by the given one.
+ *
+ * @method
+ * @param {Long} other Long by which to divide.
+ * @return {Long} this Long divided by the given one.
+ */
+Long.prototype.div = function(other) {
+  if (other.isZero()) {
+    throw Error('division by zero');
+  } else if (this.isZero()) {
+    return Long.ZERO;
+  }
+
+  if (this.equals(Long.MIN_VALUE)) {
+    if (other.equals(Long.ONE) || other.equals(Long.NEG_ONE)) {
+      return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
+    } else if (other.equals(Long.MIN_VALUE)) {
+      return Long.ONE;
+    } else {
+      // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
+      var halfThis = this.shiftRight(1);
+      var approx = halfThis.div(other).shiftLeft(1);
+      if (approx.equals(Long.ZERO)) {
+        return other.isNegative() ? Long.ONE : Long.NEG_ONE;
+      } else {
+        var rem = this.subtract(other.multiply(approx));
+        var result = approx.add(rem.div(other));
+        return result;
+      }
+    }
+  } else if (other.equals(Long.MIN_VALUE)) {
+    return Long.ZERO;
+  }
+
+  if (this.isNegative()) {
+    if (other.isNegative()) {
+      return this.negate().div(other.negate());
+    } else {
+      return this.negate()
+        .div(other)
+        .negate();
+    }
+  } else if (other.isNegative()) {
+    return this.div(other.negate()).negate();
+  }
+
+  // Repeat the following until the remainder is less than other:  find a
+  // floating-point that approximates remainder / other *from below*, add this
+  // into the result, and subtract it from the remainder.  It is critical that
+  // the approximate value is less than or equal to the real value so that the
+  // remainder never becomes negative.
+  var res = Long.ZERO;
+  rem = this;
+  while (rem.greaterThanOrEqual(other)) {
+    // Approximate the result of division. This may be a little greater or
+    // smaller than the actual value.
+    approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber()));
+
+    // We will tweak the approximate result by changing it in the 48-th digit or
+    // the smallest non-fractional digit, whichever is larger.
+    var log2 = Math.ceil(Math.log(approx) / Math.LN2);
+    var delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48);
+
+    // Decrease the approximation until it is smaller than the remainder.  Note
+    // that if it is too large, the product overflows and is negative.
+    var approxRes = Long.fromNumber(approx);
+    var approxRem = approxRes.multiply(other);
+    while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
+      approx -= delta;
+      approxRes = Long.fromNumber(approx);
+      approxRem = approxRes.multiply(other);
+    }
+
+    // We know the answer can't be zero... and actually, zero would cause
+    // infinite recursion since we would make no progress.
+    if (approxRes.isZero()) {
+      approxRes = Long.ONE;
+    }
+
+    res = res.add(approxRes);
+    rem = rem.subtract(approxRem);
+  }
+  return res;
+};
+
+/**
+ * Returns this Long modulo the given one.
+ *
+ * @method
+ * @param {Long} other Long by which to mod.
+ * @return {Long} this Long modulo the given one.
+ */
+Long.prototype.modulo = function(other) {
+  return this.subtract(this.div(other).multiply(other));
+};
+
+/**
+ * The bitwise-NOT of this value.
+ *
+ * @method
+ * @return {Long} the bitwise-NOT of this value.
+ */
+Long.prototype.not = function() {
+  return Long.fromBits(~this.low_, ~this.high_);
+};
+
+/**
+ * Returns the bitwise-AND of this Long and the given one.
+ *
+ * @method
+ * @param {Long} other the Long with which to AND.
+ * @return {Long} the bitwise-AND of this and the other.
+ */
+Long.prototype.and = function(other) {
+  return Long.fromBits(this.low_ & other.low_, this.high_ & other.high_);
+};
+
+/**
+ * Returns the bitwise-OR of this Long and the given one.
+ *
+ * @method
+ * @param {Long} other the Long with which to OR.
+ * @return {Long} the bitwise-OR of this and the other.
+ */
+Long.prototype.or = function(other) {
+  return Long.fromBits(this.low_ | other.low_, this.high_ | other.high_);
+};
+
+/**
+ * Returns the bitwise-XOR of this Long and the given one.
+ *
+ * @method
+ * @param {Long} other the Long with which to XOR.
+ * @return {Long} the bitwise-XOR of this and the other.
+ */
+Long.prototype.xor = function(other) {
+  return Long.fromBits(this.low_ ^ other.low_, this.high_ ^ other.high_);
+};
+
+/**
+ * Returns this Long with bits shifted to the left by the given amount.
+ *
+ * @method
+ * @param {number} numBits the number of bits by which to shift.
+ * @return {Long} this shifted to the left by the given amount.
+ */
+Long.prototype.shiftLeft = function(numBits) {
+  numBits &= 63;
+  if (numBits === 0) {
+    return this;
+  } else {
+    var low = this.low_;
+    if (numBits < 32) {
+      var high = this.high_;
+      return Long.fromBits(low << numBits, (high << numBits) | (low >>> (32 - numBits)));
+    } else {
+      return Long.fromBits(0, low << (numBits - 32));
+    }
+  }
+};
+
+/**
+ * Returns this Long with bits shifted to the right by the given amount.
+ *
+ * @method
+ * @param {number} numBits the number of bits by which to shift.
+ * @return {Long} this shifted to the right by the given amount.
+ */
+Long.prototype.shiftRight = function(numBits) {
+  numBits &= 63;
+  if (numBits === 0) {
+    return this;
+  } else {
+    var high = this.high_;
+    if (numBits < 32) {
+      var low = this.low_;
+      return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >> numBits);
+    } else {
+      return Long.fromBits(high >> (numBits - 32), high >= 0 ? 0 : -1);
+    }
+  }
+};
+
+/**
+ * Returns this Long with bits shifted to the right by the given amount, with the new top bits matching the current sign bit.
+ *
+ * @method
+ * @param {number} numBits the number of bits by which to shift.
+ * @return {Long} this shifted to the right by the given amount, with zeros placed into the new leading bits.
+ */
+Long.prototype.shiftRightUnsigned = function(numBits) {
+  numBits &= 63;
+  if (numBits === 0) {
+    return this;
+  } else {
+    var high = this.high_;
+    if (numBits < 32) {
+      var low = this.low_;
+      return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits);
+    } else if (numBits === 32) {
+      return Long.fromBits(high, 0);
+    } else {
+      return Long.fromBits(high >>> (numBits - 32), 0);
+    }
+  }
+};
+
+/**
+ * Returns a Long representing the given (32-bit) integer value.
+ *
+ * @method
+ * @param {number} value the 32-bit integer in question.
+ * @return {Long} the corresponding Long value.
+ */
+Long.fromInt = function(value) {
+  if (-128 <= value && value < 128) {
+    var cachedObj = Long.INT_CACHE_[value];
+    if (cachedObj) {
+      return cachedObj;
+    }
+  }
+
+  var obj = new Long(value | 0, value < 0 ? -1 : 0);
+  if (-128 <= value && value < 128) {
+    Long.INT_CACHE_[value] = obj;
+  }
+  return obj;
+};
+
+/**
+ * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
+ *
+ * @method
+ * @param {number} value the number in question.
+ * @return {Long} the corresponding Long value.
+ */
+Long.fromNumber = function(value) {
+  if (isNaN(value) || !isFinite(value)) {
+    return Long.ZERO;
+  } else if (value <= -Long.TWO_PWR_63_DBL_) {
+    return Long.MIN_VALUE;
+  } else if (value + 1 >= Long.TWO_PWR_63_DBL_) {
+    return Long.MAX_VALUE;
+  } else if (value < 0) {
+    return Long.fromNumber(-value).negate();
+  } else {
+    return new Long((value % Long.TWO_PWR_32_DBL_) | 0, (value / Long.TWO_PWR_32_DBL_) | 0);
+  }
+};
+
+/**
+ * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
+ * @param {bigint} value - The number in question
+ * @returns {Long} The corresponding Long value
+ */
+Long.fromBigInt =  function(value) {
+  return Long.fromString(value.toString(10), 10);
+}
+
+/**
+ * Returns a Long representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits.
+ *
+ * @method
+ * @param {number} lowBits the low 32-bits.
+ * @param {number} highBits the high 32-bits.
+ * @return {Long} the corresponding Long value.
+ */
+Long.fromBits = function(lowBits, highBits) {
+  return new Long(lowBits, highBits);
+};
+
+/**
+ * Returns a Long representation of the given string, written using the given radix.
+ *
+ * @method
+ * @param {string} str the textual representation of the Long.
+ * @param {number} opt_radix the radix in which the text is written.
+ * @return {Long} the corresponding Long value.
+ */
+Long.fromString = function(str, opt_radix) {
+  if (str.length === 0) {
+    throw Error('number format error: empty string');
+  }
+
+  var radix = opt_radix || 10;
+  if (radix < 2 || 36 < radix) {
+    throw Error('radix out of range: ' + radix);
+  }
+
+  if (str.charAt(0) === '-') {
+    return Long.fromString(str.substring(1), radix).negate();
+  } else if (str.indexOf('-') >= 0) {
+    throw Error('number format error: interior "-" character: ' + str);
+  }
+
+  // Do several (8) digits each time through the loop, so as to
+  // minimize the calls to the very expensive emulated div.
+  var radixToPower = Long.fromNumber(Math.pow(radix, 8));
+
+  var result = Long.ZERO;
+  for (var i = 0; i < str.length; i += 8) {
+    var size = Math.min(8, str.length - i);
+    var value = parseInt(str.substring(i, i + size), radix);
+    if (size < 8) {
+      var power = Long.fromNumber(Math.pow(radix, size));
+      result = result.multiply(power).add(Long.fromNumber(value));
+    } else {
+      result = result.multiply(radixToPower);
+      result = result.add(Long.fromNumber(value));
+    }
+  }
+  return result;
+};
+
+// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the
+// from* methods on which they depend.
+
+/**
+ * A cache of the Long representations of small integer values.
+ * @type {Object}
+ * @ignore
+ */
+Long.INT_CACHE_ = {};
+
+// NOTE: the compiler should inline these constant values below and then remove
+// these variables, so there should be no runtime penalty for these.
+
+/**
+ * Number used repeated below in calculations.  This must appear before the
+ * first call to any from* function below.
+ * @type {number}
+ * @ignore
+ */
+Long.TWO_PWR_16_DBL_ = 1 << 16;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Long.TWO_PWR_24_DBL_ = 1 << 24;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Long.TWO_PWR_32_DBL_ = Long.TWO_PWR_16_DBL_ * Long.TWO_PWR_16_DBL_;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Long.TWO_PWR_31_DBL_ = Long.TWO_PWR_32_DBL_ / 2;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Long.TWO_PWR_48_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_16_DBL_;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Long.TWO_PWR_64_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_32_DBL_;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Long.TWO_PWR_63_DBL_ = Long.TWO_PWR_64_DBL_ / 2;
+
+/** @type {Long} */
+Long.ZERO = Long.fromInt(0);
+
+/** @type {Long} */
+Long.ONE = Long.fromInt(1);
+
+/** @type {Long} */
+Long.NEG_ONE = Long.fromInt(-1);
+
+/** @type {Long} */
+Long.MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0);
+
+/** @type {Long} */
+Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0);
+
+/**
+ * @type {Long}
+ * @ignore
+ */
+Long.TWO_PWR_24_ = Long.fromInt(1 << 24);
+
+/**
+ * Expose.
+ */
+module.exports = Long;
+module.exports.Long = Long;

+ 128 - 0
node_modules/bson/lib/bson/map.js

@@ -0,0 +1,128 @@
+'use strict';
+
+// We have an ES6 Map available, return the native instance
+if (typeof global.Map !== 'undefined') {
+  module.exports = global.Map;
+  module.exports.Map = global.Map;
+} else {
+  // We will return a polyfill
+  var Map = function(array) {
+    this._keys = [];
+    this._values = {};
+
+    for (var i = 0; i < array.length; i++) {
+      if (array[i] == null) continue; // skip null and undefined
+      var entry = array[i];
+      var key = entry[0];
+      var value = entry[1];
+      // Add the key to the list of keys in order
+      this._keys.push(key);
+      // Add the key and value to the values dictionary with a point
+      // to the location in the ordered keys list
+      this._values[key] = { v: value, i: this._keys.length - 1 };
+    }
+  };
+
+  Map.prototype.clear = function() {
+    this._keys = [];
+    this._values = {};
+  };
+
+  Map.prototype.delete = function(key) {
+    var value = this._values[key];
+    if (value == null) return false;
+    // Delete entry
+    delete this._values[key];
+    // Remove the key from the ordered keys list
+    this._keys.splice(value.i, 1);
+    return true;
+  };
+
+  Map.prototype.entries = function() {
+    var self = this;
+    var index = 0;
+
+    return {
+      next: function() {
+        var key = self._keys[index++];
+        return {
+          value: key !== undefined ? [key, self._values[key].v] : undefined,
+          done: key !== undefined ? false : true
+        };
+      }
+    };
+  };
+
+  Map.prototype.forEach = function(callback, self) {
+    self = self || this;
+
+    for (var i = 0; i < this._keys.length; i++) {
+      var key = this._keys[i];
+      // Call the forEach callback
+      callback.call(self, this._values[key].v, key, self);
+    }
+  };
+
+  Map.prototype.get = function(key) {
+    return this._values[key] ? this._values[key].v : undefined;
+  };
+
+  Map.prototype.has = function(key) {
+    return this._values[key] != null;
+  };
+
+  Map.prototype.keys = function() {
+    var self = this;
+    var index = 0;
+
+    return {
+      next: function() {
+        var key = self._keys[index++];
+        return {
+          value: key !== undefined ? key : undefined,
+          done: key !== undefined ? false : true
+        };
+      }
+    };
+  };
+
+  Map.prototype.set = function(key, value) {
+    if (this._values[key]) {
+      this._values[key].v = value;
+      return this;
+    }
+
+    // Add the key to the list of keys in order
+    this._keys.push(key);
+    // Add the key and value to the values dictionary with a point
+    // to the location in the ordered keys list
+    this._values[key] = { v: value, i: this._keys.length - 1 };
+    return this;
+  };
+
+  Map.prototype.values = function() {
+    var self = this;
+    var index = 0;
+
+    return {
+      next: function() {
+        var key = self._keys[index++];
+        return {
+          value: key !== undefined ? self._values[key].v : undefined,
+          done: key !== undefined ? false : true
+        };
+      }
+    };
+  };
+
+  // Last ismaster
+  Object.defineProperty(Map.prototype, 'size', {
+    enumerable: true,
+    get: function() {
+      return this._keys.length;
+    }
+  });
+
+  module.exports = Map;
+  module.exports.Map = Map;
+}

+ 14 - 0
node_modules/bson/lib/bson/max_key.js

@@ -0,0 +1,14 @@
+/**
+ * A class representation of the BSON MaxKey type.
+ *
+ * @class
+ * @return {MaxKey} A MaxKey instance
+ */
+function MaxKey() {
+  if (!(this instanceof MaxKey)) return new MaxKey();
+
+  this._bsontype = 'MaxKey';
+}
+
+module.exports = MaxKey;
+module.exports.MaxKey = MaxKey;

+ 14 - 0
node_modules/bson/lib/bson/min_key.js

@@ -0,0 +1,14 @@
+/**
+ * A class representation of the BSON MinKey type.
+ *
+ * @class
+ * @return {MinKey} A MinKey instance
+ */
+function MinKey() {
+  if (!(this instanceof MinKey)) return new MinKey();
+
+  this._bsontype = 'MinKey';
+}
+
+module.exports = MinKey;
+module.exports.MinKey = MinKey;

+ 392 - 0
node_modules/bson/lib/bson/objectid.js

@@ -0,0 +1,392 @@
+// Custom inspect property name / symbol.
+var inspect = 'inspect';
+
+var utils = require('./parser/utils');
+
+/**
+ * Machine id.
+ *
+ * Create a random 3-byte value (i.e. unique for this
+ * process). Other drivers use a md5 of the machine id here, but
+ * that would mean an asyc call to gethostname, so we don't bother.
+ * @ignore
+ */
+var MACHINE_ID = parseInt(Math.random() * 0xffffff, 10);
+
+// Regular expression that checks for hex value
+var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');
+
+// Check if buffer exists
+try {
+  if (Buffer && Buffer.from) {
+    var hasBufferType = true;
+    inspect = require('util').inspect.custom || 'inspect';
+  }
+} catch (err) {
+  hasBufferType = false;
+}
+
+/**
+* Create a new ObjectID instance
+*
+* @class
+* @param {(string|number)} id Can be a 24 byte hex string, 12 byte binary string or a Number.
+* @property {number} generationTime The generation time of this ObjectId instance
+* @return {ObjectID} instance of ObjectID.
+*/
+var ObjectID = function ObjectID(id) {
+  // Duck-typing to support ObjectId from different npm packages
+  if (id instanceof ObjectID) return id;
+  if (!(this instanceof ObjectID)) return new ObjectID(id);
+
+  this._bsontype = 'ObjectID';
+
+  // The most common usecase (blank id, new objectId instance)
+  if (id == null || typeof id === 'number') {
+    // Generate a new id
+    this.id = this.generate(id);
+    // If we are caching the hex string
+    if (ObjectID.cacheHexString) this.__id = this.toString('hex');
+    // Return the object
+    return;
+  }
+
+  // Check if the passed in id is valid
+  var valid = ObjectID.isValid(id);
+
+  // Throw an error if it's not a valid setup
+  if (!valid && id != null) {
+    throw new Error(
+      'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'
+    );
+  } else if (valid && typeof id === 'string' && id.length === 24 && hasBufferType) {
+    return new ObjectID(utils.toBuffer(id, 'hex'));
+  } else if (valid && typeof id === 'string' && id.length === 24) {
+    return ObjectID.createFromHexString(id);
+  } else if (id != null && id.length === 12) {
+    // assume 12 byte string
+    this.id = id;
+  } else if (id != null && typeof id.toHexString === 'function') {
+    // Duck-typing to support ObjectId from different npm packages
+    return id;
+  } else {
+    throw new Error(
+      'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'
+    );
+  }
+
+  if (ObjectID.cacheHexString) this.__id = this.toString('hex');
+};
+
+// Allow usage of ObjectId as well as ObjectID
+// var ObjectId = ObjectID;
+
+// Precomputed hex table enables speedy hex string conversion
+var hexTable = [];
+for (var i = 0; i < 256; i++) {
+  hexTable[i] = (i <= 15 ? '0' : '') + i.toString(16);
+}
+
+/**
+* Return the ObjectID id as a 24 byte hex string representation
+*
+* @method
+* @return {string} return the 24 byte hex string representation.
+*/
+ObjectID.prototype.toHexString = function() {
+  if (ObjectID.cacheHexString && this.__id) return this.__id;
+
+  var hexString = '';
+  if (!this.id || !this.id.length) {
+    throw new Error(
+      'invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is [' +
+        JSON.stringify(this.id) +
+        ']'
+    );
+  }
+
+  if (this.id instanceof _Buffer) {
+    hexString = convertToHex(this.id);
+    if (ObjectID.cacheHexString) this.__id = hexString;
+    return hexString;
+  }
+
+  for (var i = 0; i < this.id.length; i++) {
+    hexString += hexTable[this.id.charCodeAt(i)];
+  }
+
+  if (ObjectID.cacheHexString) this.__id = hexString;
+  return hexString;
+};
+
+/**
+* Update the ObjectID index used in generating new ObjectID's on the driver
+*
+* @method
+* @return {number} returns next index value.
+* @ignore
+*/
+ObjectID.prototype.get_inc = function() {
+  return (ObjectID.index = (ObjectID.index + 1) % 0xffffff);
+};
+
+/**
+* Update the ObjectID index used in generating new ObjectID's on the driver
+*
+* @method
+* @return {number} returns next index value.
+* @ignore
+*/
+ObjectID.prototype.getInc = function() {
+  return this.get_inc();
+};
+
+/**
+* Generate a 12 byte id buffer used in ObjectID's
+*
+* @method
+* @param {number} [time] optional parameter allowing to pass in a second based timestamp.
+* @return {Buffer} return the 12 byte id buffer string.
+*/
+ObjectID.prototype.generate = function(time) {
+  if ('number' !== typeof time) {
+    time = ~~(Date.now() / 1000);
+  }
+
+  // Use pid
+  var pid =
+    (typeof process === 'undefined' || process.pid === 1
+      ? Math.floor(Math.random() * 100000)
+      : process.pid) % 0xffff;
+  var inc = this.get_inc();
+  // Buffer used
+  var buffer = utils.allocBuffer(12);
+  // Encode time
+  buffer[3] = time & 0xff;
+  buffer[2] = (time >> 8) & 0xff;
+  buffer[1] = (time >> 16) & 0xff;
+  buffer[0] = (time >> 24) & 0xff;
+  // Encode machine
+  buffer[6] = MACHINE_ID & 0xff;
+  buffer[5] = (MACHINE_ID >> 8) & 0xff;
+  buffer[4] = (MACHINE_ID >> 16) & 0xff;
+  // Encode pid
+  buffer[8] = pid & 0xff;
+  buffer[7] = (pid >> 8) & 0xff;
+  // Encode index
+  buffer[11] = inc & 0xff;
+  buffer[10] = (inc >> 8) & 0xff;
+  buffer[9] = (inc >> 16) & 0xff;
+  // Return the buffer
+  return buffer;
+};
+
+/**
+* Converts the id into a 24 byte hex string for printing
+*
+* @param {String} format The Buffer toString format parameter.
+* @return {String} return the 24 byte hex string representation.
+* @ignore
+*/
+ObjectID.prototype.toString = function(format) {
+  // Is the id a buffer then use the buffer toString method to return the format
+  if (this.id && this.id.copy) {
+    return this.id.toString(typeof format === 'string' ? format : 'hex');
+  }
+
+  // if(this.buffer )
+  return this.toHexString();
+};
+
+/**
+* Converts to a string representation of this Id.
+*
+* @return {String} return the 24 byte hex string representation.
+* @ignore
+*/
+ObjectID.prototype[inspect] = ObjectID.prototype.toString;
+
+/**
+* Converts to its JSON representation.
+*
+* @return {String} return the 24 byte hex string representation.
+* @ignore
+*/
+ObjectID.prototype.toJSON = function() {
+  return this.toHexString();
+};
+
+/**
+* Compares the equality of this ObjectID with `otherID`.
+*
+* @method
+* @param {object} otherID ObjectID instance to compare against.
+* @return {boolean} the result of comparing two ObjectID's
+*/
+ObjectID.prototype.equals = function equals(otherId) {
+  // var id;
+
+  if (otherId instanceof ObjectID) {
+    return this.toString() === otherId.toString();
+  } else if (
+    typeof otherId === 'string' &&
+    ObjectID.isValid(otherId) &&
+    otherId.length === 12 &&
+    this.id instanceof _Buffer
+  ) {
+    return otherId === this.id.toString('binary');
+  } else if (typeof otherId === 'string' && ObjectID.isValid(otherId) && otherId.length === 24) {
+    return otherId.toLowerCase() === this.toHexString();
+  } else if (typeof otherId === 'string' && ObjectID.isValid(otherId) && otherId.length === 12) {
+    return otherId === this.id;
+  } else if (otherId != null && (otherId instanceof ObjectID || otherId.toHexString)) {
+    return otherId.toHexString() === this.toHexString();
+  } else {
+    return false;
+  }
+};
+
+/**
+* Returns the generation date (accurate up to the second) that this ID was generated.
+*
+* @method
+* @return {date} the generation date
+*/
+ObjectID.prototype.getTimestamp = function() {
+  var timestamp = new Date();
+  var time = this.id[3] | (this.id[2] << 8) | (this.id[1] << 16) | (this.id[0] << 24);
+  timestamp.setTime(Math.floor(time) * 1000);
+  return timestamp;
+};
+
+/**
+* @ignore
+*/
+ObjectID.index = ~~(Math.random() * 0xffffff);
+
+/**
+* @ignore
+*/
+ObjectID.createPk = function createPk() {
+  return new ObjectID();
+};
+
+/**
+* Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID.
+*
+* @method
+* @param {number} time an integer number representing a number of seconds.
+* @return {ObjectID} return the created ObjectID
+*/
+ObjectID.createFromTime = function createFromTime(time) {
+  var buffer = utils.toBuffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
+  // Encode time into first 4 bytes
+  buffer[3] = time & 0xff;
+  buffer[2] = (time >> 8) & 0xff;
+  buffer[1] = (time >> 16) & 0xff;
+  buffer[0] = (time >> 24) & 0xff;
+  // Return the new objectId
+  return new ObjectID(buffer);
+};
+
+// Lookup tables
+//var encodeLookup = '0123456789abcdef'.split('');
+var decodeLookup = [];
+i = 0;
+while (i < 10) decodeLookup[0x30 + i] = i++;
+while (i < 16) decodeLookup[0x41 - 10 + i] = decodeLookup[0x61 - 10 + i] = i++;
+
+var _Buffer = Buffer;
+var convertToHex = function(bytes) {
+  return bytes.toString('hex');
+};
+
+/**
+* Creates an ObjectID from a hex string representation of an ObjectID.
+*
+* @method
+* @param {string} hexString create a ObjectID from a passed in 24 byte hexstring.
+* @return {ObjectID} return the created ObjectID
+*/
+ObjectID.createFromHexString = function createFromHexString(string) {
+  // Throw an error if it's not a valid setup
+  if (typeof string === 'undefined' || (string != null && string.length !== 24)) {
+    throw new Error(
+      'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'
+    );
+  }
+
+  // Use Buffer.from method if available
+  if (hasBufferType) return new ObjectID(utils.toBuffer(string, 'hex'));
+
+  // Calculate lengths
+  var array = new _Buffer(12);
+  var n = 0;
+  var i = 0;
+
+  while (i < 24) {
+    array[n++] = (decodeLookup[string.charCodeAt(i++)] << 4) | decodeLookup[string.charCodeAt(i++)];
+  }
+
+  return new ObjectID(array);
+};
+
+/**
+* Checks if a value is a valid bson ObjectId
+*
+* @method
+* @return {boolean} return true if the value is a valid bson ObjectId, return false otherwise.
+*/
+ObjectID.isValid = function isValid(id) {
+  if (id == null) return false;
+
+  if (typeof id === 'number') {
+    return true;
+  }
+
+  if (typeof id === 'string') {
+    return id.length === 12 || (id.length === 24 && checkForHexRegExp.test(id));
+  }
+
+  if (id instanceof ObjectID) {
+    return true;
+  }
+
+  if (id instanceof _Buffer) {
+    return true;
+  }
+
+  // Duck-Typing detection of ObjectId like objects
+  if (
+      typeof id.toHexString === 'function' &&
+      (id.id instanceof _Buffer || typeof id.id === 'string')
+  ) {
+    return id.id.length === 12 || (id.id.length === 24 && checkForHexRegExp.test(id.id));
+  }
+
+  return false;
+};
+
+/**
+* @ignore
+*/
+Object.defineProperty(ObjectID.prototype, 'generationTime', {
+  enumerable: true,
+  get: function() {
+    return this.id[3] | (this.id[2] << 8) | (this.id[1] << 16) | (this.id[0] << 24);
+  },
+  set: function(value) {
+    // Encode time into first 4 bytes
+    this.id[3] = value & 0xff;
+    this.id[2] = (value >> 8) & 0xff;
+    this.id[1] = (value >> 16) & 0xff;
+    this.id[0] = (value >> 24) & 0xff;
+  }
+});
+
+/**
+ * Expose.
+ */
+module.exports = ObjectID;
+module.exports.ObjectID = ObjectID;
+module.exports.ObjectId = ObjectID;

+ 255 - 0
node_modules/bson/lib/bson/parser/calculate_size.js

@@ -0,0 +1,255 @@
+'use strict';
+
+var Long = require('../long').Long,
+  Double = require('../double').Double,
+  Timestamp = require('../timestamp').Timestamp,
+  ObjectID = require('../objectid').ObjectID,
+  Symbol = require('../symbol').Symbol,
+  BSONRegExp = require('../regexp').BSONRegExp,
+  Code = require('../code').Code,
+  Decimal128 = require('../decimal128'),
+  MinKey = require('../min_key').MinKey,
+  MaxKey = require('../max_key').MaxKey,
+  DBRef = require('../db_ref').DBRef,
+  Binary = require('../binary').Binary;
+
+var normalizedFunctionString = require('./utils').normalizedFunctionString;
+
+// To ensure that 0.4 of node works correctly
+var isDate = function isDate(d) {
+  return typeof d === 'object' && Object.prototype.toString.call(d) === '[object Date]';
+};
+
+var calculateObjectSize = function calculateObjectSize(
+  object,
+  serializeFunctions,
+  ignoreUndefined
+) {
+  var totalLength = 4 + 1;
+
+  if (Array.isArray(object)) {
+    for (var i = 0; i < object.length; i++) {
+      totalLength += calculateElement(
+        i.toString(),
+        object[i],
+        serializeFunctions,
+        true,
+        ignoreUndefined
+      );
+    }
+  } else {
+    // If we have toBSON defined, override the current object
+    if (object.toBSON) {
+      object = object.toBSON();
+    }
+
+    // Calculate size
+    for (var key in object) {
+      totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined);
+    }
+  }
+
+  return totalLength;
+};
+
+/**
+ * @ignore
+ * @api private
+ */
+function calculateElement(name, value, serializeFunctions, isArray, ignoreUndefined) {
+  // If we have toBSON defined, override the current object
+  if (value && value.toBSON) {
+    value = value.toBSON();
+  }
+
+  switch (typeof value) {
+    case 'string':
+      return 1 + Buffer.byteLength(name, 'utf8') + 1 + 4 + Buffer.byteLength(value, 'utf8') + 1;
+    case 'number':
+      if (Math.floor(value) === value && value >= BSON.JS_INT_MIN && value <= BSON.JS_INT_MAX) {
+        if (value >= BSON.BSON_INT32_MIN && value <= BSON.BSON_INT32_MAX) {
+          // 32 bit
+          return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (4 + 1);
+        } else {
+          return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
+        }
+      } else {
+        // 64 bit
+        return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
+      }
+    case 'undefined':
+      if (isArray || !ignoreUndefined)
+        return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
+      return 0;
+    case 'boolean':
+      return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 1);
+    case 'object':
+      if (
+        value == null ||
+        value instanceof MinKey ||
+        value instanceof MaxKey ||
+        value['_bsontype'] === 'MinKey' ||
+        value['_bsontype'] === 'MaxKey'
+      ) {
+        return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
+      } else if (value instanceof ObjectID || value['_bsontype'] === 'ObjectID' || value['_bsontype'] === 'ObjectId') {
+        return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1);
+      } else if (value instanceof Date || isDate(value)) {
+        return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
+      } else if (typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {
+        return (
+          (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.length
+        );
+      } else if (
+        value instanceof Long ||
+        value instanceof Double ||
+        value instanceof Timestamp ||
+        value['_bsontype'] === 'Long' ||
+        value['_bsontype'] === 'Double' ||
+        value['_bsontype'] === 'Timestamp'
+      ) {
+        return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
+      } else if (value instanceof Decimal128 || value['_bsontype'] === 'Decimal128') {
+        return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1);
+      } else if (value instanceof Code || value['_bsontype'] === 'Code') {
+        // Calculate size depending on the availability of a scope
+        if (value.scope != null && Object.keys(value.scope).length > 0) {
+          return (
+            (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+            1 +
+            4 +
+            4 +
+            Buffer.byteLength(value.code.toString(), 'utf8') +
+            1 +
+            calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined)
+          );
+        } else {
+          return (
+            (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+            1 +
+            4 +
+            Buffer.byteLength(value.code.toString(), 'utf8') +
+            1
+          );
+        }
+      } else if (value instanceof Binary || value['_bsontype'] === 'Binary') {
+        // Check what kind of subtype we have
+        if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
+          return (
+            (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+            (value.position + 1 + 4 + 1 + 4)
+          );
+        } else {
+          return (
+            (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (value.position + 1 + 4 + 1)
+          );
+        }
+      } else if (value instanceof Symbol || value['_bsontype'] === 'Symbol') {
+        return (
+          (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+          Buffer.byteLength(value.value, 'utf8') +
+          4 +
+          1 +
+          1
+        );
+      } else if (value instanceof DBRef || value['_bsontype'] === 'DBRef') {
+        // Set up correct object for serialization
+        var ordered_values = {
+          $ref: value.namespace,
+          $id: value.oid
+        };
+
+        // Add db reference if it exists
+        if (null != value.db) {
+          ordered_values['$db'] = value.db;
+        }
+
+        return (
+          (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+          1 +
+          calculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined)
+        );
+      } else if (
+        value instanceof RegExp ||
+        Object.prototype.toString.call(value) === '[object RegExp]'
+      ) {
+        return (
+          (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+          1 +
+          Buffer.byteLength(value.source, 'utf8') +
+          1 +
+          (value.global ? 1 : 0) +
+          (value.ignoreCase ? 1 : 0) +
+          (value.multiline ? 1 : 0) +
+          1
+        );
+      } else if (value instanceof BSONRegExp || value['_bsontype'] === 'BSONRegExp') {
+        return (
+          (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+          1 +
+          Buffer.byteLength(value.pattern, 'utf8') +
+          1 +
+          Buffer.byteLength(value.options, 'utf8') +
+          1
+        );
+      } else {
+        return (
+          (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+          calculateObjectSize(value, serializeFunctions, ignoreUndefined) +
+          1
+        );
+      }
+    case 'function':
+      // WTF for 0.4.X where typeof /someregexp/ === 'function'
+      if (
+        value instanceof RegExp ||
+        Object.prototype.toString.call(value) === '[object RegExp]' ||
+        String.call(value) === '[object RegExp]'
+      ) {
+        return (
+          (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+          1 +
+          Buffer.byteLength(value.source, 'utf8') +
+          1 +
+          (value.global ? 1 : 0) +
+          (value.ignoreCase ? 1 : 0) +
+          (value.multiline ? 1 : 0) +
+          1
+        );
+      } else {
+        if (serializeFunctions && value.scope != null && Object.keys(value.scope).length > 0) {
+          return (
+            (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+            1 +
+            4 +
+            4 +
+            Buffer.byteLength(normalizedFunctionString(value), 'utf8') +
+            1 +
+            calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined)
+          );
+        } else if (serializeFunctions) {
+          return (
+            (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
+            1 +
+            4 +
+            Buffer.byteLength(normalizedFunctionString(value), 'utf8') +
+            1
+          );
+        }
+      }
+  }
+
+  return 0;
+}
+
+var BSON = {};
+
+// BSON MAX VALUES
+BSON.BSON_INT32_MAX = 0x7fffffff;
+BSON.BSON_INT32_MIN = -0x80000000;
+
+// JS MAX PRECISE VALUES
+BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double.
+BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double.
+
+module.exports = calculateObjectSize;

+ 782 - 0
node_modules/bson/lib/bson/parser/deserializer.js

@@ -0,0 +1,782 @@
+'use strict';
+
+var Long = require('../long').Long,
+  Double = require('../double').Double,
+  Timestamp = require('../timestamp').Timestamp,
+  ObjectID = require('../objectid').ObjectID,
+  Symbol = require('../symbol').Symbol,
+  Code = require('../code').Code,
+  MinKey = require('../min_key').MinKey,
+  MaxKey = require('../max_key').MaxKey,
+  Decimal128 = require('../decimal128'),
+  Int32 = require('../int_32'),
+  DBRef = require('../db_ref').DBRef,
+  BSONRegExp = require('../regexp').BSONRegExp,
+  Binary = require('../binary').Binary;
+
+var utils = require('./utils');
+
+var deserialize = function(buffer, options, isArray) {
+  options = options == null ? {} : options;
+  var index = options && options.index ? options.index : 0;
+  // Read the document size
+  var size =
+    buffer[index] |
+    (buffer[index + 1] << 8) |
+    (buffer[index + 2] << 16) |
+    (buffer[index + 3] << 24);
+
+  // Ensure buffer is valid size
+  if (size < 5 || buffer.length < size || size + index > buffer.length) {
+    throw new Error('corrupt bson message');
+  }
+
+  // Illegal end value
+  if (buffer[index + size - 1] !== 0) {
+    throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");
+  }
+
+  // Start deserializtion
+  return deserializeObject(buffer, index, options, isArray);
+};
+
+var deserializeObject = function(buffer, index, options, isArray) {
+  var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions'];
+  var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions'];
+  var cacheFunctionsCrc32 =
+    options['cacheFunctionsCrc32'] == null ? false : options['cacheFunctionsCrc32'];
+
+  if (!cacheFunctionsCrc32) var crc32 = null;
+
+  var fieldsAsRaw = options['fieldsAsRaw'] == null ? null : options['fieldsAsRaw'];
+
+  // Return raw bson buffer instead of parsing it
+  var raw = options['raw'] == null ? false : options['raw'];
+
+  // Return BSONRegExp objects instead of native regular expressions
+  var bsonRegExp = typeof options['bsonRegExp'] === 'boolean' ? options['bsonRegExp'] : false;
+
+  // Controls the promotion of values vs wrapper classes
+  var promoteBuffers = options['promoteBuffers'] == null ? false : options['promoteBuffers'];
+  var promoteLongs = options['promoteLongs'] == null ? true : options['promoteLongs'];
+  var promoteValues = options['promoteValues'] == null ? true : options['promoteValues'];
+
+  // Set the start index
+  var startIndex = index;
+
+  // Validate that we have at least 4 bytes of buffer
+  if (buffer.length < 5) throw new Error('corrupt bson message < 5 bytes long');
+
+  // Read the document size
+  var size =
+    buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
+
+  // Ensure buffer is valid size
+  if (size < 5 || size > buffer.length) throw new Error('corrupt bson message');
+
+  // Create holding object
+  var object = isArray ? [] : {};
+  // Used for arrays to skip having to perform utf8 decoding
+  var arrayIndex = 0;
+
+  var done = false;
+
+  // While we have more left data left keep parsing
+  // while (buffer[index + 1] !== 0) {
+  while (!done) {
+    // Read the type
+    var elementType = buffer[index++];
+    // If we get a zero it's the last byte, exit
+    if (elementType === 0) break;
+
+    // Get the start search index
+    var i = index;
+    // Locate the end of the c string
+    while (buffer[i] !== 0x00 && i < buffer.length) {
+      i++;
+    }
+
+    // If are at the end of the buffer there is a problem with the document
+    if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString');
+    var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i);
+
+    index = i + 1;
+
+    if (elementType === BSON.BSON_DATA_STRING) {
+      var stringSize =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      if (
+        stringSize <= 0 ||
+        stringSize > buffer.length - index ||
+        buffer[index + stringSize - 1] !== 0
+      )
+        throw new Error('bad string length in bson');
+      object[name] = buffer.toString('utf8', index, index + stringSize - 1);
+      index = index + stringSize;
+    } else if (elementType === BSON.BSON_DATA_OID) {
+      var oid = utils.allocBuffer(12);
+      buffer.copy(oid, 0, index, index + 12);
+      object[name] = new ObjectID(oid);
+      index = index + 12;
+    } else if (elementType === BSON.BSON_DATA_INT && promoteValues === false) {
+      object[name] = new Int32(
+        buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24)
+      );
+    } else if (elementType === BSON.BSON_DATA_INT) {
+      object[name] =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+    } else if (elementType === BSON.BSON_DATA_NUMBER && promoteValues === false) {
+      object[name] = new Double(buffer.readDoubleLE(index));
+      index = index + 8;
+    } else if (elementType === BSON.BSON_DATA_NUMBER) {
+      object[name] = buffer.readDoubleLE(index);
+      index = index + 8;
+    } else if (elementType === BSON.BSON_DATA_DATE) {
+      var lowBits =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      var highBits =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      object[name] = new Date(new Long(lowBits, highBits).toNumber());
+    } else if (elementType === BSON.BSON_DATA_BOOLEAN) {
+      if (buffer[index] !== 0 && buffer[index] !== 1) throw new Error('illegal boolean type value');
+      object[name] = buffer[index++] === 1;
+    } else if (elementType === BSON.BSON_DATA_OBJECT) {
+      var _index = index;
+      var objectSize =
+        buffer[index] |
+        (buffer[index + 1] << 8) |
+        (buffer[index + 2] << 16) |
+        (buffer[index + 3] << 24);
+      if (objectSize <= 0 || objectSize > buffer.length - index)
+        throw new Error('bad embedded document length in bson');
+
+      // We have a raw value
+      if (raw) {
+        object[name] = buffer.slice(index, index + objectSize);
+      } else {
+        object[name] = deserializeObject(buffer, _index, options, false);
+      }
+
+      index = index + objectSize;
+    } else if (elementType === BSON.BSON_DATA_ARRAY) {
+      _index = index;
+      objectSize =
+        buffer[index] |
+        (buffer[index + 1] << 8) |
+        (buffer[index + 2] << 16) |
+        (buffer[index + 3] << 24);
+      var arrayOptions = options;
+
+      // Stop index
+      var stopIndex = index + objectSize;
+
+      // All elements of array to be returned as raw bson
+      if (fieldsAsRaw && fieldsAsRaw[name]) {
+        arrayOptions = {};
+        for (var n in options) arrayOptions[n] = options[n];
+        arrayOptions['raw'] = true;
+      }
+
+      object[name] = deserializeObject(buffer, _index, arrayOptions, true);
+      index = index + objectSize;
+
+      if (buffer[index - 1] !== 0) throw new Error('invalid array terminator byte');
+      if (index !== stopIndex) throw new Error('corrupted array bson');
+    } else if (elementType === BSON.BSON_DATA_UNDEFINED) {
+      object[name] = undefined;
+    } else if (elementType === BSON.BSON_DATA_NULL) {
+      object[name] = null;
+    } else if (elementType === BSON.BSON_DATA_LONG) {
+      // Unpack the low and high bits
+      lowBits =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      highBits =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      var long = new Long(lowBits, highBits);
+      // Promote the long if possible
+      if (promoteLongs && promoteValues === true) {
+        object[name] =
+          long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG)
+            ? long.toNumber()
+            : long;
+      } else {
+        object[name] = long;
+      }
+    } else if (elementType === BSON.BSON_DATA_DECIMAL128) {
+      // Buffer to contain the decimal bytes
+      var bytes = utils.allocBuffer(16);
+      // Copy the next 16 bytes into the bytes buffer
+      buffer.copy(bytes, 0, index, index + 16);
+      // Update index
+      index = index + 16;
+      // Assign the new Decimal128 value
+      var decimal128 = new Decimal128(bytes);
+      // If we have an alternative mapper use that
+      object[name] = decimal128.toObject ? decimal128.toObject() : decimal128;
+    } else if (elementType === BSON.BSON_DATA_BINARY) {
+      var binarySize =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      var totalBinarySize = binarySize;
+      var subType = buffer[index++];
+
+      // Did we have a negative binary size, throw
+      if (binarySize < 0) throw new Error('Negative binary type element size found');
+
+      // Is the length longer than the document
+      if (binarySize > buffer.length) throw new Error('Binary type size larger than document size');
+
+      // Decode as raw Buffer object if options specifies it
+      if (buffer['slice'] != null) {
+        // If we have subtype 2 skip the 4 bytes for the size
+        if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
+          binarySize =
+            buffer[index++] |
+            (buffer[index++] << 8) |
+            (buffer[index++] << 16) |
+            (buffer[index++] << 24);
+          if (binarySize < 0)
+            throw new Error('Negative binary type element size found for subtype 0x02');
+          if (binarySize > totalBinarySize - 4)
+            throw new Error('Binary type with subtype 0x02 contains to long binary size');
+          if (binarySize < totalBinarySize - 4)
+            throw new Error('Binary type with subtype 0x02 contains to short binary size');
+        }
+
+        if (promoteBuffers && promoteValues) {
+          object[name] = buffer.slice(index, index + binarySize);
+        } else {
+          object[name] = new Binary(buffer.slice(index, index + binarySize), subType);
+        }
+      } else {
+        var _buffer =
+          typeof Uint8Array !== 'undefined'
+            ? new Uint8Array(new ArrayBuffer(binarySize))
+            : new Array(binarySize);
+        // If we have subtype 2 skip the 4 bytes for the size
+        if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
+          binarySize =
+            buffer[index++] |
+            (buffer[index++] << 8) |
+            (buffer[index++] << 16) |
+            (buffer[index++] << 24);
+          if (binarySize < 0)
+            throw new Error('Negative binary type element size found for subtype 0x02');
+          if (binarySize > totalBinarySize - 4)
+            throw new Error('Binary type with subtype 0x02 contains to long binary size');
+          if (binarySize < totalBinarySize - 4)
+            throw new Error('Binary type with subtype 0x02 contains to short binary size');
+        }
+
+        // Copy the data
+        for (i = 0; i < binarySize; i++) {
+          _buffer[i] = buffer[index + i];
+        }
+
+        if (promoteBuffers && promoteValues) {
+          object[name] = _buffer;
+        } else {
+          object[name] = new Binary(_buffer, subType);
+        }
+      }
+
+      // Update the index
+      index = index + binarySize;
+    } else if (elementType === BSON.BSON_DATA_REGEXP && bsonRegExp === false) {
+      // Get the start search index
+      i = index;
+      // Locate the end of the c string
+      while (buffer[i] !== 0x00 && i < buffer.length) {
+        i++;
+      }
+      // If are at the end of the buffer there is a problem with the document
+      if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString');
+      // Return the C string
+      var source = buffer.toString('utf8', index, i);
+      // Create the regexp
+      index = i + 1;
+
+      // Get the start search index
+      i = index;
+      // Locate the end of the c string
+      while (buffer[i] !== 0x00 && i < buffer.length) {
+        i++;
+      }
+      // If are at the end of the buffer there is a problem with the document
+      if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString');
+      // Return the C string
+      var regExpOptions = buffer.toString('utf8', index, i);
+      index = i + 1;
+
+      // For each option add the corresponding one for javascript
+      var optionsArray = new Array(regExpOptions.length);
+
+      // Parse options
+      for (i = 0; i < regExpOptions.length; i++) {
+        switch (regExpOptions[i]) {
+          case 'm':
+            optionsArray[i] = 'm';
+            break;
+          case 's':
+            optionsArray[i] = 'g';
+            break;
+          case 'i':
+            optionsArray[i] = 'i';
+            break;
+        }
+      }
+
+      object[name] = new RegExp(source, optionsArray.join(''));
+    } else if (elementType === BSON.BSON_DATA_REGEXP && bsonRegExp === true) {
+      // Get the start search index
+      i = index;
+      // Locate the end of the c string
+      while (buffer[i] !== 0x00 && i < buffer.length) {
+        i++;
+      }
+      // If are at the end of the buffer there is a problem with the document
+      if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString');
+      // Return the C string
+      source = buffer.toString('utf8', index, i);
+      index = i + 1;
+
+      // Get the start search index
+      i = index;
+      // Locate the end of the c string
+      while (buffer[i] !== 0x00 && i < buffer.length) {
+        i++;
+      }
+      // If are at the end of the buffer there is a problem with the document
+      if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString');
+      // Return the C string
+      regExpOptions = buffer.toString('utf8', index, i);
+      index = i + 1;
+
+      // Set the object
+      object[name] = new BSONRegExp(source, regExpOptions);
+    } else if (elementType === BSON.BSON_DATA_SYMBOL) {
+      stringSize =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      if (
+        stringSize <= 0 ||
+        stringSize > buffer.length - index ||
+        buffer[index + stringSize - 1] !== 0
+      )
+        throw new Error('bad string length in bson');
+      object[name] = new Symbol(buffer.toString('utf8', index, index + stringSize - 1));
+      index = index + stringSize;
+    } else if (elementType === BSON.BSON_DATA_TIMESTAMP) {
+      lowBits =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      highBits =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      object[name] = new Timestamp(lowBits, highBits);
+    } else if (elementType === BSON.BSON_DATA_MIN_KEY) {
+      object[name] = new MinKey();
+    } else if (elementType === BSON.BSON_DATA_MAX_KEY) {
+      object[name] = new MaxKey();
+    } else if (elementType === BSON.BSON_DATA_CODE) {
+      stringSize =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      if (
+        stringSize <= 0 ||
+        stringSize > buffer.length - index ||
+        buffer[index + stringSize - 1] !== 0
+      )
+        throw new Error('bad string length in bson');
+      var functionString = buffer.toString('utf8', index, index + stringSize - 1);
+
+      // If we are evaluating the functions
+      if (evalFunctions) {
+        // If we have cache enabled let's look for the md5 of the function in the cache
+        if (cacheFunctions) {
+          var hash = cacheFunctionsCrc32 ? crc32(functionString) : functionString;
+          // Got to do this to avoid V8 deoptimizing the call due to finding eval
+          object[name] = isolateEvalWithHash(functionCache, hash, functionString, object);
+        } else {
+          object[name] = isolateEval(functionString);
+        }
+      } else {
+        object[name] = new Code(functionString);
+      }
+
+      // Update parse index position
+      index = index + stringSize;
+    } else if (elementType === BSON.BSON_DATA_CODE_W_SCOPE) {
+      var totalSize =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+
+      // Element cannot be shorter than totalSize + stringSize + documentSize + terminator
+      if (totalSize < 4 + 4 + 4 + 1) {
+        throw new Error('code_w_scope total size shorter minimum expected length');
+      }
+
+      // Get the code string size
+      stringSize =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      // Check if we have a valid string
+      if (
+        stringSize <= 0 ||
+        stringSize > buffer.length - index ||
+        buffer[index + stringSize - 1] !== 0
+      )
+        throw new Error('bad string length in bson');
+
+      // Javascript function
+      functionString = buffer.toString('utf8', index, index + stringSize - 1);
+      // Update parse index position
+      index = index + stringSize;
+      // Parse the element
+      _index = index;
+      // Decode the size of the object document
+      objectSize =
+        buffer[index] |
+        (buffer[index + 1] << 8) |
+        (buffer[index + 2] << 16) |
+        (buffer[index + 3] << 24);
+      // Decode the scope object
+      var scopeObject = deserializeObject(buffer, _index, options, false);
+      // Adjust the index
+      index = index + objectSize;
+
+      // Check if field length is to short
+      if (totalSize < 4 + 4 + objectSize + stringSize) {
+        throw new Error('code_w_scope total size is to short, truncating scope');
+      }
+
+      // Check if totalSize field is to long
+      if (totalSize > 4 + 4 + objectSize + stringSize) {
+        throw new Error('code_w_scope total size is to long, clips outer document');
+      }
+
+      // If we are evaluating the functions
+      if (evalFunctions) {
+        // If we have cache enabled let's look for the md5 of the function in the cache
+        if (cacheFunctions) {
+          hash = cacheFunctionsCrc32 ? crc32(functionString) : functionString;
+          // Got to do this to avoid V8 deoptimizing the call due to finding eval
+          object[name] = isolateEvalWithHash(functionCache, hash, functionString, object);
+        } else {
+          object[name] = isolateEval(functionString);
+        }
+
+        object[name].scope = scopeObject;
+      } else {
+        object[name] = new Code(functionString, scopeObject);
+      }
+    } else if (elementType === BSON.BSON_DATA_DBPOINTER) {
+      // Get the code string size
+      stringSize =
+        buffer[index++] |
+        (buffer[index++] << 8) |
+        (buffer[index++] << 16) |
+        (buffer[index++] << 24);
+      // Check if we have a valid string
+      if (
+        stringSize <= 0 ||
+        stringSize > buffer.length - index ||
+        buffer[index + stringSize - 1] !== 0
+      )
+        throw new Error('bad string length in bson');
+      // Namespace
+      var namespace = buffer.toString('utf8', index, index + stringSize - 1);
+      // Update parse index position
+      index = index + stringSize;
+
+      // Read the oid
+      var oidBuffer = utils.allocBuffer(12);
+      buffer.copy(oidBuffer, 0, index, index + 12);
+      oid = new ObjectID(oidBuffer);
+
+      // Update the index
+      index = index + 12;
+
+      // Split the namespace
+      var parts = namespace.split('.');
+      var db = parts.shift();
+      var collection = parts.join('.');
+      // Upgrade to DBRef type
+      object[name] = new DBRef(collection, oid, db);
+    } else {
+      throw new Error(
+        'Detected unknown BSON type ' +
+          elementType.toString(16) +
+          ' for fieldname "' +
+          name +
+          '", are you using the latest BSON parser'
+      );
+    }
+  }
+
+  // Check if the deserialization was against a valid array/object
+  if (size !== index - startIndex) {
+    if (isArray) throw new Error('corrupt array bson');
+    throw new Error('corrupt object bson');
+  }
+
+  // Check if we have a db ref object
+  if (object['$id'] != null) object = new DBRef(object['$ref'], object['$id'], object['$db']);
+  return object;
+};
+
+/**
+ * Ensure eval is isolated.
+ *
+ * @ignore
+ * @api private
+ */
+var isolateEvalWithHash = function(functionCache, hash, functionString, object) {
+  // Contains the value we are going to set
+  var value = null;
+
+  // Check for cache hit, eval if missing and return cached function
+  if (functionCache[hash] == null) {
+    eval('value = ' + functionString);
+    functionCache[hash] = value;
+  }
+  // Set the object
+  return functionCache[hash].bind(object);
+};
+
+/**
+ * Ensure eval is isolated.
+ *
+ * @ignore
+ * @api private
+ */
+var isolateEval = function(functionString) {
+  // Contains the value we are going to set
+  var value = null;
+  // Eval the function
+  eval('value = ' + functionString);
+  return value;
+};
+
+var BSON = {};
+
+/**
+ * Contains the function cache if we have that enable to allow for avoiding the eval step on each deserialization, comparison is by md5
+ *
+ * @ignore
+ * @api private
+ */
+var functionCache = (BSON.functionCache = {});
+
+/**
+ * Number BSON Type
+ *
+ * @classconstant BSON_DATA_NUMBER
+ **/
+BSON.BSON_DATA_NUMBER = 1;
+/**
+ * String BSON Type
+ *
+ * @classconstant BSON_DATA_STRING
+ **/
+BSON.BSON_DATA_STRING = 2;
+/**
+ * Object BSON Type
+ *
+ * @classconstant BSON_DATA_OBJECT
+ **/
+BSON.BSON_DATA_OBJECT = 3;
+/**
+ * Array BSON Type
+ *
+ * @classconstant BSON_DATA_ARRAY
+ **/
+BSON.BSON_DATA_ARRAY = 4;
+/**
+ * Binary BSON Type
+ *
+ * @classconstant BSON_DATA_BINARY
+ **/
+BSON.BSON_DATA_BINARY = 5;
+/**
+ * Binary BSON Type
+ *
+ * @classconstant BSON_DATA_UNDEFINED
+ **/
+BSON.BSON_DATA_UNDEFINED = 6;
+/**
+ * ObjectID BSON Type
+ *
+ * @classconstant BSON_DATA_OID
+ **/
+BSON.BSON_DATA_OID = 7;
+/**
+ * Boolean BSON Type
+ *
+ * @classconstant BSON_DATA_BOOLEAN
+ **/
+BSON.BSON_DATA_BOOLEAN = 8;
+/**
+ * Date BSON Type
+ *
+ * @classconstant BSON_DATA_DATE
+ **/
+BSON.BSON_DATA_DATE = 9;
+/**
+ * null BSON Type
+ *
+ * @classconstant BSON_DATA_NULL
+ **/
+BSON.BSON_DATA_NULL = 10;
+/**
+ * RegExp BSON Type
+ *
+ * @classconstant BSON_DATA_REGEXP
+ **/
+BSON.BSON_DATA_REGEXP = 11;
+/**
+ * Code BSON Type
+ *
+ * @classconstant BSON_DATA_DBPOINTER
+ **/
+BSON.BSON_DATA_DBPOINTER = 12;
+/**
+ * Code BSON Type
+ *
+ * @classconstant BSON_DATA_CODE
+ **/
+BSON.BSON_DATA_CODE = 13;
+/**
+ * Symbol BSON Type
+ *
+ * @classconstant BSON_DATA_SYMBOL
+ **/
+BSON.BSON_DATA_SYMBOL = 14;
+/**
+ * Code with Scope BSON Type
+ *
+ * @classconstant BSON_DATA_CODE_W_SCOPE
+ **/
+BSON.BSON_DATA_CODE_W_SCOPE = 15;
+/**
+ * 32 bit Integer BSON Type
+ *
+ * @classconstant BSON_DATA_INT
+ **/
+BSON.BSON_DATA_INT = 16;
+/**
+ * Timestamp BSON Type
+ *
+ * @classconstant BSON_DATA_TIMESTAMP
+ **/
+BSON.BSON_DATA_TIMESTAMP = 17;
+/**
+ * Long BSON Type
+ *
+ * @classconstant BSON_DATA_LONG
+ **/
+BSON.BSON_DATA_LONG = 18;
+/**
+ * Long BSON Type
+ *
+ * @classconstant BSON_DATA_DECIMAL128
+ **/
+BSON.BSON_DATA_DECIMAL128 = 19;
+/**
+ * MinKey BSON Type
+ *
+ * @classconstant BSON_DATA_MIN_KEY
+ **/
+BSON.BSON_DATA_MIN_KEY = 0xff;
+/**
+ * MaxKey BSON Type
+ *
+ * @classconstant BSON_DATA_MAX_KEY
+ **/
+BSON.BSON_DATA_MAX_KEY = 0x7f;
+
+/**
+ * Binary Default Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_DEFAULT
+ **/
+BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0;
+/**
+ * Binary Function Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_FUNCTION
+ **/
+BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1;
+/**
+ * Binary Byte Array Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_BYTE_ARRAY
+ **/
+BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
+/**
+ * Binary UUID Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_UUID
+ **/
+BSON.BSON_BINARY_SUBTYPE_UUID = 3;
+/**
+ * Binary MD5 Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_MD5
+ **/
+BSON.BSON_BINARY_SUBTYPE_MD5 = 4;
+/**
+ * Binary User Defined Type
+ *
+ * @classconstant BSON_BINARY_SUBTYPE_USER_DEFINED
+ **/
+BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
+
+// BSON MAX VALUES
+BSON.BSON_INT32_MAX = 0x7fffffff;
+BSON.BSON_INT32_MIN = -0x80000000;
+
+BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1;
+BSON.BSON_INT64_MIN = -Math.pow(2, 63);
+
+// JS MAX PRECISE VALUES
+BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double.
+BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double.
+
+// Internal long versions
+var JS_INT_MAX_LONG = Long.fromNumber(0x20000000000000); // Any integer up to 2^53 can be precisely represented by a double.
+var JS_INT_MIN_LONG = Long.fromNumber(-0x20000000000000); // Any integer down to -2^53 can be precisely represented by a double.
+
+module.exports = deserialize;

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1194 - 0
node_modules/bson/lib/bson/parser/serializer.js


+ 28 - 0
node_modules/bson/lib/bson/parser/utils.js

@@ -0,0 +1,28 @@
+'use strict';
+
+/**
+ * Normalizes our expected stringified form of a function across versions of node
+ * @param {Function} fn The function to stringify
+ */
+function normalizedFunctionString(fn) {
+  return fn.toString().replace(/function *\(/, 'function (');
+}
+
+function newBuffer(item, encoding) {
+  return new Buffer(item, encoding);
+}
+
+function allocBuffer() {
+  return Buffer.alloc.apply(Buffer, arguments);
+}
+
+function toBuffer() {
+  return Buffer.from.apply(Buffer, arguments);
+}
+
+module.exports = {
+  normalizedFunctionString: normalizedFunctionString,
+  allocBuffer: typeof Buffer.alloc === 'function' ? allocBuffer : newBuffer,
+  toBuffer: typeof Buffer.from === 'function' ? toBuffer : newBuffer
+};
+

+ 33 - 0
node_modules/bson/lib/bson/regexp.js

@@ -0,0 +1,33 @@
+/**
+ * A class representation of the BSON RegExp type.
+ *
+ * @class
+ * @return {BSONRegExp} A MinKey instance
+ */
+function BSONRegExp(pattern, options) {
+  if (!(this instanceof BSONRegExp)) return new BSONRegExp();
+
+  // Execute
+  this._bsontype = 'BSONRegExp';
+  this.pattern = pattern || '';
+  this.options = options || '';
+
+  // Validate options
+  for (var i = 0; i < this.options.length; i++) {
+    if (
+      !(
+        this.options[i] === 'i' ||
+        this.options[i] === 'm' ||
+        this.options[i] === 'x' ||
+        this.options[i] === 'l' ||
+        this.options[i] === 's' ||
+        this.options[i] === 'u'
+      )
+    ) {
+      throw new Error('the regular expression options [' + this.options[i] + '] is not supported');
+    }
+  }
+}
+
+module.exports = BSONRegExp;
+module.exports.BSONRegExp = BSONRegExp;

+ 50 - 0
node_modules/bson/lib/bson/symbol.js

@@ -0,0 +1,50 @@
+// Custom inspect property name / symbol.
+var inspect = Buffer ? require('util').inspect.custom || 'inspect' : 'inspect';
+
+/**
+ * A class representation of the BSON Symbol type.
+ *
+ * @class
+ * @deprecated
+ * @param {string} value the string representing the symbol.
+ * @return {Symbol}
+ */
+function Symbol(value) {
+  if (!(this instanceof Symbol)) return new Symbol(value);
+  this._bsontype = 'Symbol';
+  this.value = value;
+}
+
+/**
+ * Access the wrapped string value.
+ *
+ * @method
+ * @return {String} returns the wrapped string.
+ */
+Symbol.prototype.valueOf = function() {
+  return this.value;
+};
+
+/**
+ * @ignore
+ */
+Symbol.prototype.toString = function() {
+  return this.value;
+};
+
+/**
+ * @ignore
+ */
+Symbol.prototype[inspect] = function() {
+  return this.value;
+};
+
+/**
+ * @ignore
+ */
+Symbol.prototype.toJSON = function() {
+  return this.value;
+};
+
+module.exports = Symbol;
+module.exports.Symbol = Symbol;

+ 854 - 0
node_modules/bson/lib/bson/timestamp.js

@@ -0,0 +1,854 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Copyright 2009 Google Inc. All Rights Reserved
+
+/**
+ * This type is for INTERNAL use in MongoDB only and should not be used in applications.
+ * The appropriate corresponding type is the JavaScript Date type.
+ * 
+ * Defines a Timestamp class for representing a 64-bit two's-complement
+ * integer value, which faithfully simulates the behavior of a Java "Timestamp". This
+ * implementation is derived from TimestampLib in GWT.
+ *
+ * Constructs a 64-bit two's-complement integer, given its low and high 32-bit
+ * values as *signed* integers.  See the from* functions below for more
+ * convenient ways of constructing Timestamps.
+ *
+ * The internal representation of a Timestamp is the two given signed, 32-bit values.
+ * We use 32-bit pieces because these are the size of integers on which
+ * Javascript performs bit-operations.  For operations like addition and
+ * multiplication, we split each number into 16-bit pieces, which can easily be
+ * multiplied within Javascript's floating-point representation without overflow
+ * or change in sign.
+ *
+ * In the algorithms below, we frequently reduce the negative case to the
+ * positive case by negating the input(s) and then post-processing the result.
+ * Note that we must ALWAYS check specially whether those values are MIN_VALUE
+ * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
+ * a positive number, it overflows back into a negative).  Not handling this
+ * case would often result in infinite recursion.
+ *
+ * @class
+ * @param {number} low  the low (signed) 32 bits of the Timestamp.
+ * @param {number} high the high (signed) 32 bits of the Timestamp.
+ */
+function Timestamp(low, high) {
+  if (!(this instanceof Timestamp)) return new Timestamp(low, high);
+  this._bsontype = 'Timestamp';
+  /**
+   * @type {number}
+   * @ignore
+   */
+  this.low_ = low | 0; // force into 32 signed bits.
+
+  /**
+   * @type {number}
+   * @ignore
+   */
+  this.high_ = high | 0; // force into 32 signed bits.
+}
+
+/**
+ * Return the int value.
+ *
+ * @return {number} the value, assuming it is a 32-bit integer.
+ */
+Timestamp.prototype.toInt = function() {
+  return this.low_;
+};
+
+/**
+ * Return the Number value.
+ *
+ * @method
+ * @return {number} the closest floating-point representation to this value.
+ */
+Timestamp.prototype.toNumber = function() {
+  return this.high_ * Timestamp.TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();
+};
+
+/**
+ * Return the JSON value.
+ *
+ * @method
+ * @return {string} the JSON representation.
+ */
+Timestamp.prototype.toJSON = function() {
+  return this.toString();
+};
+
+/**
+ * Return the String value.
+ *
+ * @method
+ * @param {number} [opt_radix] the radix in which the text should be written.
+ * @return {string} the textual representation of this value.
+ */
+Timestamp.prototype.toString = function(opt_radix) {
+  var radix = opt_radix || 10;
+  if (radix < 2 || 36 < radix) {
+    throw Error('radix out of range: ' + radix);
+  }
+
+  if (this.isZero()) {
+    return '0';
+  }
+
+  if (this.isNegative()) {
+    if (this.equals(Timestamp.MIN_VALUE)) {
+      // We need to change the Timestamp value before it can be negated, so we remove
+      // the bottom-most digit in this base and then recurse to do the rest.
+      var radixTimestamp = Timestamp.fromNumber(radix);
+      var div = this.div(radixTimestamp);
+      var rem = div.multiply(radixTimestamp).subtract(this);
+      return div.toString(radix) + rem.toInt().toString(radix);
+    } else {
+      return '-' + this.negate().toString(radix);
+    }
+  }
+
+  // Do several (6) digits each time through the loop, so as to
+  // minimize the calls to the very expensive emulated div.
+  var radixToPower = Timestamp.fromNumber(Math.pow(radix, 6));
+
+  rem = this;
+  var result = '';
+
+  while (!rem.isZero()) {
+    var remDiv = rem.div(radixToPower);
+    var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt();
+    var digits = intval.toString(radix);
+
+    rem = remDiv;
+    if (rem.isZero()) {
+      return digits + result;
+    } else {
+      while (digits.length < 6) {
+        digits = '0' + digits;
+      }
+      result = '' + digits + result;
+    }
+  }
+};
+
+/**
+ * Return the high 32-bits value.
+ *
+ * @method
+ * @return {number} the high 32-bits as a signed value.
+ */
+Timestamp.prototype.getHighBits = function() {
+  return this.high_;
+};
+
+/**
+ * Return the low 32-bits value.
+ *
+ * @method
+ * @return {number} the low 32-bits as a signed value.
+ */
+Timestamp.prototype.getLowBits = function() {
+  return this.low_;
+};
+
+/**
+ * Return the low unsigned 32-bits value.
+ *
+ * @method
+ * @return {number} the low 32-bits as an unsigned value.
+ */
+Timestamp.prototype.getLowBitsUnsigned = function() {
+  return this.low_ >= 0 ? this.low_ : Timestamp.TWO_PWR_32_DBL_ + this.low_;
+};
+
+/**
+ * Returns the number of bits needed to represent the absolute value of this Timestamp.
+ *
+ * @method
+ * @return {number} Returns the number of bits needed to represent the absolute value of this Timestamp.
+ */
+Timestamp.prototype.getNumBitsAbs = function() {
+  if (this.isNegative()) {
+    if (this.equals(Timestamp.MIN_VALUE)) {
+      return 64;
+    } else {
+      return this.negate().getNumBitsAbs();
+    }
+  } else {
+    var val = this.high_ !== 0 ? this.high_ : this.low_;
+    for (var bit = 31; bit > 0; bit--) {
+      if ((val & (1 << bit)) !== 0) {
+        break;
+      }
+    }
+    return this.high_ !== 0 ? bit + 33 : bit + 1;
+  }
+};
+
+/**
+ * Return whether this value is zero.
+ *
+ * @method
+ * @return {boolean} whether this value is zero.
+ */
+Timestamp.prototype.isZero = function() {
+  return this.high_ === 0 && this.low_ === 0;
+};
+
+/**
+ * Return whether this value is negative.
+ *
+ * @method
+ * @return {boolean} whether this value is negative.
+ */
+Timestamp.prototype.isNegative = function() {
+  return this.high_ < 0;
+};
+
+/**
+ * Return whether this value is odd.
+ *
+ * @method
+ * @return {boolean} whether this value is odd.
+ */
+Timestamp.prototype.isOdd = function() {
+  return (this.low_ & 1) === 1;
+};
+
+/**
+ * Return whether this Timestamp equals the other
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {boolean} whether this Timestamp equals the other
+ */
+Timestamp.prototype.equals = function(other) {
+  return this.high_ === other.high_ && this.low_ === other.low_;
+};
+
+/**
+ * Return whether this Timestamp does not equal the other.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {boolean} whether this Timestamp does not equal the other.
+ */
+Timestamp.prototype.notEquals = function(other) {
+  return this.high_ !== other.high_ || this.low_ !== other.low_;
+};
+
+/**
+ * Return whether this Timestamp is less than the other.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {boolean} whether this Timestamp is less than the other.
+ */
+Timestamp.prototype.lessThan = function(other) {
+  return this.compare(other) < 0;
+};
+
+/**
+ * Return whether this Timestamp is less than or equal to the other.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {boolean} whether this Timestamp is less than or equal to the other.
+ */
+Timestamp.prototype.lessThanOrEqual = function(other) {
+  return this.compare(other) <= 0;
+};
+
+/**
+ * Return whether this Timestamp is greater than the other.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {boolean} whether this Timestamp is greater than the other.
+ */
+Timestamp.prototype.greaterThan = function(other) {
+  return this.compare(other) > 0;
+};
+
+/**
+ * Return whether this Timestamp is greater than or equal to the other.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {boolean} whether this Timestamp is greater than or equal to the other.
+ */
+Timestamp.prototype.greaterThanOrEqual = function(other) {
+  return this.compare(other) >= 0;
+};
+
+/**
+ * Compares this Timestamp with the given one.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {boolean} 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater.
+ */
+Timestamp.prototype.compare = function(other) {
+  if (this.equals(other)) {
+    return 0;
+  }
+
+  var thisNeg = this.isNegative();
+  var otherNeg = other.isNegative();
+  if (thisNeg && !otherNeg) {
+    return -1;
+  }
+  if (!thisNeg && otherNeg) {
+    return 1;
+  }
+
+  // at this point, the signs are the same, so subtraction will not overflow
+  if (this.subtract(other).isNegative()) {
+    return -1;
+  } else {
+    return 1;
+  }
+};
+
+/**
+ * The negation of this value.
+ *
+ * @method
+ * @return {Timestamp} the negation of this value.
+ */
+Timestamp.prototype.negate = function() {
+  if (this.equals(Timestamp.MIN_VALUE)) {
+    return Timestamp.MIN_VALUE;
+  } else {
+    return this.not().add(Timestamp.ONE);
+  }
+};
+
+/**
+ * Returns the sum of this and the given Timestamp.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to add to this one.
+ * @return {Timestamp} the sum of this and the given Timestamp.
+ */
+Timestamp.prototype.add = function(other) {
+  // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
+
+  var a48 = this.high_ >>> 16;
+  var a32 = this.high_ & 0xffff;
+  var a16 = this.low_ >>> 16;
+  var a00 = this.low_ & 0xffff;
+
+  var b48 = other.high_ >>> 16;
+  var b32 = other.high_ & 0xffff;
+  var b16 = other.low_ >>> 16;
+  var b00 = other.low_ & 0xffff;
+
+  var c48 = 0,
+    c32 = 0,
+    c16 = 0,
+    c00 = 0;
+  c00 += a00 + b00;
+  c16 += c00 >>> 16;
+  c00 &= 0xffff;
+  c16 += a16 + b16;
+  c32 += c16 >>> 16;
+  c16 &= 0xffff;
+  c32 += a32 + b32;
+  c48 += c32 >>> 16;
+  c32 &= 0xffff;
+  c48 += a48 + b48;
+  c48 &= 0xffff;
+  return Timestamp.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
+};
+
+/**
+ * Returns the difference of this and the given Timestamp.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to subtract from this.
+ * @return {Timestamp} the difference of this and the given Timestamp.
+ */
+Timestamp.prototype.subtract = function(other) {
+  return this.add(other.negate());
+};
+
+/**
+ * Returns the product of this and the given Timestamp.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp to multiply with this.
+ * @return {Timestamp} the product of this and the other.
+ */
+Timestamp.prototype.multiply = function(other) {
+  if (this.isZero()) {
+    return Timestamp.ZERO;
+  } else if (other.isZero()) {
+    return Timestamp.ZERO;
+  }
+
+  if (this.equals(Timestamp.MIN_VALUE)) {
+    return other.isOdd() ? Timestamp.MIN_VALUE : Timestamp.ZERO;
+  } else if (other.equals(Timestamp.MIN_VALUE)) {
+    return this.isOdd() ? Timestamp.MIN_VALUE : Timestamp.ZERO;
+  }
+
+  if (this.isNegative()) {
+    if (other.isNegative()) {
+      return this.negate().multiply(other.negate());
+    } else {
+      return this.negate()
+        .multiply(other)
+        .negate();
+    }
+  } else if (other.isNegative()) {
+    return this.multiply(other.negate()).negate();
+  }
+
+  // If both Timestamps are small, use float multiplication
+  if (this.lessThan(Timestamp.TWO_PWR_24_) && other.lessThan(Timestamp.TWO_PWR_24_)) {
+    return Timestamp.fromNumber(this.toNumber() * other.toNumber());
+  }
+
+  // Divide each Timestamp into 4 chunks of 16 bits, and then add up 4x4 products.
+  // We can skip products that would overflow.
+
+  var a48 = this.high_ >>> 16;
+  var a32 = this.high_ & 0xffff;
+  var a16 = this.low_ >>> 16;
+  var a00 = this.low_ & 0xffff;
+
+  var b48 = other.high_ >>> 16;
+  var b32 = other.high_ & 0xffff;
+  var b16 = other.low_ >>> 16;
+  var b00 = other.low_ & 0xffff;
+
+  var c48 = 0,
+    c32 = 0,
+    c16 = 0,
+    c00 = 0;
+  c00 += a00 * b00;
+  c16 += c00 >>> 16;
+  c00 &= 0xffff;
+  c16 += a16 * b00;
+  c32 += c16 >>> 16;
+  c16 &= 0xffff;
+  c16 += a00 * b16;
+  c32 += c16 >>> 16;
+  c16 &= 0xffff;
+  c32 += a32 * b00;
+  c48 += c32 >>> 16;
+  c32 &= 0xffff;
+  c32 += a16 * b16;
+  c48 += c32 >>> 16;
+  c32 &= 0xffff;
+  c32 += a00 * b32;
+  c48 += c32 >>> 16;
+  c32 &= 0xffff;
+  c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
+  c48 &= 0xffff;
+  return Timestamp.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
+};
+
+/**
+ * Returns this Timestamp divided by the given one.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp by which to divide.
+ * @return {Timestamp} this Timestamp divided by the given one.
+ */
+Timestamp.prototype.div = function(other) {
+  if (other.isZero()) {
+    throw Error('division by zero');
+  } else if (this.isZero()) {
+    return Timestamp.ZERO;
+  }
+
+  if (this.equals(Timestamp.MIN_VALUE)) {
+    if (other.equals(Timestamp.ONE) || other.equals(Timestamp.NEG_ONE)) {
+      return Timestamp.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
+    } else if (other.equals(Timestamp.MIN_VALUE)) {
+      return Timestamp.ONE;
+    } else {
+      // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
+      var halfThis = this.shiftRight(1);
+      var approx = halfThis.div(other).shiftLeft(1);
+      if (approx.equals(Timestamp.ZERO)) {
+        return other.isNegative() ? Timestamp.ONE : Timestamp.NEG_ONE;
+      } else {
+        var rem = this.subtract(other.multiply(approx));
+        var result = approx.add(rem.div(other));
+        return result;
+      }
+    }
+  } else if (other.equals(Timestamp.MIN_VALUE)) {
+    return Timestamp.ZERO;
+  }
+
+  if (this.isNegative()) {
+    if (other.isNegative()) {
+      return this.negate().div(other.negate());
+    } else {
+      return this.negate()
+        .div(other)
+        .negate();
+    }
+  } else if (other.isNegative()) {
+    return this.div(other.negate()).negate();
+  }
+
+  // Repeat the following until the remainder is less than other:  find a
+  // floating-point that approximates remainder / other *from below*, add this
+  // into the result, and subtract it from the remainder.  It is critical that
+  // the approximate value is less than or equal to the real value so that the
+  // remainder never becomes negative.
+  var res = Timestamp.ZERO;
+  rem = this;
+  while (rem.greaterThanOrEqual(other)) {
+    // Approximate the result of division. This may be a little greater or
+    // smaller than the actual value.
+    approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber()));
+
+    // We will tweak the approximate result by changing it in the 48-th digit or
+    // the smallest non-fractional digit, whichever is larger.
+    var log2 = Math.ceil(Math.log(approx) / Math.LN2);
+    var delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48);
+
+    // Decrease the approximation until it is smaller than the remainder.  Note
+    // that if it is too large, the product overflows and is negative.
+    var approxRes = Timestamp.fromNumber(approx);
+    var approxRem = approxRes.multiply(other);
+    while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
+      approx -= delta;
+      approxRes = Timestamp.fromNumber(approx);
+      approxRem = approxRes.multiply(other);
+    }
+
+    // We know the answer can't be zero... and actually, zero would cause
+    // infinite recursion since we would make no progress.
+    if (approxRes.isZero()) {
+      approxRes = Timestamp.ONE;
+    }
+
+    res = res.add(approxRes);
+    rem = rem.subtract(approxRem);
+  }
+  return res;
+};
+
+/**
+ * Returns this Timestamp modulo the given one.
+ *
+ * @method
+ * @param {Timestamp} other Timestamp by which to mod.
+ * @return {Timestamp} this Timestamp modulo the given one.
+ */
+Timestamp.prototype.modulo = function(other) {
+  return this.subtract(this.div(other).multiply(other));
+};
+
+/**
+ * The bitwise-NOT of this value.
+ *
+ * @method
+ * @return {Timestamp} the bitwise-NOT of this value.
+ */
+Timestamp.prototype.not = function() {
+  return Timestamp.fromBits(~this.low_, ~this.high_);
+};
+
+/**
+ * Returns the bitwise-AND of this Timestamp and the given one.
+ *
+ * @method
+ * @param {Timestamp} other the Timestamp with which to AND.
+ * @return {Timestamp} the bitwise-AND of this and the other.
+ */
+Timestamp.prototype.and = function(other) {
+  return Timestamp.fromBits(this.low_ & other.low_, this.high_ & other.high_);
+};
+
+/**
+ * Returns the bitwise-OR of this Timestamp and the given one.
+ *
+ * @method
+ * @param {Timestamp} other the Timestamp with which to OR.
+ * @return {Timestamp} the bitwise-OR of this and the other.
+ */
+Timestamp.prototype.or = function(other) {
+  return Timestamp.fromBits(this.low_ | other.low_, this.high_ | other.high_);
+};
+
+/**
+ * Returns the bitwise-XOR of this Timestamp and the given one.
+ *
+ * @method
+ * @param {Timestamp} other the Timestamp with which to XOR.
+ * @return {Timestamp} the bitwise-XOR of this and the other.
+ */
+Timestamp.prototype.xor = function(other) {
+  return Timestamp.fromBits(this.low_ ^ other.low_, this.high_ ^ other.high_);
+};
+
+/**
+ * Returns this Timestamp with bits shifted to the left by the given amount.
+ *
+ * @method
+ * @param {number} numBits the number of bits by which to shift.
+ * @return {Timestamp} this shifted to the left by the given amount.
+ */
+Timestamp.prototype.shiftLeft = function(numBits) {
+  numBits &= 63;
+  if (numBits === 0) {
+    return this;
+  } else {
+    var low = this.low_;
+    if (numBits < 32) {
+      var high = this.high_;
+      return Timestamp.fromBits(low << numBits, (high << numBits) | (low >>> (32 - numBits)));
+    } else {
+      return Timestamp.fromBits(0, low << (numBits - 32));
+    }
+  }
+};
+
+/**
+ * Returns this Timestamp with bits shifted to the right by the given amount.
+ *
+ * @method
+ * @param {number} numBits the number of bits by which to shift.
+ * @return {Timestamp} this shifted to the right by the given amount.
+ */
+Timestamp.prototype.shiftRight = function(numBits) {
+  numBits &= 63;
+  if (numBits === 0) {
+    return this;
+  } else {
+    var high = this.high_;
+    if (numBits < 32) {
+      var low = this.low_;
+      return Timestamp.fromBits((low >>> numBits) | (high << (32 - numBits)), high >> numBits);
+    } else {
+      return Timestamp.fromBits(high >> (numBits - 32), high >= 0 ? 0 : -1);
+    }
+  }
+};
+
+/**
+ * Returns this Timestamp with bits shifted to the right by the given amount, with the new top bits matching the current sign bit.
+ *
+ * @method
+ * @param {number} numBits the number of bits by which to shift.
+ * @return {Timestamp} this shifted to the right by the given amount, with zeros placed into the new leading bits.
+ */
+Timestamp.prototype.shiftRightUnsigned = function(numBits) {
+  numBits &= 63;
+  if (numBits === 0) {
+    return this;
+  } else {
+    var high = this.high_;
+    if (numBits < 32) {
+      var low = this.low_;
+      return Timestamp.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits);
+    } else if (numBits === 32) {
+      return Timestamp.fromBits(high, 0);
+    } else {
+      return Timestamp.fromBits(high >>> (numBits - 32), 0);
+    }
+  }
+};
+
+/**
+ * Returns a Timestamp representing the given (32-bit) integer value.
+ *
+ * @method
+ * @param {number} value the 32-bit integer in question.
+ * @return {Timestamp} the corresponding Timestamp value.
+ */
+Timestamp.fromInt = function(value) {
+  if (-128 <= value && value < 128) {
+    var cachedObj = Timestamp.INT_CACHE_[value];
+    if (cachedObj) {
+      return cachedObj;
+    }
+  }
+
+  var obj = new Timestamp(value | 0, value < 0 ? -1 : 0);
+  if (-128 <= value && value < 128) {
+    Timestamp.INT_CACHE_[value] = obj;
+  }
+  return obj;
+};
+
+/**
+ * Returns a Timestamp representing the given value, provided that it is a finite number. Otherwise, zero is returned.
+ *
+ * @method
+ * @param {number} value the number in question.
+ * @return {Timestamp} the corresponding Timestamp value.
+ */
+Timestamp.fromNumber = function(value) {
+  if (isNaN(value) || !isFinite(value)) {
+    return Timestamp.ZERO;
+  } else if (value <= -Timestamp.TWO_PWR_63_DBL_) {
+    return Timestamp.MIN_VALUE;
+  } else if (value + 1 >= Timestamp.TWO_PWR_63_DBL_) {
+    return Timestamp.MAX_VALUE;
+  } else if (value < 0) {
+    return Timestamp.fromNumber(-value).negate();
+  } else {
+    return new Timestamp(
+      (value % Timestamp.TWO_PWR_32_DBL_) | 0,
+      (value / Timestamp.TWO_PWR_32_DBL_) | 0
+    );
+  }
+};
+
+/**
+ * Returns a Timestamp representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits.
+ *
+ * @method
+ * @param {number} lowBits the low 32-bits.
+ * @param {number} highBits the high 32-bits.
+ * @return {Timestamp} the corresponding Timestamp value.
+ */
+Timestamp.fromBits = function(lowBits, highBits) {
+  return new Timestamp(lowBits, highBits);
+};
+
+/**
+ * Returns a Timestamp representation of the given string, written using the given radix.
+ *
+ * @method
+ * @param {string} str the textual representation of the Timestamp.
+ * @param {number} opt_radix the radix in which the text is written.
+ * @return {Timestamp} the corresponding Timestamp value.
+ */
+Timestamp.fromString = function(str, opt_radix) {
+  if (str.length === 0) {
+    throw Error('number format error: empty string');
+  }
+
+  var radix = opt_radix || 10;
+  if (radix < 2 || 36 < radix) {
+    throw Error('radix out of range: ' + radix);
+  }
+
+  if (str.charAt(0) === '-') {
+    return Timestamp.fromString(str.substring(1), radix).negate();
+  } else if (str.indexOf('-') >= 0) {
+    throw Error('number format error: interior "-" character: ' + str);
+  }
+
+  // Do several (8) digits each time through the loop, so as to
+  // minimize the calls to the very expensive emulated div.
+  var radixToPower = Timestamp.fromNumber(Math.pow(radix, 8));
+
+  var result = Timestamp.ZERO;
+  for (var i = 0; i < str.length; i += 8) {
+    var size = Math.min(8, str.length - i);
+    var value = parseInt(str.substring(i, i + size), radix);
+    if (size < 8) {
+      var power = Timestamp.fromNumber(Math.pow(radix, size));
+      result = result.multiply(power).add(Timestamp.fromNumber(value));
+    } else {
+      result = result.multiply(radixToPower);
+      result = result.add(Timestamp.fromNumber(value));
+    }
+  }
+  return result;
+};
+
+// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the
+// from* methods on which they depend.
+
+/**
+ * A cache of the Timestamp representations of small integer values.
+ * @type {Object}
+ * @ignore
+ */
+Timestamp.INT_CACHE_ = {};
+
+// NOTE: the compiler should inline these constant values below and then remove
+// these variables, so there should be no runtime penalty for these.
+
+/**
+ * Number used repeated below in calculations.  This must appear before the
+ * first call to any from* function below.
+ * @type {number}
+ * @ignore
+ */
+Timestamp.TWO_PWR_16_DBL_ = 1 << 16;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Timestamp.TWO_PWR_24_DBL_ = 1 << 24;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Timestamp.TWO_PWR_32_DBL_ = Timestamp.TWO_PWR_16_DBL_ * Timestamp.TWO_PWR_16_DBL_;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Timestamp.TWO_PWR_31_DBL_ = Timestamp.TWO_PWR_32_DBL_ / 2;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Timestamp.TWO_PWR_48_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_16_DBL_;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Timestamp.TWO_PWR_64_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_32_DBL_;
+
+/**
+ * @type {number}
+ * @ignore
+ */
+Timestamp.TWO_PWR_63_DBL_ = Timestamp.TWO_PWR_64_DBL_ / 2;
+
+/** @type {Timestamp} */
+Timestamp.ZERO = Timestamp.fromInt(0);
+
+/** @type {Timestamp} */
+Timestamp.ONE = Timestamp.fromInt(1);
+
+/** @type {Timestamp} */
+Timestamp.NEG_ONE = Timestamp.fromInt(-1);
+
+/** @type {Timestamp} */
+Timestamp.MAX_VALUE = Timestamp.fromBits(0xffffffff | 0, 0x7fffffff | 0);
+
+/** @type {Timestamp} */
+Timestamp.MIN_VALUE = Timestamp.fromBits(0, 0x80000000 | 0);
+
+/**
+ * @type {Timestamp}
+ * @ignore
+ */
+Timestamp.TWO_PWR_24_ = Timestamp.fromInt(1 << 24);
+
+/**
+ * Expose.
+ */
+module.exports = Timestamp;
+module.exports.Timestamp = Timestamp;

+ 58 - 0
node_modules/bson/package.json

@@ -0,0 +1,58 @@
+{
+  "name": "bson",
+  "description": "A bson parser for node.js and the browser",
+  "keywords": [
+    "mongodb",
+    "bson",
+    "parser"
+  ],
+  "files": [
+    "lib",
+    "index.js",
+    "browser_build",
+    "bower.json"
+  ],
+  "version": "1.1.6",
+  "author": "Christian Amor Kvalheim <christkv@gmail.com>",
+  "contributors": [],
+  "repository": "mongodb/js-bson",
+  "bugs": {
+    "mail": "node-mongodb-native@googlegroups.com",
+    "url": "https://github.com/mongodb/js-bson/issues"
+  },
+  "devDependencies": {
+    "benchmark": "1.0.0",
+    "colors": "1.1.0",
+    "nodeunit": "0.9.0",
+    "babel-core": "^6.14.0",
+    "babel-loader": "^6.2.5",
+    "babel-polyfill": "^6.13.0",
+    "babel-preset-es2015": "^6.14.0",
+    "babel-preset-stage-0": "^6.5.0",
+    "babel-register": "^6.14.0",
+    "conventional-changelog-cli": "^1.3.5",
+    "standard-version": "^9.1.1",
+    "webpack": "^1.13.2",
+    "webpack-polyfills-plugin": "0.0.9"
+  },
+  "config": {
+    "native": false
+  },
+  "main": "./index",
+  "directories": {
+    "lib": "./lib/bson"
+  },
+  "engines": {
+    "node": ">=0.6.19"
+  },
+  "scripts": {
+    "test": "nodeunit ./test/node",
+    "build": "webpack --config ./webpack.dist.config.js",
+    "changelog": "conventional-changelog -p angular -i HISTORY.md -s",
+    "lint": "eslint lib test",
+    "format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'",
+    "release": "standard-version -i HISTORY.md"
+  },
+  "browser": "lib/bson/bson.js",
+  "license": "Apache-2.0"
+}

+ 2 - 0
node_modules/buffer-equal-constant-time/.npmignore

@@ -0,0 +1,2 @@
+.*.sw[mnop]
+node_modules/

+ 4 - 0
node_modules/buffer-equal-constant-time/.travis.yml

@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+- "0.11"
+- "0.10"

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
node_modules/buffer-equal-constant-time/LICENSE.txt


+ 50 - 0
node_modules/buffer-equal-constant-time/README.md

@@ -0,0 +1,50 @@
+# buffer-equal-constant-time
+
+Constant-time `Buffer` comparison for node.js.  Should work with browserify too.
+
+[![Build Status](https://travis-ci.org/goinstant/buffer-equal-constant-time.png?branch=master)](https://travis-ci.org/goinstant/buffer-equal-constant-time)
+
+```sh
+  npm install buffer-equal-constant-time
+```
+
+# Usage
+
+```js
+  var bufferEq = require('buffer-equal-constant-time');
+
+  var a = new Buffer('asdf');
+  var b = new Buffer('asdf');
+  if (bufferEq(a,b)) {
+    // the same!
+  } else {
+    // different in at least one byte!
+  }
+```
+
+If you'd like to install an `.equal()` method onto the node.js `Buffer` and
+`SlowBuffer` prototypes:
+
+```js
+  require('buffer-equal-constant-time').install();
+
+  var a = new Buffer('asdf');
+  var b = new Buffer('asdf');
+  if (a.equal(b)) {
+    // the same!
+  } else {
+    // different in at least one byte!
+  }
+```
+
+To get rid of the installed `.equal()` method, call `.restore()`:
+
+```js
+  require('buffer-equal-constant-time').restore();
+```
+
+# Legal
+
+&copy; 2013 GoInstant Inc., a salesforce.com company
+
+Licensed under the BSD 3-clause license.

+ 41 - 0
node_modules/buffer-equal-constant-time/index.js

@@ -0,0 +1,41 @@
+/*jshint node:true */
+'use strict';
+var Buffer = require('buffer').Buffer; // browserify
+var SlowBuffer = require('buffer').SlowBuffer;
+
+module.exports = bufferEq;
+
+function bufferEq(a, b) {
+
+  // shortcutting on type is necessary for correctness
+  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
+    return false;
+  }
+
+  // buffer sizes should be well-known information, so despite this
+  // shortcutting, it doesn't leak any information about the *contents* of the
+  // buffers.
+  if (a.length !== b.length) {
+    return false;
+  }
+
+  var c = 0;
+  for (var i = 0; i < a.length; i++) {
+    /*jshint bitwise:false */
+    c |= a[i] ^ b[i]; // XOR
+  }
+  return c === 0;
+}
+
+bufferEq.install = function() {
+  Buffer.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
+    return bufferEq(this, that);
+  };
+};
+
+var origBufEqual = Buffer.prototype.equal;
+var origSlowBufEqual = SlowBuffer.prototype.equal;
+bufferEq.restore = function() {
+  Buffer.prototype.equal = origBufEqual;
+  SlowBuffer.prototype.equal = origSlowBufEqual;
+};

+ 21 - 0
node_modules/buffer-equal-constant-time/package.json

@@ -0,0 +1,21 @@
+{
+  "name": "buffer-equal-constant-time",
+  "version": "1.0.1",
+  "description": "Constant-time comparison of Buffers",
+  "main": "index.js",
+  "scripts": {
+    "test": "mocha test.js"
+  },
+  "repository": "git@github.com:goinstant/buffer-equal-constant-time.git",
+  "keywords": [
+    "buffer",
+    "equal",
+    "constant-time",
+    "crypto"
+  ],
+  "author": "GoInstant Inc., a salesforce.com company",
+  "license": "BSD-3-Clause",
+  "devDependencies": {
+    "mocha": "~1.15.1"
+  }
+}

+ 42 - 0
node_modules/buffer-equal-constant-time/test.js

@@ -0,0 +1,42 @@
+/*jshint node:true */
+'use strict';
+
+var bufferEq = require('./index');
+var assert = require('assert');
+
+describe('buffer-equal-constant-time', function() {
+  var a = new Buffer('asdfasdf123456');
+  var b = new Buffer('asdfasdf123456');
+  var c = new Buffer('asdfasdf');
+
+  describe('bufferEq', function() {
+    it('says a == b', function() {
+      assert.strictEqual(bufferEq(a, b), true);
+    });
+
+    it('says a != c', function() {
+      assert.strictEqual(bufferEq(a, c), false);
+    });
+  });
+
+  describe('install/restore', function() {
+    before(function() {
+      bufferEq.install();
+    });
+    after(function() {
+      bufferEq.restore();
+    });
+
+    it('installed an .equal method', function() {
+      var SlowBuffer = require('buffer').SlowBuffer;
+      assert.ok(Buffer.prototype.equal);
+      assert.ok(SlowBuffer.prototype.equal);
+    });
+
+    it('infected existing Buffers', function() {
+      assert.strictEqual(a.equal(b), true);
+      assert.strictEqual(a.equal(c), false);
+    });
+  });
+
+});

+ 21 - 0
node_modules/buffer-from/LICENSE

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2016, 2018 Linus Unnebäck
+
+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.

+ 72 - 0
node_modules/buffer-from/index.js

@@ -0,0 +1,72 @@
+/* eslint-disable node/no-deprecated-api */
+
+var toString = Object.prototype.toString
+
+var isModern = (
+  typeof Buffer !== 'undefined' &&
+  typeof Buffer.alloc === 'function' &&
+  typeof Buffer.allocUnsafe === 'function' &&
+  typeof Buffer.from === 'function'
+)
+
+function isArrayBuffer (input) {
+  return toString.call(input).slice(8, -1) === 'ArrayBuffer'
+}
+
+function fromArrayBuffer (obj, byteOffset, length) {
+  byteOffset >>>= 0
+
+  var maxLength = obj.byteLength - byteOffset
+
+  if (maxLength < 0) {
+    throw new RangeError("'offset' is out of bounds")
+  }
+
+  if (length === undefined) {
+    length = maxLength
+  } else {
+    length >>>= 0
+
+    if (length > maxLength) {
+      throw new RangeError("'length' is out of bounds")
+    }
+  }
+
+  return isModern
+    ? Buffer.from(obj.slice(byteOffset, byteOffset + length))
+    : new Buffer(new Uint8Array(obj.slice(byteOffset, byteOffset + length)))
+}
+
+function fromString (string, encoding) {
+  if (typeof encoding !== 'string' || encoding === '') {
+    encoding = 'utf8'
+  }
+
+  if (!Buffer.isEncoding(encoding)) {
+    throw new TypeError('"encoding" must be a valid string encoding')
+  }
+
+  return isModern
+    ? Buffer.from(string, encoding)
+    : new Buffer(string, encoding)
+}
+
+function bufferFrom (value, encodingOrOffset, length) {
+  if (typeof value === 'number') {
+    throw new TypeError('"value" argument must not be a number')
+  }
+
+  if (isArrayBuffer(value)) {
+    return fromArrayBuffer(value, encodingOrOffset, length)
+  }
+
+  if (typeof value === 'string') {
+    return fromString(value, encodingOrOffset)
+  }
+
+  return isModern
+    ? Buffer.from(value)
+    : new Buffer(value)
+}
+
+module.exports = bufferFrom

+ 19 - 0
node_modules/buffer-from/package.json

@@ -0,0 +1,19 @@
+{
+  "name": "buffer-from",
+  "version": "1.1.2",
+  "license": "MIT",
+  "repository": "LinusU/buffer-from",
+  "files": [
+    "index.js"
+  ],
+  "scripts": {
+    "test": "standard && node test"
+  },
+  "devDependencies": {
+    "standard": "^12.0.1"
+  },
+  "keywords": [
+    "buffer",
+    "buffer from"
+  ]
+}

+ 69 - 0
node_modules/buffer-from/readme.md

@@ -0,0 +1,69 @@
+# Buffer From
+
+A [ponyfill](https://ponyfill.com) for `Buffer.from`, uses native implementation if available.
+
+## Installation
+
+```sh
+npm install --save buffer-from
+```
+
+## Usage
+
+```js
+const bufferFrom = require('buffer-from')
+
+console.log(bufferFrom([1, 2, 3, 4]))
+//=> <Buffer 01 02 03 04>
+
+const arr = new Uint8Array([1, 2, 3, 4])
+console.log(bufferFrom(arr.buffer, 1, 2))
+//=> <Buffer 02 03>
+
+console.log(bufferFrom('test', 'utf8'))
+//=> <Buffer 74 65 73 74>
+
+const buf = bufferFrom('test')
+console.log(bufferFrom(buf))
+//=> <Buffer 74 65 73 74>
+```
+
+## API
+
+### bufferFrom(array)
+
+- `array` &lt;Array&gt;
+
+Allocates a new `Buffer` using an `array` of octets.
+
+### bufferFrom(arrayBuffer[, byteOffset[, length]])
+
+- `arrayBuffer` &lt;ArrayBuffer&gt; The `.buffer` property of a TypedArray or ArrayBuffer
+- `byteOffset` &lt;Integer&gt; Where to start copying from `arrayBuffer`. **Default:** `0`
+- `length` &lt;Integer&gt; How many bytes to copy from `arrayBuffer`. **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.
+
+The optional `byteOffset` and `length` arguments specify a memory range within
+the `arrayBuffer` that will be shared by the `Buffer`.
+
+### bufferFrom(buffer)
+
+- `buffer` &lt;Buffer&gt; An existing `Buffer` to copy data from
+
+Copies the passed `buffer` data onto a new `Buffer` instance.
+
+### bufferFrom(string[, encoding])
+
+- `string` &lt;String&gt; A string to encode.
+- `encoding` &lt;String&gt; The encoding of `string`. **Default:** `'utf8'`
+
+Creates a new `Buffer` containing the given JavaScript string `string`. If
+provided, the `encoding` parameter identifies the character encoding of
+`string`.
+
+## See also
+
+- [buffer-alloc](https://github.com/LinusU/buffer-alloc) A ponyfill for `Buffer.alloc`
+- [buffer-alloc-unsafe](https://github.com/LinusU/buffer-alloc-unsafe) A ponyfill for `Buffer.allocUnsafe`

+ 17 - 0
node_modules/busboy/.travis.yml

@@ -0,0 +1,17 @@
+sudo: false
+language: cpp
+notifications:
+  email: false
+env:
+  matrix:
+  - TRAVIS_NODE_VERSION="0.10"
+  - TRAVIS_NODE_VERSION="0.12"
+  - TRAVIS_NODE_VERSION="4"
+  - TRAVIS_NODE_VERSION="6"
+  - TRAVIS_NODE_VERSION="7"
+install:
+  - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
+  - node --version
+  - npm --version
+  - npm install
+script: npm test

+ 19 - 0
node_modules/busboy/LICENSE

@@ -0,0 +1,19 @@
+Copyright Brian White. 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.

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 225 - 0
node_modules/busboy/README.md


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 73 - 0
node_modules/busboy/deps/encoding/encoding-indexes.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 2391 - 0
node_modules/busboy/deps/encoding/encoding.js


+ 89 - 0
node_modules/busboy/lib/main.js

@@ -0,0 +1,89 @@
+var fs = require('fs'),
+    WritableStream = require('stream').Writable
+                     || require('readable-stream').Writable,
+    inherits = require('util').inherits;
+
+var parseParams = require('./utils').parseParams;
+
+function Busboy(opts) {
+  if (!(this instanceof Busboy))
+    return new Busboy(opts);
+  if (opts.highWaterMark !== undefined)
+    WritableStream.call(this, { highWaterMark: opts.highWaterMark });
+  else
+    WritableStream.call(this);
+
+  this._done = false;
+  this._parser = undefined;
+  this._finished = false;
+
+  this.opts = opts;
+  if (opts.headers && typeof opts.headers['content-type'] === 'string')
+    this.parseHeaders(opts.headers);
+  else
+    throw new Error('Missing Content-Type');
+}
+inherits(Busboy, WritableStream);
+
+Busboy.prototype.emit = function(ev) {
+  if (ev === 'finish') {
+    if (!this._done) {
+      this._parser && this._parser.end();
+      return;
+    } else if (this._finished) {
+      return;
+    }
+    this._finished = true;
+  }
+  WritableStream.prototype.emit.apply(this, arguments);
+};
+
+Busboy.prototype.parseHeaders = function(headers) {
+  this._parser = undefined;
+  if (headers['content-type']) {
+    var parsed = parseParams(headers['content-type']),
+        matched, type;
+    for (var i = 0; i < TYPES.length; ++i) {
+      type = TYPES[i];
+      if (typeof type.detect === 'function')
+        matched = type.detect(parsed);
+      else
+        matched = type.detect.test(parsed[0]);
+      if (matched)
+        break;
+    }
+    if (matched) {
+      var cfg = {
+        limits: this.opts.limits,
+        headers: headers,
+        parsedConType: parsed,
+        highWaterMark: undefined,
+        fileHwm: undefined,
+        defCharset: undefined,
+        preservePath: false
+      };
+      if (this.opts.highWaterMark)
+        cfg.highWaterMark = this.opts.highWaterMark;
+      if (this.opts.fileHwm)
+        cfg.fileHwm = this.opts.fileHwm;
+      cfg.defCharset = this.opts.defCharset;
+      cfg.preservePath = this.opts.preservePath;
+      this._parser = type(this, cfg);
+      return;
+    }
+  }
+  throw new Error('Unsupported content type: ' + headers['content-type']);
+};
+
+Busboy.prototype._write = function(chunk, encoding, cb) {
+  if (!this._parser)
+    return cb(new Error('Not ready to parse. Missing Content-Type?'));
+  this._parser.write(chunk, cb);
+};
+
+var TYPES = [
+  require('./types/multipart'),
+  require('./types/urlencoded'),
+];
+
+module.exports = Busboy;

+ 324 - 0
node_modules/busboy/lib/types/multipart.js

@@ -0,0 +1,324 @@
+// TODO:
+//  * support 1 nested multipart level
+//    (see second multipart example here:
+//     http://www.w3.org/TR/html401/interact/forms.html#didx-multipartform-data)
+//  * support limits.fieldNameSize
+//     -- this will require modifications to utils.parseParams
+
+var ReadableStream = require('stream').Readable || require('readable-stream'),
+    inherits = require('util').inherits;
+
+var Dicer = require('dicer');
+
+var parseParams = require('../utils').parseParams,
+    decodeText = require('../utils').decodeText,
+    basename = require('../utils').basename;
+
+var RE_BOUNDARY = /^boundary$/i,
+    RE_FIELD = /^form-data$/i,
+    RE_CHARSET = /^charset$/i,
+    RE_FILENAME = /^filename$/i,
+    RE_NAME = /^name$/i;
+
+Multipart.detect = /^multipart\/form-data/i;
+function Multipart(boy, cfg) {
+  if (!(this instanceof Multipart))
+    return new Multipart(boy, cfg);
+  var i,
+      len,
+      self = this,
+      boundary,
+      limits = cfg.limits,
+      parsedConType = cfg.parsedConType || [],
+      defCharset = cfg.defCharset || 'utf8',
+      preservePath = cfg.preservePath,
+      fileopts = (typeof cfg.fileHwm === 'number'
+                  ? { highWaterMark: cfg.fileHwm }
+                  : {});
+
+  for (i = 0, len = parsedConType.length; i < len; ++i) {
+    if (Array.isArray(parsedConType[i])
+        && RE_BOUNDARY.test(parsedConType[i][0])) {
+      boundary = parsedConType[i][1];
+      break;
+    }
+  }
+
+  function checkFinished() {
+    if (nends === 0 && finished && !boy._done) {
+      finished = false;
+      process.nextTick(function() {
+        boy._done = true;
+        boy.emit('finish');
+      });
+    }
+  }
+
+  if (typeof boundary !== 'string')
+    throw new Error('Multipart: Boundary not found');
+
+  var fieldSizeLimit = (limits && typeof limits.fieldSize === 'number'
+                        ? limits.fieldSize
+                        : 1 * 1024 * 1024),
+      fileSizeLimit = (limits && typeof limits.fileSize === 'number'
+                       ? limits.fileSize
+                       : Infinity),
+      filesLimit = (limits && typeof limits.files === 'number'
+                    ? limits.files
+                    : Infinity),
+      fieldsLimit = (limits && typeof limits.fields === 'number'
+                     ? limits.fields
+                     : Infinity),
+      partsLimit = (limits && typeof limits.parts === 'number'
+                    ? limits.parts
+                    : Infinity);
+
+  var nfiles = 0,
+      nfields = 0,
+      nends = 0,
+      curFile,
+      curField,
+      finished = false;
+
+  this._needDrain = false;
+  this._pause = false;
+  this._cb = undefined;
+  this._nparts = 0;
+  this._boy = boy;
+
+  var parserCfg = {
+    boundary: boundary,
+    maxHeaderPairs: (limits && limits.headerPairs)
+  };
+  if (fileopts.highWaterMark)
+    parserCfg.partHwm = fileopts.highWaterMark;
+  if (cfg.highWaterMark)
+    parserCfg.highWaterMark = cfg.highWaterMark;
+
+  this.parser = new Dicer(parserCfg);
+  this.parser.on('drain', function() {
+    self._needDrain = false;
+    if (self._cb && !self._pause) {
+      var cb = self._cb;
+      self._cb = undefined;
+      cb();
+    }
+  }).on('part', function onPart(part) {
+    if (++self._nparts > partsLimit) {
+      self.parser.removeListener('part', onPart);
+      self.parser.on('part', skipPart);
+      boy.hitPartsLimit = true;
+      boy.emit('partsLimit');
+      return skipPart(part);
+    }
+
+    // hack because streams2 _always_ doesn't emit 'end' until nextTick, so let
+    // us emit 'end' early since we know the part has ended if we are already
+    // seeing the next part
+    if (curField) {
+      var field = curField;
+      field.emit('end');
+      field.removeAllListeners('end');
+    }
+
+    part.on('header', function(header) {
+      var contype,
+          fieldname,
+          parsed,
+          charset,
+          encoding,
+          filename,
+          nsize = 0;
+
+      if (header['content-type']) {
+        parsed = parseParams(header['content-type'][0]);
+        if (parsed[0]) {
+          contype = parsed[0].toLowerCase();
+          for (i = 0, len = parsed.length; i < len; ++i) {
+            if (RE_CHARSET.test(parsed[i][0])) {
+              charset = parsed[i][1].toLowerCase();
+              break;
+            }
+          }
+        }
+      }
+
+      if (contype === undefined)
+        contype = 'text/plain';
+      if (charset === undefined)
+        charset = defCharset;
+
+      if (header['content-disposition']) {
+        parsed = parseParams(header['content-disposition'][0]);
+        if (!RE_FIELD.test(parsed[0]))
+          return skipPart(part);
+        for (i = 0, len = parsed.length; i < len; ++i) {
+          if (RE_NAME.test(parsed[i][0])) {
+            fieldname = decodeText(parsed[i][1], 'binary', 'utf8');
+          } else if (RE_FILENAME.test(parsed[i][0])) {
+            filename = decodeText(parsed[i][1], 'binary', 'utf8');
+            if (!preservePath)
+              filename = basename(filename);
+          }
+        }
+      } else
+        return skipPart(part);
+
+      if (header['content-transfer-encoding'])
+        encoding = header['content-transfer-encoding'][0].toLowerCase();
+      else
+        encoding = '7bit';
+
+      var onData,
+          onEnd;
+      if (contype === 'application/octet-stream' || filename !== undefined) {
+        // file/binary field
+        if (nfiles === filesLimit) {
+          if (!boy.hitFilesLimit) {
+            boy.hitFilesLimit = true;
+            boy.emit('filesLimit');
+          }
+          return skipPart(part);
+        }
+
+        ++nfiles;
+
+        if (!boy._events.file) {
+          self.parser._ignore();
+          return;
+        }
+
+        ++nends;
+        var file = new FileStream(fileopts);
+        curFile = file;
+        file.on('end', function() {
+          --nends;
+          checkFinished();
+          if (self._cb && !self._needDrain) {
+            var cb = self._cb;
+            self._cb = undefined;
+            cb();
+          }
+        });
+        file._read = function(n) {
+          if (!self._pause)
+            return;
+          self._pause = false;
+          if (self._cb && !self._needDrain) {
+            var cb = self._cb;
+            self._cb = undefined;
+            cb();
+          }
+        };
+        boy.emit('file', fieldname, file, filename, encoding, contype);
+
+        onData = function(data) {
+          if ((nsize += data.length) > fileSizeLimit) {
+            var extralen = (fileSizeLimit - (nsize - data.length));
+            if (extralen > 0)
+              file.push(data.slice(0, extralen));
+            file.emit('limit');
+            file.truncated = true;
+            part.removeAllListeners('data');
+          } else if (!file.push(data))
+            self._pause = true;
+        };
+
+        onEnd = function() {
+          curFile = undefined;
+          file.push(null);
+        };
+      } else {
+        // non-file field
+        if (nfields === fieldsLimit) {
+          if (!boy.hitFieldsLimit) {
+            boy.hitFieldsLimit = true;
+            boy.emit('fieldsLimit');
+          }
+          return skipPart(part);
+        }
+
+        ++nfields;
+        ++nends;
+        var buffer = '',
+            truncated = false;
+        curField = part;
+
+        onData = function(data) {
+          if ((nsize += data.length) > fieldSizeLimit) {
+            var extralen = (fieldSizeLimit - (nsize - data.length));
+            buffer += data.toString('binary', 0, extralen);
+            truncated = true;
+            part.removeAllListeners('data');
+          } else
+            buffer += data.toString('binary');
+        };
+
+        onEnd = function() {
+          curField = undefined;
+          if (buffer.length)
+            buffer = decodeText(buffer, 'binary', charset);
+          boy.emit('field', fieldname, buffer, false, truncated, encoding, contype);
+          --nends;
+          checkFinished();
+        };
+      }
+
+      /* As of node@2efe4ab761666 (v0.10.29+/v0.11.14+), busboy had become
+         broken. Streams2/streams3 is a huge black box of confusion, but
+         somehow overriding the sync state seems to fix things again (and still
+         seems to work for previous node versions).
+      */
+      part._readableState.sync = false;
+
+      part.on('data', onData);
+      part.on('end', onEnd);
+    }).on('error', function(err) {
+      if (curFile)
+        curFile.emit('error', err);
+    });
+  }).on('error', function(err) {
+    boy.emit('error', err);
+  }).on('finish', function() {
+    finished = true;
+    checkFinished();
+  });
+}
+
+Multipart.prototype.write = function(chunk, cb) {
+  var r;
+  if ((r = this.parser.write(chunk)) && !this._pause)
+    cb();
+  else {
+    this._needDrain = !r;
+    this._cb = cb;
+  }
+};
+
+Multipart.prototype.end = function() {
+  var self = this;
+  if (this._nparts === 0 && !self._boy._done) {
+    process.nextTick(function() {
+      self._boy._done = true;
+      self._boy.emit('finish');
+    });
+  } else if (this.parser.writable)
+    this.parser.end();
+};
+
+function skipPart(part) {
+  part.resume();
+}
+
+function FileStream(opts) {
+  if (!(this instanceof FileStream))
+    return new FileStream(opts);
+  ReadableStream.call(this, opts);
+
+  this.truncated = false;
+}
+inherits(FileStream, ReadableStream);
+
+FileStream.prototype._read = function(n) {};
+
+module.exports = Multipart;

+ 214 - 0
node_modules/busboy/lib/types/urlencoded.js

@@ -0,0 +1,214 @@
+var Decoder = require('../utils').Decoder,
+    decodeText = require('../utils').decodeText;
+
+var RE_CHARSET = /^charset$/i;
+
+UrlEncoded.detect = /^application\/x-www-form-urlencoded/i;
+function UrlEncoded(boy, cfg) {
+  if (!(this instanceof UrlEncoded))
+    return new UrlEncoded(boy, cfg);
+  var limits = cfg.limits,
+      headers = cfg.headers,
+      parsedConType = cfg.parsedConType;
+  this.boy = boy;
+
+  this.fieldSizeLimit = (limits && typeof limits.fieldSize === 'number'
+                         ? limits.fieldSize
+                         : 1 * 1024 * 1024);
+  this.fieldNameSizeLimit = (limits && typeof limits.fieldNameSize === 'number'
+                             ? limits.fieldNameSize
+                             : 100);
+  this.fieldsLimit = (limits && typeof limits.fields === 'number'
+                      ? limits.fields
+                      : Infinity);
+
+  var charset;
+  for (var i = 0, len = parsedConType.length; i < len; ++i) {
+    if (Array.isArray(parsedConType[i])
+        && RE_CHARSET.test(parsedConType[i][0])) {
+      charset = parsedConType[i][1].toLowerCase();
+      break;
+    }
+  }
+
+  if (charset === undefined)
+    charset = cfg.defCharset || 'utf8';
+
+  this.decoder = new Decoder();
+  this.charset = charset;
+  this._fields = 0;
+  this._state = 'key';
+  this._checkingBytes = true;
+  this._bytesKey = 0;
+  this._bytesVal = 0;
+  this._key = '';
+  this._val = '';
+  this._keyTrunc = false;
+  this._valTrunc = false;
+  this._hitlimit = false;
+}
+
+UrlEncoded.prototype.write = function(data, cb) {
+  if (this._fields === this.fieldsLimit) {
+    if (!this.boy.hitFieldsLimit) {
+      this.boy.hitFieldsLimit = true;
+      this.boy.emit('fieldsLimit');
+    }
+    return cb();
+  }
+
+  var idxeq, idxamp, i, p = 0, len = data.length;
+
+  while (p < len) {
+    if (this._state === 'key') {
+      idxeq = idxamp = undefined;
+      for (i = p; i < len; ++i) {
+        if (!this._checkingBytes)
+          ++p;
+        if (data[i] === 0x3D/*=*/) {
+          idxeq = i;
+          break;
+        } else if (data[i] === 0x26/*&*/) {
+          idxamp = i;
+          break;
+        }
+        if (this._checkingBytes && this._bytesKey === this.fieldNameSizeLimit) {
+          this._hitLimit = true;
+          break;
+        } else if (this._checkingBytes)
+          ++this._bytesKey;
+      }
+
+      if (idxeq !== undefined) {
+        // key with assignment
+        if (idxeq > p)
+          this._key += this.decoder.write(data.toString('binary', p, idxeq));
+        this._state = 'val';
+
+        this._hitLimit = false;
+        this._checkingBytes = true;
+        this._val = '';
+        this._bytesVal = 0;
+        this._valTrunc = false;
+        this.decoder.reset();
+
+        p = idxeq + 1;
+      } else if (idxamp !== undefined) {
+        // key with no assignment
+        ++this._fields;
+        var key, keyTrunc = this._keyTrunc;
+        if (idxamp > p)
+          key = (this._key += this.decoder.write(data.toString('binary', p, idxamp)));
+        else
+          key = this._key;
+
+        this._hitLimit = false;
+        this._checkingBytes = true;
+        this._key = '';
+        this._bytesKey = 0;
+        this._keyTrunc = false;
+        this.decoder.reset();
+
+        if (key.length) {
+          this.boy.emit('field', decodeText(key, 'binary', this.charset),
+                                 '',
+                                 keyTrunc,
+                                 false);
+        }
+
+        p = idxamp + 1;
+        if (this._fields === this.fieldsLimit)
+          return cb();
+      } else if (this._hitLimit) {
+        // we may not have hit the actual limit if there are encoded bytes...
+        if (i > p)
+          this._key += this.decoder.write(data.toString('binary', p, i));
+        p = i;
+        if ((this._bytesKey = this._key.length) === this.fieldNameSizeLimit) {
+          // yep, we actually did hit the limit
+          this._checkingBytes = false;
+          this._keyTrunc = true;
+        }
+      } else {
+        if (p < len)
+          this._key += this.decoder.write(data.toString('binary', p));
+        p = len;
+      }
+    } else {
+      idxamp = undefined;
+      for (i = p; i < len; ++i) {
+        if (!this._checkingBytes)
+          ++p;
+        if (data[i] === 0x26/*&*/) {
+          idxamp = i;
+          break;
+        }
+        if (this._checkingBytes && this._bytesVal === this.fieldSizeLimit) {
+          this._hitLimit = true;
+          break;
+        }
+        else if (this._checkingBytes)
+          ++this._bytesVal;
+      }
+
+      if (idxamp !== undefined) {
+        ++this._fields;
+        if (idxamp > p)
+          this._val += this.decoder.write(data.toString('binary', p, idxamp));
+        this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
+                               decodeText(this._val, 'binary', this.charset),
+                               this._keyTrunc,
+                               this._valTrunc);
+        this._state = 'key';
+
+        this._hitLimit = false;
+        this._checkingBytes = true;
+        this._key = '';
+        this._bytesKey = 0;
+        this._keyTrunc = false;
+        this.decoder.reset();
+
+        p = idxamp + 1;
+        if (this._fields === this.fieldsLimit)
+          return cb();
+      } else if (this._hitLimit) {
+        // we may not have hit the actual limit if there are encoded bytes...
+        if (i > p)
+          this._val += this.decoder.write(data.toString('binary', p, i));
+        p = i;
+        if ((this._val === '' && this.fieldSizeLimit === 0)
+            || (this._bytesVal = this._val.length) === this.fieldSizeLimit) {
+          // yep, we actually did hit the limit
+          this._checkingBytes = false;
+          this._valTrunc = true;
+        }
+      } else {
+        if (p < len)
+          this._val += this.decoder.write(data.toString('binary', p));
+        p = len;
+      }
+    }
+  }
+  cb();
+};
+
+UrlEncoded.prototype.end = function() {
+  if (this.boy._done)
+    return;
+
+  if (this._state === 'key' && this._key.length > 0) {
+    this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
+                           '',
+                           this._keyTrunc,
+                           false);
+  } else if (this._state === 'val') {
+    this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
+                           decodeText(this._val, 'binary', this.charset),
+                           this._keyTrunc,
+                           this._valTrunc);
+  }
+  this.boy._done = true;
+  this.boy.emit('finish');
+};
+
+module.exports = UrlEncoded;

+ 186 - 0
node_modules/busboy/lib/utils.js

@@ -0,0 +1,186 @@
+var jsencoding = require('../deps/encoding/encoding');
+
+var RE_ENCODED = /%([a-fA-F0-9]{2})/g;
+function encodedReplacer(match, byte) {
+  return String.fromCharCode(parseInt(byte, 16));
+}
+function parseParams(str) {
+  var res = [],
+      state = 'key',
+      charset = '',
+      inquote = false,
+      escaping = false,
+      p = 0,
+      tmp = '';
+
+  for (var i = 0, len = str.length; i < len; ++i) {
+    if (str[i] === '\\' && inquote) {
+      if (escaping)
+        escaping = false;
+      else {
+        escaping = true;
+        continue;
+      }
+    } else if (str[i] === '"') {
+      if (!escaping) {
+        if (inquote) {
+          inquote = false;
+          state = 'key';
+        } else
+          inquote = true;
+        continue;
+      } else
+        escaping = false;
+    } else {
+      if (escaping && inquote)
+        tmp += '\\';
+      escaping = false;
+      if ((state === 'charset' || state === 'lang') && str[i] === "'") {
+        if (state === 'charset') {
+          state = 'lang';
+          charset = tmp.substring(1);
+        } else
+          state = 'value';
+        tmp = '';
+        continue;
+      } else if (state === 'key'
+                 && (str[i] === '*' || str[i] === '=')
+                 && res.length) {
+        if (str[i] === '*')
+          state = 'charset';
+        else
+          state = 'value';
+        res[p] = [tmp, undefined];
+        tmp = '';
+        continue;
+      } else if (!inquote && str[i] === ';') {
+        state = 'key';
+        if (charset) {
+          if (tmp.length) {
+            tmp = decodeText(tmp.replace(RE_ENCODED, encodedReplacer),
+                             'binary',
+                             charset);
+          }
+          charset = '';
+        }
+        if (res[p] === undefined)
+          res[p] = tmp;
+        else
+          res[p][1] = tmp;
+        tmp = '';
+        ++p;
+        continue;
+      } else if (!inquote && (str[i] === ' ' || str[i] === '\t'))
+        continue;
+    }
+    tmp += str[i];
+  }
+  if (charset && tmp.length) {
+    tmp = decodeText(tmp.replace(RE_ENCODED, encodedReplacer),
+                     'binary',
+                     charset);
+  }
+
+  if (res[p] === undefined) {
+    if (tmp)
+      res[p] = tmp;
+  } else
+    res[p][1] = tmp;
+
+  return res;
+};
+exports.parseParams = parseParams;
+
+
+function decodeText(text, textEncoding, destEncoding) {
+  var ret;
+  if (text && jsencoding.encodingExists(destEncoding)) {
+    try {
+      ret = jsencoding.TextDecoder(destEncoding)
+                      .decode(new Buffer(text, textEncoding));
+    } catch(e) {}
+  }
+  return (typeof ret === 'string' ? ret : text);
+}
+exports.decodeText = decodeText;
+
+
+var HEX = [
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
+  0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+], RE_PLUS = /\+/g;
+function Decoder() {
+  this.buffer = undefined;
+}
+Decoder.prototype.write = function(str) {
+  // Replace '+' with ' ' before decoding
+  str = str.replace(RE_PLUS, ' ');
+  var res = '';
+  var i = 0, p = 0, len = str.length;
+  for (; i < len; ++i) {
+    if (this.buffer !== undefined) {
+      if (!HEX[str.charCodeAt(i)]) {
+        res += '%' + this.buffer;
+        this.buffer = undefined;
+        --i; // retry character
+      } else {
+        this.buffer += str[i];
+        ++p;
+        if (this.buffer.length === 2) {
+          res += String.fromCharCode(parseInt(this.buffer, 16));
+          this.buffer = undefined;
+        }
+      }
+    } else if (str[i] === '%') {
+      if (i > p) {
+        res += str.substring(p, i);
+        p = i;
+      }
+      this.buffer = '';
+      ++p;
+    }
+  }
+  if (p < len && this.buffer === undefined)
+    res += str.substring(p);
+  return res;
+};
+Decoder.prototype.reset = function() {
+  this.buffer = undefined;
+};
+exports.Decoder = Decoder;
+
+
+var RE_SPLIT_POSIX =
+      /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,
+    RE_SPLIT_DEVICE =
+      /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,
+    RE_SPLIT_WINDOWS =
+      /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
+function splitPathPosix(filename) {
+  return RE_SPLIT_POSIX.exec(filename).slice(1);
+}
+function splitPathWindows(filename) {
+  // Separate device+slash from tail
+  var result = RE_SPLIT_DEVICE.exec(filename),
+      device = (result[1] || '') + (result[2] || ''),
+      tail = result[3] || '';
+  // Split the tail into dir, basename and extension
+  var result2 = RE_SPLIT_WINDOWS.exec(tail),
+      dir = result2[1],
+      basename = result2[2],
+      ext = result2[3];
+  return [device, dir, basename, ext];
+}
+function basename(path) {
+  var f = splitPathPosix(path)[2];
+  if (f === path)
+    f = splitPathWindows(path)[2];
+  return f;
+}
+exports.basename = basename;

+ 54 - 0
node_modules/busboy/node_modules/isarray/README.md

@@ -0,0 +1,54 @@
+
+# isarray
+
+`Array#isArray` for older browsers.
+
+## Usage
+
+```js
+var isArray = require('isarray');
+
+console.log(isArray([])); // => true
+console.log(isArray({})); // => false
+```
+
+## Installation
+
+With [npm](http://npmjs.org) do
+
+```bash
+$ npm install isarray
+```
+
+Then bundle for the browser with
+[browserify](https://github.com/substack/browserify).
+
+With [component](http://component.io) do
+
+```bash
+$ component install juliangruber/isarray
+```
+
+## License
+
+(MIT)
+
+Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
+
+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.

+ 209 - 0
node_modules/busboy/node_modules/isarray/build/build.js

@@ -0,0 +1,209 @@
+
+/**
+ * Require the given path.
+ *
+ * @param {String} path
+ * @return {Object} exports
+ * @api public
+ */
+
+function require(path, parent, orig) {
+  var resolved = require.resolve(path);
+
+  // lookup failed
+  if (null == resolved) {
+    orig = orig || path;
+    parent = parent || 'root';
+    var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
+    err.path = orig;
+    err.parent = parent;
+    err.require = true;
+    throw err;
+  }
+
+  var module = require.modules[resolved];
+
+  // perform real require()
+  // by invoking the module's
+  // registered function
+  if (!module.exports) {
+    module.exports = {};
+    module.client = module.component = true;
+    module.call(this, module.exports, require.relative(resolved), module);
+  }
+
+  return module.exports;
+}
+
+/**
+ * Registered modules.
+ */
+
+require.modules = {};
+
+/**
+ * Registered aliases.
+ */
+
+require.aliases = {};
+
+/**
+ * Resolve `path`.
+ *
+ * Lookup:
+ *
+ *   - PATH/index.js
+ *   - PATH.js
+ *   - PATH
+ *
+ * @param {String} path
+ * @return {String} path or null
+ * @api private
+ */
+
+require.resolve = function(path) {
+  if (path.charAt(0) === '/') path = path.slice(1);
+  var index = path + '/index.js';
+
+  var paths = [
+    path,
+    path + '.js',
+    path + '.json',
+    path + '/index.js',
+    path + '/index.json'
+  ];
+
+  for (var i = 0; i < paths.length; i++) {
+    var path = paths[i];
+    if (require.modules.hasOwnProperty(path)) return path;
+  }
+
+  if (require.aliases.hasOwnProperty(index)) {
+    return require.aliases[index];
+  }
+};
+
+/**
+ * Normalize `path` relative to the current path.
+ *
+ * @param {String} curr
+ * @param {String} path
+ * @return {String}
+ * @api private
+ */
+
+require.normalize = function(curr, path) {
+  var segs = [];
+
+  if ('.' != path.charAt(0)) return path;
+
+  curr = curr.split('/');
+  path = path.split('/');
+
+  for (var i = 0; i < path.length; ++i) {
+    if ('..' == path[i]) {
+      curr.pop();
+    } else if ('.' != path[i] && '' != path[i]) {
+      segs.push(path[i]);
+    }
+  }
+
+  return curr.concat(segs).join('/');
+};
+
+/**
+ * Register module at `path` with callback `definition`.
+ *
+ * @param {String} path
+ * @param {Function} definition
+ * @api private
+ */
+
+require.register = function(path, definition) {
+  require.modules[path] = definition;
+};
+
+/**
+ * Alias a module definition.
+ *
+ * @param {String} from
+ * @param {String} to
+ * @api private
+ */
+
+require.alias = function(from, to) {
+  if (!require.modules.hasOwnProperty(from)) {
+    throw new Error('Failed to alias "' + from + '", it does not exist');
+  }
+  require.aliases[to] = from;
+};
+
+/**
+ * Return a require function relative to the `parent` path.
+ *
+ * @param {String} parent
+ * @return {Function}
+ * @api private
+ */
+
+require.relative = function(parent) {
+  var p = require.normalize(parent, '..');
+
+  /**
+   * lastIndexOf helper.
+   */
+
+  function lastIndexOf(arr, obj) {
+    var i = arr.length;
+    while (i--) {
+      if (arr[i] === obj) return i;
+    }
+    return -1;
+  }
+
+  /**
+   * The relative require() itself.
+   */
+
+  function localRequire(path) {
+    var resolved = localRequire.resolve(path);
+    return require(resolved, parent, path);
+  }
+
+  /**
+   * Resolve relative to the parent.
+   */
+
+  localRequire.resolve = function(path) {
+    var c = path.charAt(0);
+    if ('/' == c) return path.slice(1);
+    if ('.' == c) return require.normalize(p, path);
+
+    // resolve deps by returning
+    // the dep in the nearest "deps"
+    // directory
+    var segs = parent.split('/');
+    var i = lastIndexOf(segs, 'deps') + 1;
+    if (!i) i = 0;
+    path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
+    return path;
+  };
+
+  /**
+   * Check if module is defined at `path`.
+   */
+
+  localRequire.exists = function(path) {
+    return require.modules.hasOwnProperty(localRequire.resolve(path));
+  };
+
+  return localRequire;
+};
+require.register("isarray/index.js", function(exports, require, module){
+module.exports = Array.isArray || function (arr) {
+  return Object.prototype.toString.call(arr) == '[object Array]';
+};
+
+});
+require.alias("isarray/index.js", "isarray/index.js");
+

+ 19 - 0
node_modules/busboy/node_modules/isarray/component.json

@@ -0,0 +1,19 @@
+{
+  "name" : "isarray",
+  "description" : "Array#isArray for older browsers",
+  "version" : "0.0.1",
+  "repository" : "juliangruber/isarray",
+  "homepage": "https://github.com/juliangruber/isarray",
+  "main" : "index.js",
+  "scripts" : [
+    "index.js"
+  ],
+  "dependencies" : {},
+  "keywords": ["browser","isarray","array"],
+  "author": {
+    "name": "Julian Gruber",
+    "email": "mail@juliangruber.com",
+    "url": "http://juliangruber.com"
+  },
+  "license": "MIT"
+}

+ 3 - 0
node_modules/busboy/node_modules/isarray/index.js

@@ -0,0 +1,3 @@
+module.exports = Array.isArray || function (arr) {
+  return Object.prototype.toString.call(arr) == '[object Array]';
+};

+ 25 - 0
node_modules/busboy/node_modules/isarray/package.json

@@ -0,0 +1,25 @@
+{
+  "name" : "isarray",
+  "description" : "Array#isArray for older browsers",
+  "version" : "0.0.1",
+  "repository" : {
+    "type" : "git",
+    "url" : "git://github.com/juliangruber/isarray.git"
+  },
+  "homepage": "https://github.com/juliangruber/isarray",
+  "main" : "index.js",
+  "scripts" : {
+    "test" : "tap test/*.js"
+  },
+  "dependencies" : {},
+  "devDependencies" : {
+    "tap" : "*"
+  },
+  "keywords": ["browser","isarray","array"],
+  "author": {
+    "name": "Julian Gruber",
+    "email": "mail@juliangruber.com",
+    "url": "http://juliangruber.com"
+  },
+  "license": "MIT"
+}

+ 0 - 0
node_modules/busboy/node_modules/readable-stream/.npmignore


Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů