From 2eaaf05d541eaba92bcb343a44119a471945aeea Mon Sep 17 00:00:00 2001 From: Low fat lard <94632232+Low-Fat-Lard@users.noreply.github.com> Date: Sun, 2 Oct 2022 17:13:44 +0000 Subject: [PATCH] 1) Changed UI 2) Created commenting sys - WIP 3) Added search page 4) Socket.io and FS support 5) will add all of the Irish back soon --- .breakpoints | 8 + database.json | 12 +- index.js | 101 +- node_modules/.package-lock.json | 591 ++ .../@socket.io/component-emitter/LICENSE | 24 + .../@socket.io/component-emitter/Readme.md | 74 + .../@socket.io/component-emitter/index.d.ts | 179 + .../@socket.io/component-emitter/index.js | 176 + .../@socket.io/component-emitter/index.mjs | 169 + .../@socket.io/component-emitter/package.json | 31 + node_modules/@types/cookie/LICENSE | 21 + node_modules/@types/cookie/README.md | 16 + node_modules/@types/cookie/index.d.ts | 135 + node_modules/@types/cookie/package.json | 30 + node_modules/@types/cors/LICENSE | 21 + node_modules/@types/cors/README.md | 78 + node_modules/@types/cors/index.d.ts | 58 + node_modules/@types/cors/package.json | 30 + .../@types/webidl-conversions/LICENSE | 21 + .../@types/webidl-conversions/README.md | 16 + .../@types/webidl-conversions/index.d.ts | 97 + .../@types/webidl-conversions/package.json | 30 + node_modules/@types/whatwg-url/LICENSE | 21 + node_modules/@types/whatwg-url/README.md | 16 + .../@types/whatwg-url/dist/URL-impl.d.ts | 23 + node_modules/@types/whatwg-url/dist/URL.d.ts | 76 + .../whatwg-url/dist/URLSearchParams-impl.d.ts | 23 + .../whatwg-url/dist/URLSearchParams.d.ts | 91 + node_modules/@types/whatwg-url/index.d.ts | 162 + node_modules/@types/whatwg-url/package.json | 33 + .../@types/whatwg-url/webidl2js-wrapper.d.ts | 4 + node_modules/base64-js/LICENSE | 21 + node_modules/base64-js/README.md | 34 + node_modules/base64-js/base64js.min.js | 1 + node_modules/base64-js/index.d.ts | 3 + node_modules/base64-js/index.js | 150 + node_modules/base64-js/package.json | 47 + node_modules/base64id/CHANGELOG.md | 16 + node_modules/base64id/LICENSE | 22 + node_modules/base64id/README.md | 18 + node_modules/base64id/lib/base64id.js | 103 + node_modules/base64id/package.json | 13 + node_modules/basic-auth/HISTORY.md | 52 + node_modules/basic-auth/LICENSE | 24 + node_modules/basic-auth/README.md | 113 + node_modules/basic-auth/index.js | 133 + .../node_modules/safe-buffer/LICENSE | 21 + .../node_modules/safe-buffer/README.md | 584 ++ .../node_modules/safe-buffer/index.d.ts | 187 + .../node_modules/safe-buffer/index.js | 62 + .../node_modules/safe-buffer/package.json | 37 + node_modules/basic-auth/package.json | 41 + node_modules/bson/LICENSE.md | 201 + node_modules/bson/README.md | 376 + node_modules/bson/bower.json | 26 + node_modules/bson/bson.d.ts | 1228 +++ node_modules/bson/dist/bson.browser.esm.js | 7470 ++++++++++++++++ .../bson/dist/bson.browser.esm.js.map | 1 + node_modules/bson/dist/bson.browser.umd.js | 7537 +++++++++++++++++ .../bson/dist/bson.browser.umd.js.map | 1 + node_modules/bson/dist/bson.bundle.js | 7536 ++++++++++++++++ node_modules/bson/dist/bson.bundle.js.map | 1 + node_modules/bson/dist/bson.esm.js | 5436 ++++++++++++ node_modules/bson/dist/bson.esm.js.map | 1 + node_modules/bson/etc/prepare.js | 19 + node_modules/bson/lib/binary.js | 426 + node_modules/bson/lib/binary.js.map | 1 + node_modules/bson/lib/bson.js | 251 + node_modules/bson/lib/bson.js.map | 1 + node_modules/bson/lib/code.js | 46 + node_modules/bson/lib/code.js.map | 1 + node_modules/bson/lib/constants.js | 82 + node_modules/bson/lib/constants.js.map | 1 + node_modules/bson/lib/db_ref.js | 97 + node_modules/bson/lib/db_ref.js.map | 1 + node_modules/bson/lib/decimal128.js | 669 ++ node_modules/bson/lib/decimal128.js.map | 1 + node_modules/bson/lib/double.js | 76 + node_modules/bson/lib/double.js.map | 1 + node_modules/bson/lib/ensure_buffer.js | 25 + node_modules/bson/lib/ensure_buffer.js.map | 1 + node_modules/bson/lib/error.js | 55 + node_modules/bson/lib/error.js.map | 1 + node_modules/bson/lib/extended_json.js | 390 + node_modules/bson/lib/extended_json.js.map | 1 + node_modules/bson/lib/int_32.js | 58 + node_modules/bson/lib/int_32.js.map | 1 + node_modules/bson/lib/long.js | 900 ++ node_modules/bson/lib/long.js.map | 1 + node_modules/bson/lib/map.js | 123 + node_modules/bson/lib/map.js.map | 1 + node_modules/bson/lib/max_key.js | 33 + node_modules/bson/lib/max_key.js.map | 1 + node_modules/bson/lib/min_key.js | 33 + node_modules/bson/lib/min_key.js.map | 1 + node_modules/bson/lib/objectid.js | 299 + node_modules/bson/lib/objectid.js.map | 1 + .../bson/lib/parser/calculate_size.js | 194 + .../bson/lib/parser/calculate_size.js.map | 1 + node_modules/bson/lib/parser/deserializer.js | 665 ++ .../bson/lib/parser/deserializer.js.map | 1 + node_modules/bson/lib/parser/serializer.js | 867 ++ .../bson/lib/parser/serializer.js.map | 1 + node_modules/bson/lib/parser/utils.js | 115 + node_modules/bson/lib/parser/utils.js.map | 1 + node_modules/bson/lib/regexp.js | 74 + node_modules/bson/lib/regexp.js.map | 1 + node_modules/bson/lib/symbol.js | 48 + node_modules/bson/lib/symbol.js.map | 1 + node_modules/bson/lib/timestamp.js | 102 + node_modules/bson/lib/timestamp.js.map | 1 + node_modules/bson/lib/utils/global.js | 18 + node_modules/bson/lib/utils/global.js.map | 1 + node_modules/bson/lib/uuid_utils.js | 35 + node_modules/bson/lib/uuid_utils.js.map | 1 + node_modules/bson/lib/validate_utf8.js | 47 + node_modules/bson/lib/validate_utf8.js.map | 1 + node_modules/bson/package.json | 116 + node_modules/bson/src/binary.ts | 481 ++ node_modules/bson/src/bson.ts | 330 + node_modules/bson/src/code.ts | 61 + node_modules/bson/src/constants.ts | 110 + node_modules/bson/src/db_ref.ts | 124 + node_modules/bson/src/decimal128.ts | 773 ++ node_modules/bson/src/double.ts | 91 + node_modules/bson/src/ensure_buffer.ts | 27 + node_modules/bson/src/error.ts | 23 + node_modules/bson/src/extended_json.ts | 462 + node_modules/bson/src/int_32.ts | 70 + node_modules/bson/src/long.ts | 1040 +++ node_modules/bson/src/map.ts | 119 + node_modules/bson/src/max_key.ts | 38 + node_modules/bson/src/min_key.ts | 38 + node_modules/bson/src/objectid.ts | 354 + .../bson/src/parser/calculate_size.ts | 228 + node_modules/bson/src/parser/deserializer.ts | 782 ++ node_modules/bson/src/parser/serializer.ts | 1076 +++ node_modules/bson/src/parser/utils.ts | 127 + node_modules/bson/src/regexp.ts | 105 + node_modules/bson/src/symbol.ts | 58 + node_modules/bson/src/timestamp.ts | 119 + node_modules/bson/src/utils/global.ts | 22 + node_modules/bson/src/uuid_utils.ts | 33 + node_modules/bson/src/validate_utf8.ts | 47 + node_modules/buffer/AUTHORS.md | 70 + node_modules/buffer/LICENSE | 21 + node_modules/buffer/README.md | 410 + node_modules/buffer/index.d.ts | 186 + node_modules/buffer/index.js | 1817 ++++ node_modules/buffer/package.json | 96 + node_modules/cors/CONTRIBUTING.md | 33 + node_modules/cors/HISTORY.md | 58 + node_modules/cors/LICENSE | 22 + node_modules/cors/README.md | 243 + node_modules/cors/lib/index.js | 238 + node_modules/cors/package.json | 41 + node_modules/denque/CHANGELOG.md | 29 + node_modules/denque/LICENSE | 201 + node_modules/denque/README.md | 77 + node_modules/denque/index.d.ts | 47 + node_modules/denque/index.js | 481 ++ node_modules/denque/package.json | 58 + node_modules/engine.io-parser/LICENSE | 22 + node_modules/engine.io-parser/Readme.md | 158 + .../engine.io-parser/build/cjs/commons.js | 19 + .../build/cjs/contrib/base64-arraybuffer.js | 47 + .../build/cjs/decodePacket.browser.js | 51 + .../build/cjs/decodePacket.js | 49 + .../build/cjs/encodePacket.browser.js | 43 + .../build/cjs/encodePacket.js | 27 + .../engine.io-parser/build/cjs/index.js | 38 + .../engine.io-parser/build/cjs/package.json | 8 + .../engine.io-parser/build/esm/commons.d.ts | 14 + .../engine.io-parser/build/esm/commons.js | 14 + .../build/esm/contrib/base64-arraybuffer.d.ts | 2 + .../build/esm/contrib/base64-arraybuffer.js | 42 + .../build/esm/decodePacket.browser.d.ts | 3 + .../build/esm/decodePacket.browser.js | 49 + .../build/esm/decodePacket.d.ts | 3 + .../build/esm/decodePacket.js | 47 + .../build/esm/encodePacket.browser.d.ts | 3 + .../build/esm/encodePacket.browser.js | 41 + .../build/esm/encodePacket.d.ts | 3 + .../build/esm/encodePacket.js | 25 + .../engine.io-parser/build/esm/index.d.ts | 7 + .../engine.io-parser/build/esm/index.js | 32 + .../engine.io-parser/build/esm/package.json | 8 + node_modules/engine.io-parser/package.json | 58 + node_modules/engine.io/LICENSE | 19 + node_modules/engine.io/README.md | 596 ++ node_modules/engine.io/build/engine.io.d.ts | 28 + node_modules/engine.io/build/engine.io.js | 56 + .../engine.io/build/parser-v3/index.d.ts | 95 + .../engine.io/build/parser-v3/index.js | 424 + .../engine.io/build/parser-v3/utf8.d.ts | 14 + .../engine.io/build/parser-v3/utf8.js | 187 + node_modules/engine.io/build/server.d.ts | 223 + node_modules/engine.io/build/server.js | 626 ++ node_modules/engine.io/build/socket.d.ts | 145 + node_modules/engine.io/build/socket.js | 462 + node_modules/engine.io/build/transport.d.ts | 76 + node_modules/engine.io/build/transport.js | 113 + .../engine.io/build/transports-uws/index.d.ts | 7 + .../engine.io/build/transports-uws/index.js | 8 + .../build/transports-uws/polling.d.ts | 103 + .../engine.io/build/transports-uws/polling.js | 363 + .../build/transports-uws/websocket.d.ts | 43 + .../build/transports-uws/websocket.js | 89 + .../engine.io/build/transports/index.d.ts | 16 + .../engine.io/build/transports/index.js | 23 + .../build/transports/polling-jsonp.d.ts | 24 + .../build/transports/polling-jsonp.js | 54 + .../engine.io/build/transports/polling.d.ts | 100 + .../engine.io/build/transports/polling.js | 342 + .../engine.io/build/transports/websocket.d.ts | 43 + .../engine.io/build/transports/websocket.js | 102 + node_modules/engine.io/build/userver.d.ts | 38 + node_modules/engine.io/build/userver.js | 212 + .../engine.io/node_modules/cookie/HISTORY.md | 134 + .../engine.io/node_modules/cookie/LICENSE | 24 + .../engine.io/node_modules/cookie/README.md | 286 + .../engine.io/node_modules/cookie/index.js | 202 + .../node_modules/cookie/package.json | 42 + .../engine.io/node_modules/debug/LICENSE | 20 + .../engine.io/node_modules/debug/README.md | 481 ++ .../engine.io/node_modules/debug/package.json | 59 + .../node_modules/debug/src/browser.js | 269 + .../node_modules/debug/src/common.js | 274 + .../engine.io/node_modules/debug/src/index.js | 10 + .../engine.io/node_modules/debug/src/node.js | 263 + .../engine.io/node_modules/ms/index.js | 162 + .../engine.io/node_modules/ms/license.md | 21 + .../engine.io/node_modules/ms/package.json | 37 + .../engine.io/node_modules/ms/readme.md | 60 + node_modules/engine.io/package.json | 80 + node_modules/engine.io/wrapper.mjs | 3 + node_modules/errorhandler/HISTORY.md | 161 + node_modules/errorhandler/LICENSE | 23 + node_modules/errorhandler/README.md | 128 + node_modules/errorhandler/index.js | 198 + node_modules/errorhandler/package.json | 43 + node_modules/errorhandler/public/error.html | 14 + node_modules/errorhandler/public/style.css | 35 + node_modules/express-session/HISTORY.md | 442 + node_modules/express-session/LICENSE | 24 + node_modules/express-session/README.md | 985 +++ node_modules/express-session/index.js | 685 ++ .../node_modules/cookie/HISTORY.md | 134 + .../node_modules/cookie/LICENSE | 24 + .../node_modules/cookie/README.md | 286 + .../node_modules/cookie/index.js | 202 + .../node_modules/cookie/package.json | 42 + node_modules/express-session/package.json | 47 + .../express-session/session/cookie.js | 150 + .../express-session/session/memory.js | 187 + .../express-session/session/session.js | 143 + node_modules/express-session/session/store.js | 102 + node_modules/ieee754/LICENSE | 11 + node_modules/ieee754/README.md | 51 + node_modules/ieee754/index.d.ts | 10 + node_modules/ieee754/index.js | 85 + node_modules/ieee754/package.json | 52 + node_modules/ip/README.md | 90 + node_modules/ip/lib/ip.js | 422 + node_modules/ip/package.json | 25 + node_modules/kareem/.eslintrc.json | 16 + .../kareem/.github/workflows/test.yml | 47 + node_modules/kareem/.travis.yml | 12 + node_modules/kareem/CHANGELOG.md | 808 ++ node_modules/kareem/LICENSE | 202 + node_modules/kareem/Makefile | 5 + node_modules/kareem/README.md | 420 + node_modules/kareem/docs.js | 41 + node_modules/kareem/index.js | 563 ++ node_modules/kareem/package.json | 25 + node_modules/kareem/test/examples.test.js | 429 + node_modules/kareem/test/misc.test.js | 71 + node_modules/kareem/test/post.test.js | 264 + node_modules/kareem/test/pre.test.js | 359 + node_modules/kareem/test/wrap.test.js | 467 + node_modules/memory-pager/.travis.yml | 4 + node_modules/memory-pager/LICENSE | 21 + node_modules/memory-pager/README.md | 65 + node_modules/memory-pager/index.js | 160 + node_modules/memory-pager/package.json | 24 + node_modules/memory-pager/test.js | 80 + .../.esm-wrapper.mjs | 6 + .../mongodb-connection-string-url/LICENSE | 192 + .../mongodb-connection-string-url/README.md | 25 + .../lib/index.d.ts | 62 + .../lib/index.js | 213 + .../lib/index.js.map | 1 + .../lib/redact.d.ts | 7 + .../lib/redact.js | 86 + .../lib/redact.js.map | 1 + .../package.json | 62 + node_modules/mongodb/LICENSE.md | 201 + node_modules/mongodb/README.md | 280 + node_modules/mongodb/etc/prepare.js | 12 + node_modules/mongodb/lib/admin.js | 123 + node_modules/mongodb/lib/admin.js.map | 1 + node_modules/mongodb/lib/bson.js | 71 + node_modules/mongodb/lib/bson.js.map | 1 + node_modules/mongodb/lib/bulk/common.js | 967 +++ node_modules/mongodb/lib/bulk/common.js.map | 1 + node_modules/mongodb/lib/bulk/ordered.js | 66 + node_modules/mongodb/lib/bulk/ordered.js.map | 1 + node_modules/mongodb/lib/bulk/unordered.js | 91 + .../mongodb/lib/bulk/unordered.js.map | 1 + node_modules/mongodb/lib/change_stream.js | 374 + node_modules/mongodb/lib/change_stream.js.map | 1 + .../mongodb/lib/cmap/auth/auth_provider.js | 36 + .../lib/cmap/auth/auth_provider.js.map | 1 + node_modules/mongodb/lib/cmap/auth/gssapi.js | 190 + .../mongodb/lib/cmap/auth/gssapi.js.map | 1 + .../lib/cmap/auth/mongo_credentials.js | 134 + .../lib/cmap/auth/mongo_credentials.js.map | 1 + node_modules/mongodb/lib/cmap/auth/mongocr.js | 44 + .../mongodb/lib/cmap/auth/mongocr.js.map | 1 + .../mongodb/lib/cmap/auth/mongodb_aws.js | 204 + .../mongodb/lib/cmap/auth/mongodb_aws.js.map | 1 + node_modules/mongodb/lib/cmap/auth/plain.js | 27 + .../mongodb/lib/cmap/auth/plain.js.map | 1 + .../mongodb/lib/cmap/auth/providers.js | 21 + .../mongodb/lib/cmap/auth/providers.js.map | 1 + node_modules/mongodb/lib/cmap/auth/scram.js | 288 + .../mongodb/lib/cmap/auth/scram.js.map | 1 + node_modules/mongodb/lib/cmap/auth/x509.js | 39 + .../mongodb/lib/cmap/auth/x509.js.map | 1 + .../lib/cmap/command_monitoring_events.js | 243 + .../lib/cmap/command_monitoring_events.js.map | 1 + node_modules/mongodb/lib/cmap/commands.js | 481 ++ node_modules/mongodb/lib/cmap/commands.js.map | 1 + node_modules/mongodb/lib/cmap/connect.js | 398 + node_modules/mongodb/lib/cmap/connect.js.map | 1 + node_modules/mongodb/lib/cmap/connection.js | 469 + .../mongodb/lib/cmap/connection.js.map | 1 + .../mongodb/lib/cmap/connection_pool.js | 523 ++ .../mongodb/lib/cmap/connection_pool.js.map | 1 + .../lib/cmap/connection_pool_events.js | 147 + .../lib/cmap/connection_pool_events.js.map | 1 + node_modules/mongodb/lib/cmap/errors.js | 33 + node_modules/mongodb/lib/cmap/errors.js.map | 1 + .../mongodb/lib/cmap/message_stream.js | 175 + .../mongodb/lib/cmap/message_stream.js.map | 1 + node_modules/mongodb/lib/cmap/metrics.js | 62 + node_modules/mongodb/lib/cmap/metrics.js.map | 1 + .../mongodb/lib/cmap/stream_description.js | 51 + .../lib/cmap/stream_description.js.map | 1 + .../lib/cmap/wire_protocol/compression.js | 96 + .../lib/cmap/wire_protocol/compression.js.map | 1 + .../lib/cmap/wire_protocol/constants.js | 15 + .../lib/cmap/wire_protocol/constants.js.map | 1 + .../mongodb/lib/cmap/wire_protocol/shared.js | 55 + .../lib/cmap/wire_protocol/shared.js.map | 1 + node_modules/mongodb/lib/collection.js | 537 ++ node_modules/mongodb/lib/collection.js.map | 1 + node_modules/mongodb/lib/connection_string.js | 1094 +++ .../mongodb/lib/connection_string.js.map | 1 + node_modules/mongodb/lib/constants.js | 129 + node_modules/mongodb/lib/constants.js.map | 1 + .../mongodb/lib/cursor/abstract_cursor.js | 646 ++ .../mongodb/lib/cursor/abstract_cursor.js.map | 1 + .../mongodb/lib/cursor/aggregation_cursor.js | 172 + .../lib/cursor/aggregation_cursor.js.map | 1 + .../lib/cursor/change_stream_cursor.js | 115 + .../lib/cursor/change_stream_cursor.js.map | 1 + .../mongodb/lib/cursor/find_cursor.js | 382 + .../mongodb/lib/cursor/find_cursor.js.map | 1 + .../lib/cursor/list_collections_cursor.js | 37 + .../lib/cursor/list_collections_cursor.js.map | 1 + .../mongodb/lib/cursor/list_indexes_cursor.js | 36 + .../lib/cursor/list_indexes_cursor.js.map | 1 + node_modules/mongodb/lib/db.js | 334 + node_modules/mongodb/lib/db.js.map | 1 + node_modules/mongodb/lib/deps.js | 63 + node_modules/mongodb/lib/deps.js.map | 1 + node_modules/mongodb/lib/encrypter.js | 109 + node_modules/mongodb/lib/encrypter.js.map | 1 + node_modules/mongodb/lib/error.js | 799 ++ node_modules/mongodb/lib/error.js.map | 1 + node_modules/mongodb/lib/explain.js | 35 + node_modules/mongodb/lib/explain.js.map | 1 + node_modules/mongodb/lib/gridfs/download.js | 317 + .../mongodb/lib/gridfs/download.js.map | 1 + node_modules/mongodb/lib/gridfs/index.js | 152 + node_modules/mongodb/lib/gridfs/index.js.map | 1 + node_modules/mongodb/lib/gridfs/upload.js | 376 + node_modules/mongodb/lib/gridfs/upload.js.map | 1 + node_modules/mongodb/lib/index.js | 164 + node_modules/mongodb/lib/index.js.map | 1 + node_modules/mongodb/lib/logger.js | 217 + node_modules/mongodb/lib/logger.js.map | 1 + node_modules/mongodb/lib/mongo_client.js | 308 + node_modules/mongodb/lib/mongo_client.js.map | 1 + node_modules/mongodb/lib/mongo_types.js | 41 + node_modules/mongodb/lib/mongo_types.js.map | 1 + .../mongodb/lib/operations/add_user.js | 72 + .../mongodb/lib/operations/add_user.js.map | 1 + .../mongodb/lib/operations/aggregate.js | 90 + .../mongodb/lib/operations/aggregate.js.map | 1 + .../mongodb/lib/operations/bulk_write.js | 43 + .../mongodb/lib/operations/bulk_write.js.map | 1 + .../mongodb/lib/operations/collections.js | 29 + .../mongodb/lib/operations/collections.js.map | 1 + .../mongodb/lib/operations/command.js | 95 + .../mongodb/lib/operations/command.js.map | 1 + .../lib/operations/common_functions.js | 71 + .../lib/operations/common_functions.js.map | 1 + .../mongodb/lib/operations/connect.js | 85 + .../mongodb/lib/operations/connect.js.map | 1 + node_modules/mongodb/lib/operations/count.js | 39 + .../mongodb/lib/operations/count.js.map | 1 + .../mongodb/lib/operations/count_documents.js | 37 + .../lib/operations/count_documents.js.map | 1 + .../lib/operations/create_collection.js | 100 + .../lib/operations/create_collection.js.map | 1 + node_modules/mongodb/lib/operations/delete.js | 135 + .../mongodb/lib/operations/delete.js.map | 1 + .../mongodb/lib/operations/distinct.js | 67 + .../mongodb/lib/operations/distinct.js.map | 1 + node_modules/mongodb/lib/operations/drop.js | 84 + .../mongodb/lib/operations/drop.js.map | 1 + .../operations/estimated_document_count.js | 38 + .../estimated_document_count.js.map | 1 + node_modules/mongodb/lib/operations/eval.js | 55 + .../mongodb/lib/operations/eval.js.map | 1 + .../lib/operations/execute_operation.js | 185 + .../lib/operations/execute_operation.js.map | 1 + node_modules/mongodb/lib/operations/find.js | 165 + .../mongodb/lib/operations/find.js.map | 1 + .../mongodb/lib/operations/find_and_modify.js | 156 + .../lib/operations/find_and_modify.js.map | 1 + .../mongodb/lib/operations/get_more.js | 58 + .../mongodb/lib/operations/get_more.js.map | 1 + .../mongodb/lib/operations/indexes.js | 270 + .../mongodb/lib/operations/indexes.js.map | 1 + node_modules/mongodb/lib/operations/insert.js | 99 + .../mongodb/lib/operations/insert.js.map | 1 + .../mongodb/lib/operations/is_capped.js | 30 + .../mongodb/lib/operations/is_capped.js.map | 1 + .../mongodb/lib/operations/kill_cursors.js | 32 + .../lib/operations/kill_cursors.js.map | 1 + .../lib/operations/list_collections.js | 46 + .../lib/operations/list_collections.js.map | 1 + .../mongodb/lib/operations/list_databases.js | 35 + .../lib/operations/list_databases.js.map | 1 + .../mongodb/lib/operations/map_reduce.js | 166 + .../mongodb/lib/operations/map_reduce.js.map | 1 + .../mongodb/lib/operations/operation.js | 70 + .../mongodb/lib/operations/operation.js.map | 1 + .../lib/operations/options_operation.js | 29 + .../lib/operations/options_operation.js.map | 1 + .../mongodb/lib/operations/profiling_level.js | 33 + .../lib/operations/profiling_level.js.map | 1 + .../mongodb/lib/operations/remove_user.js | 21 + .../mongodb/lib/operations/remove_user.js.map | 1 + node_modules/mongodb/lib/operations/rename.js | 46 + .../mongodb/lib/operations/rename.js.map | 1 + .../mongodb/lib/operations/run_command.js | 26 + .../mongodb/lib/operations/run_command.js.map | 1 + .../lib/operations/set_profiling_level.js | 51 + .../lib/operations/set_profiling_level.js.map | 1 + node_modules/mongodb/lib/operations/stats.js | 48 + .../mongodb/lib/operations/stats.js.map | 1 + node_modules/mongodb/lib/operations/update.js | 200 + .../mongodb/lib/operations/update.js.map | 1 + .../lib/operations/validate_collection.js | 41 + .../lib/operations/validate_collection.js.map | 1 + node_modules/mongodb/lib/promise_provider.js | 36 + .../mongodb/lib/promise_provider.js.map | 1 + node_modules/mongodb/lib/read_concern.js | 74 + node_modules/mongodb/lib/read_concern.js.map | 1 + node_modules/mongodb/lib/read_preference.js | 204 + .../mongodb/lib/read_preference.js.map | 1 + node_modules/mongodb/lib/sdam/common.js | 56 + node_modules/mongodb/lib/sdam/common.js.map | 1 + node_modules/mongodb/lib/sdam/events.js | 125 + node_modules/mongodb/lib/sdam/events.js.map | 1 + node_modules/mongodb/lib/sdam/monitor.js | 327 + node_modules/mongodb/lib/sdam/monitor.js.map | 1 + node_modules/mongodb/lib/sdam/server.js | 345 + node_modules/mongodb/lib/sdam/server.js.map | 1 + .../mongodb/lib/sdam/server_description.js | 190 + .../lib/sdam/server_description.js.map | 1 + .../mongodb/lib/sdam/server_selection.js | 228 + .../mongodb/lib/sdam/server_selection.js.map | 1 + node_modules/mongodb/lib/sdam/srv_polling.js | 122 + .../mongodb/lib/sdam/srv_polling.js.map | 1 + node_modules/mongodb/lib/sdam/topology.js | 645 ++ node_modules/mongodb/lib/sdam/topology.js.map | 1 + .../mongodb/lib/sdam/topology_description.js | 340 + .../lib/sdam/topology_description.js.map | 1 + node_modules/mongodb/lib/sessions.js | 746 ++ node_modules/mongodb/lib/sessions.js.map | 1 + node_modules/mongodb/lib/sort.js | 97 + node_modules/mongodb/lib/sort.js.map | 1 + node_modules/mongodb/lib/transactions.js | 138 + node_modules/mongodb/lib/transactions.js.map | 1 + node_modules/mongodb/lib/utils.js | 1108 +++ node_modules/mongodb/lib/utils.js.map | 1 + node_modules/mongodb/lib/write_concern.js | 71 + node_modules/mongodb/lib/write_concern.js.map | 1 + node_modules/mongodb/mongodb.d.ts | 6725 +++++++++++++++ node_modules/mongodb/package.json | 136 + node_modules/mongodb/src/admin.ts | 314 + node_modules/mongodb/src/bson.ts | 116 + node_modules/mongodb/src/bulk/common.ts | 1384 +++ node_modules/mongodb/src/bulk/ordered.ts | 82 + node_modules/mongodb/src/bulk/unordered.ts | 109 + node_modules/mongodb/src/change_stream.ts | 941 ++ .../mongodb/src/cmap/auth/auth_provider.ts | 60 + node_modules/mongodb/src/cmap/auth/gssapi.ts | 241 + .../src/cmap/auth/mongo_credentials.ts | 190 + node_modules/mongodb/src/cmap/auth/mongocr.ts | 47 + .../mongodb/src/cmap/auth/mongodb_aws.ts | 293 + node_modules/mongodb/src/cmap/auth/plain.ts | 25 + .../mongodb/src/cmap/auth/providers.ts | 21 + node_modules/mongodb/src/cmap/auth/scram.ts | 384 + node_modules/mongodb/src/cmap/auth/x509.ts | 53 + .../src/cmap/command_monitoring_events.ts | 301 + node_modules/mongodb/src/cmap/commands.ts | 703 ++ node_modules/mongodb/src/cmap/connect.ts | 523 ++ node_modules/mongodb/src/cmap/connection.ts | 752 ++ .../mongodb/src/cmap/connection_pool.ts | 747 ++ .../src/cmap/connection_pool_events.ts | 179 + node_modules/mongodb/src/cmap/errors.ts | 38 + .../mongodb/src/cmap/message_stream.ts | 242 + node_modules/mongodb/src/cmap/metrics.ts | 58 + .../mongodb/src/cmap/stream_description.ts | 76 + .../src/cmap/wire_protocol/compression.ts | 130 + .../src/cmap/wire_protocol/constants.ts | 11 + .../mongodb/src/cmap/wire_protocol/shared.ts | 76 + node_modules/mongodb/src/collection.ts | 1700 ++++ node_modules/mongodb/src/connection_string.ts | 1267 +++ node_modules/mongodb/src/constants.ts | 134 + .../mongodb/src/cursor/abstract_cursor.ts | 931 ++ .../mongodb/src/cursor/aggregation_cursor.ts | 219 + .../src/cursor/change_stream_cursor.ts | 194 + .../mongodb/src/cursor/find_cursor.ts | 480 ++ .../src/cursor/list_collections_cursor.ts | 52 + .../mongodb/src/cursor/list_indexes_cursor.ts | 41 + node_modules/mongodb/src/db.ts | 770 ++ node_modules/mongodb/src/deps.ts | 378 + node_modules/mongodb/src/encrypter.ts | 135 + node_modules/mongodb/src/error.ts | 924 ++ node_modules/mongodb/src/explain.ts | 52 + node_modules/mongodb/src/gridfs/download.ts | 458 + node_modules/mongodb/src/gridfs/index.ts | 257 + node_modules/mongodb/src/gridfs/upload.ts | 566 ++ node_modules/mongodb/src/index.ts | 477 ++ node_modules/mongodb/src/logger.ts | 265 + node_modules/mongodb/src/mongo_client.ts | 797 ++ node_modules/mongodb/src/mongo_types.ts | 548 ++ .../mongodb/src/operations/add_user.ts | 118 + .../mongodb/src/operations/aggregate.ts | 144 + .../mongodb/src/operations/bulk_write.ts | 67 + .../mongodb/src/operations/collections.ts | 48 + .../mongodb/src/operations/command.ts | 193 + .../src/operations/common_functions.ts | 102 + .../mongodb/src/operations/connect.ts | 107 + node_modules/mongodb/src/operations/count.ts | 68 + .../mongodb/src/operations/count_documents.ts | 57 + .../src/operations/create_collection.ts | 200 + node_modules/mongodb/src/operations/delete.ts | 194 + .../mongodb/src/operations/distinct.ts | 90 + node_modules/mongodb/src/operations/drop.ts | 120 + .../operations/estimated_document_count.ts | 62 + node_modules/mongodb/src/operations/eval.ts | 82 + .../src/operations/execute_operation.ts | 298 + node_modules/mongodb/src/operations/find.ts | 288 + .../mongodb/src/operations/find_and_modify.ts | 295 + .../mongodb/src/operations/get_more.ts | 106 + .../mongodb/src/operations/indexes.ts | 500 ++ node_modules/mongodb/src/operations/insert.ts | 158 + .../mongodb/src/operations/is_capped.ts | 42 + .../mongodb/src/operations/kill_cursors.ts | 53 + .../src/operations/list_collections.ts | 91 + .../mongodb/src/operations/list_databases.ts | 65 + .../mongodb/src/operations/map_reduce.ts | 250 + .../mongodb/src/operations/operation.ts | 125 + .../src/operations/options_operation.ts | 42 + .../mongodb/src/operations/profiling_level.ts | 39 + .../mongodb/src/operations/remove_user.ts | 33 + node_modules/mongodb/src/operations/rename.ts | 67 + .../mongodb/src/operations/run_command.ts | 36 + .../src/operations/set_profiling_level.ts | 74 + node_modules/mongodb/src/operations/stats.ts | 271 + node_modules/mongodb/src/operations/update.ts | 334 + .../src/operations/validate_collection.ts | 59 + node_modules/mongodb/src/promise_provider.ts | 41 + node_modules/mongodb/src/read_concern.ts | 88 + node_modules/mongodb/src/read_preference.ts | 271 + node_modules/mongodb/src/sdam/common.ts | 79 + node_modules/mongodb/src/sdam/events.ts | 182 + node_modules/mongodb/src/sdam/monitor.ts | 472 ++ node_modules/mongodb/src/sdam/server.ts | 535 ++ .../mongodb/src/sdam/server_description.ts | 262 + .../mongodb/src/sdam/server_selection.ts | 324 + node_modules/mongodb/src/sdam/srv_polling.ts | 165 + node_modules/mongodb/src/sdam/topology.ts | 1007 +++ .../mongodb/src/sdam/topology_description.ts | 486 ++ node_modules/mongodb/src/sessions.ts | 1075 +++ node_modules/mongodb/src/sort.ts | 132 + node_modules/mongodb/src/transactions.ts | 187 + node_modules/mongodb/src/utils.ts | 1411 +++ node_modules/mongodb/src/write_concern.ts | 114 + node_modules/mongodb/tsconfig.json | 40 + node_modules/mongoose/.eslintrc.json | 194 + node_modules/mongoose/.mocharc.yml | 2 + node_modules/mongoose/LICENSE.md | 22 + node_modules/mongoose/README.md | 366 + node_modules/mongoose/SECURITY.md | 1 + node_modules/mongoose/browser.js | 8 + node_modules/mongoose/dist/browser.umd.js | 1636 ++++ node_modules/mongoose/index.js | 63 + node_modules/mongoose/lgtm.yml | 12 + node_modules/mongoose/lib/aggregate.js | 1145 +++ node_modules/mongoose/lib/browser.js | 158 + node_modules/mongoose/lib/browserDocument.js | 101 + node_modules/mongoose/lib/cast.js | 380 + node_modules/mongoose/lib/cast/boolean.js | 32 + node_modules/mongoose/lib/cast/date.js | 41 + node_modules/mongoose/lib/cast/decimal128.js | 36 + node_modules/mongoose/lib/cast/number.js | 42 + node_modules/mongoose/lib/cast/objectid.js | 29 + node_modules/mongoose/lib/cast/string.js | 37 + node_modules/mongoose/lib/collection.js | 311 + node_modules/mongoose/lib/connection.js | 1552 ++++ node_modules/mongoose/lib/connectionstate.js | 26 + .../mongoose/lib/cursor/AggregationCursor.js | 380 + .../mongoose/lib/cursor/ChangeStream.js | 139 + .../mongoose/lib/cursor/QueryCursor.js | 519 ++ node_modules/mongoose/lib/document.js | 4590 ++++++++++ .../mongoose/lib/document_provider.js | 30 + node_modules/mongoose/lib/driver.js | 15 + node_modules/mongoose/lib/drivers/SPEC.md | 4 + .../lib/drivers/browser/ReadPreference.js | 7 + .../mongoose/lib/drivers/browser/binary.js | 14 + .../lib/drivers/browser/decimal128.js | 7 + .../mongoose/lib/drivers/browser/index.js | 16 + .../mongoose/lib/drivers/browser/objectid.js | 29 + .../node-mongodb-native/ReadPreference.js | 47 + .../lib/drivers/node-mongodb-native/binary.js | 10 + .../drivers/node-mongodb-native/collection.js | 419 + .../drivers/node-mongodb-native/connection.js | 166 + .../drivers/node-mongodb-native/decimal128.js | 7 + .../lib/drivers/node-mongodb-native/index.js | 12 + .../drivers/node-mongodb-native/objectid.js | 16 + .../lib/error/browserMissingSchema.js | 28 + node_modules/mongoose/lib/error/cast.js | 158 + .../mongoose/lib/error/disconnected.js | 33 + .../mongoose/lib/error/divergentArray.js | 38 + .../mongoose/lib/error/eachAsyncMultiError.js | 41 + node_modules/mongoose/lib/error/index.js | 217 + node_modules/mongoose/lib/error/messages.js | 47 + .../mongoose/lib/error/missingSchema.js | 31 + .../mongoose/lib/error/mongooseError.js | 13 + node_modules/mongoose/lib/error/notFound.js | 45 + .../mongoose/lib/error/objectExpected.js | 30 + .../mongoose/lib/error/objectParameter.js | 30 + .../mongoose/lib/error/overwriteModel.js | 30 + .../mongoose/lib/error/parallelSave.js | 30 + .../mongoose/lib/error/parallelValidate.js | 31 + .../mongoose/lib/error/serverSelection.js | 61 + node_modules/mongoose/lib/error/strict.js | 33 + .../mongoose/lib/error/strictPopulate.js | 29 + .../mongoose/lib/error/syncIndexes.js | 30 + node_modules/mongoose/lib/error/validation.js | 123 + node_modules/mongoose/lib/error/validator.js | 98 + node_modules/mongoose/lib/error/version.js | 36 + .../aggregate/prepareDiscriminatorPipeline.js | 37 + .../aggregate/stringifyFunctionOperators.js | 50 + .../mongoose/lib/helpers/arrayDepth.js | 33 + node_modules/mongoose/lib/helpers/clone.js | 177 + node_modules/mongoose/lib/helpers/common.js | 106 + .../mongoose/lib/helpers/cursor/eachAsync.js | 208 + .../areDiscriminatorValuesEqual.js | 16 + ...checkEmbeddedDiscriminatorKeyProjection.js | 12 + .../helpers/discriminator/getConstructor.js | 26 + .../discriminator/getDiscriminatorByValue.js | 28 + .../getSchemaDiscriminatorByValue.js | 27 + .../discriminator/mergeDiscriminatorSchema.js | 63 + .../lib/helpers/document/applyDefaults.js | 115 + .../helpers/document/cleanModifiedSubpaths.js | 35 + .../mongoose/lib/helpers/document/compile.js | 227 + .../document/getEmbeddedDiscriminatorPath.js | 50 + .../lib/helpers/document/handleSpreadDoc.js | 35 + node_modules/mongoose/lib/helpers/each.js | 25 + node_modules/mongoose/lib/helpers/firstKey.js | 8 + node_modules/mongoose/lib/helpers/get.js | 65 + .../lib/helpers/getConstructorName.js | 16 + .../lib/helpers/getDefaultBulkwriteResult.js | 27 + .../mongoose/lib/helpers/getFunctionName.js | 10 + .../mongoose/lib/helpers/immediate.js | 16 + .../helpers/indexes/applySchemaCollation.js | 13 + .../decorateDiscriminatorIndexOptions.js | 14 + .../lib/helpers/indexes/getRelatedIndexes.js | 59 + .../lib/helpers/indexes/isDefaultIdIndex.js | 18 + .../lib/helpers/indexes/isIndexEqual.js | 96 + .../lib/helpers/indexes/isTextIndex.js | 16 + .../mongoose/lib/helpers/isAsyncFunction.js | 22 + .../mongoose/lib/helpers/isBsonType.js | 16 + .../mongoose/lib/helpers/isMongooseObject.js | 22 + node_modules/mongoose/lib/helpers/isObject.js | 16 + .../mongoose/lib/helpers/isPromise.js | 6 + .../mongoose/lib/helpers/isSimpleValidator.js | 22 + .../lib/helpers/model/applyDefaultsToPOJO.js | 52 + .../mongoose/lib/helpers/model/applyHooks.js | 149 + .../lib/helpers/model/applyMethods.js | 70 + .../lib/helpers/model/applyStaticHooks.js | 71 + .../lib/helpers/model/applyStatics.js | 13 + .../lib/helpers/model/castBulkWrite.js | 240 + .../lib/helpers/model/discriminator.js | 210 + .../lib/helpers/model/pushNestedArrayPaths.js | 15 + node_modules/mongoose/lib/helpers/once.js | 12 + .../mongoose/lib/helpers/parallelLimit.js | 55 + .../path/flattenObjectWithDottedPaths.js | 39 + .../mongoose/lib/helpers/path/parentPaths.js | 18 + .../lib/helpers/path/setDottedPath.js | 33 + .../mongoose/lib/helpers/pluralize.js | 94 + .../lib/helpers/populate/SkipPopulateValue.js | 10 + .../populate/assignRawDocsToIdStructure.js | 111 + .../lib/helpers/populate/assignVals.js | 334 + .../populate/createPopulateQueryFilter.js | 86 + .../populate/getModelsMapForPopulate.js | 730 ++ .../lib/helpers/populate/getSchemaTypes.js | 231 + .../lib/helpers/populate/getVirtual.js | 72 + .../lib/helpers/populate/leanPopulateMap.js | 7 + .../lib/helpers/populate/lookupLocalFields.js | 40 + .../populate/markArraySubdocsPopulated.js | 47 + .../helpers/populate/modelNamesFromRefPath.js | 68 + .../populate/removeDeselectedForeignField.js | 31 + .../lib/helpers/populate/validateRef.js | 19 + .../mongoose/lib/helpers/printJestWarning.js | 17 + .../lib/helpers/processConnectionOptions.js | 64 + .../lib/helpers/projection/applyProjection.js | 77 + .../helpers/projection/hasIncludedChildren.js | 40 + .../projection/isDefiningProjection.js | 18 + .../lib/helpers/projection/isExclusive.js | 35 + .../lib/helpers/projection/isInclusive.js | 38 + .../lib/helpers/projection/isPathExcluded.js | 36 + .../projection/isPathSelectedInclusive.js | 28 + .../lib/helpers/projection/isSubpath.js | 14 + .../lib/helpers/projection/parseProjection.js | 33 + .../mongoose/lib/helpers/promiseOrCallback.js | 55 + .../lib/helpers/query/applyGlobalOption.js | 29 + .../lib/helpers/query/applyQueryMiddleware.js | 79 + .../mongoose/lib/helpers/query/cast$expr.js | 282 + .../lib/helpers/query/castFilterPath.js | 54 + .../mongoose/lib/helpers/query/castUpdate.js | 559 ++ .../lib/helpers/query/completeMany.js | 52 + .../query/getEmbeddedDiscriminatorPath.js | 90 + .../lib/helpers/query/handleImmutable.js | 28 + .../lib/helpers/query/hasDollarKeys.js | 23 + .../mongoose/lib/helpers/query/isOperator.js | 14 + .../lib/helpers/query/sanitizeFilter.js | 38 + .../lib/helpers/query/sanitizeProjection.js | 14 + .../helpers/query/selectPopulatedFields.js | 49 + .../mongoose/lib/helpers/query/trusted.js | 13 + .../mongoose/lib/helpers/query/validOps.js | 24 + .../mongoose/lib/helpers/query/wrapThunk.js | 31 + .../mongoose/lib/helpers/schema/addAutoId.js | 7 + .../lib/helpers/schema/applyPlugins.js | 55 + .../lib/helpers/schema/applyWriteConcern.js | 30 + .../schema/cleanPositionalOperators.js | 12 + .../mongoose/lib/helpers/schema/getIndexes.js | 164 + .../helpers/schema/getKeysInSchemaOrder.js | 28 + .../mongoose/lib/helpers/schema/getPath.js | 38 + .../lib/helpers/schema/handleIdOption.js | 20 + .../helpers/schema/handleTimestampOption.js | 24 + .../mongoose/lib/helpers/schema/idGetter.js | 32 + .../mongoose/lib/helpers/schema/merge.js | 27 + .../lib/helpers/schematype/handleImmutable.js | 50 + .../lib/helpers/setDefaultsOnInsert.js | 132 + .../mongoose/lib/helpers/specialProperties.js | 3 + node_modules/mongoose/lib/helpers/symbols.js | 20 + node_modules/mongoose/lib/helpers/timers.js | 3 + .../timestamps/setDocumentTimestamps.js | 26 + .../lib/helpers/timestamps/setupTimestamps.js | 101 + .../lib/helpers/topology/allServersUnknown.js | 12 + .../mongoose/lib/helpers/topology/isAtlas.js | 31 + .../lib/helpers/topology/isSSLError.js | 16 + .../update/applyTimestampsToChildren.js | 193 + .../helpers/update/applyTimestampsToUpdate.js | 117 + .../lib/helpers/update/castArrayFilters.js | 83 + .../lib/helpers/update/modifiedPaths.js | 33 + .../helpers/update/moveImmutableProperties.js | 53 + .../update/removeUnusedArrayFilters.js | 32 + .../update/updatedPathsByArrayFilter.js | 27 + .../mongoose/lib/helpers/updateValidators.js | 249 + node_modules/mongoose/lib/index.js | 1282 +++ node_modules/mongoose/lib/internal.js | 46 + node_modules/mongoose/lib/model.js | 5236 ++++++++++++ node_modules/mongoose/lib/options.js | 15 + .../mongoose/lib/options/PopulateOptions.js | 36 + .../lib/options/SchemaArrayOptions.js | 78 + .../lib/options/SchemaBufferOptions.js | 38 + .../mongoose/lib/options/SchemaDateOptions.js | 71 + .../lib/options/SchemaDocumentArrayOptions.js | 68 + .../mongoose/lib/options/SchemaMapOptions.js | 43 + .../lib/options/SchemaNumberOptions.js | 101 + .../lib/options/SchemaObjectIdOptions.js | 64 + .../lib/options/SchemaStringOptions.js | 138 + .../lib/options/SchemaSubdocumentOptions.js | 42 + .../mongoose/lib/options/SchemaTypeOptions.js | 244 + .../mongoose/lib/options/VirtualOptions.js | 164 + .../mongoose/lib/options/propertyOptions.js | 8 + .../mongoose/lib/options/removeOptions.js | 14 + .../mongoose/lib/options/saveOptions.js | 14 + .../mongoose/lib/plugins/clearValidating.js | 28 + .../mongoose/lib/plugins/removeSubdocs.js | 31 + .../mongoose/lib/plugins/saveSubdocs.js | 66 + node_modules/mongoose/lib/plugins/sharding.js | 83 + .../mongoose/lib/plugins/trackTransaction.js | 92 + .../lib/plugins/validateBeforeSave.js | 45 + node_modules/mongoose/lib/promise_provider.js | 49 + node_modules/mongoose/lib/query.js | 5952 +++++++++++++ node_modules/mongoose/lib/queryhelpers.js | 346 + node_modules/mongoose/lib/schema.js | 2488 ++++++ .../mongoose/lib/schema/SubdocumentPath.js | 366 + node_modules/mongoose/lib/schema/array.js | 663 ++ node_modules/mongoose/lib/schema/boolean.js | 267 + node_modules/mongoose/lib/schema/buffer.js | 269 + node_modules/mongoose/lib/schema/date.js | 404 + .../mongoose/lib/schema/decimal128.js | 210 + .../mongoose/lib/schema/documentarray.js | 617 ++ node_modules/mongoose/lib/schema/index.js | 37 + node_modules/mongoose/lib/schema/map.js | 84 + node_modules/mongoose/lib/schema/mixed.js | 132 + node_modules/mongoose/lib/schema/number.js | 438 + node_modules/mongoose/lib/schema/objectid.js | 295 + .../mongoose/lib/schema/operators/bitwise.js | 38 + .../mongoose/lib/schema/operators/exists.js | 12 + .../lib/schema/operators/geospatial.js | 107 + .../mongoose/lib/schema/operators/helpers.js | 32 + .../mongoose/lib/schema/operators/text.js | 39 + .../mongoose/lib/schema/operators/type.js | 20 + node_modules/mongoose/lib/schema/string.js | 694 ++ node_modules/mongoose/lib/schema/symbols.js | 5 + node_modules/mongoose/lib/schematype.js | 1724 ++++ node_modules/mongoose/lib/statemachine.js | 207 + .../mongoose/lib/types/ArraySubdocument.js | 189 + .../mongoose/lib/types/DocumentArray/index.js | 113 + .../DocumentArray/isMongooseDocumentArray.js | 5 + .../lib/types/DocumentArray/methods/index.js | 383 + .../mongoose/lib/types/array/index.js | 116 + .../lib/types/array/isMongooseArray.js | 5 + .../mongoose/lib/types/array/methods/index.js | 1015 +++ node_modules/mongoose/lib/types/buffer.js | 277 + node_modules/mongoose/lib/types/decimal128.js | 13 + node_modules/mongoose/lib/types/index.js | 20 + node_modules/mongoose/lib/types/map.js | 321 + node_modules/mongoose/lib/types/objectid.js | 41 + .../mongoose/lib/types/subdocument.js | 432 + node_modules/mongoose/lib/utils.js | 1009 +++ node_modules/mongoose/lib/validoptions.js | 36 + node_modules/mongoose/lib/virtualtype.js | 175 + node_modules/mongoose/mongoose-6.6.1.tgz | Bin 0 -> 513457 bytes .../mongoose/node_modules/ms/index.js | 162 + .../mongoose/node_modules/ms/license.md | 21 + .../mongoose/node_modules/ms/package.json | 38 + .../mongoose/node_modules/ms/readme.md | 59 + node_modules/mongoose/package.json | 148 + .../mongoose/scripts/build-browser.js | 18 + .../mongoose/scripts/create-tarball.js | 7 + node_modules/mongoose/tools/auth.js | 31 + node_modules/mongoose/tools/repl.js | 35 + node_modules/mongoose/tools/sharded.js | 46 + node_modules/mongoose/tsconfig.json | 9 + node_modules/mongoose/types/aggregate.d.ts | 229 + node_modules/mongoose/types/callback.d.ts | 8 + node_modules/mongoose/types/collection.d.ts | 46 + node_modules/mongoose/types/connection.d.ts | 242 + node_modules/mongoose/types/cursor.d.ts | 55 + node_modules/mongoose/types/document.d.ts | 266 + node_modules/mongoose/types/error.d.ts | 133 + node_modules/mongoose/types/expressions.d.ts | 2903 +++++++ node_modules/mongoose/types/helpers.d.ts | 32 + node_modules/mongoose/types/index.d.ts | 593 ++ node_modules/mongoose/types/indexes.d.ts | 98 + .../mongoose/types/inferschematype.d.ts | 172 + node_modules/mongoose/types/middlewares.d.ts | 14 + node_modules/mongoose/types/models.d.ts | 442 + .../mongoose/types/mongooseoptions.d.ts | 199 + .../mongoose/types/pipelinestage.d.ts | 281 + node_modules/mongoose/types/populate.d.ts | 40 + node_modules/mongoose/types/query.d.ts | 659 ++ .../mongoose/types/schemaoptions.d.ts | 217 + node_modules/mongoose/types/schematypes.d.ts | 427 + node_modules/mongoose/types/session.d.ts | 36 + node_modules/mongoose/types/types.d.ts | 104 + node_modules/mongoose/types/utility.d.ts | 41 + node_modules/mongoose/types/validation.d.ts | 32 + node_modules/mongoose/types/virtuals.d.ts | 14 + node_modules/morgan/HISTORY.md | 215 + node_modules/morgan/LICENSE | 23 + node_modules/morgan/README.md | 417 + node_modules/morgan/index.js | 544 ++ .../node_modules/on-finished/HISTORY.md | 88 + .../morgan/node_modules/on-finished/LICENSE | 23 + .../morgan/node_modules/on-finished/README.md | 154 + .../morgan/node_modules/on-finished/index.js | 196 + .../node_modules/on-finished/package.json | 31 + node_modules/morgan/package.json | 52 + node_modules/mpath/.travis.yml | 9 + node_modules/mpath/History.md | 88 + node_modules/mpath/LICENSE | 22 + node_modules/mpath/README.md | 278 + node_modules/mpath/SECURITY.md | 5 + node_modules/mpath/index.js | 3 + node_modules/mpath/lib/index.js | 336 + node_modules/mpath/lib/stringToParts.js | 48 + node_modules/mpath/package.json | 144 + node_modules/mpath/test/.eslintrc.yml | 4 + node_modules/mpath/test/index.js | 1879 ++++ node_modules/mpath/test/stringToParts.js | 30 + node_modules/mquery/.eslintignore | 1 + node_modules/mquery/.eslintrc.json | 123 + node_modules/mquery/.travis.yml | 15 + node_modules/mquery/History.md | 376 + node_modules/mquery/LICENSE | 22 + node_modules/mquery/Makefile | 26 + node_modules/mquery/README.md | 1373 +++ node_modules/mquery/SECURITY.md | 1 + .../mquery/lib/collection/collection.js | 47 + node_modules/mquery/lib/collection/index.js | 13 + node_modules/mquery/lib/collection/node.js | 132 + node_modules/mquery/lib/env.js | 22 + node_modules/mquery/lib/mquery.js | 3198 +++++++ node_modules/mquery/lib/permissions.js | 84 + node_modules/mquery/lib/utils.js | 335 + .../mquery/node_modules/debug/LICENSE | 20 + .../mquery/node_modules/debug/README.md | 481 ++ .../mquery/node_modules/debug/package.json | 59 + .../mquery/node_modules/debug/src/browser.js | 269 + .../mquery/node_modules/debug/src/common.js | 274 + .../mquery/node_modules/debug/src/index.js | 10 + .../mquery/node_modules/debug/src/node.js | 263 + node_modules/mquery/node_modules/ms/index.js | 162 + .../mquery/node_modules/ms/license.md | 21 + .../mquery/node_modules/ms/package.json | 37 + node_modules/mquery/node_modules/ms/readme.md | 60 + node_modules/mquery/package.json | 38 + node_modules/mquery/test/.eslintrc.yml | 2 + .../mquery/test/collection/browser.js | 0 node_modules/mquery/test/collection/mongo.js | 0 node_modules/mquery/test/collection/node.js | 29 + node_modules/mquery/test/env.js | 22 + node_modules/mquery/test/index.js | 2925 +++++++ node_modules/mquery/test/utils.test.js | 182 + node_modules/object-assign/index.js | 90 + node_modules/object-assign/license | 21 + node_modules/object-assign/package.json | 42 + node_modules/object-assign/readme.md | 61 + node_modules/on-headers/HISTORY.md | 21 + node_modules/on-headers/LICENSE | 22 + node_modules/on-headers/README.md | 81 + node_modules/on-headers/index.js | 132 + node_modules/on-headers/package.json | 42 + node_modules/punycode/LICENSE-MIT.txt | 20 + node_modules/punycode/README.md | 122 + node_modules/punycode/package.json | 58 + node_modules/punycode/punycode.es6.js | 441 + node_modules/punycode/punycode.js | 440 + node_modules/random-bytes/HISTORY.md | 4 + node_modules/random-bytes/LICENSE | 21 + node_modules/random-bytes/README.md | 77 + node_modules/random-bytes/index.js | 101 + node_modules/random-bytes/package.json | 36 + node_modules/saslprep/.editorconfig | 10 + node_modules/saslprep/.gitattributes | 1 + node_modules/saslprep/.travis.yml | 10 + node_modules/saslprep/CHANGELOG.md | 19 + node_modules/saslprep/LICENSE | 22 + node_modules/saslprep/code-points.mem | Bin 0 -> 419864 bytes node_modules/saslprep/generate-code-points.js | 51 + node_modules/saslprep/index.js | 157 + node_modules/saslprep/lib/code-points.js | 996 +++ .../saslprep/lib/memory-code-points.js | 39 + node_modules/saslprep/lib/util.js | 21 + node_modules/saslprep/package.json | 72 + node_modules/saslprep/readme.md | 31 + node_modules/saslprep/test/index.js | 76 + node_modules/saslprep/test/util.js | 16 + node_modules/sift/MIT-LICENSE.txt | 20 + node_modules/sift/README.md | 465 + node_modules/sift/es/index.js | 626 ++ node_modules/sift/es/index.js.map | 1 + node_modules/sift/es5m/index.js | 729 ++ node_modules/sift/es5m/index.js.map | 1 + node_modules/sift/index.d.ts | 4 + node_modules/sift/index.js | 4 + node_modules/sift/lib/core.d.ts | 119 + node_modules/sift/lib/index.d.ts | 6 + node_modules/sift/lib/index.js | 766 ++ node_modules/sift/lib/index.js.map | 1 + node_modules/sift/lib/operations.d.ts | 88 + node_modules/sift/lib/utils.d.ts | 9 + node_modules/sift/package.json | 62 + node_modules/sift/sift.csp.min.js | 763 ++ node_modules/sift/sift.csp.min.js.map | 1 + node_modules/sift/sift.min.js | 16 + node_modules/sift/sift.min.js.map | 1 + node_modules/sift/src/core.d.ts | 123 + node_modules/sift/src/core.js | 270 + node_modules/sift/src/core.js.map | 1 + node_modules/sift/src/core.ts | 479 ++ node_modules/sift/src/index.d.ts | 6 + node_modules/sift/src/index.js | 35 + node_modules/sift/src/index.js.map | 1 + node_modules/sift/src/index.ts | 42 + node_modules/sift/src/operations.d.ts | 85 + node_modules/sift/src/operations.js | 276 + node_modules/sift/src/operations.js.map | 1 + node_modules/sift/src/operations.ts | 411 + node_modules/sift/src/utils.d.ts | 9 + node_modules/sift/src/utils.js | 70 + node_modules/sift/src/utils.js.map | 1 + node_modules/sift/src/utils.ts | 68 + node_modules/smart-buffer/.prettierrc.yaml | 5 + node_modules/smart-buffer/.travis.yml | 13 + node_modules/smart-buffer/LICENSE | 20 + node_modules/smart-buffer/README.md | 633 ++ .../smart-buffer/build/smartbuffer.js | 1233 +++ .../smart-buffer/build/smartbuffer.js.map | 1 + node_modules/smart-buffer/build/utils.js | 108 + node_modules/smart-buffer/build/utils.js.map | 1 + node_modules/smart-buffer/docs/CHANGELOG.md | 70 + node_modules/smart-buffer/docs/README_v3.md | 367 + node_modules/smart-buffer/docs/ROADMAP.md | 0 node_modules/smart-buffer/package.json | 79 + .../smart-buffer/typings/smartbuffer.d.ts | 755 ++ node_modules/smart-buffer/typings/utils.d.ts | 66 + node_modules/socket.io-adapter/LICENSE | 20 + node_modules/socket.io-adapter/Readme.md | 23 + .../socket.io-adapter/dist/index.d.ts | 140 + node_modules/socket.io-adapter/dist/index.js | 275 + node_modules/socket.io-adapter/package.json | 29 + node_modules/socket.io-parser/LICENSE | 20 + node_modules/socket.io-parser/Readme.md | 81 + .../socket.io-parser/build/cjs/binary.js | 88 + .../socket.io-parser/build/cjs/index.js | 298 + .../socket.io-parser/build/cjs/is-binary.js | 55 + .../socket.io-parser/build/cjs/package.json | 3 + .../build/esm-debug/binary.d.ts | 20 + .../build/esm-debug/binary.js | 83 + .../build/esm-debug/index.d.ts | 90 + .../socket.io-parser/build/esm-debug/index.js | 293 + .../build/esm-debug/is-binary.d.ts | 7 + .../build/esm-debug/is-binary.js | 50 + .../build/esm-debug/package.json | 3 + .../socket.io-parser/build/esm/binary.d.ts | 20 + .../socket.io-parser/build/esm/binary.js | 83 + .../socket.io-parser/build/esm/index.d.ts | 90 + .../socket.io-parser/build/esm/index.js | 288 + .../socket.io-parser/build/esm/is-binary.d.ts | 7 + .../socket.io-parser/build/esm/is-binary.js | 50 + .../socket.io-parser/build/esm/package.json | 3 + .../node_modules/debug/LICENSE | 20 + .../node_modules/debug/README.md | 481 ++ .../node_modules/debug/package.json | 59 + .../node_modules/debug/src/browser.js | 269 + .../node_modules/debug/src/common.js | 274 + .../node_modules/debug/src/index.js | 10 + .../node_modules/debug/src/node.js | 263 + .../socket.io-parser/node_modules/ms/index.js | 162 + .../node_modules/ms/license.md | 21 + .../node_modules/ms/package.json | 37 + .../node_modules/ms/readme.md | 60 + node_modules/socket.io-parser/package.json | 55 + node_modules/socket.io/LICENSE | 22 + node_modules/socket.io/Readme.md | 269 + .../client-dist/socket.io.esm.min.js | 7 + .../client-dist/socket.io.esm.min.js.map | 1 + .../socket.io/client-dist/socket.io.js | 4438 ++++++++++ .../socket.io/client-dist/socket.io.js.map | 1 + .../socket.io/client-dist/socket.io.min.js | 7 + .../client-dist/socket.io.min.js.map | 1 + .../client-dist/socket.io.msgpack.min.js | 7 + .../client-dist/socket.io.msgpack.min.js.map | 1 + .../socket.io/dist/broadcast-operator.d.ts | 158 + .../socket.io/dist/broadcast-operator.js | 291 + node_modules/socket.io/dist/client.d.ts | 119 + node_modules/socket.io/dist/client.js | 267 + node_modules/socket.io/dist/index.d.ts | 342 + node_modules/socket.io/dist/index.js | 603 ++ node_modules/socket.io/dist/namespace.d.ts | 204 + node_modules/socket.io/dist/namespace.js | 310 + .../socket.io/dist/parent-namespace.d.ts | 15 + .../socket.io/dist/parent-namespace.js | 47 + node_modules/socket.io/dist/socket.d.ts | 451 + node_modules/socket.io/dist/socket.js | 714 ++ node_modules/socket.io/dist/typed-events.d.ts | 110 + node_modules/socket.io/dist/typed-events.js | 81 + node_modules/socket.io/dist/uws.d.ts | 3 + node_modules/socket.io/dist/uws.js | 135 + .../socket.io/node_modules/debug/LICENSE | 20 + .../socket.io/node_modules/debug/README.md | 481 ++ .../socket.io/node_modules/debug/package.json | 59 + .../node_modules/debug/src/browser.js | 269 + .../node_modules/debug/src/common.js | 274 + .../socket.io/node_modules/debug/src/index.js | 10 + .../socket.io/node_modules/debug/src/node.js | 263 + .../socket.io/node_modules/ms/index.js | 162 + .../socket.io/node_modules/ms/license.md | 21 + .../socket.io/node_modules/ms/package.json | 37 + .../socket.io/node_modules/ms/readme.md | 60 + node_modules/socket.io/package.json | 96 + node_modules/socket.io/wrapper.mjs | 3 + node_modules/socks/.eslintrc.cjs | 11 + node_modules/socks/.prettierrc.yaml | 7 + node_modules/socks/LICENSE | 20 + node_modules/socks/README.md | 686 ++ .../socks/build/client/socksclient.js | 795 ++ .../socks/build/client/socksclient.js.map | 1 + node_modules/socks/build/common/constants.js | 114 + .../socks/build/common/constants.js.map | 1 + node_modules/socks/build/common/helpers.js | 128 + .../socks/build/common/helpers.js.map | 1 + .../socks/build/common/receivebuffer.js | 43 + .../socks/build/common/receivebuffer.js.map | 1 + node_modules/socks/build/common/util.js | 25 + node_modules/socks/build/common/util.js.map | 1 + node_modules/socks/build/index.js | 18 + node_modules/socks/build/index.js.map | 1 + node_modules/socks/docs/examples/index.md | 17 + .../examples/javascript/associateExample.md | 90 + .../docs/examples/javascript/bindExample.md | 83 + .../examples/javascript/connectExample.md | 258 + .../examples/typescript/associateExample.md | 93 + .../docs/examples/typescript/bindExample.md | 86 + .../examples/typescript/connectExample.md | 265 + node_modules/socks/docs/index.md | 5 + node_modules/socks/docs/migratingFromV1.md | 86 + node_modules/socks/package.json | 58 + .../socks/typings/client/socksclient.d.ts | 162 + .../socks/typings/common/constants.d.ts | 152 + .../socks/typings/common/helpers.d.ts | 13 + .../socks/typings/common/receivebuffer.d.ts | 12 + node_modules/socks/typings/common/util.d.ts | 17 + node_modules/socks/typings/index.d.ts | 1 + node_modules/sparse-bitfield/.npmignore | 1 + node_modules/sparse-bitfield/.travis.yml | 6 + node_modules/sparse-bitfield/LICENSE | 21 + node_modules/sparse-bitfield/README.md | 62 + node_modules/sparse-bitfield/index.js | 95 + node_modules/sparse-bitfield/package.json | 27 + node_modules/sparse-bitfield/test.js | 79 + node_modules/tr46/LICENSE.md | 21 + node_modules/tr46/README.md | 78 + node_modules/tr46/index.js | 298 + node_modules/tr46/lib/mappingTable.json | 1 + node_modules/tr46/lib/regexes.js | 29 + node_modules/tr46/lib/statusMapping.js | 11 + node_modules/tr46/package.json | 47 + node_modules/uid-safe/HISTORY.md | 61 + node_modules/uid-safe/LICENSE | 22 + node_modules/uid-safe/README.md | 77 + node_modules/uid-safe/index.js | 107 + node_modules/uid-safe/package.json | 46 + node_modules/webidl-conversions/LICENSE.md | 12 + node_modules/webidl-conversions/README.md | 99 + node_modules/webidl-conversions/lib/index.js | 450 + node_modules/webidl-conversions/package.json | 35 + node_modules/whatwg-url/LICENSE.txt | 21 + node_modules/whatwg-url/README.md | 106 + node_modules/whatwg-url/index.js | 27 + node_modules/whatwg-url/lib/Function.js | 42 + node_modules/whatwg-url/lib/URL-impl.js | 209 + node_modules/whatwg-url/lib/URL.js | 442 + .../whatwg-url/lib/URLSearchParams-impl.js | 130 + .../whatwg-url/lib/URLSearchParams.js | 472 ++ node_modules/whatwg-url/lib/VoidFunction.js | 26 + node_modules/whatwg-url/lib/encoding.js | 16 + node_modules/whatwg-url/lib/infra.js | 26 + .../whatwg-url/lib/percent-encoding.js | 142 + .../whatwg-url/lib/url-state-machine.js | 1244 +++ node_modules/whatwg-url/lib/urlencoded.js | 106 + node_modules/whatwg-url/lib/utils.js | 190 + node_modules/whatwg-url/package.json | 58 + node_modules/whatwg-url/webidl2js-wrapper.js | 7 + node_modules/ws/LICENSE | 19 + node_modules/ws/README.md | 493 ++ node_modules/ws/browser.js | 8 + node_modules/ws/index.js | 13 + node_modules/ws/lib/buffer-util.js | 126 + node_modules/ws/lib/constants.js | 12 + node_modules/ws/lib/event-target.js | 266 + node_modules/ws/lib/extension.js | 203 + node_modules/ws/lib/limiter.js | 55 + node_modules/ws/lib/permessage-deflate.js | 511 ++ node_modules/ws/lib/receiver.js | 612 ++ node_modules/ws/lib/sender.js | 422 + node_modules/ws/lib/stream.js | 180 + node_modules/ws/lib/subprotocol.js | 62 + node_modules/ws/lib/validation.js | 124 + node_modules/ws/lib/websocket-server.js | 485 ++ node_modules/ws/lib/websocket.js | 1149 +++ node_modules/ws/package.json | 61 + node_modules/ws/wrapper.mjs | 8 + package-lock.json | 1021 ++- package.json | 9 +- partials/footer.ejs | 2 + partials/head.ejs | 5 + partials/menu.ejs | 15 + public/css/style.css | 78 + public/js/home.js | 34 + public/js/main.js | 31 + public/js/post.js | 116 + public/js/search.js | 29 + public/main.js | 30 - public/style.css | 3 - replies.json | 7 + view/index.ejs | 24 + view/post.ejs | 30 + view/search.ejs | 22 + views/index.ejs | 19 - views/post.ejs | 12 - 1219 files changed, 238646 insertions(+), 96 deletions(-) create mode 100644 node_modules/@socket.io/component-emitter/LICENSE create mode 100644 node_modules/@socket.io/component-emitter/Readme.md create mode 100644 node_modules/@socket.io/component-emitter/index.d.ts create mode 100644 node_modules/@socket.io/component-emitter/index.js create mode 100644 node_modules/@socket.io/component-emitter/index.mjs create mode 100644 node_modules/@socket.io/component-emitter/package.json create mode 100755 node_modules/@types/cookie/LICENSE create mode 100755 node_modules/@types/cookie/README.md create mode 100755 node_modules/@types/cookie/index.d.ts create mode 100755 node_modules/@types/cookie/package.json create mode 100755 node_modules/@types/cors/LICENSE create mode 100755 node_modules/@types/cors/README.md create mode 100755 node_modules/@types/cors/index.d.ts create mode 100755 node_modules/@types/cors/package.json create mode 100755 node_modules/@types/webidl-conversions/LICENSE create mode 100755 node_modules/@types/webidl-conversions/README.md create mode 100755 node_modules/@types/webidl-conversions/index.d.ts create mode 100755 node_modules/@types/webidl-conversions/package.json create mode 100755 node_modules/@types/whatwg-url/LICENSE create mode 100755 node_modules/@types/whatwg-url/README.md create mode 100755 node_modules/@types/whatwg-url/dist/URL-impl.d.ts create mode 100755 node_modules/@types/whatwg-url/dist/URL.d.ts create mode 100755 node_modules/@types/whatwg-url/dist/URLSearchParams-impl.d.ts create mode 100755 node_modules/@types/whatwg-url/dist/URLSearchParams.d.ts create mode 100755 node_modules/@types/whatwg-url/index.d.ts create mode 100755 node_modules/@types/whatwg-url/package.json create mode 100755 node_modules/@types/whatwg-url/webidl2js-wrapper.d.ts create mode 100644 node_modules/base64-js/LICENSE create mode 100644 node_modules/base64-js/README.md create mode 100644 node_modules/base64-js/base64js.min.js create mode 100644 node_modules/base64-js/index.d.ts create mode 100644 node_modules/base64-js/index.js create mode 100644 node_modules/base64-js/package.json create mode 100644 node_modules/base64id/CHANGELOG.md create mode 100644 node_modules/base64id/LICENSE create mode 100644 node_modules/base64id/README.md create mode 100644 node_modules/base64id/lib/base64id.js create mode 100644 node_modules/base64id/package.json create mode 100644 node_modules/basic-auth/HISTORY.md create mode 100644 node_modules/basic-auth/LICENSE create mode 100644 node_modules/basic-auth/README.md create mode 100644 node_modules/basic-auth/index.js create mode 100644 node_modules/basic-auth/node_modules/safe-buffer/LICENSE create mode 100644 node_modules/basic-auth/node_modules/safe-buffer/README.md create mode 100644 node_modules/basic-auth/node_modules/safe-buffer/index.d.ts create mode 100644 node_modules/basic-auth/node_modules/safe-buffer/index.js create mode 100644 node_modules/basic-auth/node_modules/safe-buffer/package.json create mode 100644 node_modules/basic-auth/package.json create mode 100644 node_modules/bson/LICENSE.md create mode 100644 node_modules/bson/README.md create mode 100644 node_modules/bson/bower.json create mode 100644 node_modules/bson/bson.d.ts create mode 100644 node_modules/bson/dist/bson.browser.esm.js create mode 100644 node_modules/bson/dist/bson.browser.esm.js.map create mode 100644 node_modules/bson/dist/bson.browser.umd.js create mode 100644 node_modules/bson/dist/bson.browser.umd.js.map create mode 100644 node_modules/bson/dist/bson.bundle.js create mode 100644 node_modules/bson/dist/bson.bundle.js.map create mode 100644 node_modules/bson/dist/bson.esm.js create mode 100644 node_modules/bson/dist/bson.esm.js.map create mode 100755 node_modules/bson/etc/prepare.js create mode 100644 node_modules/bson/lib/binary.js create mode 100644 node_modules/bson/lib/binary.js.map create mode 100644 node_modules/bson/lib/bson.js create mode 100644 node_modules/bson/lib/bson.js.map create mode 100644 node_modules/bson/lib/code.js create mode 100644 node_modules/bson/lib/code.js.map create mode 100644 node_modules/bson/lib/constants.js create mode 100644 node_modules/bson/lib/constants.js.map create mode 100644 node_modules/bson/lib/db_ref.js create mode 100644 node_modules/bson/lib/db_ref.js.map create mode 100644 node_modules/bson/lib/decimal128.js create mode 100644 node_modules/bson/lib/decimal128.js.map create mode 100644 node_modules/bson/lib/double.js create mode 100644 node_modules/bson/lib/double.js.map create mode 100644 node_modules/bson/lib/ensure_buffer.js create mode 100644 node_modules/bson/lib/ensure_buffer.js.map create mode 100644 node_modules/bson/lib/error.js create mode 100644 node_modules/bson/lib/error.js.map create mode 100644 node_modules/bson/lib/extended_json.js create mode 100644 node_modules/bson/lib/extended_json.js.map create mode 100644 node_modules/bson/lib/int_32.js create mode 100644 node_modules/bson/lib/int_32.js.map create mode 100644 node_modules/bson/lib/long.js create mode 100644 node_modules/bson/lib/long.js.map create mode 100644 node_modules/bson/lib/map.js create mode 100644 node_modules/bson/lib/map.js.map create mode 100644 node_modules/bson/lib/max_key.js create mode 100644 node_modules/bson/lib/max_key.js.map create mode 100644 node_modules/bson/lib/min_key.js create mode 100644 node_modules/bson/lib/min_key.js.map create mode 100644 node_modules/bson/lib/objectid.js create mode 100644 node_modules/bson/lib/objectid.js.map create mode 100644 node_modules/bson/lib/parser/calculate_size.js create mode 100644 node_modules/bson/lib/parser/calculate_size.js.map create mode 100644 node_modules/bson/lib/parser/deserializer.js create mode 100644 node_modules/bson/lib/parser/deserializer.js.map create mode 100644 node_modules/bson/lib/parser/serializer.js create mode 100644 node_modules/bson/lib/parser/serializer.js.map create mode 100644 node_modules/bson/lib/parser/utils.js create mode 100644 node_modules/bson/lib/parser/utils.js.map create mode 100644 node_modules/bson/lib/regexp.js create mode 100644 node_modules/bson/lib/regexp.js.map create mode 100644 node_modules/bson/lib/symbol.js create mode 100644 node_modules/bson/lib/symbol.js.map create mode 100644 node_modules/bson/lib/timestamp.js create mode 100644 node_modules/bson/lib/timestamp.js.map create mode 100644 node_modules/bson/lib/utils/global.js create mode 100644 node_modules/bson/lib/utils/global.js.map create mode 100644 node_modules/bson/lib/uuid_utils.js create mode 100644 node_modules/bson/lib/uuid_utils.js.map create mode 100644 node_modules/bson/lib/validate_utf8.js create mode 100644 node_modules/bson/lib/validate_utf8.js.map create mode 100644 node_modules/bson/package.json create mode 100644 node_modules/bson/src/binary.ts create mode 100644 node_modules/bson/src/bson.ts create mode 100644 node_modules/bson/src/code.ts create mode 100644 node_modules/bson/src/constants.ts create mode 100644 node_modules/bson/src/db_ref.ts create mode 100644 node_modules/bson/src/decimal128.ts create mode 100644 node_modules/bson/src/double.ts create mode 100644 node_modules/bson/src/ensure_buffer.ts create mode 100644 node_modules/bson/src/error.ts create mode 100644 node_modules/bson/src/extended_json.ts create mode 100644 node_modules/bson/src/int_32.ts create mode 100644 node_modules/bson/src/long.ts create mode 100644 node_modules/bson/src/map.ts create mode 100644 node_modules/bson/src/max_key.ts create mode 100644 node_modules/bson/src/min_key.ts create mode 100644 node_modules/bson/src/objectid.ts create mode 100644 node_modules/bson/src/parser/calculate_size.ts create mode 100644 node_modules/bson/src/parser/deserializer.ts create mode 100644 node_modules/bson/src/parser/serializer.ts create mode 100644 node_modules/bson/src/parser/utils.ts create mode 100644 node_modules/bson/src/regexp.ts create mode 100644 node_modules/bson/src/symbol.ts create mode 100644 node_modules/bson/src/timestamp.ts create mode 100644 node_modules/bson/src/utils/global.ts create mode 100644 node_modules/bson/src/uuid_utils.ts create mode 100644 node_modules/bson/src/validate_utf8.ts create mode 100644 node_modules/buffer/AUTHORS.md create mode 100644 node_modules/buffer/LICENSE create mode 100644 node_modules/buffer/README.md create mode 100644 node_modules/buffer/index.d.ts create mode 100644 node_modules/buffer/index.js create mode 100644 node_modules/buffer/package.json create mode 100644 node_modules/cors/CONTRIBUTING.md create mode 100644 node_modules/cors/HISTORY.md create mode 100644 node_modules/cors/LICENSE create mode 100644 node_modules/cors/README.md create mode 100644 node_modules/cors/lib/index.js create mode 100644 node_modules/cors/package.json create mode 100644 node_modules/denque/CHANGELOG.md create mode 100644 node_modules/denque/LICENSE create mode 100644 node_modules/denque/README.md create mode 100644 node_modules/denque/index.d.ts create mode 100644 node_modules/denque/index.js create mode 100644 node_modules/denque/package.json create mode 100644 node_modules/engine.io-parser/LICENSE create mode 100644 node_modules/engine.io-parser/Readme.md create mode 100644 node_modules/engine.io-parser/build/cjs/commons.js create mode 100644 node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js create mode 100644 node_modules/engine.io-parser/build/cjs/decodePacket.browser.js create mode 100644 node_modules/engine.io-parser/build/cjs/decodePacket.js create mode 100644 node_modules/engine.io-parser/build/cjs/encodePacket.browser.js create mode 100644 node_modules/engine.io-parser/build/cjs/encodePacket.js create mode 100644 node_modules/engine.io-parser/build/cjs/index.js create mode 100644 node_modules/engine.io-parser/build/cjs/package.json create mode 100644 node_modules/engine.io-parser/build/esm/commons.d.ts create mode 100644 node_modules/engine.io-parser/build/esm/commons.js create mode 100644 node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts create mode 100644 node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js create mode 100644 node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts create mode 100644 node_modules/engine.io-parser/build/esm/decodePacket.browser.js create mode 100644 node_modules/engine.io-parser/build/esm/decodePacket.d.ts create mode 100644 node_modules/engine.io-parser/build/esm/decodePacket.js create mode 100644 node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts create mode 100644 node_modules/engine.io-parser/build/esm/encodePacket.browser.js create mode 100644 node_modules/engine.io-parser/build/esm/encodePacket.d.ts create mode 100644 node_modules/engine.io-parser/build/esm/encodePacket.js create mode 100644 node_modules/engine.io-parser/build/esm/index.d.ts create mode 100644 node_modules/engine.io-parser/build/esm/index.js create mode 100644 node_modules/engine.io-parser/build/esm/package.json create mode 100644 node_modules/engine.io-parser/package.json create mode 100644 node_modules/engine.io/LICENSE create mode 100644 node_modules/engine.io/README.md create mode 100644 node_modules/engine.io/build/engine.io.d.ts create mode 100644 node_modules/engine.io/build/engine.io.js create mode 100644 node_modules/engine.io/build/parser-v3/index.d.ts create mode 100644 node_modules/engine.io/build/parser-v3/index.js create mode 100644 node_modules/engine.io/build/parser-v3/utf8.d.ts create mode 100644 node_modules/engine.io/build/parser-v3/utf8.js create mode 100644 node_modules/engine.io/build/server.d.ts create mode 100644 node_modules/engine.io/build/server.js create mode 100644 node_modules/engine.io/build/socket.d.ts create mode 100644 node_modules/engine.io/build/socket.js create mode 100644 node_modules/engine.io/build/transport.d.ts create mode 100644 node_modules/engine.io/build/transport.js create mode 100644 node_modules/engine.io/build/transports-uws/index.d.ts create mode 100644 node_modules/engine.io/build/transports-uws/index.js create mode 100644 node_modules/engine.io/build/transports-uws/polling.d.ts create mode 100644 node_modules/engine.io/build/transports-uws/polling.js create mode 100644 node_modules/engine.io/build/transports-uws/websocket.d.ts create mode 100644 node_modules/engine.io/build/transports-uws/websocket.js create mode 100644 node_modules/engine.io/build/transports/index.d.ts create mode 100644 node_modules/engine.io/build/transports/index.js create mode 100644 node_modules/engine.io/build/transports/polling-jsonp.d.ts create mode 100644 node_modules/engine.io/build/transports/polling-jsonp.js create mode 100644 node_modules/engine.io/build/transports/polling.d.ts create mode 100644 node_modules/engine.io/build/transports/polling.js create mode 100644 node_modules/engine.io/build/transports/websocket.d.ts create mode 100644 node_modules/engine.io/build/transports/websocket.js create mode 100644 node_modules/engine.io/build/userver.d.ts create mode 100644 node_modules/engine.io/build/userver.js create mode 100644 node_modules/engine.io/node_modules/cookie/HISTORY.md create mode 100644 node_modules/engine.io/node_modules/cookie/LICENSE create mode 100644 node_modules/engine.io/node_modules/cookie/README.md create mode 100644 node_modules/engine.io/node_modules/cookie/index.js create mode 100644 node_modules/engine.io/node_modules/cookie/package.json create mode 100644 node_modules/engine.io/node_modules/debug/LICENSE create mode 100644 node_modules/engine.io/node_modules/debug/README.md create mode 100644 node_modules/engine.io/node_modules/debug/package.json create mode 100644 node_modules/engine.io/node_modules/debug/src/browser.js create mode 100644 node_modules/engine.io/node_modules/debug/src/common.js create mode 100644 node_modules/engine.io/node_modules/debug/src/index.js create mode 100644 node_modules/engine.io/node_modules/debug/src/node.js create mode 100644 node_modules/engine.io/node_modules/ms/index.js create mode 100644 node_modules/engine.io/node_modules/ms/license.md create mode 100644 node_modules/engine.io/node_modules/ms/package.json create mode 100644 node_modules/engine.io/node_modules/ms/readme.md create mode 100644 node_modules/engine.io/package.json create mode 100644 node_modules/engine.io/wrapper.mjs create mode 100644 node_modules/errorhandler/HISTORY.md create mode 100644 node_modules/errorhandler/LICENSE create mode 100644 node_modules/errorhandler/README.md create mode 100644 node_modules/errorhandler/index.js create mode 100644 node_modules/errorhandler/package.json create mode 100644 node_modules/errorhandler/public/error.html create mode 100644 node_modules/errorhandler/public/style.css create mode 100644 node_modules/express-session/HISTORY.md create mode 100644 node_modules/express-session/LICENSE create mode 100644 node_modules/express-session/README.md create mode 100644 node_modules/express-session/index.js create mode 100644 node_modules/express-session/node_modules/cookie/HISTORY.md create mode 100644 node_modules/express-session/node_modules/cookie/LICENSE create mode 100644 node_modules/express-session/node_modules/cookie/README.md create mode 100644 node_modules/express-session/node_modules/cookie/index.js create mode 100644 node_modules/express-session/node_modules/cookie/package.json create mode 100644 node_modules/express-session/package.json create mode 100644 node_modules/express-session/session/cookie.js create mode 100644 node_modules/express-session/session/memory.js create mode 100644 node_modules/express-session/session/session.js create mode 100644 node_modules/express-session/session/store.js create mode 100644 node_modules/ieee754/LICENSE create mode 100644 node_modules/ieee754/README.md create mode 100644 node_modules/ieee754/index.d.ts create mode 100644 node_modules/ieee754/index.js create mode 100644 node_modules/ieee754/package.json create mode 100644 node_modules/ip/README.md create mode 100644 node_modules/ip/lib/ip.js create mode 100644 node_modules/ip/package.json create mode 100644 node_modules/kareem/.eslintrc.json create mode 100644 node_modules/kareem/.github/workflows/test.yml create mode 100644 node_modules/kareem/.travis.yml create mode 100644 node_modules/kareem/CHANGELOG.md create mode 100644 node_modules/kareem/LICENSE create mode 100644 node_modules/kareem/Makefile create mode 100644 node_modules/kareem/README.md create mode 100644 node_modules/kareem/docs.js create mode 100644 node_modules/kareem/index.js create mode 100644 node_modules/kareem/package.json create mode 100644 node_modules/kareem/test/examples.test.js create mode 100644 node_modules/kareem/test/misc.test.js create mode 100644 node_modules/kareem/test/post.test.js create mode 100644 node_modules/kareem/test/pre.test.js create mode 100644 node_modules/kareem/test/wrap.test.js create mode 100644 node_modules/memory-pager/.travis.yml create mode 100644 node_modules/memory-pager/LICENSE create mode 100644 node_modules/memory-pager/README.md create mode 100644 node_modules/memory-pager/index.js create mode 100644 node_modules/memory-pager/package.json create mode 100644 node_modules/memory-pager/test.js create mode 100644 node_modules/mongodb-connection-string-url/.esm-wrapper.mjs create mode 100644 node_modules/mongodb-connection-string-url/LICENSE create mode 100644 node_modules/mongodb-connection-string-url/README.md create mode 100644 node_modules/mongodb-connection-string-url/lib/index.d.ts create mode 100644 node_modules/mongodb-connection-string-url/lib/index.js create mode 100644 node_modules/mongodb-connection-string-url/lib/index.js.map create mode 100644 node_modules/mongodb-connection-string-url/lib/redact.d.ts create mode 100644 node_modules/mongodb-connection-string-url/lib/redact.js create mode 100644 node_modules/mongodb-connection-string-url/lib/redact.js.map create mode 100644 node_modules/mongodb-connection-string-url/package.json create mode 100644 node_modules/mongodb/LICENSE.md create mode 100644 node_modules/mongodb/README.md create mode 100755 node_modules/mongodb/etc/prepare.js create mode 100644 node_modules/mongodb/lib/admin.js create mode 100644 node_modules/mongodb/lib/admin.js.map create mode 100644 node_modules/mongodb/lib/bson.js create mode 100644 node_modules/mongodb/lib/bson.js.map create mode 100644 node_modules/mongodb/lib/bulk/common.js create mode 100644 node_modules/mongodb/lib/bulk/common.js.map create mode 100644 node_modules/mongodb/lib/bulk/ordered.js create mode 100644 node_modules/mongodb/lib/bulk/ordered.js.map create mode 100644 node_modules/mongodb/lib/bulk/unordered.js create mode 100644 node_modules/mongodb/lib/bulk/unordered.js.map create mode 100644 node_modules/mongodb/lib/change_stream.js create mode 100644 node_modules/mongodb/lib/change_stream.js.map create mode 100644 node_modules/mongodb/lib/cmap/auth/auth_provider.js create mode 100644 node_modules/mongodb/lib/cmap/auth/auth_provider.js.map create mode 100644 node_modules/mongodb/lib/cmap/auth/gssapi.js create mode 100644 node_modules/mongodb/lib/cmap/auth/gssapi.js.map create mode 100644 node_modules/mongodb/lib/cmap/auth/mongo_credentials.js create mode 100644 node_modules/mongodb/lib/cmap/auth/mongo_credentials.js.map create mode 100644 node_modules/mongodb/lib/cmap/auth/mongocr.js create mode 100644 node_modules/mongodb/lib/cmap/auth/mongocr.js.map create mode 100644 node_modules/mongodb/lib/cmap/auth/mongodb_aws.js create mode 100644 node_modules/mongodb/lib/cmap/auth/mongodb_aws.js.map create mode 100644 node_modules/mongodb/lib/cmap/auth/plain.js create mode 100644 node_modules/mongodb/lib/cmap/auth/plain.js.map create mode 100644 node_modules/mongodb/lib/cmap/auth/providers.js create mode 100644 node_modules/mongodb/lib/cmap/auth/providers.js.map create mode 100644 node_modules/mongodb/lib/cmap/auth/scram.js create mode 100644 node_modules/mongodb/lib/cmap/auth/scram.js.map create mode 100644 node_modules/mongodb/lib/cmap/auth/x509.js create mode 100644 node_modules/mongodb/lib/cmap/auth/x509.js.map create mode 100644 node_modules/mongodb/lib/cmap/command_monitoring_events.js create mode 100644 node_modules/mongodb/lib/cmap/command_monitoring_events.js.map create mode 100644 node_modules/mongodb/lib/cmap/commands.js create mode 100644 node_modules/mongodb/lib/cmap/commands.js.map create mode 100644 node_modules/mongodb/lib/cmap/connect.js create mode 100644 node_modules/mongodb/lib/cmap/connect.js.map create mode 100644 node_modules/mongodb/lib/cmap/connection.js create mode 100644 node_modules/mongodb/lib/cmap/connection.js.map create mode 100644 node_modules/mongodb/lib/cmap/connection_pool.js create mode 100644 node_modules/mongodb/lib/cmap/connection_pool.js.map create mode 100644 node_modules/mongodb/lib/cmap/connection_pool_events.js create mode 100644 node_modules/mongodb/lib/cmap/connection_pool_events.js.map create mode 100644 node_modules/mongodb/lib/cmap/errors.js create mode 100644 node_modules/mongodb/lib/cmap/errors.js.map create mode 100644 node_modules/mongodb/lib/cmap/message_stream.js create mode 100644 node_modules/mongodb/lib/cmap/message_stream.js.map create mode 100644 node_modules/mongodb/lib/cmap/metrics.js create mode 100644 node_modules/mongodb/lib/cmap/metrics.js.map create mode 100644 node_modules/mongodb/lib/cmap/stream_description.js create mode 100644 node_modules/mongodb/lib/cmap/stream_description.js.map create mode 100644 node_modules/mongodb/lib/cmap/wire_protocol/compression.js create mode 100644 node_modules/mongodb/lib/cmap/wire_protocol/compression.js.map create mode 100644 node_modules/mongodb/lib/cmap/wire_protocol/constants.js create mode 100644 node_modules/mongodb/lib/cmap/wire_protocol/constants.js.map create mode 100644 node_modules/mongodb/lib/cmap/wire_protocol/shared.js create mode 100644 node_modules/mongodb/lib/cmap/wire_protocol/shared.js.map create mode 100644 node_modules/mongodb/lib/collection.js create mode 100644 node_modules/mongodb/lib/collection.js.map create mode 100644 node_modules/mongodb/lib/connection_string.js create mode 100644 node_modules/mongodb/lib/connection_string.js.map create mode 100644 node_modules/mongodb/lib/constants.js create mode 100644 node_modules/mongodb/lib/constants.js.map create mode 100644 node_modules/mongodb/lib/cursor/abstract_cursor.js create mode 100644 node_modules/mongodb/lib/cursor/abstract_cursor.js.map create mode 100644 node_modules/mongodb/lib/cursor/aggregation_cursor.js create mode 100644 node_modules/mongodb/lib/cursor/aggregation_cursor.js.map create mode 100644 node_modules/mongodb/lib/cursor/change_stream_cursor.js create mode 100644 node_modules/mongodb/lib/cursor/change_stream_cursor.js.map create mode 100644 node_modules/mongodb/lib/cursor/find_cursor.js create mode 100644 node_modules/mongodb/lib/cursor/find_cursor.js.map create mode 100644 node_modules/mongodb/lib/cursor/list_collections_cursor.js create mode 100644 node_modules/mongodb/lib/cursor/list_collections_cursor.js.map create mode 100644 node_modules/mongodb/lib/cursor/list_indexes_cursor.js create mode 100644 node_modules/mongodb/lib/cursor/list_indexes_cursor.js.map create mode 100644 node_modules/mongodb/lib/db.js create mode 100644 node_modules/mongodb/lib/db.js.map create mode 100644 node_modules/mongodb/lib/deps.js create mode 100644 node_modules/mongodb/lib/deps.js.map create mode 100644 node_modules/mongodb/lib/encrypter.js create mode 100644 node_modules/mongodb/lib/encrypter.js.map create mode 100644 node_modules/mongodb/lib/error.js create mode 100644 node_modules/mongodb/lib/error.js.map create mode 100644 node_modules/mongodb/lib/explain.js create mode 100644 node_modules/mongodb/lib/explain.js.map create mode 100644 node_modules/mongodb/lib/gridfs/download.js create mode 100644 node_modules/mongodb/lib/gridfs/download.js.map create mode 100644 node_modules/mongodb/lib/gridfs/index.js create mode 100644 node_modules/mongodb/lib/gridfs/index.js.map create mode 100644 node_modules/mongodb/lib/gridfs/upload.js create mode 100644 node_modules/mongodb/lib/gridfs/upload.js.map create mode 100644 node_modules/mongodb/lib/index.js create mode 100644 node_modules/mongodb/lib/index.js.map create mode 100644 node_modules/mongodb/lib/logger.js create mode 100644 node_modules/mongodb/lib/logger.js.map create mode 100644 node_modules/mongodb/lib/mongo_client.js create mode 100644 node_modules/mongodb/lib/mongo_client.js.map create mode 100644 node_modules/mongodb/lib/mongo_types.js create mode 100644 node_modules/mongodb/lib/mongo_types.js.map create mode 100644 node_modules/mongodb/lib/operations/add_user.js create mode 100644 node_modules/mongodb/lib/operations/add_user.js.map create mode 100644 node_modules/mongodb/lib/operations/aggregate.js create mode 100644 node_modules/mongodb/lib/operations/aggregate.js.map create mode 100644 node_modules/mongodb/lib/operations/bulk_write.js create mode 100644 node_modules/mongodb/lib/operations/bulk_write.js.map create mode 100644 node_modules/mongodb/lib/operations/collections.js create mode 100644 node_modules/mongodb/lib/operations/collections.js.map create mode 100644 node_modules/mongodb/lib/operations/command.js create mode 100644 node_modules/mongodb/lib/operations/command.js.map create mode 100644 node_modules/mongodb/lib/operations/common_functions.js create mode 100644 node_modules/mongodb/lib/operations/common_functions.js.map create mode 100644 node_modules/mongodb/lib/operations/connect.js create mode 100644 node_modules/mongodb/lib/operations/connect.js.map create mode 100644 node_modules/mongodb/lib/operations/count.js create mode 100644 node_modules/mongodb/lib/operations/count.js.map create mode 100644 node_modules/mongodb/lib/operations/count_documents.js create mode 100644 node_modules/mongodb/lib/operations/count_documents.js.map create mode 100644 node_modules/mongodb/lib/operations/create_collection.js create mode 100644 node_modules/mongodb/lib/operations/create_collection.js.map create mode 100644 node_modules/mongodb/lib/operations/delete.js create mode 100644 node_modules/mongodb/lib/operations/delete.js.map create mode 100644 node_modules/mongodb/lib/operations/distinct.js create mode 100644 node_modules/mongodb/lib/operations/distinct.js.map create mode 100644 node_modules/mongodb/lib/operations/drop.js create mode 100644 node_modules/mongodb/lib/operations/drop.js.map create mode 100644 node_modules/mongodb/lib/operations/estimated_document_count.js create mode 100644 node_modules/mongodb/lib/operations/estimated_document_count.js.map create mode 100644 node_modules/mongodb/lib/operations/eval.js create mode 100644 node_modules/mongodb/lib/operations/eval.js.map create mode 100644 node_modules/mongodb/lib/operations/execute_operation.js create mode 100644 node_modules/mongodb/lib/operations/execute_operation.js.map create mode 100644 node_modules/mongodb/lib/operations/find.js create mode 100644 node_modules/mongodb/lib/operations/find.js.map create mode 100644 node_modules/mongodb/lib/operations/find_and_modify.js create mode 100644 node_modules/mongodb/lib/operations/find_and_modify.js.map create mode 100644 node_modules/mongodb/lib/operations/get_more.js create mode 100644 node_modules/mongodb/lib/operations/get_more.js.map create mode 100644 node_modules/mongodb/lib/operations/indexes.js create mode 100644 node_modules/mongodb/lib/operations/indexes.js.map create mode 100644 node_modules/mongodb/lib/operations/insert.js create mode 100644 node_modules/mongodb/lib/operations/insert.js.map create mode 100644 node_modules/mongodb/lib/operations/is_capped.js create mode 100644 node_modules/mongodb/lib/operations/is_capped.js.map create mode 100644 node_modules/mongodb/lib/operations/kill_cursors.js create mode 100644 node_modules/mongodb/lib/operations/kill_cursors.js.map create mode 100644 node_modules/mongodb/lib/operations/list_collections.js create mode 100644 node_modules/mongodb/lib/operations/list_collections.js.map create mode 100644 node_modules/mongodb/lib/operations/list_databases.js create mode 100644 node_modules/mongodb/lib/operations/list_databases.js.map create mode 100644 node_modules/mongodb/lib/operations/map_reduce.js create mode 100644 node_modules/mongodb/lib/operations/map_reduce.js.map create mode 100644 node_modules/mongodb/lib/operations/operation.js create mode 100644 node_modules/mongodb/lib/operations/operation.js.map create mode 100644 node_modules/mongodb/lib/operations/options_operation.js create mode 100644 node_modules/mongodb/lib/operations/options_operation.js.map create mode 100644 node_modules/mongodb/lib/operations/profiling_level.js create mode 100644 node_modules/mongodb/lib/operations/profiling_level.js.map create mode 100644 node_modules/mongodb/lib/operations/remove_user.js create mode 100644 node_modules/mongodb/lib/operations/remove_user.js.map create mode 100644 node_modules/mongodb/lib/operations/rename.js create mode 100644 node_modules/mongodb/lib/operations/rename.js.map create mode 100644 node_modules/mongodb/lib/operations/run_command.js create mode 100644 node_modules/mongodb/lib/operations/run_command.js.map create mode 100644 node_modules/mongodb/lib/operations/set_profiling_level.js create mode 100644 node_modules/mongodb/lib/operations/set_profiling_level.js.map create mode 100644 node_modules/mongodb/lib/operations/stats.js create mode 100644 node_modules/mongodb/lib/operations/stats.js.map create mode 100644 node_modules/mongodb/lib/operations/update.js create mode 100644 node_modules/mongodb/lib/operations/update.js.map create mode 100644 node_modules/mongodb/lib/operations/validate_collection.js create mode 100644 node_modules/mongodb/lib/operations/validate_collection.js.map create mode 100644 node_modules/mongodb/lib/promise_provider.js create mode 100644 node_modules/mongodb/lib/promise_provider.js.map create mode 100644 node_modules/mongodb/lib/read_concern.js create mode 100644 node_modules/mongodb/lib/read_concern.js.map create mode 100644 node_modules/mongodb/lib/read_preference.js create mode 100644 node_modules/mongodb/lib/read_preference.js.map create mode 100644 node_modules/mongodb/lib/sdam/common.js create mode 100644 node_modules/mongodb/lib/sdam/common.js.map create mode 100644 node_modules/mongodb/lib/sdam/events.js create mode 100644 node_modules/mongodb/lib/sdam/events.js.map create mode 100644 node_modules/mongodb/lib/sdam/monitor.js create mode 100644 node_modules/mongodb/lib/sdam/monitor.js.map create mode 100644 node_modules/mongodb/lib/sdam/server.js create mode 100644 node_modules/mongodb/lib/sdam/server.js.map create mode 100644 node_modules/mongodb/lib/sdam/server_description.js create mode 100644 node_modules/mongodb/lib/sdam/server_description.js.map create mode 100644 node_modules/mongodb/lib/sdam/server_selection.js create mode 100644 node_modules/mongodb/lib/sdam/server_selection.js.map create mode 100644 node_modules/mongodb/lib/sdam/srv_polling.js create mode 100644 node_modules/mongodb/lib/sdam/srv_polling.js.map create mode 100644 node_modules/mongodb/lib/sdam/topology.js create mode 100644 node_modules/mongodb/lib/sdam/topology.js.map create mode 100644 node_modules/mongodb/lib/sdam/topology_description.js create mode 100644 node_modules/mongodb/lib/sdam/topology_description.js.map create mode 100644 node_modules/mongodb/lib/sessions.js create mode 100644 node_modules/mongodb/lib/sessions.js.map create mode 100644 node_modules/mongodb/lib/sort.js create mode 100644 node_modules/mongodb/lib/sort.js.map create mode 100644 node_modules/mongodb/lib/transactions.js create mode 100644 node_modules/mongodb/lib/transactions.js.map create mode 100644 node_modules/mongodb/lib/utils.js create mode 100644 node_modules/mongodb/lib/utils.js.map create mode 100644 node_modules/mongodb/lib/write_concern.js create mode 100644 node_modules/mongodb/lib/write_concern.js.map create mode 100644 node_modules/mongodb/mongodb.d.ts create mode 100644 node_modules/mongodb/package.json create mode 100644 node_modules/mongodb/src/admin.ts create mode 100644 node_modules/mongodb/src/bson.ts create mode 100644 node_modules/mongodb/src/bulk/common.ts create mode 100644 node_modules/mongodb/src/bulk/ordered.ts create mode 100644 node_modules/mongodb/src/bulk/unordered.ts create mode 100644 node_modules/mongodb/src/change_stream.ts create mode 100644 node_modules/mongodb/src/cmap/auth/auth_provider.ts create mode 100644 node_modules/mongodb/src/cmap/auth/gssapi.ts create mode 100644 node_modules/mongodb/src/cmap/auth/mongo_credentials.ts create mode 100644 node_modules/mongodb/src/cmap/auth/mongocr.ts create mode 100644 node_modules/mongodb/src/cmap/auth/mongodb_aws.ts create mode 100644 node_modules/mongodb/src/cmap/auth/plain.ts create mode 100644 node_modules/mongodb/src/cmap/auth/providers.ts create mode 100644 node_modules/mongodb/src/cmap/auth/scram.ts create mode 100644 node_modules/mongodb/src/cmap/auth/x509.ts create mode 100644 node_modules/mongodb/src/cmap/command_monitoring_events.ts create mode 100644 node_modules/mongodb/src/cmap/commands.ts create mode 100644 node_modules/mongodb/src/cmap/connect.ts create mode 100644 node_modules/mongodb/src/cmap/connection.ts create mode 100644 node_modules/mongodb/src/cmap/connection_pool.ts create mode 100644 node_modules/mongodb/src/cmap/connection_pool_events.ts create mode 100644 node_modules/mongodb/src/cmap/errors.ts create mode 100644 node_modules/mongodb/src/cmap/message_stream.ts create mode 100644 node_modules/mongodb/src/cmap/metrics.ts create mode 100644 node_modules/mongodb/src/cmap/stream_description.ts create mode 100644 node_modules/mongodb/src/cmap/wire_protocol/compression.ts create mode 100644 node_modules/mongodb/src/cmap/wire_protocol/constants.ts create mode 100644 node_modules/mongodb/src/cmap/wire_protocol/shared.ts create mode 100644 node_modules/mongodb/src/collection.ts create mode 100644 node_modules/mongodb/src/connection_string.ts create mode 100644 node_modules/mongodb/src/constants.ts create mode 100644 node_modules/mongodb/src/cursor/abstract_cursor.ts create mode 100644 node_modules/mongodb/src/cursor/aggregation_cursor.ts create mode 100644 node_modules/mongodb/src/cursor/change_stream_cursor.ts create mode 100644 node_modules/mongodb/src/cursor/find_cursor.ts create mode 100644 node_modules/mongodb/src/cursor/list_collections_cursor.ts create mode 100644 node_modules/mongodb/src/cursor/list_indexes_cursor.ts create mode 100644 node_modules/mongodb/src/db.ts create mode 100644 node_modules/mongodb/src/deps.ts create mode 100644 node_modules/mongodb/src/encrypter.ts create mode 100644 node_modules/mongodb/src/error.ts create mode 100644 node_modules/mongodb/src/explain.ts create mode 100644 node_modules/mongodb/src/gridfs/download.ts create mode 100644 node_modules/mongodb/src/gridfs/index.ts create mode 100644 node_modules/mongodb/src/gridfs/upload.ts create mode 100644 node_modules/mongodb/src/index.ts create mode 100644 node_modules/mongodb/src/logger.ts create mode 100644 node_modules/mongodb/src/mongo_client.ts create mode 100644 node_modules/mongodb/src/mongo_types.ts create mode 100644 node_modules/mongodb/src/operations/add_user.ts create mode 100644 node_modules/mongodb/src/operations/aggregate.ts create mode 100644 node_modules/mongodb/src/operations/bulk_write.ts create mode 100644 node_modules/mongodb/src/operations/collections.ts create mode 100644 node_modules/mongodb/src/operations/command.ts create mode 100644 node_modules/mongodb/src/operations/common_functions.ts create mode 100644 node_modules/mongodb/src/operations/connect.ts create mode 100644 node_modules/mongodb/src/operations/count.ts create mode 100644 node_modules/mongodb/src/operations/count_documents.ts create mode 100644 node_modules/mongodb/src/operations/create_collection.ts create mode 100644 node_modules/mongodb/src/operations/delete.ts create mode 100644 node_modules/mongodb/src/operations/distinct.ts create mode 100644 node_modules/mongodb/src/operations/drop.ts create mode 100644 node_modules/mongodb/src/operations/estimated_document_count.ts create mode 100644 node_modules/mongodb/src/operations/eval.ts create mode 100644 node_modules/mongodb/src/operations/execute_operation.ts create mode 100644 node_modules/mongodb/src/operations/find.ts create mode 100644 node_modules/mongodb/src/operations/find_and_modify.ts create mode 100644 node_modules/mongodb/src/operations/get_more.ts create mode 100644 node_modules/mongodb/src/operations/indexes.ts create mode 100644 node_modules/mongodb/src/operations/insert.ts create mode 100644 node_modules/mongodb/src/operations/is_capped.ts create mode 100644 node_modules/mongodb/src/operations/kill_cursors.ts create mode 100644 node_modules/mongodb/src/operations/list_collections.ts create mode 100644 node_modules/mongodb/src/operations/list_databases.ts create mode 100644 node_modules/mongodb/src/operations/map_reduce.ts create mode 100644 node_modules/mongodb/src/operations/operation.ts create mode 100644 node_modules/mongodb/src/operations/options_operation.ts create mode 100644 node_modules/mongodb/src/operations/profiling_level.ts create mode 100644 node_modules/mongodb/src/operations/remove_user.ts create mode 100644 node_modules/mongodb/src/operations/rename.ts create mode 100644 node_modules/mongodb/src/operations/run_command.ts create mode 100644 node_modules/mongodb/src/operations/set_profiling_level.ts create mode 100644 node_modules/mongodb/src/operations/stats.ts create mode 100644 node_modules/mongodb/src/operations/update.ts create mode 100644 node_modules/mongodb/src/operations/validate_collection.ts create mode 100644 node_modules/mongodb/src/promise_provider.ts create mode 100644 node_modules/mongodb/src/read_concern.ts create mode 100644 node_modules/mongodb/src/read_preference.ts create mode 100644 node_modules/mongodb/src/sdam/common.ts create mode 100644 node_modules/mongodb/src/sdam/events.ts create mode 100644 node_modules/mongodb/src/sdam/monitor.ts create mode 100644 node_modules/mongodb/src/sdam/server.ts create mode 100644 node_modules/mongodb/src/sdam/server_description.ts create mode 100644 node_modules/mongodb/src/sdam/server_selection.ts create mode 100644 node_modules/mongodb/src/sdam/srv_polling.ts create mode 100644 node_modules/mongodb/src/sdam/topology.ts create mode 100644 node_modules/mongodb/src/sdam/topology_description.ts create mode 100644 node_modules/mongodb/src/sessions.ts create mode 100644 node_modules/mongodb/src/sort.ts create mode 100644 node_modules/mongodb/src/transactions.ts create mode 100644 node_modules/mongodb/src/utils.ts create mode 100644 node_modules/mongodb/src/write_concern.ts create mode 100644 node_modules/mongodb/tsconfig.json create mode 100644 node_modules/mongoose/.eslintrc.json create mode 100644 node_modules/mongoose/.mocharc.yml create mode 100644 node_modules/mongoose/LICENSE.md create mode 100644 node_modules/mongoose/README.md create mode 100644 node_modules/mongoose/SECURITY.md create mode 100644 node_modules/mongoose/browser.js create mode 100644 node_modules/mongoose/dist/browser.umd.js create mode 100644 node_modules/mongoose/index.js create mode 100644 node_modules/mongoose/lgtm.yml create mode 100644 node_modules/mongoose/lib/aggregate.js create mode 100644 node_modules/mongoose/lib/browser.js create mode 100644 node_modules/mongoose/lib/browserDocument.js create mode 100644 node_modules/mongoose/lib/cast.js create mode 100644 node_modules/mongoose/lib/cast/boolean.js create mode 100644 node_modules/mongoose/lib/cast/date.js create mode 100644 node_modules/mongoose/lib/cast/decimal128.js create mode 100644 node_modules/mongoose/lib/cast/number.js create mode 100644 node_modules/mongoose/lib/cast/objectid.js create mode 100644 node_modules/mongoose/lib/cast/string.js create mode 100644 node_modules/mongoose/lib/collection.js create mode 100644 node_modules/mongoose/lib/connection.js create mode 100644 node_modules/mongoose/lib/connectionstate.js create mode 100644 node_modules/mongoose/lib/cursor/AggregationCursor.js create mode 100644 node_modules/mongoose/lib/cursor/ChangeStream.js create mode 100644 node_modules/mongoose/lib/cursor/QueryCursor.js create mode 100644 node_modules/mongoose/lib/document.js create mode 100644 node_modules/mongoose/lib/document_provider.js create mode 100644 node_modules/mongoose/lib/driver.js create mode 100644 node_modules/mongoose/lib/drivers/SPEC.md create mode 100644 node_modules/mongoose/lib/drivers/browser/ReadPreference.js create mode 100644 node_modules/mongoose/lib/drivers/browser/binary.js create mode 100644 node_modules/mongoose/lib/drivers/browser/decimal128.js create mode 100644 node_modules/mongoose/lib/drivers/browser/index.js create mode 100644 node_modules/mongoose/lib/drivers/browser/objectid.js create mode 100644 node_modules/mongoose/lib/drivers/node-mongodb-native/ReadPreference.js create mode 100644 node_modules/mongoose/lib/drivers/node-mongodb-native/binary.js create mode 100644 node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js create mode 100644 node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js create mode 100644 node_modules/mongoose/lib/drivers/node-mongodb-native/decimal128.js create mode 100644 node_modules/mongoose/lib/drivers/node-mongodb-native/index.js create mode 100644 node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js create mode 100644 node_modules/mongoose/lib/error/browserMissingSchema.js create mode 100644 node_modules/mongoose/lib/error/cast.js create mode 100644 node_modules/mongoose/lib/error/disconnected.js create mode 100644 node_modules/mongoose/lib/error/divergentArray.js create mode 100644 node_modules/mongoose/lib/error/eachAsyncMultiError.js create mode 100644 node_modules/mongoose/lib/error/index.js create mode 100644 node_modules/mongoose/lib/error/messages.js create mode 100644 node_modules/mongoose/lib/error/missingSchema.js create mode 100644 node_modules/mongoose/lib/error/mongooseError.js create mode 100644 node_modules/mongoose/lib/error/notFound.js create mode 100644 node_modules/mongoose/lib/error/objectExpected.js create mode 100644 node_modules/mongoose/lib/error/objectParameter.js create mode 100644 node_modules/mongoose/lib/error/overwriteModel.js create mode 100644 node_modules/mongoose/lib/error/parallelSave.js create mode 100644 node_modules/mongoose/lib/error/parallelValidate.js create mode 100644 node_modules/mongoose/lib/error/serverSelection.js create mode 100644 node_modules/mongoose/lib/error/strict.js create mode 100644 node_modules/mongoose/lib/error/strictPopulate.js create mode 100644 node_modules/mongoose/lib/error/syncIndexes.js create mode 100644 node_modules/mongoose/lib/error/validation.js create mode 100644 node_modules/mongoose/lib/error/validator.js create mode 100644 node_modules/mongoose/lib/error/version.js create mode 100644 node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js create mode 100644 node_modules/mongoose/lib/helpers/aggregate/stringifyFunctionOperators.js create mode 100644 node_modules/mongoose/lib/helpers/arrayDepth.js create mode 100644 node_modules/mongoose/lib/helpers/clone.js create mode 100644 node_modules/mongoose/lib/helpers/common.js create mode 100644 node_modules/mongoose/lib/helpers/cursor/eachAsync.js create mode 100644 node_modules/mongoose/lib/helpers/discriminator/areDiscriminatorValuesEqual.js create mode 100644 node_modules/mongoose/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js create mode 100644 node_modules/mongoose/lib/helpers/discriminator/getConstructor.js create mode 100644 node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js create mode 100644 node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js create mode 100644 node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js create mode 100644 node_modules/mongoose/lib/helpers/document/applyDefaults.js create mode 100644 node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js create mode 100644 node_modules/mongoose/lib/helpers/document/compile.js create mode 100644 node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js create mode 100644 node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js create mode 100644 node_modules/mongoose/lib/helpers/each.js create mode 100644 node_modules/mongoose/lib/helpers/firstKey.js create mode 100644 node_modules/mongoose/lib/helpers/get.js create mode 100644 node_modules/mongoose/lib/helpers/getConstructorName.js create mode 100644 node_modules/mongoose/lib/helpers/getDefaultBulkwriteResult.js create mode 100644 node_modules/mongoose/lib/helpers/getFunctionName.js create mode 100644 node_modules/mongoose/lib/helpers/immediate.js create mode 100644 node_modules/mongoose/lib/helpers/indexes/applySchemaCollation.js create mode 100644 node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js create mode 100644 node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js create mode 100644 node_modules/mongoose/lib/helpers/indexes/isDefaultIdIndex.js create mode 100644 node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js create mode 100644 node_modules/mongoose/lib/helpers/indexes/isTextIndex.js create mode 100644 node_modules/mongoose/lib/helpers/isAsyncFunction.js create mode 100644 node_modules/mongoose/lib/helpers/isBsonType.js create mode 100644 node_modules/mongoose/lib/helpers/isMongooseObject.js create mode 100644 node_modules/mongoose/lib/helpers/isObject.js create mode 100644 node_modules/mongoose/lib/helpers/isPromise.js create mode 100644 node_modules/mongoose/lib/helpers/isSimpleValidator.js create mode 100644 node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js create mode 100644 node_modules/mongoose/lib/helpers/model/applyHooks.js create mode 100644 node_modules/mongoose/lib/helpers/model/applyMethods.js create mode 100644 node_modules/mongoose/lib/helpers/model/applyStaticHooks.js create mode 100644 node_modules/mongoose/lib/helpers/model/applyStatics.js create mode 100644 node_modules/mongoose/lib/helpers/model/castBulkWrite.js create mode 100644 node_modules/mongoose/lib/helpers/model/discriminator.js create mode 100644 node_modules/mongoose/lib/helpers/model/pushNestedArrayPaths.js create mode 100644 node_modules/mongoose/lib/helpers/once.js create mode 100644 node_modules/mongoose/lib/helpers/parallelLimit.js create mode 100644 node_modules/mongoose/lib/helpers/path/flattenObjectWithDottedPaths.js create mode 100644 node_modules/mongoose/lib/helpers/path/parentPaths.js create mode 100644 node_modules/mongoose/lib/helpers/path/setDottedPath.js create mode 100644 node_modules/mongoose/lib/helpers/pluralize.js create mode 100644 node_modules/mongoose/lib/helpers/populate/SkipPopulateValue.js create mode 100644 node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js create mode 100644 node_modules/mongoose/lib/helpers/populate/assignVals.js create mode 100644 node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js create mode 100644 node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js create mode 100644 node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js create mode 100644 node_modules/mongoose/lib/helpers/populate/getVirtual.js create mode 100644 node_modules/mongoose/lib/helpers/populate/leanPopulateMap.js create mode 100644 node_modules/mongoose/lib/helpers/populate/lookupLocalFields.js create mode 100644 node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js create mode 100644 node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js create mode 100644 node_modules/mongoose/lib/helpers/populate/removeDeselectedForeignField.js create mode 100644 node_modules/mongoose/lib/helpers/populate/validateRef.js create mode 100644 node_modules/mongoose/lib/helpers/printJestWarning.js create mode 100644 node_modules/mongoose/lib/helpers/processConnectionOptions.js create mode 100644 node_modules/mongoose/lib/helpers/projection/applyProjection.js create mode 100644 node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js create mode 100644 node_modules/mongoose/lib/helpers/projection/isDefiningProjection.js create mode 100644 node_modules/mongoose/lib/helpers/projection/isExclusive.js create mode 100644 node_modules/mongoose/lib/helpers/projection/isInclusive.js create mode 100644 node_modules/mongoose/lib/helpers/projection/isPathExcluded.js create mode 100644 node_modules/mongoose/lib/helpers/projection/isPathSelectedInclusive.js create mode 100644 node_modules/mongoose/lib/helpers/projection/isSubpath.js create mode 100644 node_modules/mongoose/lib/helpers/projection/parseProjection.js create mode 100644 node_modules/mongoose/lib/helpers/promiseOrCallback.js create mode 100644 node_modules/mongoose/lib/helpers/query/applyGlobalOption.js create mode 100644 node_modules/mongoose/lib/helpers/query/applyQueryMiddleware.js create mode 100644 node_modules/mongoose/lib/helpers/query/cast$expr.js create mode 100644 node_modules/mongoose/lib/helpers/query/castFilterPath.js create mode 100644 node_modules/mongoose/lib/helpers/query/castUpdate.js create mode 100644 node_modules/mongoose/lib/helpers/query/completeMany.js create mode 100644 node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js create mode 100644 node_modules/mongoose/lib/helpers/query/handleImmutable.js create mode 100644 node_modules/mongoose/lib/helpers/query/hasDollarKeys.js create mode 100644 node_modules/mongoose/lib/helpers/query/isOperator.js create mode 100644 node_modules/mongoose/lib/helpers/query/sanitizeFilter.js create mode 100644 node_modules/mongoose/lib/helpers/query/sanitizeProjection.js create mode 100644 node_modules/mongoose/lib/helpers/query/selectPopulatedFields.js create mode 100644 node_modules/mongoose/lib/helpers/query/trusted.js create mode 100644 node_modules/mongoose/lib/helpers/query/validOps.js create mode 100644 node_modules/mongoose/lib/helpers/query/wrapThunk.js create mode 100644 node_modules/mongoose/lib/helpers/schema/addAutoId.js create mode 100644 node_modules/mongoose/lib/helpers/schema/applyPlugins.js create mode 100644 node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js create mode 100644 node_modules/mongoose/lib/helpers/schema/cleanPositionalOperators.js create mode 100644 node_modules/mongoose/lib/helpers/schema/getIndexes.js create mode 100644 node_modules/mongoose/lib/helpers/schema/getKeysInSchemaOrder.js create mode 100644 node_modules/mongoose/lib/helpers/schema/getPath.js create mode 100644 node_modules/mongoose/lib/helpers/schema/handleIdOption.js create mode 100644 node_modules/mongoose/lib/helpers/schema/handleTimestampOption.js create mode 100644 node_modules/mongoose/lib/helpers/schema/idGetter.js create mode 100644 node_modules/mongoose/lib/helpers/schema/merge.js create mode 100644 node_modules/mongoose/lib/helpers/schematype/handleImmutable.js create mode 100644 node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js create mode 100644 node_modules/mongoose/lib/helpers/specialProperties.js create mode 100644 node_modules/mongoose/lib/helpers/symbols.js create mode 100644 node_modules/mongoose/lib/helpers/timers.js create mode 100644 node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js create mode 100644 node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js create mode 100644 node_modules/mongoose/lib/helpers/topology/allServersUnknown.js create mode 100644 node_modules/mongoose/lib/helpers/topology/isAtlas.js create mode 100644 node_modules/mongoose/lib/helpers/topology/isSSLError.js create mode 100644 node_modules/mongoose/lib/helpers/update/applyTimestampsToChildren.js create mode 100644 node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js create mode 100644 node_modules/mongoose/lib/helpers/update/castArrayFilters.js create mode 100644 node_modules/mongoose/lib/helpers/update/modifiedPaths.js create mode 100644 node_modules/mongoose/lib/helpers/update/moveImmutableProperties.js create mode 100644 node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js create mode 100644 node_modules/mongoose/lib/helpers/update/updatedPathsByArrayFilter.js create mode 100644 node_modules/mongoose/lib/helpers/updateValidators.js create mode 100644 node_modules/mongoose/lib/index.js create mode 100644 node_modules/mongoose/lib/internal.js create mode 100644 node_modules/mongoose/lib/model.js create mode 100644 node_modules/mongoose/lib/options.js create mode 100644 node_modules/mongoose/lib/options/PopulateOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaArrayOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaBufferOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaDateOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaDocumentArrayOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaMapOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaNumberOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaObjectIdOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaStringOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaSubdocumentOptions.js create mode 100644 node_modules/mongoose/lib/options/SchemaTypeOptions.js create mode 100644 node_modules/mongoose/lib/options/VirtualOptions.js create mode 100644 node_modules/mongoose/lib/options/propertyOptions.js create mode 100644 node_modules/mongoose/lib/options/removeOptions.js create mode 100644 node_modules/mongoose/lib/options/saveOptions.js create mode 100644 node_modules/mongoose/lib/plugins/clearValidating.js create mode 100644 node_modules/mongoose/lib/plugins/removeSubdocs.js create mode 100644 node_modules/mongoose/lib/plugins/saveSubdocs.js create mode 100644 node_modules/mongoose/lib/plugins/sharding.js create mode 100644 node_modules/mongoose/lib/plugins/trackTransaction.js create mode 100644 node_modules/mongoose/lib/plugins/validateBeforeSave.js create mode 100644 node_modules/mongoose/lib/promise_provider.js create mode 100644 node_modules/mongoose/lib/query.js create mode 100644 node_modules/mongoose/lib/queryhelpers.js create mode 100644 node_modules/mongoose/lib/schema.js create mode 100644 node_modules/mongoose/lib/schema/SubdocumentPath.js create mode 100644 node_modules/mongoose/lib/schema/array.js create mode 100644 node_modules/mongoose/lib/schema/boolean.js create mode 100644 node_modules/mongoose/lib/schema/buffer.js create mode 100644 node_modules/mongoose/lib/schema/date.js create mode 100644 node_modules/mongoose/lib/schema/decimal128.js create mode 100644 node_modules/mongoose/lib/schema/documentarray.js create mode 100644 node_modules/mongoose/lib/schema/index.js create mode 100644 node_modules/mongoose/lib/schema/map.js create mode 100644 node_modules/mongoose/lib/schema/mixed.js create mode 100644 node_modules/mongoose/lib/schema/number.js create mode 100644 node_modules/mongoose/lib/schema/objectid.js create mode 100644 node_modules/mongoose/lib/schema/operators/bitwise.js create mode 100644 node_modules/mongoose/lib/schema/operators/exists.js create mode 100644 node_modules/mongoose/lib/schema/operators/geospatial.js create mode 100644 node_modules/mongoose/lib/schema/operators/helpers.js create mode 100644 node_modules/mongoose/lib/schema/operators/text.js create mode 100644 node_modules/mongoose/lib/schema/operators/type.js create mode 100644 node_modules/mongoose/lib/schema/string.js create mode 100644 node_modules/mongoose/lib/schema/symbols.js create mode 100644 node_modules/mongoose/lib/schematype.js create mode 100644 node_modules/mongoose/lib/statemachine.js create mode 100644 node_modules/mongoose/lib/types/ArraySubdocument.js create mode 100644 node_modules/mongoose/lib/types/DocumentArray/index.js create mode 100644 node_modules/mongoose/lib/types/DocumentArray/isMongooseDocumentArray.js create mode 100644 node_modules/mongoose/lib/types/DocumentArray/methods/index.js create mode 100644 node_modules/mongoose/lib/types/array/index.js create mode 100644 node_modules/mongoose/lib/types/array/isMongooseArray.js create mode 100644 node_modules/mongoose/lib/types/array/methods/index.js create mode 100644 node_modules/mongoose/lib/types/buffer.js create mode 100644 node_modules/mongoose/lib/types/decimal128.js create mode 100644 node_modules/mongoose/lib/types/index.js create mode 100644 node_modules/mongoose/lib/types/map.js create mode 100644 node_modules/mongoose/lib/types/objectid.js create mode 100644 node_modules/mongoose/lib/types/subdocument.js create mode 100644 node_modules/mongoose/lib/utils.js create mode 100644 node_modules/mongoose/lib/validoptions.js create mode 100644 node_modules/mongoose/lib/virtualtype.js create mode 100644 node_modules/mongoose/mongoose-6.6.1.tgz create mode 100644 node_modules/mongoose/node_modules/ms/index.js create mode 100644 node_modules/mongoose/node_modules/ms/license.md create mode 100644 node_modules/mongoose/node_modules/ms/package.json create mode 100644 node_modules/mongoose/node_modules/ms/readme.md create mode 100644 node_modules/mongoose/package.json create mode 100644 node_modules/mongoose/scripts/build-browser.js create mode 100644 node_modules/mongoose/scripts/create-tarball.js create mode 100644 node_modules/mongoose/tools/auth.js create mode 100644 node_modules/mongoose/tools/repl.js create mode 100644 node_modules/mongoose/tools/sharded.js create mode 100644 node_modules/mongoose/tsconfig.json create mode 100644 node_modules/mongoose/types/aggregate.d.ts create mode 100644 node_modules/mongoose/types/callback.d.ts create mode 100644 node_modules/mongoose/types/collection.d.ts create mode 100644 node_modules/mongoose/types/connection.d.ts create mode 100644 node_modules/mongoose/types/cursor.d.ts create mode 100644 node_modules/mongoose/types/document.d.ts create mode 100644 node_modules/mongoose/types/error.d.ts create mode 100644 node_modules/mongoose/types/expressions.d.ts create mode 100644 node_modules/mongoose/types/helpers.d.ts create mode 100644 node_modules/mongoose/types/index.d.ts create mode 100644 node_modules/mongoose/types/indexes.d.ts create mode 100644 node_modules/mongoose/types/inferschematype.d.ts create mode 100644 node_modules/mongoose/types/middlewares.d.ts create mode 100644 node_modules/mongoose/types/models.d.ts create mode 100644 node_modules/mongoose/types/mongooseoptions.d.ts create mode 100644 node_modules/mongoose/types/pipelinestage.d.ts create mode 100644 node_modules/mongoose/types/populate.d.ts create mode 100644 node_modules/mongoose/types/query.d.ts create mode 100644 node_modules/mongoose/types/schemaoptions.d.ts create mode 100644 node_modules/mongoose/types/schematypes.d.ts create mode 100644 node_modules/mongoose/types/session.d.ts create mode 100644 node_modules/mongoose/types/types.d.ts create mode 100644 node_modules/mongoose/types/utility.d.ts create mode 100644 node_modules/mongoose/types/validation.d.ts create mode 100644 node_modules/mongoose/types/virtuals.d.ts create mode 100644 node_modules/morgan/HISTORY.md create mode 100644 node_modules/morgan/LICENSE create mode 100644 node_modules/morgan/README.md create mode 100644 node_modules/morgan/index.js create mode 100644 node_modules/morgan/node_modules/on-finished/HISTORY.md create mode 100644 node_modules/morgan/node_modules/on-finished/LICENSE create mode 100644 node_modules/morgan/node_modules/on-finished/README.md create mode 100644 node_modules/morgan/node_modules/on-finished/index.js create mode 100644 node_modules/morgan/node_modules/on-finished/package.json create mode 100644 node_modules/morgan/package.json create mode 100644 node_modules/mpath/.travis.yml create mode 100644 node_modules/mpath/History.md create mode 100644 node_modules/mpath/LICENSE create mode 100644 node_modules/mpath/README.md create mode 100644 node_modules/mpath/SECURITY.md create mode 100644 node_modules/mpath/index.js create mode 100644 node_modules/mpath/lib/index.js create mode 100644 node_modules/mpath/lib/stringToParts.js create mode 100644 node_modules/mpath/package.json create mode 100644 node_modules/mpath/test/.eslintrc.yml create mode 100644 node_modules/mpath/test/index.js create mode 100644 node_modules/mpath/test/stringToParts.js create mode 100644 node_modules/mquery/.eslintignore create mode 100644 node_modules/mquery/.eslintrc.json create mode 100644 node_modules/mquery/.travis.yml create mode 100644 node_modules/mquery/History.md create mode 100644 node_modules/mquery/LICENSE create mode 100644 node_modules/mquery/Makefile create mode 100644 node_modules/mquery/README.md create mode 100644 node_modules/mquery/SECURITY.md create mode 100644 node_modules/mquery/lib/collection/collection.js create mode 100644 node_modules/mquery/lib/collection/index.js create mode 100644 node_modules/mquery/lib/collection/node.js create mode 100644 node_modules/mquery/lib/env.js create mode 100644 node_modules/mquery/lib/mquery.js create mode 100644 node_modules/mquery/lib/permissions.js create mode 100644 node_modules/mquery/lib/utils.js create mode 100644 node_modules/mquery/node_modules/debug/LICENSE create mode 100644 node_modules/mquery/node_modules/debug/README.md create mode 100644 node_modules/mquery/node_modules/debug/package.json create mode 100644 node_modules/mquery/node_modules/debug/src/browser.js create mode 100644 node_modules/mquery/node_modules/debug/src/common.js create mode 100644 node_modules/mquery/node_modules/debug/src/index.js create mode 100644 node_modules/mquery/node_modules/debug/src/node.js create mode 100644 node_modules/mquery/node_modules/ms/index.js create mode 100644 node_modules/mquery/node_modules/ms/license.md create mode 100644 node_modules/mquery/node_modules/ms/package.json create mode 100644 node_modules/mquery/node_modules/ms/readme.md create mode 100644 node_modules/mquery/package.json create mode 100644 node_modules/mquery/test/.eslintrc.yml create mode 100644 node_modules/mquery/test/collection/browser.js create mode 100644 node_modules/mquery/test/collection/mongo.js create mode 100644 node_modules/mquery/test/collection/node.js create mode 100644 node_modules/mquery/test/env.js create mode 100644 node_modules/mquery/test/index.js create mode 100644 node_modules/mquery/test/utils.test.js create mode 100644 node_modules/object-assign/index.js create mode 100644 node_modules/object-assign/license create mode 100644 node_modules/object-assign/package.json create mode 100644 node_modules/object-assign/readme.md create mode 100644 node_modules/on-headers/HISTORY.md create mode 100644 node_modules/on-headers/LICENSE create mode 100644 node_modules/on-headers/README.md create mode 100644 node_modules/on-headers/index.js create mode 100644 node_modules/on-headers/package.json create mode 100644 node_modules/punycode/LICENSE-MIT.txt create mode 100644 node_modules/punycode/README.md create mode 100644 node_modules/punycode/package.json create mode 100644 node_modules/punycode/punycode.es6.js create mode 100644 node_modules/punycode/punycode.js create mode 100644 node_modules/random-bytes/HISTORY.md create mode 100644 node_modules/random-bytes/LICENSE create mode 100644 node_modules/random-bytes/README.md create mode 100644 node_modules/random-bytes/index.js create mode 100644 node_modules/random-bytes/package.json create mode 100644 node_modules/saslprep/.editorconfig create mode 100644 node_modules/saslprep/.gitattributes create mode 100644 node_modules/saslprep/.travis.yml create mode 100644 node_modules/saslprep/CHANGELOG.md create mode 100644 node_modules/saslprep/LICENSE create mode 100644 node_modules/saslprep/code-points.mem create mode 100644 node_modules/saslprep/generate-code-points.js create mode 100644 node_modules/saslprep/index.js create mode 100644 node_modules/saslprep/lib/code-points.js create mode 100644 node_modules/saslprep/lib/memory-code-points.js create mode 100644 node_modules/saslprep/lib/util.js create mode 100644 node_modules/saslprep/package.json create mode 100644 node_modules/saslprep/readme.md create mode 100644 node_modules/saslprep/test/index.js create mode 100644 node_modules/saslprep/test/util.js create mode 100644 node_modules/sift/MIT-LICENSE.txt create mode 100755 node_modules/sift/README.md create mode 100644 node_modules/sift/es/index.js create mode 100644 node_modules/sift/es/index.js.map create mode 100644 node_modules/sift/es5m/index.js create mode 100644 node_modules/sift/es5m/index.js.map create mode 100644 node_modules/sift/index.d.ts create mode 100644 node_modules/sift/index.js create mode 100644 node_modules/sift/lib/core.d.ts create mode 100644 node_modules/sift/lib/index.d.ts create mode 100644 node_modules/sift/lib/index.js create mode 100644 node_modules/sift/lib/index.js.map create mode 100644 node_modules/sift/lib/operations.d.ts create mode 100644 node_modules/sift/lib/utils.d.ts create mode 100644 node_modules/sift/package.json create mode 100644 node_modules/sift/sift.csp.min.js create mode 100644 node_modules/sift/sift.csp.min.js.map create mode 100644 node_modules/sift/sift.min.js create mode 100644 node_modules/sift/sift.min.js.map create mode 100644 node_modules/sift/src/core.d.ts create mode 100644 node_modules/sift/src/core.js create mode 100644 node_modules/sift/src/core.js.map create mode 100644 node_modules/sift/src/core.ts create mode 100644 node_modules/sift/src/index.d.ts create mode 100644 node_modules/sift/src/index.js create mode 100644 node_modules/sift/src/index.js.map create mode 100644 node_modules/sift/src/index.ts create mode 100644 node_modules/sift/src/operations.d.ts create mode 100644 node_modules/sift/src/operations.js create mode 100644 node_modules/sift/src/operations.js.map create mode 100644 node_modules/sift/src/operations.ts create mode 100644 node_modules/sift/src/utils.d.ts create mode 100644 node_modules/sift/src/utils.js create mode 100644 node_modules/sift/src/utils.js.map create mode 100644 node_modules/sift/src/utils.ts create mode 100644 node_modules/smart-buffer/.prettierrc.yaml create mode 100644 node_modules/smart-buffer/.travis.yml create mode 100644 node_modules/smart-buffer/LICENSE create mode 100644 node_modules/smart-buffer/README.md create mode 100644 node_modules/smart-buffer/build/smartbuffer.js create mode 100644 node_modules/smart-buffer/build/smartbuffer.js.map create mode 100644 node_modules/smart-buffer/build/utils.js create mode 100644 node_modules/smart-buffer/build/utils.js.map create mode 100644 node_modules/smart-buffer/docs/CHANGELOG.md create mode 100644 node_modules/smart-buffer/docs/README_v3.md create mode 100644 node_modules/smart-buffer/docs/ROADMAP.md create mode 100644 node_modules/smart-buffer/package.json create mode 100644 node_modules/smart-buffer/typings/smartbuffer.d.ts create mode 100644 node_modules/smart-buffer/typings/utils.d.ts create mode 100644 node_modules/socket.io-adapter/LICENSE create mode 100644 node_modules/socket.io-adapter/Readme.md create mode 100644 node_modules/socket.io-adapter/dist/index.d.ts create mode 100644 node_modules/socket.io-adapter/dist/index.js create mode 100644 node_modules/socket.io-adapter/package.json create mode 100644 node_modules/socket.io-parser/LICENSE create mode 100644 node_modules/socket.io-parser/Readme.md create mode 100644 node_modules/socket.io-parser/build/cjs/binary.js create mode 100644 node_modules/socket.io-parser/build/cjs/index.js create mode 100644 node_modules/socket.io-parser/build/cjs/is-binary.js create mode 100644 node_modules/socket.io-parser/build/cjs/package.json create mode 100644 node_modules/socket.io-parser/build/esm-debug/binary.d.ts create mode 100644 node_modules/socket.io-parser/build/esm-debug/binary.js create mode 100644 node_modules/socket.io-parser/build/esm-debug/index.d.ts create mode 100644 node_modules/socket.io-parser/build/esm-debug/index.js create mode 100644 node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts create mode 100644 node_modules/socket.io-parser/build/esm-debug/is-binary.js create mode 100644 node_modules/socket.io-parser/build/esm-debug/package.json create mode 100644 node_modules/socket.io-parser/build/esm/binary.d.ts create mode 100644 node_modules/socket.io-parser/build/esm/binary.js create mode 100644 node_modules/socket.io-parser/build/esm/index.d.ts create mode 100644 node_modules/socket.io-parser/build/esm/index.js create mode 100644 node_modules/socket.io-parser/build/esm/is-binary.d.ts create mode 100644 node_modules/socket.io-parser/build/esm/is-binary.js create mode 100644 node_modules/socket.io-parser/build/esm/package.json create mode 100644 node_modules/socket.io-parser/node_modules/debug/LICENSE create mode 100644 node_modules/socket.io-parser/node_modules/debug/README.md create mode 100644 node_modules/socket.io-parser/node_modules/debug/package.json create mode 100644 node_modules/socket.io-parser/node_modules/debug/src/browser.js create mode 100644 node_modules/socket.io-parser/node_modules/debug/src/common.js create mode 100644 node_modules/socket.io-parser/node_modules/debug/src/index.js create mode 100644 node_modules/socket.io-parser/node_modules/debug/src/node.js create mode 100644 node_modules/socket.io-parser/node_modules/ms/index.js create mode 100644 node_modules/socket.io-parser/node_modules/ms/license.md create mode 100644 node_modules/socket.io-parser/node_modules/ms/package.json create mode 100644 node_modules/socket.io-parser/node_modules/ms/readme.md create mode 100644 node_modules/socket.io-parser/package.json create mode 100644 node_modules/socket.io/LICENSE create mode 100644 node_modules/socket.io/Readme.md create mode 100644 node_modules/socket.io/client-dist/socket.io.esm.min.js create mode 100644 node_modules/socket.io/client-dist/socket.io.esm.min.js.map create mode 100644 node_modules/socket.io/client-dist/socket.io.js create mode 100644 node_modules/socket.io/client-dist/socket.io.js.map create mode 100644 node_modules/socket.io/client-dist/socket.io.min.js create mode 100644 node_modules/socket.io/client-dist/socket.io.min.js.map create mode 100644 node_modules/socket.io/client-dist/socket.io.msgpack.min.js create mode 100644 node_modules/socket.io/client-dist/socket.io.msgpack.min.js.map create mode 100644 node_modules/socket.io/dist/broadcast-operator.d.ts create mode 100644 node_modules/socket.io/dist/broadcast-operator.js create mode 100644 node_modules/socket.io/dist/client.d.ts create mode 100644 node_modules/socket.io/dist/client.js create mode 100644 node_modules/socket.io/dist/index.d.ts create mode 100644 node_modules/socket.io/dist/index.js create mode 100644 node_modules/socket.io/dist/namespace.d.ts create mode 100644 node_modules/socket.io/dist/namespace.js create mode 100644 node_modules/socket.io/dist/parent-namespace.d.ts create mode 100644 node_modules/socket.io/dist/parent-namespace.js create mode 100644 node_modules/socket.io/dist/socket.d.ts create mode 100644 node_modules/socket.io/dist/socket.js create mode 100644 node_modules/socket.io/dist/typed-events.d.ts create mode 100644 node_modules/socket.io/dist/typed-events.js create mode 100644 node_modules/socket.io/dist/uws.d.ts create mode 100644 node_modules/socket.io/dist/uws.js create mode 100644 node_modules/socket.io/node_modules/debug/LICENSE create mode 100644 node_modules/socket.io/node_modules/debug/README.md create mode 100644 node_modules/socket.io/node_modules/debug/package.json create mode 100644 node_modules/socket.io/node_modules/debug/src/browser.js create mode 100644 node_modules/socket.io/node_modules/debug/src/common.js create mode 100644 node_modules/socket.io/node_modules/debug/src/index.js create mode 100644 node_modules/socket.io/node_modules/debug/src/node.js create mode 100644 node_modules/socket.io/node_modules/ms/index.js create mode 100644 node_modules/socket.io/node_modules/ms/license.md create mode 100644 node_modules/socket.io/node_modules/ms/package.json create mode 100644 node_modules/socket.io/node_modules/ms/readme.md create mode 100644 node_modules/socket.io/package.json create mode 100644 node_modules/socket.io/wrapper.mjs create mode 100644 node_modules/socks/.eslintrc.cjs create mode 100644 node_modules/socks/.prettierrc.yaml create mode 100644 node_modules/socks/LICENSE create mode 100644 node_modules/socks/README.md create mode 100644 node_modules/socks/build/client/socksclient.js create mode 100644 node_modules/socks/build/client/socksclient.js.map create mode 100644 node_modules/socks/build/common/constants.js create mode 100644 node_modules/socks/build/common/constants.js.map create mode 100644 node_modules/socks/build/common/helpers.js create mode 100644 node_modules/socks/build/common/helpers.js.map create mode 100644 node_modules/socks/build/common/receivebuffer.js create mode 100644 node_modules/socks/build/common/receivebuffer.js.map create mode 100644 node_modules/socks/build/common/util.js create mode 100644 node_modules/socks/build/common/util.js.map create mode 100644 node_modules/socks/build/index.js create mode 100644 node_modules/socks/build/index.js.map create mode 100644 node_modules/socks/docs/examples/index.md create mode 100644 node_modules/socks/docs/examples/javascript/associateExample.md create mode 100644 node_modules/socks/docs/examples/javascript/bindExample.md create mode 100644 node_modules/socks/docs/examples/javascript/connectExample.md create mode 100644 node_modules/socks/docs/examples/typescript/associateExample.md create mode 100644 node_modules/socks/docs/examples/typescript/bindExample.md create mode 100644 node_modules/socks/docs/examples/typescript/connectExample.md create mode 100644 node_modules/socks/docs/index.md create mode 100644 node_modules/socks/docs/migratingFromV1.md create mode 100644 node_modules/socks/package.json create mode 100644 node_modules/socks/typings/client/socksclient.d.ts create mode 100644 node_modules/socks/typings/common/constants.d.ts create mode 100644 node_modules/socks/typings/common/helpers.d.ts create mode 100644 node_modules/socks/typings/common/receivebuffer.d.ts create mode 100644 node_modules/socks/typings/common/util.d.ts create mode 100644 node_modules/socks/typings/index.d.ts create mode 100644 node_modules/sparse-bitfield/.npmignore create mode 100644 node_modules/sparse-bitfield/.travis.yml create mode 100644 node_modules/sparse-bitfield/LICENSE create mode 100644 node_modules/sparse-bitfield/README.md create mode 100644 node_modules/sparse-bitfield/index.js create mode 100644 node_modules/sparse-bitfield/package.json create mode 100644 node_modules/sparse-bitfield/test.js create mode 100644 node_modules/tr46/LICENSE.md create mode 100644 node_modules/tr46/README.md create mode 100644 node_modules/tr46/index.js create mode 100644 node_modules/tr46/lib/mappingTable.json create mode 100644 node_modules/tr46/lib/regexes.js create mode 100644 node_modules/tr46/lib/statusMapping.js create mode 100644 node_modules/tr46/package.json create mode 100644 node_modules/uid-safe/HISTORY.md create mode 100644 node_modules/uid-safe/LICENSE create mode 100644 node_modules/uid-safe/README.md create mode 100644 node_modules/uid-safe/index.js create mode 100644 node_modules/uid-safe/package.json create mode 100644 node_modules/webidl-conversions/LICENSE.md create mode 100644 node_modules/webidl-conversions/README.md create mode 100644 node_modules/webidl-conversions/lib/index.js create mode 100644 node_modules/webidl-conversions/package.json create mode 100644 node_modules/whatwg-url/LICENSE.txt create mode 100644 node_modules/whatwg-url/README.md create mode 100644 node_modules/whatwg-url/index.js create mode 100644 node_modules/whatwg-url/lib/Function.js create mode 100644 node_modules/whatwg-url/lib/URL-impl.js create mode 100644 node_modules/whatwg-url/lib/URL.js create mode 100644 node_modules/whatwg-url/lib/URLSearchParams-impl.js create mode 100644 node_modules/whatwg-url/lib/URLSearchParams.js create mode 100644 node_modules/whatwg-url/lib/VoidFunction.js create mode 100644 node_modules/whatwg-url/lib/encoding.js create mode 100644 node_modules/whatwg-url/lib/infra.js create mode 100644 node_modules/whatwg-url/lib/percent-encoding.js create mode 100644 node_modules/whatwg-url/lib/url-state-machine.js create mode 100644 node_modules/whatwg-url/lib/urlencoded.js create mode 100644 node_modules/whatwg-url/lib/utils.js create mode 100644 node_modules/whatwg-url/package.json create mode 100644 node_modules/whatwg-url/webidl2js-wrapper.js create mode 100644 node_modules/ws/LICENSE create mode 100644 node_modules/ws/README.md create mode 100644 node_modules/ws/browser.js create mode 100644 node_modules/ws/index.js create mode 100644 node_modules/ws/lib/buffer-util.js create mode 100644 node_modules/ws/lib/constants.js create mode 100644 node_modules/ws/lib/event-target.js create mode 100644 node_modules/ws/lib/extension.js create mode 100644 node_modules/ws/lib/limiter.js create mode 100644 node_modules/ws/lib/permessage-deflate.js create mode 100644 node_modules/ws/lib/receiver.js create mode 100644 node_modules/ws/lib/sender.js create mode 100644 node_modules/ws/lib/stream.js create mode 100644 node_modules/ws/lib/subprotocol.js create mode 100644 node_modules/ws/lib/validation.js create mode 100644 node_modules/ws/lib/websocket-server.js create mode 100644 node_modules/ws/lib/websocket.js create mode 100644 node_modules/ws/package.json create mode 100644 node_modules/ws/wrapper.mjs create mode 100644 partials/footer.ejs create mode 100644 partials/head.ejs create mode 100644 partials/menu.ejs create mode 100644 public/css/style.css create mode 100644 public/js/home.js create mode 100644 public/js/main.js create mode 100644 public/js/post.js create mode 100644 public/js/search.js delete mode 100644 public/main.js delete mode 100644 public/style.css create mode 100644 replies.json create mode 100644 view/index.ejs create mode 100644 view/post.ejs create mode 100644 view/search.ejs delete mode 100644 views/index.ejs delete mode 100644 views/post.ejs diff --git a/.breakpoints b/.breakpoints index ff2466a..5f19308 100644 --- a/.breakpoints +++ b/.breakpoints @@ -1,5 +1,13 @@ { "files": { + "views/index.ejs": [ + { + "id": "45d3f9e0-0855-4f49-9d54-00011c145d35", + "line": 16, + "version": 552, + "index": 453 + } + ], "views/post.ejs": [ { "id": "728f013b-b0b8-42e7-afa4-46729eb5cb5d", diff --git a/database.json b/database.json index b6d75dc..0133266 100644 --- a/database.json +++ b/database.json @@ -1,5 +1,13 @@ -{ + +[ + { "title": ["Hello world"], "posturl": ["test"], "content": ["My first blog post"] -} \ No newline at end of file + }, + { + "title": ["Hello world2"], + "posturl": ["test2"], + "content": ["My first blog post2"] + } +] diff --git a/index.js b/index.js index 5f2e1c2..f764756 100644 --- a/index.js +++ b/index.js @@ -1,41 +1,86 @@ -// Declare express -const express = require('express'); +const express = require('express') +const app = express() +const http = require('http'); -// Declare database and requitment -const JSONdb = require('simple-json-db'); -const db = new JSONdb('database.json'); +// Import socket.io +const socketIo = require('socket.io'); +const server = http.Server(app); -// Declare port -const app = express(); -const port = 4040; +// restart +const io = socketIo(server); +const path = require("path"); +const { writeFileSync, readFileSync } = require('fs'); +var data; +let loadPosts = () => JSON.parse(readFileSync('database.json')); +let loadReplies = () => JSON.parse(readFileSync('replies.json')); +var replies = { id: 1, body: '3000', time: '12:00' }; +var config = []; +const d = new Date(); +const dateFormat = d.toDateString(); +var writectx = null; -// Set view engine -app.set('view engine', 'ejs'); -// Set main page -app.get('/', (req, res) => { - app.locals.title = db.get('title'); - app.locals.postUrl = db.get('posturl'); +io.on('connection', function connection(ws) { + console.log('A new client Connected!'); + ws.send('Welcome New Client!'); - res.render('index'); -}) + ws.on("reply", function incoming(message) { + console.log('received: %s', message); -// Set blog page -app.get('/post/:posturl', (req, res) => { - postUrl = req.params.posturl; - dbIndex = db.get('posturl').indexOf(postUrl); + var replyArray = message.toString(); + var reply = replyArray.split(","); + + replies = { id: parseInt(reply[0], 10), body: reply[1], time: dateFormat }; + writectx = message; + const path = './replies.json'; + config.push(replies); + try { + writeFileSync(path, JSON.stringify(config, null, 2), 'utf8'); + console.log('Data successfully saved to disk'); + } catch (error) { + console.log('An error has occurred ', error); + } + + }); +}); + +server.listen(3000, () => console.log(`Lisening on port :3000`)) - if (dbIndex != -1) { - app.locals.title = db.get('title')[dbIndex]; - app.locals.content = db.get('content')[dbIndex]; - res.render('post'); +app.use(express.static(__dirname + "/view")); +app.use(express.static(__dirname + '/public')); +//main page +app.get("/", function(request, response) { + response.render(path.join(__dirname + "/view/index.ejs")); +}) +//json +app.get("/posts", function(request, response) { + response.send(loadPosts()); +}); +//search +app.get("/search/:searchterm", function(request, response) { + app.locals.term = request.params.searchterm; + response.render(path.join(__dirname + "/view/search.ejs")); +}); +//post +app.get('/post/:posturl', (request, response) => { + postUrl = request.params.posturl; + for (var i = 0; i < loadPosts().length; i++) { + dbIndex = JSON.stringify(loadPosts()[i]).indexOf(postUrl); + if (loadPosts()[i].posturl == postUrl) { + app.locals.title = loadPosts()[i].title; + app.locals.content = loadPosts()[i].content; + app.locals.posturl = loadPosts()[i].posturl; + } + } + if (dbIndex != -1) { + response.render(path.join(__dirname + "/view/post.ejs")); } else { - res.send('Page not found :(') + //error + response.send('Page not found :(') } }); -// Run app -app.listen(port, () => { - console.log('App is live'); +app.get("/replies", function(request, response) { + response.send(loadReplies()); }); \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index a11ef39..731aaa1 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -4,11 +4,40 @@ "lockfileVersion": 2, "requires": true, "packages": { + "node_modules/@socket.io/component-emitter": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" + }, + "node_modules/@types/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + }, + "node_modules/@types/cors": { + "version": "2.8.12", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", + "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==" + }, "node_modules/@types/node": { "version": "18.0.6", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.6.tgz", "integrity": "sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==" }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-xTE1E+YF4aWPJJeUzaZI5DRntlkY3+BCVJi0axFptnjGmAoWxkyREIh/XMrfxVLejwQxMCfDXdICo0VLxThrog==" + }, + "node_modules/@types/whatwg-url": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.2.tgz", + "integrity": "sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==", + "dependencies": { + "@types/node": "*", + "@types/webidl-conversions": "*" + } + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -50,6 +79,49 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/base64id": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", + "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", + "engines": { + "node": "^4.5.0 || >= 5.9" + } + }, + "node_modules/basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "dependencies": { + "safe-buffer": "5.1.2" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/basic-auth/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, "node_modules/body-parser": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.0.tgz", @@ -82,6 +154,40 @@ "concat-map": "0.0.1" } }, + "node_modules/bson": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-4.7.0.tgz", + "integrity": "sha512-VrlEE4vuiO1WTpfof4VmaVolCVYkYTgB9iWgYNOrVlnifpME/06fhFRmONgBhClD5pFC1t9ZWqFUQEQAzY43bA==", + "dependencies": { + "buffer": "^5.6.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -170,6 +276,18 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/data-uri-to-buffer": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", @@ -186,6 +304,14 @@ "ms": "2.0.0" } }, + "node_modules/denque": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", + "engines": { + "node": ">=0.10" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -230,6 +356,75 @@ "node": ">= 0.8" } }, + "node_modules/engine.io": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.2.0.tgz", + "integrity": "sha512-4KzwW3F3bk+KlzSOY57fj/Jx6LyRQ1nbcyIadehl+AnXjKT7gDO0ORdRi/84ixvMKTym6ZKuxvbzN62HDDU1Lg==", + "dependencies": { + "@types/cookie": "^0.4.1", + "@types/cors": "^2.8.12", + "@types/node": ">=10.0.0", + "accepts": "~1.3.4", + "base64id": "2.0.0", + "cookie": "~0.4.1", + "cors": "~2.8.5", + "debug": "~4.3.1", + "engine.io-parser": "~5.0.3", + "ws": "~8.2.3" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/engine.io-parser": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.4.tgz", + "integrity": "sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/engine.io/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/engine.io/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/engine.io/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/errorhandler": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/errorhandler/-/errorhandler-1.5.1.tgz", + "integrity": "sha512-rcOwbfvP1WTViVoUjcfZicVzjhjTuhSMntHh6mW3IrEiyE6mJyXvsToJUJGlGlw/2xU9P5whlWNGlIDVeCiT4A==", + "dependencies": { + "accepts": "~1.3.7", + "escape-html": "~1.0.3" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -284,6 +479,32 @@ "node": ">= 0.10.0" } }, + "node_modules/express-session": { + "version": "1.17.3", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.3.tgz", + "integrity": "sha512-4+otWXlShYlG1Ma+2Jnn+xgKUZTMJ5QD3YvfilX3AcocOAbIkVylSWEklzALe/+Pu4qV6TYBj5GwOBFfdKqLBw==", + "dependencies": { + "cookie": "0.4.2", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-headers": "~1.0.2", + "parseurl": "~1.3.3", + "safe-buffer": "5.2.1", + "uid-safe": "~2.1.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/express-session/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/fetch-blob": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.1.5.tgz", @@ -451,11 +672,35 @@ "node": ">=0.10.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "node_modules/ip": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", + "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -481,6 +726,11 @@ "node": ">=10" } }, + "node_modules/kareem": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.4.1.tgz", + "integrity": "sha512-aJ9opVoXroQUPfovYP5kaj2lM7Jn02Gw13bL0lg9v0V7SaUc0qavPs0Eue7d2DcC3NjqI6QAUElXNsuZSeM+EA==" + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -489,6 +739,12 @@ "node": ">= 0.6" } }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, "node_modules/merge-descriptors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", @@ -543,6 +799,124 @@ "node": "*" } }, + "node_modules/mongodb": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.9.1.tgz", + "integrity": "sha512-ZhgI/qBf84fD7sI4waZBoLBNJYPQN5IOC++SBCiPiyhzpNKOxN/fi0tBHvH2dEC42HXtNEbFB0zmNz4+oVtorQ==", + "dependencies": { + "bson": "^4.7.0", + "denque": "^2.1.0", + "mongodb-connection-string-url": "^2.5.3", + "socks": "^2.7.0" + }, + "engines": { + "node": ">=12.9.0" + }, + "optionalDependencies": { + "saslprep": "^1.0.3" + } + }, + "node_modules/mongodb-connection-string-url": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.4.tgz", + "integrity": "sha512-SeAxuWs0ez3iI3vvmLk/j2y+zHwigTDKQhtdxTgt5ZCOQQS5+HW4g45/Xw5vzzbn7oQXCNQ24Z40AkJsizEy7w==", + "dependencies": { + "@types/whatwg-url": "^8.2.1", + "whatwg-url": "^11.0.0" + } + }, + "node_modules/mongoose": { + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.6.3.tgz", + "integrity": "sha512-2Ye018PNBBXJd717qhfjBGo7k8HQb/pKziO9d5wY14iZSUI7hxqL7bwNDg+poeBwnlhBYLncZkips15Blfgxbw==", + "dependencies": { + "bson": "^4.6.5", + "kareem": "2.4.1", + "mongodb": "4.9.1", + "mpath": "0.9.0", + "mquery": "4.0.3", + "ms": "2.1.3", + "sift": "16.0.0" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mongoose" + } + }, + "node_modules/mongoose/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/morgan": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", + "integrity": "sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==", + "dependencies": { + "basic-auth": "~2.0.1", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-finished": "~2.3.0", + "on-headers": "~1.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/morgan/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mquery": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-4.0.3.tgz", + "integrity": "sha512-J5heI+P08I6VJ2Ky3+33IpCdAvlYGTSUjwTPxkAr8i8EoduPMBX2OY/wa3IKZIQl7MU4SbFk8ndgSKyB/cl1zA==", + "dependencies": { + "debug": "4.x" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/mquery/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mquery/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -591,6 +965,14 @@ "url": "https://opencollective.com/node-fetch" } }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object-inspect": { "version": "1.12.2", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", @@ -610,6 +992,14 @@ "node": ">= 0.8" } }, + "node_modules/on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -635,6 +1025,14 @@ "node": ">= 0.10" } }, + "node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "engines": { + "node": ">=6" + } + }, "node_modules/qs": { "version": "6.10.3", "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", @@ -649,6 +1047,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -695,6 +1101,18 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/saslprep": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", + "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", + "optional": true, + "dependencies": { + "sparse-bitfield": "^3.0.3" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", @@ -755,6 +1173,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/sift": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/sift/-/sift-16.0.0.tgz", + "integrity": "sha512-ILTjdP2Mv9V1kIxWMXeMTIRbOBrqKc4JAXmFMnFq3fKeyQ2Qwa3Dw1ubcye3vR+Y6ofA0b9gNDr/y2t6eUeIzQ==" + }, "node_modules/simple-json-db": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/simple-json-db/-/simple-json-db-2.0.0.tgz", @@ -763,6 +1186,112 @@ "node": ">=10.0" } }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socket.io": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.5.2.tgz", + "integrity": "sha512-6fCnk4ARMPZN448+SQcnn1u8OHUC72puJcNtSgg2xS34Cu7br1gQ09YKkO1PFfDn/wyUE9ZgMAwosJed003+NQ==", + "dependencies": { + "accepts": "~1.3.4", + "base64id": "~2.0.0", + "debug": "~4.3.2", + "engine.io": "~6.2.0", + "socket.io-adapter": "~2.4.0", + "socket.io-parser": "~4.2.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/socket.io-adapter": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.4.0.tgz", + "integrity": "sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg==" + }, + "node_modules/socket.io-parser": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.1.tgz", + "integrity": "sha512-V4GrkLy+HeF1F/en3SpUaM+7XxYXpuMUWLGde1kSSh5nQMN4hLrbPIkD+otwh6q9R6NOQBN4AMaOZ2zVjui82g==", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/socket.io-parser/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/socket.io-parser/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/socket.io/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/socket.io/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/socks": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.0.tgz", + "integrity": "sha512-scnOe9y4VuiNUULJN72GrM26BNOjVsfPXI+j+98PkyEfsIXroa5ofyjT+FzGvn/xHs73U2JtoBYAVx9Hl4quSA==", + "dependencies": { + "ip": "^2.0.0", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.13.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "optional": true, + "dependencies": { + "memory-pager": "^1.0.2" + } + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -790,6 +1319,17 @@ "node": ">=0.6" } }, + "node_modules/tr46": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "dependencies": { + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -802,6 +1342,17 @@ "node": ">= 0.6" } }, + "node_modules/uid-safe": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", + "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", + "dependencies": { + "random-bytes": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -833,6 +1384,46 @@ "engines": { "node": ">= 8" } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "dependencies": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/ws": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", + "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } } } } diff --git a/node_modules/@socket.io/component-emitter/LICENSE b/node_modules/@socket.io/component-emitter/LICENSE new file mode 100644 index 0000000..de51692 --- /dev/null +++ b/node_modules/@socket.io/component-emitter/LICENSE @@ -0,0 +1,24 @@ +(The MIT License) + +Copyright (c) 2014 Component 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. diff --git a/node_modules/@socket.io/component-emitter/Readme.md b/node_modules/@socket.io/component-emitter/Readme.md new file mode 100644 index 0000000..0f3f9b9 --- /dev/null +++ b/node_modules/@socket.io/component-emitter/Readme.md @@ -0,0 +1,74 @@ +# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter) + + Event emitter component. + +## Installation + +``` +$ component install component/emitter +``` + +## API + +### Emitter(obj) + + The `Emitter` may also be used as a mixin. For example + a "plain" object may become an emitter, or you may + extend an existing prototype. + + As an `Emitter` instance: + +```js +var Emitter = require('emitter'); +var emitter = new Emitter; +emitter.emit('something'); +``` + + As a mixin: + +```js +var Emitter = require('emitter'); +var user = { name: 'tobi' }; +Emitter(user); + +user.emit('im a user'); +``` + + As a prototype mixin: + +```js +var Emitter = require('emitter'); +Emitter(User.prototype); +``` + +### Emitter#on(event, fn) + + Register an `event` handler `fn`. + +### Emitter#once(event, fn) + + Register a single-shot `event` handler `fn`, + removed immediately after it is invoked the + first time. + +### Emitter#off(event, fn) + + * Pass `event` and `fn` to remove a listener. + * Pass `event` to remove all listeners on that event. + * Pass nothing to remove all listeners on all events. + +### Emitter#emit(event, ...) + + Emit an `event` with variable option args. + +### Emitter#listeners(event) + + Return an array of callbacks, or an empty array. + +### Emitter#hasListeners(event) + + Check if this emitter has `event` handlers. + +## License + +MIT diff --git a/node_modules/@socket.io/component-emitter/index.d.ts b/node_modules/@socket.io/component-emitter/index.d.ts new file mode 100644 index 0000000..49a74e1 --- /dev/null +++ b/node_modules/@socket.io/component-emitter/index.d.ts @@ -0,0 +1,179 @@ +/** + * An events map is an interface that maps event names to their value, which + * represents the type of the `on` listener. + */ +export interface EventsMap { + [event: string]: any; +} + +/** + * The default events map, used if no EventsMap is given. Using this EventsMap + * is equivalent to accepting all event names, and any data. + */ +export interface DefaultEventsMap { + [event: string]: (...args: any[]) => void; +} + +/** + * Returns a union type containing all the keys of an event map. + */ +export type EventNames = keyof Map & (string | symbol); + +/** The tuple type representing the parameters of an event listener */ +export type EventParams< + Map extends EventsMap, + Ev extends EventNames + > = Parameters; + +/** + * The event names that are either in ReservedEvents or in UserEvents + */ +export type ReservedOrUserEventNames< + ReservedEventsMap extends EventsMap, + UserEvents extends EventsMap + > = EventNames | EventNames; + +/** + * Type of a listener of a user event or a reserved event. If `Ev` is in + * `ReservedEvents`, the reserved event listener is returned. + */ +export type ReservedOrUserListener< + ReservedEvents extends EventsMap, + UserEvents extends EventsMap, + Ev extends ReservedOrUserEventNames + > = FallbackToUntypedListener< + Ev extends EventNames + ? ReservedEvents[Ev] + : Ev extends EventNames + ? UserEvents[Ev] + : never + >; + +/** + * Returns an untyped listener type if `T` is `never`; otherwise, returns `T`. + * + * This is a hack to mitigate https://github.com/socketio/socket.io/issues/3833. + * Needed because of https://github.com/microsoft/TypeScript/issues/41778 + */ +type FallbackToUntypedListener = [T] extends [never] + ? (...args: any[]) => void | Promise + : T; + +/** + * Strictly typed version of an `EventEmitter`. A `TypedEventEmitter` takes type + * parameters for mappings of event names to event data types, and strictly + * types method calls to the `EventEmitter` according to these event maps. + * + * @typeParam ListenEvents - `EventsMap` of user-defined events that can be + * listened to with `on` or `once` + * @typeParam EmitEvents - `EventsMap` of user-defined events that can be + * emitted with `emit` + * @typeParam ReservedEvents - `EventsMap` of reserved events, that can be + * emitted by socket.io with `emitReserved`, and can be listened to with + * `listen`. + */ +export class Emitter< + ListenEvents extends EventsMap, + EmitEvents extends EventsMap, + ReservedEvents extends EventsMap = {} + > { + /** + * Adds the `listener` function as an event listener for `ev`. + * + * @param ev Name of the event + * @param listener Callback function + */ + on>( + ev: Ev, + listener: ReservedOrUserListener + ): this; + + /** + * Adds a one-time `listener` function as an event listener for `ev`. + * + * @param ev Name of the event + * @param listener Callback function + */ + once>( + ev: Ev, + listener: ReservedOrUserListener + ): this; + + /** + * Removes the `listener` function as an event listener for `ev`. + * + * @param ev Name of the event + * @param listener Callback function + */ + off>( + ev?: Ev, + listener?: ReservedOrUserListener + ): this; + + /** + * Emits an event. + * + * @param ev Name of the event + * @param args Values to send to listeners of this event + */ + emit>( + ev: Ev, + ...args: EventParams + ): this; + + /** + * Emits a reserved event. + * + * This method is `protected`, so that only a class extending + * `StrictEventEmitter` can emit its own reserved events. + * + * @param ev Reserved event name + * @param args Arguments to emit along with the event + */ + protected emitReserved>( + ev: Ev, + ...args: EventParams + ): this; + + /** + * Returns the listeners listening to an event. + * + * @param event Event name + * @returns Array of listeners subscribed to `event` + */ + listeners>( + event: Ev + ): ReservedOrUserListener[]; + + /** + * Returns true if there is a listener for this event. + * + * @param event Event name + * @returns boolean + */ + hasListeners< + Ev extends ReservedOrUserEventNames + >(event: Ev): boolean; + + /** + * Removes the `listener` function as an event listener for `ev`. + * + * @param ev Name of the event + * @param listener Callback function + */ + removeListener< + Ev extends ReservedOrUserEventNames + >( + ev?: Ev, + listener?: ReservedOrUserListener + ): this; + + /** + * Removes all `listener` function as an event listener for `ev`. + * + * @param ev Name of the event + */ + removeAllListeners< + Ev extends ReservedOrUserEventNames + >(ev?: Ev): this; +} diff --git a/node_modules/@socket.io/component-emitter/index.js b/node_modules/@socket.io/component-emitter/index.js new file mode 100644 index 0000000..e0d5497 --- /dev/null +++ b/node_modules/@socket.io/component-emitter/index.js @@ -0,0 +1,176 @@ + +/** + * Expose `Emitter`. + */ + +exports.Emitter = Emitter; + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +} + +/** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.on = +Emitter.prototype.addEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks['$' + event] = this._callbacks['$' + event] || []) + .push(fn); + return this; +}; + +/** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.once = function(event, fn){ + function on() { + this.off(event, on); + fn.apply(this, arguments); + } + + on.fn = fn; + this.on(event, on); + return this; +}; + +/** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.off = +Emitter.prototype.removeListener = +Emitter.prototype.removeAllListeners = +Emitter.prototype.removeEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks['$' + event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks['$' + event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; + } + } + + // Remove event specific arrays for event types that no + // one is subscribed for to avoid memory leak. + if (callbacks.length === 0) { + delete this._callbacks['$' + event]; + } + + return this; +}; + +/** + * Emit `event` with the given args. + * + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} + */ + +Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; + + var args = new Array(arguments.length - 1) + , callbacks = this._callbacks['$' + event]; + + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + } + } + + return this; +}; + +// alias used for reserved events (protected method) +Emitter.prototype.emitReserved = Emitter.prototype.emit; + +/** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ + +Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks['$' + event] || []; +}; + +/** + * Check if this emitter has `event` handlers. + * + * @param {String} event + * @return {Boolean} + * @api public + */ + +Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; +}; diff --git a/node_modules/@socket.io/component-emitter/index.mjs b/node_modules/@socket.io/component-emitter/index.mjs new file mode 100644 index 0000000..b2e5c3f --- /dev/null +++ b/node_modules/@socket.io/component-emitter/index.mjs @@ -0,0 +1,169 @@ +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +export function Emitter(obj) { + if (obj) return mixin(obj); +} + +/** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.on = +Emitter.prototype.addEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks['$' + event] = this._callbacks['$' + event] || []) + .push(fn); + return this; +}; + +/** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.once = function(event, fn){ + function on() { + this.off(event, on); + fn.apply(this, arguments); + } + + on.fn = fn; + this.on(event, on); + return this; +}; + +/** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.off = +Emitter.prototype.removeListener = +Emitter.prototype.removeAllListeners = +Emitter.prototype.removeEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks['$' + event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks['$' + event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; + } + } + + // Remove event specific arrays for event types that no + // one is subscribed for to avoid memory leak. + if (callbacks.length === 0) { + delete this._callbacks['$' + event]; + } + + return this; +}; + +/** + * Emit `event` with the given args. + * + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} + */ + +Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; + + var args = new Array(arguments.length - 1) + , callbacks = this._callbacks['$' + event]; + + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + } + } + + return this; +}; + +// alias used for reserved events (protected method) +Emitter.prototype.emitReserved = Emitter.prototype.emit; + +/** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ + +Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks['$' + event] || []; +}; + +/** + * Check if this emitter has `event` handlers. + * + * @param {String} event + * @return {Boolean} + * @api public + */ + +Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; +}; diff --git a/node_modules/@socket.io/component-emitter/package.json b/node_modules/@socket.io/component-emitter/package.json new file mode 100644 index 0000000..c73c23d --- /dev/null +++ b/node_modules/@socket.io/component-emitter/package.json @@ -0,0 +1,31 @@ +{ + "name": "@socket.io/component-emitter", + "description": "Event emitter", + "version": "3.1.0", + "license": "MIT", + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "component": { + "scripts": { + "emitter/index.js": "index.js" + } + }, + "main": "index.js", + "module": "index.mjs", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/socketio/emitter.git" + }, + "scripts": { + "test": "make test" + }, + "files": [ + "index.js", + "index.mjs", + "index.d.ts", + "LICENSE" + ] +} diff --git a/node_modules/@types/cookie/LICENSE b/node_modules/@types/cookie/LICENSE new file mode 100755 index 0000000..9e841e7 --- /dev/null +++ b/node_modules/@types/cookie/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/node_modules/@types/cookie/README.md b/node_modules/@types/cookie/README.md new file mode 100755 index 0000000..b6b6998 --- /dev/null +++ b/node_modules/@types/cookie/README.md @@ -0,0 +1,16 @@ +# Installation +> `npm install --save @types/cookie` + +# Summary +This package contains type definitions for cookie (https://github.com/jshttp/cookie). + +# Details +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cookie. + +### Additional Details + * Last updated: Tue, 06 Jul 2021 20:32:30 GMT + * Dependencies: none + * Global values: none + +# Credits +These definitions were written by [Pine Mizune](https://github.com/pine), and [Piotr Błażejewicz](https://github.com/peterblazejewicz). diff --git a/node_modules/@types/cookie/index.d.ts b/node_modules/@types/cookie/index.d.ts new file mode 100755 index 0000000..a9690c3 --- /dev/null +++ b/node_modules/@types/cookie/index.d.ts @@ -0,0 +1,135 @@ +// Type definitions for cookie 0.4 +// Project: https://github.com/jshttp/cookie +// Definitions by: Pine Mizune +// Piotr Błażejewicz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Basic HTTP cookie parser and serializer for HTTP servers. + */ + +/** + * Additional serialization options + */ +export interface CookieSerializeOptions { + /** + * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3|Domain Set-Cookie attribute}. By default, no + * domain is set, and most clients will consider the cookie to apply to only + * the current domain. + */ + domain?: string | undefined; + + /** + * Specifies a function that will be used to encode a cookie's value. Since + * value of a cookie has a limited character set (and must be a simple + * string), this function can be used to encode a value into a string suited + * for a cookie's value. + * + * The default function is the global `encodeURIComponent`, which will + * encode a JavaScript string into UTF-8 byte sequences and then URL-encode + * any that fall outside of the cookie range. + */ + encode?(value: string): string; + + /** + * Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1|`Expires` `Set-Cookie` attribute}. By default, + * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete + * it on a condition like exiting a web browser application. + * + * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification} + * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is + * possible not all clients by obey this, so if both are set, they should + * point to the same date and time. + */ + expires?: Date | undefined; + /** + * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6|`HttpOnly` `Set-Cookie` attribute}. + * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By + * default, the `HttpOnly` attribute is not set. + * + * *Note* be careful when setting this to true, as compliant clients will + * not allow client-side JavaScript to see the cookie in `document.cookie`. + */ + httpOnly?: boolean | undefined; + /** + * Specifies the number (in seconds) to be the value for the `Max-Age` + * `Set-Cookie` attribute. The given number will be converted to an integer + * by rounding down. By default, no maximum age is set. + * + * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification} + * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is + * possible not all clients by obey this, so if both are set, they should + * point to the same date and time. + */ + maxAge?: number | undefined; + /** + * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}. + * By default, the path is considered the "default path". + */ + path?: string | undefined; + /** + * Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}. + * + * - `true` will set the `SameSite` attribute to `Strict` for strict same + * site enforcement. + * - `false` will not set the `SameSite` attribute. + * - `'lax'` will set the `SameSite` attribute to Lax for lax same site + * enforcement. + * - `'strict'` will set the `SameSite` attribute to Strict for strict same + * site enforcement. + * - `'none'` will set the SameSite attribute to None for an explicit + * cross-site cookie. + * + * More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}. + * + * *note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it. + */ + sameSite?: true | false | 'lax' | 'strict' | 'none' | undefined; + /** + * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5|`Secure` `Set-Cookie` attribute}. When truthy, the + * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set. + * + * *Note* be careful when setting this to `true`, as compliant clients will + * not send the cookie back to the server in the future if the browser does + * not have an HTTPS connection. + */ + secure?: boolean | undefined; +} + +/** + * Additional parsing options + */ +export interface CookieParseOptions { + /** + * Specifies a function that will be used to decode a cookie's value. Since + * the value of a cookie has a limited character set (and must be a simple + * string), this function can be used to decode a previously-encoded cookie + * value into a JavaScript string or other object. + * + * The default function is the global `decodeURIComponent`, which will decode + * any URL-encoded sequences into their byte representations. + * + * *Note* if an error is thrown from this function, the original, non-decoded + * cookie value will be returned as the cookie's value. + */ + decode?(value: string): string; +} + +/** + * Parse an HTTP Cookie header string and returning an object of all cookie + * name-value pairs. + * + * @param str the string representing a `Cookie` header value + * @param [options] object containing parsing options + */ +export function parse(str: string, options?: CookieParseOptions): { [key: string]: string }; + +/** + * Serialize a cookie name-value pair into a `Set-Cookie` header string. + * + * @param name the name for the cookie + * @param value value to set the cookie to + * @param [options] object containing serialization options + * @throws {TypeError} when `maxAge` options is invalid + */ +export function serialize(name: string, value: string, options?: CookieSerializeOptions): string; diff --git a/node_modules/@types/cookie/package.json b/node_modules/@types/cookie/package.json new file mode 100755 index 0000000..4aae1e4 --- /dev/null +++ b/node_modules/@types/cookie/package.json @@ -0,0 +1,30 @@ +{ + "name": "@types/cookie", + "version": "0.4.1", + "description": "TypeScript definitions for cookie", + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cookie", + "license": "MIT", + "contributors": [ + { + "name": "Pine Mizune", + "url": "https://github.com/pine", + "githubUsername": "pine" + }, + { + "name": "Piotr Błażejewicz", + "url": "https://github.com/peterblazejewicz", + "githubUsername": "peterblazejewicz" + } + ], + "main": "", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", + "directory": "types/cookie" + }, + "scripts": {}, + "dependencies": {}, + "typesPublisherContentHash": "7d4a6dd505c896319459ae131b5fa8fc0a2ed25552db53dac87946119bb21559", + "typeScriptVersion": "3.6" +} \ No newline at end of file diff --git a/node_modules/@types/cors/LICENSE b/node_modules/@types/cors/LICENSE new file mode 100755 index 0000000..9e841e7 --- /dev/null +++ b/node_modules/@types/cors/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/node_modules/@types/cors/README.md b/node_modules/@types/cors/README.md new file mode 100755 index 0000000..2448c42 --- /dev/null +++ b/node_modules/@types/cors/README.md @@ -0,0 +1,78 @@ +# Installation +> `npm install --save @types/cors` + +# Summary +This package contains type definitions for cors (https://github.com/expressjs/cors/). + +# Details +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors. +## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors/index.d.ts) +````ts +// Type definitions for cors 2.8 +// Project: https://github.com/expressjs/cors/ +// Definitions by: Alan Plum +// Gaurav Sharma +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { IncomingHttpHeaders } from 'http'; + +type StaticOrigin = boolean | string | RegExp | (boolean | string | RegExp)[]; + +type CustomOrigin = (requestOrigin: string | undefined, callback: (err: Error | null, origin?: StaticOrigin) => void) => void; + +declare namespace e { + interface CorsRequest { + method?: string | undefined; + headers: IncomingHttpHeaders; + } + interface CorsOptions { + /** + * @default '*'' + */ + origin?: StaticOrigin | CustomOrigin | undefined; + /** + * @default 'GET,HEAD,PUT,PATCH,POST,DELETE' + */ + methods?: string | string[] | undefined; + allowedHeaders?: string | string[] | undefined; + exposedHeaders?: string | string[] | undefined; + credentials?: boolean | undefined; + maxAge?: number | undefined; + /** + * @default false + */ + preflightContinue?: boolean | undefined; + /** + * @default 204 + */ + optionsSuccessStatus?: number | undefined; + } + type CorsOptionsDelegate = ( + req: T, + callback: (err: Error | null, options?: CorsOptions) => void, + ) => void; +} + +declare function e( + options?: e.CorsOptions | e.CorsOptionsDelegate, +): ( + req: T, + res: { + statusCode?: number | undefined; + setHeader(key: string, value: string): any; + end(): any; + }, + next: (err?: any) => any, +) => void; +export = e; + +```` + +### Additional Details + * Last updated: Fri, 09 Jul 2021 07:31:29 GMT + * Dependencies: none + * Global values: none + +# Credits +These definitions were written by [Alan Plum](https://github.com/pluma), and [Gaurav Sharma](https://github.com/gtpan77). diff --git a/node_modules/@types/cors/index.d.ts b/node_modules/@types/cors/index.d.ts new file mode 100755 index 0000000..9cc6124 --- /dev/null +++ b/node_modules/@types/cors/index.d.ts @@ -0,0 +1,58 @@ +// Type definitions for cors 2.8 +// Project: https://github.com/expressjs/cors/ +// Definitions by: Alan Plum +// Gaurav Sharma +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { IncomingHttpHeaders } from 'http'; + +type StaticOrigin = boolean | string | RegExp | (boolean | string | RegExp)[]; + +type CustomOrigin = (requestOrigin: string | undefined, callback: (err: Error | null, origin?: StaticOrigin) => void) => void; + +declare namespace e { + interface CorsRequest { + method?: string | undefined; + headers: IncomingHttpHeaders; + } + interface CorsOptions { + /** + * @default '*'' + */ + origin?: StaticOrigin | CustomOrigin | undefined; + /** + * @default 'GET,HEAD,PUT,PATCH,POST,DELETE' + */ + methods?: string | string[] | undefined; + allowedHeaders?: string | string[] | undefined; + exposedHeaders?: string | string[] | undefined; + credentials?: boolean | undefined; + maxAge?: number | undefined; + /** + * @default false + */ + preflightContinue?: boolean | undefined; + /** + * @default 204 + */ + optionsSuccessStatus?: number | undefined; + } + type CorsOptionsDelegate = ( + req: T, + callback: (err: Error | null, options?: CorsOptions) => void, + ) => void; +} + +declare function e( + options?: e.CorsOptions | e.CorsOptionsDelegate, +): ( + req: T, + res: { + statusCode?: number | undefined; + setHeader(key: string, value: string): any; + end(): any; + }, + next: (err?: any) => any, +) => void; +export = e; diff --git a/node_modules/@types/cors/package.json b/node_modules/@types/cors/package.json new file mode 100755 index 0000000..bb2814a --- /dev/null +++ b/node_modules/@types/cors/package.json @@ -0,0 +1,30 @@ +{ + "name": "@types/cors", + "version": "2.8.12", + "description": "TypeScript definitions for cors", + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors", + "license": "MIT", + "contributors": [ + { + "name": "Alan Plum", + "url": "https://github.com/pluma", + "githubUsername": "pluma" + }, + { + "name": "Gaurav Sharma", + "url": "https://github.com/gtpan77", + "githubUsername": "gtpan77" + } + ], + "main": "", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", + "directory": "types/cors" + }, + "scripts": {}, + "dependencies": {}, + "typesPublisherContentHash": "53ea51a6543d58d3c1b9035a9c361d8f06d7be01973be2895820b2fb7ad9563a", + "typeScriptVersion": "3.6" +} \ No newline at end of file diff --git a/node_modules/@types/webidl-conversions/LICENSE b/node_modules/@types/webidl-conversions/LICENSE new file mode 100755 index 0000000..9e841e7 --- /dev/null +++ b/node_modules/@types/webidl-conversions/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/node_modules/@types/webidl-conversions/README.md b/node_modules/@types/webidl-conversions/README.md new file mode 100755 index 0000000..f0abd00 --- /dev/null +++ b/node_modules/@types/webidl-conversions/README.md @@ -0,0 +1,16 @@ +# Installation +> `npm install --save @types/webidl-conversions` + +# Summary +This package contains type definitions for webidl-conversions (https://github.com/jsdom/webidl-conversions#readme). + +# Details +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/webidl-conversions. + +### Additional Details + * Last updated: Mon, 29 Aug 2022 23:32:44 GMT + * Dependencies: none + * Global values: none + +# Credits +These definitions were written by [ExE Boss](https://github.com/ExE-Boss), and [BendingBender](https://github.com/BendingBender). diff --git a/node_modules/@types/webidl-conversions/index.d.ts b/node_modules/@types/webidl-conversions/index.d.ts new file mode 100755 index 0000000..ba90653 --- /dev/null +++ b/node_modules/@types/webidl-conversions/index.d.ts @@ -0,0 +1,97 @@ +// Type definitions for webidl-conversions 7.0 +// Project: https://github.com/jsdom/webidl-conversions#readme +// Definitions by: ExE Boss +// BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace WebIDLConversions { + interface Globals { + [key: string]: unknown; + + Number: (value?: unknown) => number; + String: (value?: unknown) => string; + TypeError: new (message?: string) => TypeError; + } + + interface Options { + context?: string | undefined; + globals?: Globals | undefined; + } + + interface IntegerOptions extends Options { + enforceRange?: boolean | undefined; + clamp?: boolean | undefined; + } + + interface StringOptions extends Options { + treatNullAsEmptyString?: boolean | undefined; + } + + interface BufferSourceOptions extends Options { + allowShared?: boolean | undefined; + } + + type IntegerConversion = (V: unknown, opts?: IntegerOptions) => number; + type StringConversion = (V: unknown, opts?: StringOptions) => string; + type NumberConversion = (V: unknown, opts?: Options) => number; +} + +declare const WebIDLConversions: { + any(V: V, opts?: WebIDLConversions.Options): V; + undefined(V?: unknown, opts?: WebIDLConversions.Options): void; + boolean(V: unknown, opts?: WebIDLConversions.Options): boolean; + + byte(V: unknown, opts?: WebIDLConversions.IntegerOptions): number; + octet(V: unknown, opts?: WebIDLConversions.IntegerOptions): number; + + short(V: unknown, opts?: WebIDLConversions.IntegerOptions): number; + ['unsigned short'](V: unknown, opts?: WebIDLConversions.IntegerOptions): number; + + long(V: unknown, opts?: WebIDLConversions.IntegerOptions): number; + ['unsigned long'](V: unknown, opts?: WebIDLConversions.IntegerOptions): number; + + ['long long'](V: unknown, opts?: WebIDLConversions.IntegerOptions): number; + ['unsigned long long'](V: unknown, opts?: WebIDLConversions.IntegerOptions): number; + + double(V: unknown, opts?: WebIDLConversions.Options): number; + ['unrestricted double'](V: unknown, opts?: WebIDLConversions.Options): number; + + float(V: unknown, opts?: WebIDLConversions.Options): number; + ['unrestricted float'](V: unknown, opts?: WebIDLConversions.Options): number; + + DOMString(V: unknown, opts?: WebIDLConversions.StringOptions): string; + ByteString(V: unknown, opts?: WebIDLConversions.StringOptions): string; + USVString(V: unknown, opts?: WebIDLConversions.StringOptions): string; + + object(V: V, opts?: WebIDLConversions.Options): V extends object ? V : V & object; + ArrayBuffer( + V: unknown, + opts?: WebIDLConversions.BufferSourceOptions & { allowShared?: false | undefined }, + ): ArrayBuffer; + ArrayBuffer(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): ArrayBufferLike; + DataView(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): DataView; + + Int8Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Int8Array; + Int16Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Int16Array; + Int32Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Int32Array; + + Uint8Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint8Array; + Uint16Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint16Array; + Uint32Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint32Array; + Uint8ClampedArray(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Uint8ClampedArray; + + Float32Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Float32Array; + Float64Array(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): Float64Array; + + ArrayBufferView(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): ArrayBufferView; + BufferSource( + V: unknown, + opts?: WebIDLConversions.BufferSourceOptions & { allowShared?: false | undefined }, + ): ArrayBuffer | ArrayBufferView; + BufferSource(V: unknown, opts?: WebIDLConversions.BufferSourceOptions): ArrayBufferLike | ArrayBufferView; + + DOMTimeStamp(V: unknown, opts?: WebIDLConversions.Options): number; +}; + +// This can't use ES6 style exports, as those can't have spaces in export names. +export = WebIDLConversions; diff --git a/node_modules/@types/webidl-conversions/package.json b/node_modules/@types/webidl-conversions/package.json new file mode 100755 index 0000000..9007033 --- /dev/null +++ b/node_modules/@types/webidl-conversions/package.json @@ -0,0 +1,30 @@ +{ + "name": "@types/webidl-conversions", + "version": "7.0.0", + "description": "TypeScript definitions for webidl-conversions", + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/webidl-conversions", + "license": "MIT", + "contributors": [ + { + "name": "ExE Boss", + "url": "https://github.com/ExE-Boss", + "githubUsername": "ExE-Boss" + }, + { + "name": "BendingBender", + "url": "https://github.com/BendingBender", + "githubUsername": "BendingBender" + } + ], + "main": "", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", + "directory": "types/webidl-conversions" + }, + "scripts": {}, + "dependencies": {}, + "typesPublisherContentHash": "e0992101980ba36c2f7240b4be2fd23d4ea0c812f8b3c9149d2efcfce2201d3b", + "typeScriptVersion": "4.0" +} \ No newline at end of file diff --git a/node_modules/@types/whatwg-url/LICENSE b/node_modules/@types/whatwg-url/LICENSE new file mode 100755 index 0000000..9e841e7 --- /dev/null +++ b/node_modules/@types/whatwg-url/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/node_modules/@types/whatwg-url/README.md b/node_modules/@types/whatwg-url/README.md new file mode 100755 index 0000000..3ba1b14 --- /dev/null +++ b/node_modules/@types/whatwg-url/README.md @@ -0,0 +1,16 @@ +# Installation +> `npm install --save @types/whatwg-url` + +# Summary +This package contains type definitions for whatwg-url (https://github.com/jsdom/whatwg-url#readme). + +# Details +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/whatwg-url. + +### Additional Details + * Last updated: Tue, 21 Jun 2022 16:31:40 GMT + * Dependencies: [@types/webidl-conversions](https://npmjs.com/package/@types/webidl-conversions), [@types/node](https://npmjs.com/package/@types/node) + * Global values: none + +# Credits +These definitions were written by [Alexander Marks](https://github.com/aomarks), and [ExE Boss](https://github.com/ExE-Boss). diff --git a/node_modules/@types/whatwg-url/dist/URL-impl.d.ts b/node_modules/@types/whatwg-url/dist/URL-impl.d.ts new file mode 100755 index 0000000..ae73946 --- /dev/null +++ b/node_modules/@types/whatwg-url/dist/URL-impl.d.ts @@ -0,0 +1,23 @@ +declare class URLImpl { + constructor( + globalObject: object, + constructorArgs: readonly [url: string, base?: string], + privateData?: {}, + ); + + href: string; + readonly origin: string; + protocol: string; + username: string; + password: string; + host: string; + hostname: string; + port: string; + pathname: string; + search: string; + readonly searchParams: URLSearchParams; + hash: string; + + toJSON(): string; +} +export { URLImpl as implementation }; diff --git a/node_modules/@types/whatwg-url/dist/URL.d.ts b/node_modules/@types/whatwg-url/dist/URL.d.ts new file mode 100755 index 0000000..47f092a --- /dev/null +++ b/node_modules/@types/whatwg-url/dist/URL.d.ts @@ -0,0 +1,76 @@ +import { Options as WebIDLConversionOptions } from "webidl-conversions"; +import { URL } from "../index"; +import { implementation as URLImpl } from "./URL-impl"; + +/** + * Checks whether `obj` is a `URL` object with an implementation + * provided by this package. + */ +export function is(obj: unknown): obj is URL; + +/** + * Checks whether `obj` is a `URLImpl` WebIDL2JS implementation object + * provided by this package. + */ +export function isImpl(obj: unknown): obj is URLImpl; + +/** + * Converts the `URL` wrapper into a `URLImpl` object. + * + * @throws {TypeError} If `obj` is not a `URL` wrapper instance provided by this package. + */ +export function convert(obj: unknown, options?: WebIDLConversionOptions): URLImpl; + +/** + * Creates a new `URL` instance. + * + * @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor + * registry or a `URL` constructor provided by this package + * in the WebIDL2JS constructor registry. + */ +export function create( + globalObject: object, + constructorArgs: readonly [url: string, base?: string], + privateData?: {}, +): URL; + +/** + * Calls `create()` and returns the internal `URLImpl`. + * + * @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor + * registry or a `URL` constructor provided by this package + * in the WebIDL2JS constructor registry. + */ +export function createImpl( + globalObject: object, + constructorArgs: readonly [url: string, base?: string], + privateData?: {}, +): URLImpl; + +/** + * Initializes the `URL` instance, called by `create()`. + * + * Useful when manually sub-classing a non-constructable wrapper object. + */ +export function setup( + obj: T, + globalObject: object, + constructorArgs: readonly [url: string, base?: string], + privateData?: {}, +): T; + +/** + * Creates a new `URL` object without runing the constructor steps. + * + * Useful when implementing specifications that initialize objects + * in different ways than their constructors do. + */ +declare function _new(globalObject: object): URLImpl; +export { _new as new }; + +/** + * Installs the `URL` constructor onto the `globalObject`. + * + * @throws {Error} If the target `globalObject` doesn't have an `Error` constructor. + */ +export function install(globalObject: object, globalNames: readonly string[]): void; diff --git a/node_modules/@types/whatwg-url/dist/URLSearchParams-impl.d.ts b/node_modules/@types/whatwg-url/dist/URLSearchParams-impl.d.ts new file mode 100755 index 0000000..3464b87 --- /dev/null +++ b/node_modules/@types/whatwg-url/dist/URLSearchParams-impl.d.ts @@ -0,0 +1,23 @@ +declare class URLSearchParamsImpl { + constructor( + globalObject: object, + constructorArgs: readonly [ + init?: + | ReadonlyArray + | { readonly [name: string]: string } + | string, + ], + privateData: { readonly doNotStripQMark?: boolean | undefined }, + ); + + append(name: string, value: string): void; + delete(name: string): void; + get(name: string): string | null; + getAll(name: string): string[]; + has(name: string): boolean; + set(name: string, value: string): void; + sort(): void; + + [Symbol.iterator](): IterableIterator<[name: string, value: string]>; +} +export { URLSearchParamsImpl as implementation }; diff --git a/node_modules/@types/whatwg-url/dist/URLSearchParams.d.ts b/node_modules/@types/whatwg-url/dist/URLSearchParams.d.ts new file mode 100755 index 0000000..c37585c --- /dev/null +++ b/node_modules/@types/whatwg-url/dist/URLSearchParams.d.ts @@ -0,0 +1,91 @@ +import { Options as WebIDLConversionOptions } from "webidl-conversions"; +import { URLSearchParams } from "../index"; +import { implementation as URLSearchParamsImpl } from "./URLSearchParams-impl"; + +/** + * Checks whether `obj` is a `URLSearchParams` object with an implementation + * provided by this package. + */ +export function is(obj: unknown): obj is URLSearchParams; + +/** + * Checks whether `obj` is a `URLSearchParamsImpl` WebIDL2JS implementation object + * provided by this package. + */ +export function isImpl(obj: unknown): obj is URLSearchParamsImpl; + +/** + * Converts the `URLSearchParams` wrapper into a `URLSearchParamsImpl` object. + * + * @throws {TypeError} If `obj` is not a `URLSearchParams` wrapper instance provided by this package. + */ +export function convert(obj: unknown, options?: WebIDLConversionOptions): URLSearchParamsImpl; + +/** + * Creates a new `URLSearchParams` instance. + * + * @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor + * registry or a `URLSearchParams` constructor provided by this package + * in the WebIDL2JS constructor registry. + */ +export function create( + globalObject: object, + constructorArgs?: readonly [ + init: + | ReadonlyArray<[name: string, value: string]> + | { readonly [name: string]: string } + | string, + ], + privateData?: { doNotStripQMark?: boolean | undefined }, +): URLSearchParams; + +/** + * Calls `create()` and returns the internal `URLSearchParamsImpl`. + * + * @throws {Error} If the `globalObject` doesn't have a WebIDL2JS constructor + * registry or a `URLSearchParams` constructor provided by this package + * in the WebIDL2JS constructor registry. + */ +export function createImpl( + globalObject: object, + constructorArgs?: readonly [ + init: + | ReadonlyArray<[name: string, value: string]> + | { readonly [name: string]: string } + | string, + ], + privateData?: { doNotStripQMark?: boolean | undefined }, +): URLSearchParamsImpl; + +/** + * Initializes the `URLSearchParams` instance, called by `create()`. + * + * Useful when manually sub-classing a non-constructable wrapper object. + */ +export function setup( + obj: T, + globalObject: object, + constructorArgs?: readonly [ + init: + | ReadonlyArray<[name: string, value: string]> + | { readonly [name: string]: string } + | string, + ], + privateData?: { doNotStripQMark?: boolean | undefined }, +): T; + +/** + * Creates a new `URLSearchParams` object without runing the constructor steps. + * + * Useful when implementing specifications that initialize objects + * in different ways than their constructors do. + */ +declare function _new(globalObject: object): URLSearchParamsImpl; +export { _new as new }; + +/** + * Installs the `URLSearchParams` constructor onto the `globalObject`. + * + * @throws {Error} If the target `globalObject` doesn't have an `Error` constructor. + */ +export function install(globalObject: object, globalNames: readonly string[]): void; diff --git a/node_modules/@types/whatwg-url/index.d.ts b/node_modules/@types/whatwg-url/index.d.ts new file mode 100755 index 0000000..3613a96 --- /dev/null +++ b/node_modules/@types/whatwg-url/index.d.ts @@ -0,0 +1,162 @@ +// Type definitions for whatwg-url 8.2 +// Project: https://github.com/jsdom/whatwg-url#readme +// Definitions by: Alexander Marks +// ExE Boss +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Minimum TypeScript Version: 3.6 + +/// + +/** https://url.spec.whatwg.org/#url-representation */ +export interface URLRecord { + scheme: string; + username: string; + password: string; + host: string | number | IPv6Address | null; + port: number | null; + path: string[]; + query: string | null; + fragment: string | null; + cannotBeABaseURL?: boolean | undefined; +} + +/** https://url.spec.whatwg.org/#concept-ipv6 */ +export type IPv6Address = [number, number, number, number, number, number, number, number]; + +/** https://url.spec.whatwg.org/#url-class */ +export class URL { + constructor(url: string, base?: string | URL); + + get href(): string; + set href(V: string); + + get origin(): string; + + get protocol(): string; + set protocol(V: string); + + get username(): string; + set username(V: string); + + get password(): string; + set password(V: string); + + get host(): string; + set host(V: string); + + get hostname(): string; + set hostname(V: string); + + get port(): string; + set port(V: string); + + get pathname(): string; + set pathname(V: string); + + get search(): string; + set search(V: string); + + get searchParams(): URLSearchParams; + + get hash(): string; + set hash(V: string); + + toJSON(): string; + + readonly [Symbol.toStringTag]: "URL"; +} + +/** https://url.spec.whatwg.org/#interface-urlsearchparams */ +export class URLSearchParams { + constructor( + init?: + | ReadonlyArray + | Iterable + | { readonly [name: string]: string } + | string, + ); + + append(name: string, value: string): void; + delete(name: string): void; + get(name: string): string | null; + getAll(name: string): string[]; + has(name: string): boolean; + set(name: string, value: string): void; + sort(): void; + + keys(): IterableIterator; + values(): IterableIterator; + entries(): IterableIterator<[name: string, value: string]>; + forEach( + callback: (this: THIS_ARG, value: string, name: string, searchParams: this) => void, + thisArg?: THIS_ARG, + ): void; + + readonly [Symbol.toStringTag]: "URLSearchParams"; + [Symbol.iterator](): IterableIterator<[name: string, value: string]>; +} + +/** https://url.spec.whatwg.org/#concept-url-parser */ +export function parseURL( + input: string, + options?: { readonly baseURL?: string | undefined; readonly encodingOverride?: string | undefined }, +): URLRecord | null; + +/** https://url.spec.whatwg.org/#concept-basic-url-parser */ +export function basicURLParse( + input: string, + options?: { + baseURL?: string | undefined; + encodingOverride?: string | undefined; + url?: URLRecord | undefined; + stateOverride?: StateOverride | undefined; + }, +): URLRecord | null; + +/** https://url.spec.whatwg.org/#scheme-start-state */ +export type StateOverride = + | "scheme start" + | "scheme" + | "no scheme" + | "special relative or authority" + | "path or authority" + | "relative" + | "relative slash" + | "special authority slashes" + | "special authority ignore slashes" + | "authority" + | "host" + | "hostname" + | "port" + | "file" + | "file slash" + | "file host" + | "path start" + | "path" + | "cannot-be-a-base-URL path" + | "query" + | "fragment"; + +/** https://url.spec.whatwg.org/#concept-url-serializer */ +export function serializeURL(urlRecord: URLRecord, excludeFragment?: boolean): string; + +/** https://url.spec.whatwg.org/#concept-host-serializer */ +export function serializeHost(host: string | number | IPv6Address): string; + +/** https://url.spec.whatwg.org/#serialize-an-integer */ +export function serializeInteger(number: number): string; + +/** https://html.spec.whatwg.org#ascii-serialisation-of-an-origin */ +export function serializeURLOrigin(urlRecord: URLRecord): string; + +/** https://url.spec.whatwg.org/#set-the-username */ +export function setTheUsername(urlRecord: URLRecord, username: string): void; + +/** https://url.spec.whatwg.org/#set-the-password */ +export function setThePassword(urlRecord: URLRecord, password: string): void; + +/** https://url.spec.whatwg.org/#cannot-have-a-username-password-port */ +export function cannotHaveAUsernamePasswordPort(urlRecord: URLRecord): boolean; + +/** https://url.spec.whatwg.org/#percent-decode */ +export function percentDecode(buffer: Extract>): Buffer; diff --git a/node_modules/@types/whatwg-url/package.json b/node_modules/@types/whatwg-url/package.json new file mode 100755 index 0000000..120d490 --- /dev/null +++ b/node_modules/@types/whatwg-url/package.json @@ -0,0 +1,33 @@ +{ + "name": "@types/whatwg-url", + "version": "8.2.2", + "description": "TypeScript definitions for whatwg-url", + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/whatwg-url", + "license": "MIT", + "contributors": [ + { + "name": "Alexander Marks", + "url": "https://github.com/aomarks", + "githubUsername": "aomarks" + }, + { + "name": "ExE Boss", + "url": "https://github.com/ExE-Boss", + "githubUsername": "ExE-Boss" + } + ], + "main": "", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", + "directory": "types/whatwg-url" + }, + "scripts": {}, + "dependencies": { + "@types/node": "*", + "@types/webidl-conversions": "*" + }, + "typesPublisherContentHash": "ea85d67c501583ff421cfbf206fafac0410c464edef169a6d88e06ecfe226dfc", + "typeScriptVersion": "4.0" +} \ No newline at end of file diff --git a/node_modules/@types/whatwg-url/webidl2js-wrapper.d.ts b/node_modules/@types/whatwg-url/webidl2js-wrapper.d.ts new file mode 100755 index 0000000..3b39af8 --- /dev/null +++ b/node_modules/@types/whatwg-url/webidl2js-wrapper.d.ts @@ -0,0 +1,4 @@ +import * as URL from "./dist/URL"; +import * as URLSearchParams from "./dist/URLSearchParams"; + +export { URL, URLSearchParams }; diff --git a/node_modules/base64-js/LICENSE b/node_modules/base64-js/LICENSE new file mode 100644 index 0000000..6d52b8a --- /dev/null +++ b/node_modules/base64-js/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Jameson Little + +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. diff --git a/node_modules/base64-js/README.md b/node_modules/base64-js/README.md new file mode 100644 index 0000000..b42a48f --- /dev/null +++ b/node_modules/base64-js/README.md @@ -0,0 +1,34 @@ +base64-js +========= + +`base64-js` does basic base64 encoding/decoding in pure JS. + +[![build status](https://secure.travis-ci.org/beatgammit/base64-js.png)](http://travis-ci.org/beatgammit/base64-js) + +Many browsers already have base64 encoding/decoding functionality, but it is for text data, not all-purpose binary data. + +Sometimes encoding/decoding binary data in the browser is useful, and that is what this module does. + +## install + +With [npm](https://npmjs.org) do: + +`npm install base64-js` and `var base64js = require('base64-js')` + +For use in web browsers do: + +`` + +[Get supported base64-js with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-base64-js?utm_source=npm-base64-js&utm_medium=referral&utm_campaign=readme) + +## methods + +`base64js` has three exposed functions, `byteLength`, `toByteArray` and `fromByteArray`, which both take a single argument. + +* `byteLength` - Takes a base64 string and returns length of byte array +* `toByteArray` - Takes a base64 string and returns a byte array +* `fromByteArray` - Takes a byte array and returns a base64 string + +## license + +MIT diff --git a/node_modules/base64-js/base64js.min.js b/node_modules/base64-js/base64js.min.js new file mode 100644 index 0000000..908ac83 --- /dev/null +++ b/node_modules/base64-js/base64js.min.js @@ -0,0 +1 @@ +(function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.base64js=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c>16,j[k++]=255&b>>8,j[k++]=255&b;return 2===h&&(b=l[a.charCodeAt(c)]<<2|l[a.charCodeAt(c+1)]>>4,j[k++]=255&b),1===h&&(b=l[a.charCodeAt(c)]<<10|l[a.charCodeAt(c+1)]<<4|l[a.charCodeAt(c+2)]>>2,j[k++]=255&b>>8,j[k++]=255&b),j}function g(a){return k[63&a>>18]+k[63&a>>12]+k[63&a>>6]+k[63&a]}function h(a,b,c){for(var d,e=[],f=b;fj?j:g+f));return 1===d?(b=a[c-1],e.push(k[b>>2]+k[63&b<<4]+"==")):2===d&&(b=(a[c-2]<<8)+a[c-1],e.push(k[b>>10]+k[63&b>>4]+k[63&b<<2]+"=")),e.join("")}c.byteLength=function(a){var b=d(a),c=b[0],e=b[1];return 3*(c+e)/4-e},c.toByteArray=f,c.fromByteArray=j;for(var k=[],l=[],m="undefined"==typeof Uint8Array?Array:Uint8Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,p=n.length;o 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + var i + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') +} diff --git a/node_modules/base64-js/package.json b/node_modules/base64-js/package.json new file mode 100644 index 0000000..c3972e3 --- /dev/null +++ b/node_modules/base64-js/package.json @@ -0,0 +1,47 @@ +{ + "name": "base64-js", + "description": "Base64 encoding/decoding in pure JS", + "version": "1.5.1", + "author": "T. Jameson Little ", + "typings": "index.d.ts", + "bugs": { + "url": "https://github.com/beatgammit/base64-js/issues" + }, + "devDependencies": { + "babel-minify": "^0.5.1", + "benchmark": "^2.1.4", + "browserify": "^16.3.0", + "standard": "*", + "tape": "4.x" + }, + "homepage": "https://github.com/beatgammit/base64-js", + "keywords": [ + "base64" + ], + "license": "MIT", + "main": "index.js", + "repository": { + "type": "git", + "url": "git://github.com/beatgammit/base64-js.git" + }, + "scripts": { + "build": "browserify -s base64js -r ./ | minify > base64js.min.js", + "lint": "standard", + "test": "npm run lint && npm run unit", + "unit": "tape test/*.js" + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] +} diff --git a/node_modules/base64id/CHANGELOG.md b/node_modules/base64id/CHANGELOG.md new file mode 100644 index 0000000..b2b8332 --- /dev/null +++ b/node_modules/base64id/CHANGELOG.md @@ -0,0 +1,16 @@ +# [2.0.0](https://github.com/faeldt/base64id/compare/1.0.0...2.0.0) (2019-05-27) + + +### Code Refactoring + +* **buffer:** replace deprecated Buffer constructor usage ([#11](https://github.com/faeldt/base64id/issues/11)) ([ccfba54](https://github.com/faeldt/base64id/commit/ccfba54)) + + +### BREAKING CHANGES + +* **buffer:** drop support for Node.js ≤ 4.4.x and 5.0.0 - 5.9.x + +See: https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/ + + + diff --git a/node_modules/base64id/LICENSE b/node_modules/base64id/LICENSE new file mode 100644 index 0000000..0d03c83 --- /dev/null +++ b/node_modules/base64id/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2012-2016 Kristian Faeldt + +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. diff --git a/node_modules/base64id/README.md b/node_modules/base64id/README.md new file mode 100644 index 0000000..17689e6 --- /dev/null +++ b/node_modules/base64id/README.md @@ -0,0 +1,18 @@ +base64id +======== + +Node.js module that generates a base64 id. + +Uses crypto.randomBytes when available, falls back to unsafe methods for node.js <= 0.4. + +To increase performance, random bytes are buffered to minimize the number of synchronous calls to crypto.randomBytes. + +## Installation + + $ npm install base64id + +## Usage + + var base64id = require('base64id'); + + var id = base64id.generateId(); diff --git a/node_modules/base64id/lib/base64id.js b/node_modules/base64id/lib/base64id.js new file mode 100644 index 0000000..15afe74 --- /dev/null +++ b/node_modules/base64id/lib/base64id.js @@ -0,0 +1,103 @@ +/*! + * base64id v0.1.0 + */ + +/** + * Module dependencies + */ + +var crypto = require('crypto'); + +/** + * Constructor + */ + +var Base64Id = function() { }; + +/** + * Get random bytes + * + * Uses a buffer if available, falls back to crypto.randomBytes + */ + +Base64Id.prototype.getRandomBytes = function(bytes) { + + var BUFFER_SIZE = 4096 + var self = this; + + bytes = bytes || 12; + + if (bytes > BUFFER_SIZE) { + return crypto.randomBytes(bytes); + } + + var bytesInBuffer = parseInt(BUFFER_SIZE/bytes); + var threshold = parseInt(bytesInBuffer*0.85); + + if (!threshold) { + return crypto.randomBytes(bytes); + } + + if (this.bytesBufferIndex == null) { + this.bytesBufferIndex = -1; + } + + if (this.bytesBufferIndex == bytesInBuffer) { + this.bytesBuffer = null; + this.bytesBufferIndex = -1; + } + + // No buffered bytes available or index above threshold + if (this.bytesBufferIndex == -1 || this.bytesBufferIndex > threshold) { + + if (!this.isGeneratingBytes) { + this.isGeneratingBytes = true; + crypto.randomBytes(BUFFER_SIZE, function(err, bytes) { + self.bytesBuffer = bytes; + self.bytesBufferIndex = 0; + self.isGeneratingBytes = false; + }); + } + + // Fall back to sync call when no buffered bytes are available + if (this.bytesBufferIndex == -1) { + return crypto.randomBytes(bytes); + } + } + + var result = this.bytesBuffer.slice(bytes*this.bytesBufferIndex, bytes*(this.bytesBufferIndex+1)); + this.bytesBufferIndex++; + + return result; +} + +/** + * Generates a base64 id + * + * (Original version from socket.io ) + */ + +Base64Id.prototype.generateId = function () { + var rand = Buffer.alloc(15); // multiple of 3 for base64 + if (!rand.writeInt32BE) { + return Math.abs(Math.random() * Math.random() * Date.now() | 0).toString() + + Math.abs(Math.random() * Math.random() * Date.now() | 0).toString(); + } + this.sequenceNumber = (this.sequenceNumber + 1) | 0; + rand.writeInt32BE(this.sequenceNumber, 11); + if (crypto.randomBytes) { + this.getRandomBytes(12).copy(rand); + } else { + // not secure for node 0.4 + [0, 4, 8].forEach(function(i) { + rand.writeInt32BE(Math.random() * Math.pow(2, 32) | 0, i); + }); + } + return rand.toString('base64').replace(/\//g, '_').replace(/\+/g, '-'); +}; + +/** + * Export + */ + +exports = module.exports = new Base64Id(); diff --git a/node_modules/base64id/package.json b/node_modules/base64id/package.json new file mode 100644 index 0000000..d03d64c --- /dev/null +++ b/node_modules/base64id/package.json @@ -0,0 +1,13 @@ +{ + "name": "base64id" + , "version": "2.0.0" + , "license": "MIT" + , "description": "Generates a base64 id" + , "author": "Kristian Faeldt " + , "repository": { + "type": "git" + , "url": "https://github.com/faeldt/base64id.git" + } + , "main": "./lib/base64id.js" + , "engines": { "node": "^4.5.0 || >= 5.9" } +} diff --git a/node_modules/basic-auth/HISTORY.md b/node_modules/basic-auth/HISTORY.md new file mode 100644 index 0000000..2c44a01 --- /dev/null +++ b/node_modules/basic-auth/HISTORY.md @@ -0,0 +1,52 @@ +2.0.1 / 2018-09-19 +================== + + * deps: safe-buffer@5.1.2 + +2.0.0 / 2017-09-12 +================== + + * Drop support for Node.js below 0.8 + * Remove `auth(ctx)` signature -- pass in header or `auth(ctx.req)` + * Use `safe-buffer` for improved Buffer API + +1.1.0 / 2016-11-18 +================== + + * Add `auth.parse` for low-level string parsing + +1.0.4 / 2016-05-10 +================== + + * Improve error message when `req` argument is not an object + * Improve error message when `req` missing `headers` property + +1.0.3 / 2015-07-01 +================== + + * Fix regression accepting a Koa context + +1.0.2 / 2015-06-12 +================== + + * Improve error message when `req` argument missing + * perf: enable strict mode + * perf: hoist regular expression + * perf: parse with regular expressions + * perf: remove argument reassignment + +1.0.1 / 2015-05-04 +================== + + * Update readme + +1.0.0 / 2014-07-01 +================== + + * Support empty password + * Support empty username + +0.0.1 / 2013-11-30 +================== + + * Initial release diff --git a/node_modules/basic-auth/LICENSE b/node_modules/basic-auth/LICENSE new file mode 100644 index 0000000..89041f6 --- /dev/null +++ b/node_modules/basic-auth/LICENSE @@ -0,0 +1,24 @@ +(The MIT License) + +Copyright (c) 2013 TJ Holowaychuk +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2015-2016 Douglas Christopher Wilson + +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. diff --git a/node_modules/basic-auth/README.md b/node_modules/basic-auth/README.md new file mode 100644 index 0000000..5f3d758 --- /dev/null +++ b/node_modules/basic-auth/README.md @@ -0,0 +1,113 @@ +# basic-auth + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Generic basic auth Authorization header field parser for whatever. + +## 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): + +``` +$ npm install basic-auth +``` + +## API + + + +```js +var auth = require('basic-auth') +``` + +### auth(req) + +Get the basic auth credentials from the given request. The `Authorization` +header is parsed and if the header is invalid, `undefined` is returned, +otherwise an object with `name` and `pass` properties. + +### auth.parse(string) + +Parse a basic auth authorization header string. This will return an object +with `name` and `pass` properties, or `undefined` if the string is invalid. + +## Example + +Pass a Node.js request object to the module export. If parsing fails +`undefined` is returned, otherwise an object with `.name` and `.pass`. + + + +```js +var auth = require('basic-auth') +var user = auth(req) +// => { name: 'something', pass: 'whatever' } +``` + +A header string from any other location can also be parsed with +`auth.parse`, for example a `Proxy-Authorization` header: + + + +```js +var auth = require('basic-auth') +var user = auth.parse(req.getHeader('Proxy-Authorization')) +``` + +### With vanilla node.js http server + +```js +var http = require('http') +var auth = require('basic-auth') +var compare = require('tsscmp') + +// Create server +var server = http.createServer(function (req, res) { + var credentials = auth(req) + + // Check credentials + // The "check" function will typically be against your user store + if (!credentials || !check(credentials.name, credentials.pass)) { + res.statusCode = 401 + res.setHeader('WWW-Authenticate', 'Basic realm="example"') + res.end('Access denied') + } else { + res.end('Access granted') + } +}) + +// Basic function to validate credentials for example +function check (name, pass) { + var valid = true + + // Simple method to prevent short-circut and use timing-safe compare + valid = compare(name, 'john') && valid + valid = compare(pass, 'secret') && valid + + return valid +} + +// Listen +server.listen(3000) +``` + +# License + +[MIT](LICENSE) + +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/basic-auth/master +[coveralls-url]: https://coveralls.io/r/jshttp/basic-auth?branch=master +[downloads-image]: https://badgen.net/npm/dm/basic-auth +[downloads-url]: https://npmjs.org/package/basic-auth +[node-version-image]: https://badgen.net/npm/node/basic-auth +[node-version-url]: https://nodejs.org/en/download +[npm-image]: https://badgen.net/npm/v/basic-auth +[npm-url]: https://npmjs.org/package/basic-auth +[travis-image]: https://badgen.net/travis/jshttp/basic-auth/master +[travis-url]: https://travis-ci.org/jshttp/basic-auth diff --git a/node_modules/basic-auth/index.js b/node_modules/basic-auth/index.js new file mode 100644 index 0000000..9106e64 --- /dev/null +++ b/node_modules/basic-auth/index.js @@ -0,0 +1,133 @@ +/*! + * basic-auth + * Copyright(c) 2013 TJ Holowaychuk + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2015-2016 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var Buffer = require('safe-buffer').Buffer + +/** + * Module exports. + * @public + */ + +module.exports = auth +module.exports.parse = parse + +/** + * RegExp for basic auth credentials + * + * credentials = auth-scheme 1*SP token68 + * auth-scheme = "Basic" ; case insensitive + * token68 = 1*( ALPHA / DIGIT / "-" / "." / "_" / "~" / "+" / "/" ) *"=" + * @private + */ + +var CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/ + +/** + * RegExp for basic auth user/pass + * + * user-pass = userid ":" password + * userid = * + * password = *TEXT + * @private + */ + +var USER_PASS_REGEXP = /^([^:]*):(.*)$/ + +/** + * Parse the Authorization header field of a request. + * + * @param {object} req + * @return {object} with .name and .pass + * @public + */ + +function auth (req) { + if (!req) { + throw new TypeError('argument req is required') + } + + if (typeof req !== 'object') { + throw new TypeError('argument req is required to be an object') + } + + // get header + var header = getAuthorization(req) + + // parse header + return parse(header) +} + +/** + * Decode base64 string. + * @private + */ + +function decodeBase64 (str) { + return Buffer.from(str, 'base64').toString() +} + +/** + * Get the Authorization header from request object. + * @private + */ + +function getAuthorization (req) { + if (!req.headers || typeof req.headers !== 'object') { + throw new TypeError('argument req is required to have headers property') + } + + return req.headers.authorization +} + +/** + * Parse basic auth to object. + * + * @param {string} string + * @return {object} + * @public + */ + +function parse (string) { + if (typeof string !== 'string') { + return undefined + } + + // parse header + var match = CREDENTIALS_REGEXP.exec(string) + + if (!match) { + return undefined + } + + // decode user pass + var userPass = USER_PASS_REGEXP.exec(decodeBase64(match[1])) + + if (!userPass) { + return undefined + } + + // return credentials object + return new Credentials(userPass[1], userPass[2]) +} + +/** + * Object to represent user credentials. + * @private + */ + +function Credentials (name, pass) { + this.name = name + this.pass = pass +} diff --git a/node_modules/basic-auth/node_modules/safe-buffer/LICENSE b/node_modules/basic-auth/node_modules/safe-buffer/LICENSE new file mode 100644 index 0000000..0c068ce --- /dev/null +++ b/node_modules/basic-auth/node_modules/safe-buffer/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Feross Aboukhadijeh + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/basic-auth/node_modules/safe-buffer/README.md b/node_modules/basic-auth/node_modules/safe-buffer/README.md new file mode 100644 index 0000000..e9a81af --- /dev/null +++ b/node_modules/basic-auth/node_modules/safe-buffer/README.md @@ -0,0 +1,584 @@ +# safe-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] + +[travis-image]: https://img.shields.io/travis/feross/safe-buffer/master.svg +[travis-url]: https://travis-ci.org/feross/safe-buffer +[npm-image]: https://img.shields.io/npm/v/safe-buffer.svg +[npm-url]: https://npmjs.org/package/safe-buffer +[downloads-image]: https://img.shields.io/npm/dm/safe-buffer.svg +[downloads-url]: https://npmjs.org/package/safe-buffer +[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg +[standard-url]: https://standardjs.com + +#### Safer Node.js Buffer API + +**Use the new Node.js Buffer APIs (`Buffer.from`, `Buffer.alloc`, +`Buffer.allocUnsafe`, `Buffer.allocUnsafeSlow`) in all versions of Node.js.** + +**Uses the built-in implementation when available.** + +## install + +``` +npm install safe-buffer +``` + +## usage + +The goal of this package is to provide a safe replacement for the node.js `Buffer`. + +It's a drop-in replacement for `Buffer`. You can use it by adding one `require` line to +the top of your node.js modules: + +```js +var Buffer = require('safe-buffer').Buffer + +// Existing buffer code will continue to work without issues: + +new Buffer('hey', 'utf8') +new Buffer([1, 2, 3], 'utf8') +new Buffer(obj) +new Buffer(16) // create an uninitialized buffer (potentially unsafe) + +// But you can use these new explicit APIs to make clear what you want: + +Buffer.from('hey', 'utf8') // convert from many types to a Buffer +Buffer.alloc(16) // create a zero-filled buffer (safe) +Buffer.allocUnsafe(16) // create an uninitialized buffer (potentially unsafe) +``` + +## api + +### Class Method: Buffer.from(array) + + +* `array` {Array} + +Allocates a new `Buffer` using an `array` of octets. + +```js +const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]); + // creates a new Buffer containing ASCII bytes + // ['b','u','f','f','e','r'] +``` + +A `TypeError` will be thrown if `array` is not an `Array`. + +### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]]) + + +* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or + a `new ArrayBuffer()` +* `byteOffset` {Number} Default: `0` +* `length` {Number} Default: `arrayBuffer.length - byteOffset` + +When passed a reference to the `.buffer` property of a `TypedArray` instance, +the newly created `Buffer` will share the same allocated memory as the +TypedArray. + +```js +const arr = new Uint16Array(2); +arr[0] = 5000; +arr[1] = 4000; + +const buf = Buffer.from(arr.buffer); // shares the memory with arr; + +console.log(buf); + // Prints: + +// changing the TypedArray changes the Buffer also +arr[1] = 6000; + +console.log(buf); + // Prints: +``` + +The optional `byteOffset` and `length` arguments specify a memory range within +the `arrayBuffer` that will be shared by the `Buffer`. + +```js +const ab = new ArrayBuffer(10); +const buf = Buffer.from(ab, 0, 2); +console.log(buf.length); + // Prints: 2 +``` + +A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`. + +### Class Method: Buffer.from(buffer) + + +* `buffer` {Buffer} + +Copies the passed `buffer` data onto a new `Buffer` instance. + +```js +const buf1 = Buffer.from('buffer'); +const buf2 = Buffer.from(buf1); + +buf1[0] = 0x61; +console.log(buf1.toString()); + // 'auffer' +console.log(buf2.toString()); + // 'buffer' (copy is not changed) +``` + +A `TypeError` will be thrown if `buffer` is not a `Buffer`. + +### Class Method: Buffer.from(str[, encoding]) + + +* `str` {String} String to encode. +* `encoding` {String} Encoding to use, Default: `'utf8'` + +Creates a new `Buffer` containing the given JavaScript string `str`. If +provided, the `encoding` parameter identifies the character encoding. +If not provided, `encoding` defaults to `'utf8'`. + +```js +const buf1 = Buffer.from('this is a tést'); +console.log(buf1.toString()); + // prints: this is a tést +console.log(buf1.toString('ascii')); + // prints: this is a tC)st + +const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex'); +console.log(buf2.toString()); + // prints: this is a tést +``` + +A `TypeError` will be thrown if `str` is not a string. + +### Class Method: Buffer.alloc(size[, fill[, encoding]]) + + +* `size` {Number} +* `fill` {Value} Default: `undefined` +* `encoding` {String} Default: `utf8` + +Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the +`Buffer` will be *zero-filled*. + +```js +const buf = Buffer.alloc(5); +console.log(buf); + // +``` + +The `size` must be less than or equal to the value of +`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is +`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will +be created if a `size` less than or equal to 0 is specified. + +If `fill` is specified, the allocated `Buffer` will be initialized by calling +`buf.fill(fill)`. See [`buf.fill()`][] for more information. + +```js +const buf = Buffer.alloc(5, 'a'); +console.log(buf); + // +``` + +If both `fill` and `encoding` are specified, the allocated `Buffer` will be +initialized by calling `buf.fill(fill, encoding)`. For example: + +```js +const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); +console.log(buf); + // +``` + +Calling `Buffer.alloc(size)` can be significantly slower than the alternative +`Buffer.allocUnsafe(size)` but ensures that the newly created `Buffer` instance +contents will *never contain sensitive data*. + +A `TypeError` will be thrown if `size` is not a number. + +### Class Method: Buffer.allocUnsafe(size) + + +* `size` {Number} + +Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must +be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit +architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is +thrown. A zero-length Buffer will be created if a `size` less than or equal to +0 is specified. + +The underlying memory for `Buffer` instances created in this way is *not +initialized*. The contents of the newly created `Buffer` are unknown and +*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such +`Buffer` instances to zeroes. + +```js +const buf = Buffer.allocUnsafe(5); +console.log(buf); + // + // (octets will be different, every time) +buf.fill(0); +console.log(buf); + // +``` + +A `TypeError` will be thrown if `size` is not a number. + +Note that the `Buffer` module pre-allocates an internal `Buffer` instance of +size `Buffer.poolSize` that is used as a pool for the fast allocation of new +`Buffer` instances created using `Buffer.allocUnsafe(size)` (and the deprecated +`new Buffer(size)` constructor) only when `size` is less than or equal to +`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). The default +value of `Buffer.poolSize` is `8192` but can be modified. + +Use of this pre-allocated internal memory pool is a key difference between +calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`. +Specifically, `Buffer.alloc(size, fill)` will *never* use the internal Buffer +pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal +Buffer pool if `size` is less than or equal to half `Buffer.poolSize`. The +difference is subtle but can be important when an application requires the +additional performance that `Buffer.allocUnsafe(size)` provides. + +### Class Method: Buffer.allocUnsafeSlow(size) + + +* `size` {Number} + +Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The +`size` must be less than or equal to the value of +`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is +`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will +be created if a `size` less than or equal to 0 is specified. + +The underlying memory for `Buffer` instances created in this way is *not +initialized*. The contents of the newly created `Buffer` are unknown and +*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such +`Buffer` instances to zeroes. + +When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances, +allocations under 4KB are, by default, sliced from a single pre-allocated +`Buffer`. This allows applications to avoid the garbage collection overhead of +creating many individually allocated Buffers. This approach improves both +performance and memory usage by eliminating the need to track and cleanup as +many `Persistent` objects. + +However, in the case where a developer may need to retain a small chunk of +memory from a pool for an indeterminate amount of time, it may be appropriate +to create an un-pooled Buffer instance using `Buffer.allocUnsafeSlow()` then +copy out the relevant bits. + +```js +// need to keep around a few small chunks of memory +const store = []; + +socket.on('readable', () => { + const data = socket.read(); + // allocate for retained data + const sb = Buffer.allocUnsafeSlow(10); + // copy the data into the new allocation + data.copy(sb, 0, 0, 10); + store.push(sb); +}); +``` + +Use of `Buffer.allocUnsafeSlow()` should be used only as a last resort *after* +a developer has observed undue memory retention in their applications. + +A `TypeError` will be thrown if `size` is not a number. + +### All the Rest + +The rest of the `Buffer` API is exactly the same as in node.js. +[See the docs](https://nodejs.org/api/buffer.html). + + +## Related links + +- [Node.js issue: Buffer(number) is unsafe](https://github.com/nodejs/node/issues/4660) +- [Node.js Enhancement Proposal: Buffer.from/Buffer.alloc/Buffer.zalloc/Buffer() soft-deprecate](https://github.com/nodejs/node-eps/pull/4) + +## Why is `Buffer` unsafe? + +Today, the node.js `Buffer` constructor is overloaded to handle many different argument +types like `String`, `Array`, `Object`, `TypedArrayView` (`Uint8Array`, etc.), +`ArrayBuffer`, and also `Number`. + +The API is optimized for convenience: you can throw any type at it, and it will try to do +what you want. + +Because the Buffer constructor is so powerful, you often see code like this: + +```js +// Convert UTF-8 strings to hex +function toHex (str) { + return new Buffer(str).toString('hex') +} +``` + +***But what happens if `toHex` is called with a `Number` argument?*** + +### Remote Memory Disclosure + +If an attacker can make your program call the `Buffer` constructor with a `Number` +argument, then they can make it allocate uninitialized memory from the node.js process. +This could potentially disclose TLS private keys, user data, or database passwords. + +When the `Buffer` constructor is passed a `Number` argument, it returns an +**UNINITIALIZED** block of memory of the specified `size`. When you create a `Buffer` like +this, you **MUST** overwrite the contents before returning it to the user. + +From the [node.js docs](https://nodejs.org/api/buffer.html#buffer_new_buffer_size): + +> `new Buffer(size)` +> +> - `size` Number +> +> The underlying memory for `Buffer` instances created in this way is not initialized. +> **The contents of a newly created `Buffer` are unknown and could contain sensitive +> data.** Use `buf.fill(0)` to initialize a Buffer to zeroes. + +(Emphasis our own.) + +Whenever the programmer intended to create an uninitialized `Buffer` you often see code +like this: + +```js +var buf = new Buffer(16) + +// Immediately overwrite the uninitialized buffer with data from another buffer +for (var i = 0; i < buf.length; i++) { + buf[i] = otherBuf[i] +} +``` + + +### Would this ever be a problem in real code? + +Yes. It's surprisingly common to forget to check the type of your variables in a +dynamically-typed language like JavaScript. + +Usually the consequences of assuming the wrong type is that your program crashes with an +uncaught exception. But the failure mode for forgetting to check the type of arguments to +the `Buffer` constructor is more catastrophic. + +Here's an example of a vulnerable service that takes a JSON payload and converts it to +hex: + +```js +// Take a JSON payload {str: "some string"} and convert it to hex +var server = http.createServer(function (req, res) { + var data = '' + req.setEncoding('utf8') + req.on('data', function (chunk) { + data += chunk + }) + req.on('end', function () { + var body = JSON.parse(data) + res.end(new Buffer(body.str).toString('hex')) + }) +}) + +server.listen(8080) +``` + +In this example, an http client just has to send: + +```json +{ + "str": 1000 +} +``` + +and it will get back 1,000 bytes of uninitialized memory from the server. + +This is a very serious bug. It's similar in severity to the +[the Heartbleed bug](http://heartbleed.com/) that allowed disclosure of OpenSSL process +memory by remote attackers. + + +### Which real-world packages were vulnerable? + +#### [`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht) + +[Mathias Buus](https://github.com/mafintosh) and I +([Feross Aboukhadijeh](http://feross.org/)) found this issue in one of our own packages, +[`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht). The bug would allow +anyone on the internet to send a series of messages to a user of `bittorrent-dht` and get +them to reveal 20 bytes at a time of uninitialized memory from the node.js process. + +Here's +[the commit](https://github.com/feross/bittorrent-dht/commit/6c7da04025d5633699800a99ec3fbadf70ad35b8) +that fixed it. We released a new fixed version, created a +[Node Security Project disclosure](https://nodesecurity.io/advisories/68), and deprecated all +vulnerable versions on npm so users will get a warning to upgrade to a newer version. + +#### [`ws`](https://www.npmjs.com/package/ws) + +That got us wondering if there were other vulnerable packages. Sure enough, within a short +period of time, we found the same issue in [`ws`](https://www.npmjs.com/package/ws), the +most popular WebSocket implementation in node.js. + +If certain APIs were called with `Number` parameters instead of `String` or `Buffer` as +expected, then uninitialized server memory would be disclosed to the remote peer. + +These were the vulnerable methods: + +```js +socket.send(number) +socket.ping(number) +socket.pong(number) +``` + +Here's a vulnerable socket server with some echo functionality: + +```js +server.on('connection', function (socket) { + socket.on('message', function (message) { + message = JSON.parse(message) + if (message.type === 'echo') { + socket.send(message.data) // send back the user's message + } + }) +}) +``` + +`socket.send(number)` called on the server, will disclose server memory. + +Here's [the release](https://github.com/websockets/ws/releases/tag/1.0.1) where the issue +was fixed, with a more detailed explanation. Props to +[Arnout Kazemier](https://github.com/3rd-Eden) for the quick fix. Here's the +[Node Security Project disclosure](https://nodesecurity.io/advisories/67). + + +### What's the solution? + +It's important that node.js offers a fast way to get memory otherwise performance-critical +applications would needlessly get a lot slower. + +But we need a better way to *signal our intent* as programmers. **When we want +uninitialized memory, we should request it explicitly.** + +Sensitive functionality should not be packed into a developer-friendly API that loosely +accepts many different types. This type of API encourages the lazy practice of passing +variables in without checking the type very carefully. + +#### A new API: `Buffer.allocUnsafe(number)` + +The functionality of creating buffers with uninitialized memory should be part of another +API. We propose `Buffer.allocUnsafe(number)`. This way, it's not part of an API that +frequently gets user input of all sorts of different types passed into it. + +```js +var buf = Buffer.allocUnsafe(16) // careful, uninitialized memory! + +// Immediately overwrite the uninitialized buffer with data from another buffer +for (var i = 0; i < buf.length; i++) { + buf[i] = otherBuf[i] +} +``` + + +### How do we fix node.js core? + +We sent [a PR to node.js core](https://github.com/nodejs/node/pull/4514) (merged as +`semver-major`) which defends against one case: + +```js +var str = 16 +new Buffer(str, 'utf8') +``` + +In this situation, it's implied that the programmer intended the first argument to be a +string, since they passed an encoding as a second argument. Today, node.js will allocate +uninitialized memory in the case of `new Buffer(number, encoding)`, which is probably not +what the programmer intended. + +But this is only a partial solution, since if the programmer does `new Buffer(variable)` +(without an `encoding` parameter) there's no way to know what they intended. If `variable` +is sometimes a number, then uninitialized memory will sometimes be returned. + +### What's the real long-term fix? + +We could deprecate and remove `new Buffer(number)` and use `Buffer.allocUnsafe(number)` when +we need uninitialized memory. But that would break 1000s of packages. + +~~We believe the best solution is to:~~ + +~~1. Change `new Buffer(number)` to return safe, zeroed-out memory~~ + +~~2. Create a new API for creating uninitialized Buffers. We propose: `Buffer.allocUnsafe(number)`~~ + +#### Update + +We now support adding three new APIs: + +- `Buffer.from(value)` - convert from any type to a buffer +- `Buffer.alloc(size)` - create a zero-filled buffer +- `Buffer.allocUnsafe(size)` - create an uninitialized buffer with given size + +This solves the core problem that affected `ws` and `bittorrent-dht` which is +`Buffer(variable)` getting tricked into taking a number argument. + +This way, existing code continues working and the impact on the npm ecosystem will be +minimal. Over time, npm maintainers can migrate performance-critical code to use +`Buffer.allocUnsafe(number)` instead of `new Buffer(number)`. + + +### Conclusion + +We think there's a serious design issue with the `Buffer` API as it exists today. It +promotes insecure software by putting high-risk functionality into a convenient API +with friendly "developer ergonomics". + +This wasn't merely a theoretical exercise because we found the issue in some of the +most popular npm packages. + +Fortunately, there's an easy fix that can be applied today. Use `safe-buffer` in place of +`buffer`. + +```js +var Buffer = require('safe-buffer').Buffer +``` + +Eventually, we hope that node.js core can switch to this new, safer behavior. We believe +the impact on the ecosystem would be minimal since it's not a breaking change. +Well-maintained, popular packages would be updated to use `Buffer.alloc` quickly, while +older, insecure packages would magically become safe from this attack vector. + + +## links + +- [Node.js PR: buffer: throw if both length and enc are passed](https://github.com/nodejs/node/pull/4514) +- [Node Security Project disclosure for `ws`](https://nodesecurity.io/advisories/67) +- [Node Security Project disclosure for`bittorrent-dht`](https://nodesecurity.io/advisories/68) + + +## credit + +The original issues in `bittorrent-dht` +([disclosure](https://nodesecurity.io/advisories/68)) and +`ws` ([disclosure](https://nodesecurity.io/advisories/67)) were discovered by +[Mathias Buus](https://github.com/mafintosh) and +[Feross Aboukhadijeh](http://feross.org/). + +Thanks to [Adam Baldwin](https://github.com/evilpacket) for helping disclose these issues +and for his work running the [Node Security Project](https://nodesecurity.io/). + +Thanks to [John Hiesey](https://github.com/jhiesey) for proofreading this README and +auditing the code. + + +## license + +MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org) diff --git a/node_modules/basic-auth/node_modules/safe-buffer/index.d.ts b/node_modules/basic-auth/node_modules/safe-buffer/index.d.ts new file mode 100644 index 0000000..e9fed80 --- /dev/null +++ b/node_modules/basic-auth/node_modules/safe-buffer/index.d.ts @@ -0,0 +1,187 @@ +declare module "safe-buffer" { + export class Buffer { + length: number + write(string: string, offset?: number, length?: number, encoding?: string): number; + toString(encoding?: string, start?: number, end?: number): string; + toJSON(): { type: 'Buffer', data: any[] }; + equals(otherBuffer: Buffer): boolean; + compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; + writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readUInt8(offset: number, noAssert?: boolean): number; + readUInt16LE(offset: number, noAssert?: boolean): number; + readUInt16BE(offset: number, noAssert?: boolean): number; + readUInt32LE(offset: number, noAssert?: boolean): number; + readUInt32BE(offset: number, noAssert?: boolean): number; + readInt8(offset: number, noAssert?: boolean): number; + readInt16LE(offset: number, noAssert?: boolean): number; + readInt16BE(offset: number, noAssert?: boolean): number; + readInt32LE(offset: number, noAssert?: boolean): number; + readInt32BE(offset: number, noAssert?: boolean): number; + readFloatLE(offset: number, noAssert?: boolean): number; + readFloatBE(offset: number, noAssert?: boolean): number; + readDoubleLE(offset: number, noAssert?: boolean): number; + readDoubleBE(offset: number, noAssert?: boolean): number; + swap16(): Buffer; + swap32(): Buffer; + swap64(): Buffer; + writeUInt8(value: number, offset: number, noAssert?: boolean): number; + writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeInt8(value: number, offset: number, noAssert?: boolean): number; + writeInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeFloatLE(value: number, offset: number, noAssert?: boolean): number; + writeFloatBE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; + fill(value: any, offset?: number, end?: number): this; + indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; + + /** + * Allocates a new buffer containing the given {str}. + * + * @param str String to store in buffer. + * @param encoding encoding to use, optional. Default is 'utf8' + */ + constructor (str: string, encoding?: string); + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + */ + constructor (size: number); + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + constructor (array: Uint8Array); + /** + * Produces a Buffer backed by the same allocated memory as + * the given {ArrayBuffer}. + * + * + * @param arrayBuffer The ArrayBuffer with which to share memory. + */ + constructor (arrayBuffer: ArrayBuffer); + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + constructor (array: any[]); + /** + * Copies the passed {buffer} data onto a new {Buffer} instance. + * + * @param buffer The buffer to copy. + */ + constructor (buffer: Buffer); + prototype: Buffer; + /** + * Allocates a new Buffer using an {array} of octets. + * + * @param array + */ + static from(array: any[]): Buffer; + /** + * When passed a reference to the .buffer property of a TypedArray instance, + * the newly created Buffer will share the same allocated memory as the TypedArray. + * The optional {byteOffset} and {length} arguments specify a memory range + * within the {arrayBuffer} that will be shared by the Buffer. + * + * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() + * @param byteOffset + * @param length + */ + static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; + /** + * Copies the passed {buffer} data onto a new Buffer instance. + * + * @param buffer + */ + static from(buffer: Buffer): Buffer; + /** + * Creates a new Buffer containing the given JavaScript string {str}. + * If provided, the {encoding} parameter identifies the character encoding. + * If not provided, {encoding} defaults to 'utf8'. + * + * @param str + */ + static from(str: string, encoding?: string): Buffer; + /** + * Returns true if {obj} is a Buffer + * + * @param obj object to test. + */ + static isBuffer(obj: any): obj is Buffer; + /** + * Returns true if {encoding} is a valid encoding argument. + * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' + * + * @param encoding string to test. + */ + static isEncoding(encoding: string): boolean; + /** + * Gives the actual byte length of a string. encoding defaults to 'utf8'. + * This is not the same as String.prototype.length since that returns the number of characters in a string. + * + * @param string string to test. + * @param encoding encoding used to evaluate (defaults to 'utf8') + */ + static byteLength(string: string, encoding?: string): number; + /** + * Returns a buffer which is the result of concatenating all the buffers in the list together. + * + * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. + * If the list has exactly one item, then the first item of the list is returned. + * If the list has more than one item, then a new Buffer is created. + * + * @param list An array of Buffer objects to concatenate + * @param totalLength Total length of the buffers when concatenated. + * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. + */ + static concat(list: Buffer[], totalLength?: number): Buffer; + /** + * The same as buf1.compare(buf2). + */ + static compare(buf1: Buffer, buf2: Buffer): number; + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + * @param fill if specified, buffer will be initialized by calling buf.fill(fill). + * If parameter is omitted, buffer will be filled with zeros. + * @param encoding encoding used for call to buf.fill while initalizing + */ + static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; + /** + * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents + * of the newly created Buffer are unknown and may contain sensitive data. + * + * @param size count of octets to allocate + */ + static allocUnsafe(size: number): Buffer; + /** + * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents + * of the newly created Buffer are unknown and may contain sensitive data. + * + * @param size count of octets to allocate + */ + static allocUnsafeSlow(size: number): Buffer; + } +} \ No newline at end of file diff --git a/node_modules/basic-auth/node_modules/safe-buffer/index.js b/node_modules/basic-auth/node_modules/safe-buffer/index.js new file mode 100644 index 0000000..22438da --- /dev/null +++ b/node_modules/basic-auth/node_modules/safe-buffer/index.js @@ -0,0 +1,62 @@ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} diff --git a/node_modules/basic-auth/node_modules/safe-buffer/package.json b/node_modules/basic-auth/node_modules/safe-buffer/package.json new file mode 100644 index 0000000..623fbc3 --- /dev/null +++ b/node_modules/basic-auth/node_modules/safe-buffer/package.json @@ -0,0 +1,37 @@ +{ + "name": "safe-buffer", + "description": "Safer Node.js Buffer API", + "version": "5.1.2", + "author": { + "name": "Feross Aboukhadijeh", + "email": "feross@feross.org", + "url": "http://feross.org" + }, + "bugs": { + "url": "https://github.com/feross/safe-buffer/issues" + }, + "devDependencies": { + "standard": "*", + "tape": "^4.0.0" + }, + "homepage": "https://github.com/feross/safe-buffer", + "keywords": [ + "buffer", + "buffer allocate", + "node security", + "safe", + "safe-buffer", + "security", + "uninitialized" + ], + "license": "MIT", + "main": "index.js", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "git://github.com/feross/safe-buffer.git" + }, + "scripts": { + "test": "standard && tape test/*.js" + } +} diff --git a/node_modules/basic-auth/package.json b/node_modules/basic-auth/package.json new file mode 100644 index 0000000..01bd8dc --- /dev/null +++ b/node_modules/basic-auth/package.json @@ -0,0 +1,41 @@ +{ + "name": "basic-auth", + "description": "node.js basic auth parser", + "version": "2.0.1", + "license": "MIT", + "keywords": [ + "basic", + "auth", + "authorization", + "basicauth" + ], + "repository": "jshttp/basic-auth", + "dependencies": { + "safe-buffer": "5.1.2" + }, + "devDependencies": { + "eslint": "5.6.0", + "eslint-config-standard": "12.0.0", + "eslint-plugin-import": "2.14.0", + "eslint-plugin-markdown": "1.0.0-beta.6", + "eslint-plugin-node": "7.0.1", + "eslint-plugin-promise": "4.0.1", + "eslint-plugin-standard": "4.0.0", + "istanbul": "0.4.5", + "mocha": "5.2.0" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "index.js" + ], + "engines": { + "node": ">= 0.8" + }, + "scripts": { + "lint": "eslint --plugin markdown --ext js,md .", + "test": "mocha --check-leaks --reporter spec --bail", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + } +} diff --git a/node_modules/bson/LICENSE.md b/node_modules/bson/LICENSE.md new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/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. diff --git a/node_modules/bson/README.md b/node_modules/bson/README.md new file mode 100644 index 0000000..cd7242f --- /dev/null +++ b/node_modules/bson/README.md @@ -0,0 +1,376 @@ +# BSON parser + +BSON is short for "Binary JSON," and is the binary-encoded serialization of JSON-like documents. You can learn more about it in [the specification](http://bsonspec.org). + +This browser version of the BSON parser is compiled using [rollup](https://rollupjs.org/) and the current version is pre-compiled in the `dist` 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). + +### Table of Contents +- [Usage](#usage) +- [Bugs/Feature Requests](#bugs--feature-requests) +- [Installation](#installation) +- [Documentation](#documentation) +- [FAQ](#faq) + +## Bugs / Feature Requests + +Think you've found a bug? Want to see a new feature in `bson`? Please open a case in our issue management tool, JIRA: + +1. Create an account and login: [jira.mongodb.org](https://jira.mongodb.org) +2. Navigate to the NODE project: [jira.mongodb.org/browse/NODE](https://jira.mongodb.org/browse/NODE) +3. Click **Create Issue** - Please provide as much information as possible about the issue and how to reproduce it. + +Bug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) and the Core Server (i.e. SERVER) project are **public**. + +## Usage + +To build a new version perform the following operations: + +``` +npm install +npm run build +``` + +### Node (no bundling) +A simple example of how to use BSON in `Node.js`: + +```js +const BSON = require('bson'); +const Long = BSON.Long; + +// Serialize a document +const doc = { long: Long.fromNumber(100) }; +const data = BSON.serialize(doc); +console.log('data:', data); + +// Deserialize the resulting Buffer +const doc_2 = BSON.deserialize(data); +console.log('doc_2:', doc_2); +``` + +### Browser (no bundling) + +If you are not using a bundler like webpack, you can include `dist/bson.bundle.js` using a script tag. It includes polyfills for built-in node types like `Buffer`. + +```html + + + +``` + +### Using webpack + +If using webpack, you can use your normal import/require syntax of your project to pull in the `bson` library. + +ES6 Example: + +```js +import { Long, serialize, deserialize } from 'bson'; + +// Serialize a document +const doc = { long: Long.fromNumber(100) }; +const data = serialize(doc); +console.log('data:', data); + +// De serialize it again +const doc_2 = deserialize(data); +console.log('doc_2:', doc_2); +``` + +ES5 Example: + +```js +const BSON = require('bson'); +const Long = BSON.Long; + +// Serialize a document +const doc = { long: Long.fromNumber(100) }; +const data = BSON.serialize(doc); +console.log('data:', data); + +// Deserialize the resulting Buffer +const doc_2 = BSON.deserialize(data); +console.log('doc_2:', doc_2); +``` + +Depending on your settings, webpack will under the hood resolve to one of the following: + +- `dist/bson.browser.esm.js` If your project is in the browser and using ES6 modules (Default for `webworker` and `web` targets) +- `dist/bson.browser.umd.js` If your project is in the browser and not using ES6 modules +- `dist/bson.esm.js` If your project is in Node.js and using ES6 modules (Default for `node` targets) +- `lib/bson.js` (the normal include path) If your project is in Node.js and not using ES6 modules + +For more information, see [this page on webpack's `resolve.mainFields`](https://webpack.js.org/configuration/resolve/#resolvemainfields) and [the `package.json` for this project](./package.json#L52) + +### Usage with Angular + +Starting with Angular 6, Angular CLI removed the shim for `global` and other node built-in variables (original comment [here](https://github.com/angular/angular-cli/issues/9827#issuecomment-386154063)). If you are using BSON with Angular, you may need to add the following shim to your `polyfills.ts` file: + +```js +// In polyfills.ts +(window as any).global = window; +``` + +- [Original Comment by Angular CLI](https://github.com/angular/angular-cli/issues/9827#issuecomment-386154063) +- [Original Source for Solution](https://stackoverflow.com/a/50488337/4930088) + +## Installation + +`npm install bson` + +## Documentation + +### Objects + +
+
EJSON : object
+
+
+ +### Functions + +
+
setInternalBufferSize(size)
+

Sets the size of the internal serialization buffer.

+
+
serialize(object)Buffer
+

Serialize a Javascript object.

+
+
serializeWithBufferAndIndex(object, buffer)Number
+

Serialize a Javascript object using a predefined Buffer and index into the buffer, useful when pre-allocating the space for serialization.

+
+
deserialize(buffer)Object
+

Deserialize data as BSON.

+
+
calculateObjectSize(object)Number
+

Calculate the bson size for a passed in Javascript object.

+
+
deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, [options])Number
+

Deserialize stream data as BSON documents.

+
+
+ + + +### EJSON + +* [EJSON](#EJSON) + + * [.parse(text, [options])](#EJSON.parse) + + * [.stringify(value, [replacer], [space], [options])](#EJSON.stringify) + + * [.serialize(bson, [options])](#EJSON.serialize) + + * [.deserialize(ejson, [options])](#EJSON.deserialize) + + + + +#### *EJSON*.parse(text, [options]) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| text | string | | | +| [options] | object | | Optional settings | +| [options.relaxed] | boolean | true | Attempt to return native JS types where possible, rather than BSON types (if true) | + +Parse an Extended JSON string, constructing the JavaScript value or object described by that +string. + +**Example** +```js +const { EJSON } = require('bson'); +const text = '{ "int32": { "$numberInt": "10" } }'; + +// prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } } +console.log(EJSON.parse(text, { relaxed: false })); + +// prints { int32: 10 } +console.log(EJSON.parse(text)); +``` + + +#### *EJSON*.stringify(value, [replacer], [space], [options]) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| value | object | | The value to convert to extended JSON | +| [replacer] | function \| array | | A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string | +| [space] | string \| number | | A String or Number object that's used to insert white space into the output JSON string for readability purposes. | +| [options] | object | | Optional settings | +| [options.relaxed] | boolean | true | Enabled Extended JSON's `relaxed` mode | +| [options.legacy] | boolean | true | Output in Extended JSON v1 | + +Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer +function is specified or optionally including only the specified properties if a replacer array +is specified. + +**Example** +```js +const { EJSON } = require('bson'); +const Int32 = require('mongodb').Int32; +const doc = { int32: new Int32(10) }; + +// prints '{"int32":{"$numberInt":"10"}}' +console.log(EJSON.stringify(doc, { relaxed: false })); + +// prints '{"int32":10}' +console.log(EJSON.stringify(doc)); +``` + + +#### *EJSON*.serialize(bson, [options]) + +| Param | Type | Description | +| --- | --- | --- | +| bson | object | The object to serialize | +| [options] | object | Optional settings passed to the `stringify` function | + +Serializes an object to an Extended JSON string, and reparse it as a JavaScript object. + + + +#### *EJSON*.deserialize(ejson, [options]) + +| Param | Type | Description | +| --- | --- | --- | +| ejson | object | The Extended JSON object to deserialize | +| [options] | object | Optional settings passed to the parse method | + +Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types + + + +### setInternalBufferSize(size) + +| Param | Type | Description | +| --- | --- | --- | +| size | number | The desired size for the internal serialization buffer | + +Sets the size of the internal serialization buffer. + + + +### serialize(object) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| object | Object | | the Javascript object to serialize. | +| [options.checkKeys] | Boolean | | the serializer will check if keys are valid. | +| [options.serializeFunctions] | Boolean | false | serialize the javascript functions **(default:false)**. | +| [options.ignoreUndefined] | Boolean | true | ignore undefined fields **(default:true)**. | + +Serialize a Javascript object. + +**Returns**: Buffer - returns the Buffer object containing the serialized object. + + +### serializeWithBufferAndIndex(object, buffer) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| object | Object | | the Javascript object to serialize. | +| buffer | Buffer | | the Buffer you pre-allocated to store the serialized BSON object. | +| [options.checkKeys] | Boolean | | the serializer will check if keys are valid. | +| [options.serializeFunctions] | Boolean | false | serialize the javascript functions **(default:false)**. | +| [options.ignoreUndefined] | Boolean | true | ignore undefined fields **(default:true)**. | +| [options.index] | Number | | the index in the buffer where we wish to start serializing into. | + +Serialize a Javascript object using a predefined Buffer and index into the buffer, useful when pre-allocating the space for serialization. + +**Returns**: Number - returns the index pointing to the last written byte in the buffer. + + +### deserialize(buffer) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| buffer | Buffer | | the buffer containing the serialized set of BSON documents. | +| [options.evalFunctions] | Object | false | evaluate functions in the BSON document scoped to the object deserialized. | +| [options.cacheFunctions] | Object | false | cache evaluated functions for reuse. | +| [options.promoteLongs] | Object | true | when deserializing a Long will fit it into a Number if it's smaller than 53 bits | +| [options.promoteBuffers] | Object | false | when deserializing a Binary will return it as a node.js Buffer instance. | +| [options.promoteValues] | Object | false | when deserializing will promote BSON values to their Node.js closest equivalent types. | +| [options.fieldsAsRaw] | Object | | allow to specify if there what fields we wish to return as unserialized raw buffer. | +| [options.bsonRegExp] | Object | false | return BSON regular expressions as BSONRegExp instances. | +| [options.allowObjectSmallerThanBufferSize] | boolean | false | allows the buffer to be larger than the parsed BSON object | + +Deserialize data as BSON. + +**Returns**: Object - returns the deserialized Javascript Object. + + +### calculateObjectSize(object) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| object | Object | | the Javascript object to calculate the BSON byte size for. | +| [options.serializeFunctions] | Boolean | false | serialize the javascript functions **(default:false)**. | +| [options.ignoreUndefined] | Boolean | true | ignore undefined fields **(default:true)**. | + +Calculate the bson size for a passed in Javascript object. + +**Returns**: Number - returns the number of bytes the BSON object will take up. + + +### deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, [options]) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| data | Buffer | | the buffer containing the serialized set of BSON documents. | +| startIndex | Number | | the start index in the data Buffer where the deserialization is to start. | +| numberOfDocuments | Number | | number of documents to deserialize. | +| documents | Array | | an array where to store the deserialized documents. | +| docStartIndex | Number | | the index in the documents array from where to start inserting documents. | +| [options] | Object | | additional options used for the deserialization. | +| [options.evalFunctions] | Object | false | evaluate functions in the BSON document scoped to the object deserialized. | +| [options.cacheFunctions] | Object | false | cache evaluated functions for reuse. | +| [options.promoteLongs] | Object | true | when deserializing a Long will fit it into a Number if it's smaller than 53 bits | +| [options.promoteBuffers] | Object | false | when deserializing a Binary will return it as a node.js Buffer instance. | +| [options.promoteValues] | Object | false | when deserializing will promote BSON values to their Node.js closest equivalent types. | +| [options.fieldsAsRaw] | Object | | allow to specify if there what fields we wish to return as unserialized raw buffer. | +| [options.bsonRegExp] | Object | false | return BSON regular expressions as BSONRegExp instances. | + +Deserialize stream data as BSON documents. + +**Returns**: 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 +const BSON = require('bson'); + +class CustomSerialize { + toBSON() { + return 42; + } +} + +const obj = { answer: new CustomSerialize() }; +// "{ answer: 42 }" +console.log(BSON.deserialize(BSON.serialize(obj))); +``` diff --git a/node_modules/bson/bower.json b/node_modules/bson/bower.json new file mode 100644 index 0000000..74aa6ea --- /dev/null +++ b/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 ", + "main": "./dist/bson.js", + "license": "Apache-2.0", + "moduleType": [ + "globals", + "node" + ], + "ignore": [ + "**/.*", + "alternate_parsers", + "benchmarks", + "bower_components", + "node_modules", + "test", + "tools" + ], + "version": "4.7.0" +} diff --git a/node_modules/bson/bson.d.ts b/node_modules/bson/bson.d.ts new file mode 100644 index 0000000..5a5cf19 --- /dev/null +++ b/node_modules/bson/bson.d.ts @@ -0,0 +1,1228 @@ +import { Buffer } from 'buffer'; + +/** + * A class representation of the BSON Binary type. + * @public + * @category BSONType + */ +export declare class Binary { + _bsontype: 'Binary'; + /* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */ + /** Initial buffer default size */ + static readonly BUFFER_SIZE = 256; + /** Default BSON type */ + static readonly SUBTYPE_DEFAULT = 0; + /** Function BSON type */ + static readonly SUBTYPE_FUNCTION = 1; + /** Byte Array BSON type */ + static readonly SUBTYPE_BYTE_ARRAY = 2; + /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */ + static readonly SUBTYPE_UUID_OLD = 3; + /** UUID BSON type */ + static readonly SUBTYPE_UUID = 4; + /** MD5 BSON type */ + static readonly SUBTYPE_MD5 = 5; + /** Encrypted BSON type */ + static readonly SUBTYPE_ENCRYPTED = 6; + /** Column BSON type */ + static readonly SUBTYPE_COLUMN = 7; + /** User BSON type */ + static readonly SUBTYPE_USER_DEFINED = 128; + buffer: Buffer; + sub_type: number; + position: number; + /** + * Create a new Binary instance. + * + * This constructor can accept a string as its first argument. In this case, + * this string will be encoded using ISO-8859-1, **not** using UTF-8. + * This is almost certainly not what you want. Use `new Binary(Buffer.from(string))` + * instead to convert the string to a Buffer using UTF-8 first. + * + * @param buffer - a buffer object containing the binary data. + * @param subType - the option binary type. + */ + constructor(buffer?: string | BinarySequence, subType?: number); + /** + * Updates this binary with byte_value. + * + * @param byteValue - a single byte we wish to write. + */ + put(byteValue: string | number | Uint8Array | Buffer | number[]): void; + /** + * Writes a buffer or string to the binary. + * + * @param sequence - a string or buffer to be written to the Binary BSON object. + * @param offset - specify the binary of where to write the content. + */ + write(sequence: string | BinarySequence, offset: number): void; + /** + * Reads **length** bytes starting at **position**. + * + * @param position - read from the given position in the Binary. + * @param length - the number of bytes to read. + */ + read(position: number, length: number): BinarySequence; + /** + * Returns the value of this binary as a string. + * @param asRaw - Will skip converting to a string + * @remarks + * This is handy when calling this function conditionally for some key value pairs and not others + */ + value(asRaw?: boolean): string | BinarySequence; + /** the length of the binary sequence */ + length(): number; + toJSON(): string; + toString(format?: string): string; + /* Excluded from this release type: toExtendedJSON */ + toUUID(): UUID; + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} + +/** @public */ +export declare interface BinaryExtended { + $binary: { + subType: string; + base64: string; + }; +} + +/** @public */ +export declare interface BinaryExtendedLegacy { + $type: string; + $binary: string; +} + +/** @public */ +export declare type BinarySequence = Uint8Array | Buffer | number[]; + +/** + * BSON default export + * @deprecated Please use named exports + * @privateRemarks + * We want to someday deprecate the default export, + * so none of the new TS types are being exported on the default + * @public + */ +declare const BSON: { + Binary: typeof Binary; + Code: typeof Code; + DBRef: typeof DBRef; + Decimal128: typeof Decimal128; + Double: typeof Double; + Int32: typeof Int32; + Long: typeof Long; + UUID: typeof UUID; + Map: MapConstructor; + MaxKey: typeof MaxKey; + MinKey: typeof MinKey; + ObjectId: typeof ObjectId; + ObjectID: typeof ObjectId; + BSONRegExp: typeof BSONRegExp; + BSONSymbol: typeof BSONSymbol; + Timestamp: typeof Timestamp; + EJSON: typeof EJSON; + setInternalBufferSize: typeof setInternalBufferSize; + serialize: typeof serialize; + serializeWithBufferAndIndex: typeof serializeWithBufferAndIndex; + deserialize: typeof deserialize; + calculateObjectSize: typeof calculateObjectSize; + deserializeStream: typeof deserializeStream; + BSONError: typeof BSONError; + BSONTypeError: typeof BSONTypeError; +}; +export default BSON; + +/* Excluded from this release type: BSON_BINARY_SUBTYPE_BYTE_ARRAY */ + +/* Excluded from this release type: BSON_BINARY_SUBTYPE_COLUMN */ + +/* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */ + +/* Excluded from this release type: BSON_BINARY_SUBTYPE_ENCRYPTED */ + +/* Excluded from this release type: BSON_BINARY_SUBTYPE_FUNCTION */ + +/* Excluded from this release type: BSON_BINARY_SUBTYPE_MD5 */ + +/* Excluded from this release type: BSON_BINARY_SUBTYPE_USER_DEFINED */ + +/* Excluded from this release type: BSON_BINARY_SUBTYPE_UUID */ + +/* Excluded from this release type: BSON_BINARY_SUBTYPE_UUID_NEW */ + +/* Excluded from this release type: BSON_DATA_ARRAY */ + +/* Excluded from this release type: BSON_DATA_BINARY */ + +/* Excluded from this release type: BSON_DATA_BOOLEAN */ + +/* Excluded from this release type: BSON_DATA_CODE */ + +/* Excluded from this release type: BSON_DATA_CODE_W_SCOPE */ + +/* Excluded from this release type: BSON_DATA_DATE */ + +/* Excluded from this release type: BSON_DATA_DBPOINTER */ + +/* Excluded from this release type: BSON_DATA_DECIMAL128 */ + +/* Excluded from this release type: BSON_DATA_INT */ + +/* Excluded from this release type: BSON_DATA_LONG */ + +/* Excluded from this release type: BSON_DATA_MAX_KEY */ + +/* Excluded from this release type: BSON_DATA_MIN_KEY */ + +/* Excluded from this release type: BSON_DATA_NULL */ + +/* Excluded from this release type: BSON_DATA_NUMBER */ + +/* Excluded from this release type: BSON_DATA_OBJECT */ + +/* Excluded from this release type: BSON_DATA_OID */ + +/* Excluded from this release type: BSON_DATA_REGEXP */ + +/* Excluded from this release type: BSON_DATA_STRING */ + +/* Excluded from this release type: BSON_DATA_SYMBOL */ + +/* Excluded from this release type: BSON_DATA_TIMESTAMP */ + +/* Excluded from this release type: BSON_DATA_UNDEFINED */ + +/* Excluded from this release type: BSON_INT32_MAX */ + +/* Excluded from this release type: BSON_INT32_MIN */ + +/* Excluded from this release type: BSON_INT64_MAX */ + +/* Excluded from this release type: BSON_INT64_MIN */ + +/** @public */ +export declare class BSONError extends Error { + constructor(message: string); + get name(): string; +} + +/** + * A class representation of the BSON RegExp type. + * @public + * @category BSONType + */ +export declare class BSONRegExp { + _bsontype: 'BSONRegExp'; + pattern: string; + options: string; + /** + * @param pattern - The regular expression pattern to match + * @param options - The regular expression options + */ + constructor(pattern: string, options?: string); + static parseOptions(options?: string): string; + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ +} + +/** @public */ +export declare interface BSONRegExpExtended { + $regularExpression: { + pattern: string; + options: string; + }; +} + +/** @public */ +export declare interface BSONRegExpExtendedLegacy { + $regex: string | BSONRegExp; + $options: string; +} + +/** + * A class representation of the BSON Symbol type. + * @public + * @category BSONType + */ +export declare class BSONSymbol { + _bsontype: 'Symbol'; + value: string; + /** + * @param value - the string representing the symbol. + */ + constructor(value: string); + /** Access the wrapped string value. */ + valueOf(): string; + toString(): string; + /* Excluded from this release type: inspect */ + toJSON(): string; + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ +} + +/** @public */ +export declare interface BSONSymbolExtended { + $symbol: string; +} + +/** @public */ +export declare class BSONTypeError extends TypeError { + constructor(message: string); + get name(): string; +} + +/** + * Calculate the bson size for a passed in Javascript object. + * + * @param object - the Javascript object to calculate the BSON byte size for + * @returns size of BSON object in bytes + * @public + */ +export declare function calculateObjectSize(object: Document, options?: CalculateObjectSizeOptions): number; + +/** @public */ +export declare type CalculateObjectSizeOptions = Pick; + +/** + * A class representation of the BSON Code type. + * @public + * @category BSONType + */ +export declare class Code { + _bsontype: 'Code'; + code: string | Function; + scope?: Document; + /** + * @param code - a string or function. + * @param scope - an optional scope for the function. + */ + constructor(code: string | Function, scope?: Document); + toJSON(): { + code: string | Function; + scope?: Document; + }; + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} + +/** @public */ +export declare interface CodeExtended { + $code: string | Function; + $scope?: Document; +} + +/** + * A class representation of the BSON DBRef type. + * @public + * @category BSONType + */ +export declare class DBRef { + _bsontype: 'DBRef'; + collection: string; + oid: ObjectId; + db?: string; + fields: Document; + /** + * @param collection - the collection name. + * @param oid - the reference ObjectId. + * @param db - optional db name, if omitted the reference is local to the current db. + */ + constructor(collection: string, oid: ObjectId, db?: string, fields?: Document); + /* Excluded from this release type: namespace */ + /* Excluded from this release type: namespace */ + toJSON(): DBRefLike & Document; + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} + +/** @public */ +export declare interface DBRefLike { + $ref: string; + $id: ObjectId; + $db?: string; +} + +/** + * A class representation of the BSON Decimal128 type. + * @public + * @category BSONType + */ +export declare class Decimal128 { + _bsontype: 'Decimal128'; + readonly bytes: Buffer; + /** + * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order, + * or a string representation as returned by .toString() + */ + constructor(bytes: Buffer | string); + /** + * Create a Decimal128 instance from a string representation + * + * @param representation - a numeric string representation. + */ + static fromString(representation: string): Decimal128; + /** Create a string representation of the raw Decimal128 value */ + toString(): string; + toJSON(): Decimal128Extended; + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} + +/** @public */ +export declare interface Decimal128Extended { + $numberDecimal: string; +} + +/** + * Deserialize data as BSON. + * + * @param buffer - the buffer containing the serialized set of BSON documents. + * @returns returns the deserialized Javascript Object. + * @public + */ +export declare function deserialize(buffer: Buffer | ArrayBufferView | ArrayBuffer, options?: DeserializeOptions): Document; + +/** @public */ +export declare interface DeserializeOptions { + /** evaluate functions in the BSON document scoped to the object deserialized. */ + evalFunctions?: boolean; + /** cache evaluated functions for reuse. */ + cacheFunctions?: boolean; + /** + * use a crc32 code for caching, otherwise use the string of the function. + * @deprecated this option to use the crc32 function never worked as intended + * due to the fact that the crc32 function itself was never implemented. + * */ + cacheFunctionsCrc32?: boolean; + /** when deserializing a Long will fit it into a Number if it's smaller than 53 bits */ + promoteLongs?: boolean; + /** when deserializing a Binary will return it as a node.js Buffer instance. */ + promoteBuffers?: boolean; + /** when deserializing will promote BSON values to their Node.js closest equivalent types. */ + promoteValues?: boolean; + /** allow to specify if there what fields we wish to return as unserialized raw buffer. */ + fieldsAsRaw?: Document; + /** return BSON regular expressions as BSONRegExp instances. */ + bsonRegExp?: boolean; + /** allows the buffer to be larger than the parsed BSON object */ + allowObjectSmallerThanBufferSize?: boolean; + /** Offset into buffer to begin reading document from */ + index?: number; + raw?: boolean; + /** Allows for opt-out utf-8 validation for all keys or + * specified keys. Must be all true or all false. + * + * @example + * ```js + * // disables validation on all keys + * validation: { utf8: false } + * + * // enables validation only on specified keys a, b, and c + * validation: { utf8: { a: true, b: true, c: true } } + * + * // disables validation only on specified keys a, b + * validation: { utf8: { a: false, b: false } } + * ``` + */ + validation?: { + utf8: boolean | Record | Record; + }; +} + +/** + * Deserialize stream data as BSON documents. + * + * @param data - the buffer containing the serialized set of BSON documents. + * @param startIndex - the start index in the data Buffer where the deserialization is to start. + * @param numberOfDocuments - number of documents to deserialize. + * @param documents - an array where to store the deserialized documents. + * @param docStartIndex - the index in the documents array from where to start inserting documents. + * @param options - additional options used for the deserialization. + * @returns next index in the buffer after deserialization **x** numbers of documents. + * @public + */ +export declare function deserializeStream(data: Buffer | ArrayBufferView | ArrayBuffer, startIndex: number, numberOfDocuments: number, documents: Document[], docStartIndex: number, options: DeserializeOptions): number; + +/** @public */ +export declare interface Document { + [key: string]: any; +} + +/** + * A class representation of the BSON Double type. + * @public + * @category BSONType + */ +export declare class Double { + _bsontype: 'Double'; + value: number; + /** + * Create a Double type + * + * @param value - the number we want to represent as a double. + */ + constructor(value: number); + /** + * Access the number value. + * + * @returns returns the wrapped double number. + */ + valueOf(): number; + toJSON(): number; + toString(radix?: number): string; + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} + +/** @public */ +export declare interface DoubleExtended { + $numberDouble: string; +} + +/** + * EJSON parse / stringify API + * @public + */ +export declare namespace EJSON { + export interface Options { + /** Output using the Extended JSON v1 spec */ + legacy?: boolean; + /** Enable Extended JSON's `relaxed` mode, which attempts to return native JS types where possible, rather than BSON types */ + relaxed?: boolean; + /** + * Disable Extended JSON's `relaxed` mode, which attempts to return BSON types where possible, rather than native JS types + * @deprecated Please use the relaxed property instead + */ + strict?: boolean; + } + /** + * Parse an Extended JSON string, constructing the JavaScript value or object described by that + * string. + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const text = '{ "int32": { "$numberInt": "10" } }'; + * + * // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } } + * console.log(EJSON.parse(text, { relaxed: false })); + * + * // prints { int32: 10 } + * console.log(EJSON.parse(text)); + * ``` + */ + export function parse(text: string, options?: EJSON.Options): SerializableTypes; + export type JSONPrimitive = string | number | boolean | null; + export type SerializableTypes = Document | Array | JSONPrimitive; + /** + * Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer + * function is specified or optionally including only the specified properties if a replacer array + * is specified. + * + * @param value - The value to convert to extended JSON + * @param replacer - A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string + * @param space - A String or Number object that's used to insert white space into the output JSON string for readability purposes. + * @param options - Optional settings + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const Int32 = require('mongodb').Int32; + * const doc = { int32: new Int32(10) }; + * + * // prints '{"int32":{"$numberInt":"10"}}' + * console.log(EJSON.stringify(doc, { relaxed: false })); + * + * // prints '{"int32":10}' + * console.log(EJSON.stringify(doc)); + * ``` + */ + export function stringify(value: SerializableTypes, replacer?: (number | string)[] | ((this: any, key: string, value: any) => any) | EJSON.Options, space?: string | number, options?: EJSON.Options): string; + /** + * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object. + * + * @param value - The object to serialize + * @param options - Optional settings passed to the `stringify` function + */ + export function serialize(value: SerializableTypes, options?: EJSON.Options): Document; + /** + * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types + * + * @param ejson - The Extended JSON object to deserialize + * @param options - Optional settings passed to the parse method + */ + export function deserialize(ejson: Document, options?: EJSON.Options): SerializableTypes; +} + +/** @public */ +export declare type EJSONOptions = EJSON.Options; + +/** + * A class representation of a BSON Int32 type. + * @public + * @category BSONType + */ +export declare class Int32 { + _bsontype: 'Int32'; + value: number; + /** + * Create an Int32 type + * + * @param value - the number we want to represent as an int32. + */ + constructor(value: number | string); + /** + * Access the number value. + * + * @returns returns the wrapped int32 number. + */ + valueOf(): number; + toString(radix?: number): string; + toJSON(): number; + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} + +/** @public */ +export declare interface Int32Extended { + $numberInt: string; +} + +declare const kId: unique symbol; + +/** + * A class representing a 64-bit integer + * @public + * @category BSONType + * @remarks + * 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. + * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class. + */ +export declare class Long { + _bsontype: 'Long'; + /** An indicator used to reliably determine if an object is a Long or not. */ + __isLong__: true; + /** + * The high 32 bits as a signed value. + */ + high: number; + /** + * The low 32 bits as a signed value. + */ + low: number; + /** + * Whether unsigned or not. + */ + unsigned: boolean; + /** + * 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. + * + * Acceptable signatures are: + * - Long(low, high, unsigned?) + * - Long(bigint, unsigned?) + * - Long(string, unsigned?) + * + * @param low - The low (signed) 32 bits of the long + * @param high - The high (signed) 32 bits of the long + * @param unsigned - Whether unsigned or not, defaults to signed + */ + constructor(low?: number | bigint | string, high?: number | boolean, unsigned?: boolean); + static TWO_PWR_24: Long; + /** Maximum unsigned value. */ + static MAX_UNSIGNED_VALUE: Long; + /** Signed zero */ + static ZERO: Long; + /** Unsigned zero. */ + static UZERO: Long; + /** Signed one. */ + static ONE: Long; + /** Unsigned one. */ + static UONE: Long; + /** Signed negative one. */ + static NEG_ONE: Long; + /** Maximum signed value. */ + static MAX_VALUE: Long; + /** Minimum signed value. */ + static MIN_VALUE: Long; + /** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. + * Each is assumed to use 32 bits. + * @param lowBits - The low 32 bits + * @param highBits - The high 32 bits + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long; + /** + * Returns a Long representing the given 32 bit integer value. + * @param value - The 32 bit integer in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromInt(value: number, unsigned?: boolean): Long; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromNumber(value: number, unsigned?: boolean): Long; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromBigInt(value: bigint, unsigned?: boolean): Long; + /** + * Returns a Long representation of the given string, written using the specified radix. + * @param str - The textual representation of the Long + * @param unsigned - Whether unsigned or not, defaults to signed + * @param radix - The radix in which the text is written (2-36), defaults to 10 + * @returns The corresponding Long value + */ + static fromString(str: string, unsigned?: boolean, radix?: number): Long; + /** + * Creates a Long from its byte representation. + * @param bytes - Byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @param le - Whether little or big endian, defaults to big endian + * @returns The corresponding Long value + */ + static fromBytes(bytes: number[], unsigned?: boolean, le?: boolean): Long; + /** + * Creates a Long from its little endian byte representation. + * @param bytes - Little endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromBytesLE(bytes: number[], unsigned?: boolean): Long; + /** + * Creates a Long from its big endian byte representation. + * @param bytes - Big endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromBytesBE(bytes: number[], unsigned?: boolean): Long; + /** + * Tests if the specified object is a Long. + */ + static isLong(value: unknown): value is Long; + /** + * Converts the specified value to a Long. + * @param unsigned - Whether unsigned or not, defaults to signed + */ + static fromValue(val: number | string | { + low: number; + high: number; + unsigned?: boolean; + }, unsigned?: boolean): Long; + /** Returns the sum of this and the specified Long. */ + add(addend: string | number | Long | Timestamp): Long; + /** + * Returns the sum of this and the specified Long. + * @returns Sum + */ + and(other: string | number | Long | Timestamp): Long; + /** + * Compares this Long's value with the specified's. + * @returns 0 if they are the same, 1 if the this is greater and -1 if the given one is greater + */ + compare(other: string | number | Long | Timestamp): 0 | 1 | -1; + /** This is an alias of {@link Long.compare} */ + comp(other: string | number | Long | Timestamp): 0 | 1 | -1; + /** + * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned. + * @returns Quotient + */ + divide(divisor: string | number | Long | Timestamp): Long; + /**This is an alias of {@link Long.divide} */ + div(divisor: string | number | Long | Timestamp): Long; + /** + * Tests if this Long's value equals the specified's. + * @param other - Other value + */ + equals(other: string | number | Long | Timestamp): boolean; + /** This is an alias of {@link Long.equals} */ + eq(other: string | number | Long | Timestamp): boolean; + /** Gets the high 32 bits as a signed integer. */ + getHighBits(): number; + /** Gets the high 32 bits as an unsigned integer. */ + getHighBitsUnsigned(): number; + /** Gets the low 32 bits as a signed integer. */ + getLowBits(): number; + /** Gets the low 32 bits as an unsigned integer. */ + getLowBitsUnsigned(): number; + /** Gets the number of bits needed to represent the absolute value of this Long. */ + getNumBitsAbs(): number; + /** Tests if this Long's value is greater than the specified's. */ + greaterThan(other: string | number | Long | Timestamp): boolean; + /** This is an alias of {@link Long.greaterThan} */ + gt(other: string | number | Long | Timestamp): boolean; + /** Tests if this Long's value is greater than or equal the specified's. */ + greaterThanOrEqual(other: string | number | Long | Timestamp): boolean; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + gte(other: string | number | Long | Timestamp): boolean; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + ge(other: string | number | Long | Timestamp): boolean; + /** Tests if this Long's value is even. */ + isEven(): boolean; + /** Tests if this Long's value is negative. */ + isNegative(): boolean; + /** Tests if this Long's value is odd. */ + isOdd(): boolean; + /** Tests if this Long's value is positive. */ + isPositive(): boolean; + /** Tests if this Long's value equals zero. */ + isZero(): boolean; + /** Tests if this Long's value is less than the specified's. */ + lessThan(other: string | number | Long | Timestamp): boolean; + /** This is an alias of {@link Long#lessThan}. */ + lt(other: string | number | Long | Timestamp): boolean; + /** Tests if this Long's value is less than or equal the specified's. */ + lessThanOrEqual(other: string | number | Long | Timestamp): boolean; + /** This is an alias of {@link Long.lessThanOrEqual} */ + lte(other: string | number | Long | Timestamp): boolean; + /** Returns this Long modulo the specified. */ + modulo(divisor: string | number | Long | Timestamp): Long; + /** This is an alias of {@link Long.modulo} */ + mod(divisor: string | number | Long | Timestamp): Long; + /** This is an alias of {@link Long.modulo} */ + rem(divisor: string | number | Long | Timestamp): Long; + /** + * Returns the product of this and the specified Long. + * @param multiplier - Multiplier + * @returns Product + */ + multiply(multiplier: string | number | Long | Timestamp): Long; + /** This is an alias of {@link Long.multiply} */ + mul(multiplier: string | number | Long | Timestamp): Long; + /** Returns the Negation of this Long's value. */ + negate(): Long; + /** This is an alias of {@link Long.negate} */ + neg(): Long; + /** Returns the bitwise NOT of this Long. */ + not(): Long; + /** Tests if this Long's value differs from the specified's. */ + notEquals(other: string | number | Long | Timestamp): boolean; + /** This is an alias of {@link Long.notEquals} */ + neq(other: string | number | Long | Timestamp): boolean; + /** This is an alias of {@link Long.notEquals} */ + ne(other: string | number | Long | Timestamp): boolean; + /** + * Returns the bitwise OR of this Long and the specified. + */ + or(other: number | string | Long): Long; + /** + * Returns this Long with bits shifted to the left by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + shiftLeft(numBits: number | Long): Long; + /** This is an alias of {@link Long.shiftLeft} */ + shl(numBits: number | Long): Long; + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + shiftRight(numBits: number | Long): Long; + /** This is an alias of {@link Long.shiftRight} */ + shr(numBits: number | Long): Long; + /** + * Returns this Long with bits logically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + shiftRightUnsigned(numBits: Long | number): Long; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + shr_u(numBits: number | Long): Long; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + shru(numBits: number | Long): Long; + /** + * Returns the difference of this and the specified Long. + * @param subtrahend - Subtrahend + * @returns Difference + */ + subtract(subtrahend: string | number | Long | Timestamp): Long; + /** This is an alias of {@link Long.subtract} */ + sub(subtrahend: string | number | Long | Timestamp): Long; + /** Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. */ + toInt(): number; + /** Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). */ + toNumber(): number; + /** Converts the Long to a BigInt (arbitrary precision). */ + toBigInt(): bigint; + /** + * Converts this Long to its byte representation. + * @param le - Whether little or big endian, defaults to big endian + * @returns Byte representation + */ + toBytes(le?: boolean): number[]; + /** + * Converts this Long to its little endian byte representation. + * @returns Little endian byte representation + */ + toBytesLE(): number[]; + /** + * Converts this Long to its big endian byte representation. + * @returns Big endian byte representation + */ + toBytesBE(): number[]; + /** + * Converts this Long to signed. + */ + toSigned(): Long; + /** + * Converts the Long to a string written in the specified radix. + * @param radix - Radix (2-36), defaults to 10 + * @throws RangeError If `radix` is out of range + */ + toString(radix?: number): string; + /** Converts this Long to unsigned. */ + toUnsigned(): Long; + /** Returns the bitwise XOR of this Long and the given one. */ + xor(other: Long | number | string): Long; + /** This is an alias of {@link Long.isZero} */ + eqz(): boolean; + /** This is an alias of {@link Long.lessThanOrEqual} */ + le(other: string | number | Long | Timestamp): boolean; + toExtendedJSON(options?: EJSONOptions): number | LongExtended; + static fromExtendedJSON(doc: { + $numberLong: string; + }, options?: EJSONOptions): number | Long; + inspect(): string; +} + +/** @public */ +export declare interface LongExtended { + $numberLong: string; +} + +/** @public */ +export declare type LongWithoutOverrides = new (low: unknown, high?: number, unsigned?: boolean) => { + [P in Exclude]: Long[P]; +}; + +/** @public */ +export declare const LongWithoutOverridesClass: LongWithoutOverrides; + +/** @public */ +declare let Map_2: MapConstructor; +export { Map_2 as Map } + +/** + * A class representation of the BSON MaxKey type. + * @public + * @category BSONType + */ +export declare class MaxKey { + _bsontype: 'MaxKey'; + constructor(); + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} + +/** @public */ +export declare interface MaxKeyExtended { + $maxKey: 1; +} + +/** + * A class representation of the BSON MinKey type. + * @public + * @category BSONType + */ +export declare class MinKey { + _bsontype: 'MinKey'; + constructor(); + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} + +/** @public */ +export declare interface MinKeyExtended { + $minKey: 1; +} + +/** + * A class representation of the BSON ObjectId type. + * @public + * @category BSONType + */ +declare class ObjectId { + _bsontype: 'ObjectID'; + /* Excluded from this release type: index */ + static cacheHexString: boolean; + /* Excluded from this release type: [kId] */ + /* Excluded from this release type: __id */ + /** + * Create an ObjectId type + * + * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number. + */ + constructor(inputId?: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array); + /** + * The ObjectId bytes + * @readonly + */ + get id(): Buffer; + set id(value: Buffer); + /** + * The generation time of this ObjectId instance + * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch + */ + get generationTime(): number; + set generationTime(value: number); + /** Returns the ObjectId id as a 24 character hex string representation */ + toHexString(): string; + /* Excluded from this release type: getInc */ + /** + * Generate a 12 byte id buffer used in ObjectId's + * + * @param time - pass in a second based timestamp. + */ + static generate(time?: number): Buffer; + /** + * Converts the id into a 24 character hex string for printing + * + * @param format - The Buffer toString format parameter. + */ + toString(format?: string): string; + /** Converts to its JSON the 24 character hex string representation. */ + toJSON(): string; + /** + * Compares the equality of this ObjectId with `otherID`. + * + * @param otherId - ObjectId instance to compare against. + */ + equals(otherId: string | ObjectId | ObjectIdLike): boolean; + /** Returns the generation date (accurate up to the second) that this ID was generated. */ + getTimestamp(): Date; + /* Excluded from this release type: createPk */ + /** + * Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId. + * + * @param time - an integer number representing a number of seconds. + */ + static createFromTime(time: number): ObjectId; + /** + * Creates an ObjectId from a hex string representation of an ObjectId. + * + * @param hexString - create a ObjectId from a passed in 24 character hexstring. + */ + static createFromHexString(hexString: string): ObjectId; + /** + * Checks if a value is a valid bson ObjectId + * + * @param id - ObjectId instance to validate. + */ + static isValid(id: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array): boolean; + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} +export { ObjectId as ObjectID } +export { ObjectId } + +/** @public */ +export declare interface ObjectIdExtended { + $oid: string; +} + +/** @public */ +export declare interface ObjectIdLike { + id: string | Buffer; + __id?: string; + toHexString(): string; +} + +/** + * Serialize a Javascript object. + * + * @param object - the Javascript object to serialize. + * @returns Buffer object containing the serialized object. + * @public + */ +export declare function serialize(object: Document, options?: SerializeOptions): Buffer; + +/** @public */ +export declare interface SerializeOptions { + /** the serializer will check if keys are valid. */ + checkKeys?: boolean; + /** serialize the javascript functions **(default:false)**. */ + serializeFunctions?: boolean; + /** serialize will not emit undefined fields **(default:true)** */ + ignoreUndefined?: boolean; + /* Excluded from this release type: minInternalBufferSize */ + /** the index in the buffer where we wish to start serializing into */ + index?: number; +} + +/** + * Serialize a Javascript object using a predefined Buffer and index into the buffer, + * useful when pre-allocating the space for serialization. + * + * @param object - the Javascript object to serialize. + * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object. + * @returns the index pointing to the last written byte in the buffer. + * @public + */ +export declare function serializeWithBufferAndIndex(object: Document, finalBuffer: Buffer, options?: SerializeOptions): number; + +/** + * Sets the size of the internal serialization buffer. + * + * @param size - The desired size for the internal serialization buffer + * @public + */ +export declare function setInternalBufferSize(size: number): void; + +/** + * @public + * @category BSONType + * */ +export declare class Timestamp extends LongWithoutOverridesClass { + _bsontype: 'Timestamp'; + static readonly MAX_VALUE: Long; + /** + * @param low - A 64-bit Long representing the Timestamp. + */ + constructor(long: Long); + /** + * @param value - A pair of two values indicating timestamp and increment. + */ + constructor(value: { + t: number; + i: number; + }); + /** + * @param low - the low (signed) 32 bits of the Timestamp. + * @param high - the high (signed) 32 bits of the Timestamp. + * @deprecated Please use `Timestamp({ t: high, i: low })` or `Timestamp(Long(low, high))` instead. + */ + constructor(low: number, high: number); + toJSON(): { + $timestamp: string; + }; + /** Returns a Timestamp represented by the given (32-bit) integer value. */ + static fromInt(value: number): Timestamp; + /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */ + static fromNumber(value: number): Timestamp; + /** + * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits. + * + * @param lowBits - the low 32-bits. + * @param highBits - the high 32-bits. + */ + static fromBits(lowBits: number, highBits: number): Timestamp; + /** + * Returns a Timestamp from the given string, optionally using the given radix. + * + * @param str - the textual representation of the Timestamp. + * @param optRadix - the radix in which the text is written. + */ + static fromString(str: string, optRadix: number): Timestamp; + /* Excluded from this release type: toExtendedJSON */ + /* Excluded from this release type: fromExtendedJSON */ + inspect(): string; +} + +/** @public */ +export declare interface TimestampExtended { + $timestamp: { + t: number; + i: number; + }; +} + +/** @public */ +export declare type TimestampOverrides = '_bsontype' | 'toExtendedJSON' | 'fromExtendedJSON' | 'inspect'; + +/** + * A class representation of the BSON UUID type. + * @public + */ +export declare class UUID extends Binary { + static cacheHexString: boolean; + /* Excluded from this release type: __id */ + /** + * Create an UUID type + * + * @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer. + */ + constructor(input?: string | Buffer | UUID); + /** + * The UUID bytes + * @readonly + */ + get id(): Buffer; + set id(value: Buffer); + /** + * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated) + * @param includeDashes - should the string exclude dash-separators. + * */ + toHexString(includeDashes?: boolean): string; + /** + * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified. + */ + toString(encoding?: string): string; + /** + * Converts the id into its JSON string representation. + * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + */ + toJSON(): string; + /** + * Compares the equality of this UUID with `otherID`. + * + * @param otherId - UUID instance to compare against. + */ + equals(otherId: string | Buffer | UUID): boolean; + /** + * Creates a Binary instance from the current UUID. + */ + toBinary(): Binary; + /** + * Generates a populated buffer containing a v4 uuid + */ + static generate(): Buffer; + /** + * Checks if a value is a valid bson UUID + * @param input - UUID, string or Buffer to validate. + */ + static isValid(input: string | Buffer | UUID): boolean; + /** + * Creates an UUID from a hex string representation of an UUID. + * @param hexString - 32 or 36 character hex string (dashes excluded/included). + */ + static createFromHexString(hexString: string): UUID; + inspect(): string; +} + +/** @public */ +export declare type UUIDExtended = { + $uuid: string; +}; + +export { } diff --git a/node_modules/bson/dist/bson.browser.esm.js b/node_modules/bson/dist/bson.browser.esm.js new file mode 100644 index 0000000..63e271c --- /dev/null +++ b/node_modules/bson/dist/bson.browser.esm.js @@ -0,0 +1,7470 @@ +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var byteLength_1 = byteLength; +var toByteArray_1 = toByteArray; +var fromByteArray_1 = fromByteArray; +var lookup = []; +var revLookup = []; +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i]; + revLookup[code.charCodeAt(i)] = i; +} // Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications + + +revLookup['-'.charCodeAt(0)] = 62; +revLookup['_'.charCodeAt(0)] = 63; + +function getLens(b64) { + var len = b64.length; + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4'); + } // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + + + var validLen = b64.indexOf('='); + if (validLen === -1) validLen = len; + var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; + return [validLen, placeHoldersLen]; +} // base64 is 4/3 + up to two characters of the original data + + +function byteLength(b64) { + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; +} + +function _byteLength(b64, validLen, placeHoldersLen) { + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; +} + +function toByteArray(b64) { + var tmp; + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); + var curByte = 0; // if there are placeholders, only get up to the last complete 4 chars + + var len = placeHoldersLen > 0 ? validLen - 4 : validLen; + var i; + + for (i = 0; i < len; i += 4) { + tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; + arr[curByte++] = tmp >> 16 & 0xFF; + arr[curByte++] = tmp >> 8 & 0xFF; + arr[curByte++] = tmp & 0xFF; + } + + if (placeHoldersLen === 2) { + tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; + arr[curByte++] = tmp & 0xFF; + } + + if (placeHoldersLen === 1) { + tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; + arr[curByte++] = tmp >> 8 & 0xFF; + arr[curByte++] = tmp & 0xFF; + } + + return arr; +} + +function tripletToBase64(num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; +} + +function encodeChunk(uint8, start, end) { + var tmp; + var output = []; + + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16 & 0xFF0000) + (uint8[i + 1] << 8 & 0xFF00) + (uint8[i + 2] & 0xFF); + output.push(tripletToBase64(tmp)); + } + + return output.join(''); +} + +function fromByteArray(uint8) { + var tmp; + var len = uint8.length; + var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes + + var parts = []; + var maxChunkLength = 16383; // must be multiple of 3 + // go through the array every three bytes, we'll deal with trailing stuff later + + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); + } // pad the end with zeros, but make sure to not forget the extra bytes + + + if (extraBytes === 1) { + tmp = uint8[len - 1]; + parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 0x3F] + '=='); + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1]; + parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 0x3F] + lookup[tmp << 2 & 0x3F] + '='); + } + + return parts.join(''); +} + +var base64Js = { + byteLength: byteLength_1, + toByteArray: toByteArray_1, + fromByteArray: fromByteArray_1 +}; + +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ +var read = function read(buffer, offset, isLE, mLen, nBytes) { + var e, m; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i = isLE ? nBytes - 1 : 0; + var d = isLE ? -1 : 1; + var 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 write = function write(buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; + var i = isLE ? 0 : nBytes - 1; + var d = isLE ? 1 : -1; + var 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; +}; + +var ieee754 = { + read: read, + write: write +}; + +var buffer$1 = createCommonjsModule(function (module, exports) { + + var customInspectSymbol = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' ? // eslint-disable-line dot-notation + Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation + : null; + exports.Buffer = Buffer; + exports.SlowBuffer = SlowBuffer; + exports.INSPECT_MAX_BYTES = 50; + var K_MAX_LENGTH = 0x7fffffff; + exports.kMaxLength = K_MAX_LENGTH; + /** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ + + Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport(); + + if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && typeof console.error === 'function') { + console.error('This browser lacks typed array (Uint8Array) support which is required by ' + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'); + } + + function typedArraySupport() { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1); + var proto = { + foo: function foo() { + return 42; + } + }; + Object.setPrototypeOf(proto, Uint8Array.prototype); + Object.setPrototypeOf(arr, proto); + return arr.foo() === 42; + } catch (e) { + return false; + } + } + + Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function get() { + if (!Buffer.isBuffer(this)) return undefined; + return this.buffer; + } + }); + Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function get() { + if (!Buffer.isBuffer(this)) return undefined; + return this.byteOffset; + } + }); + + function createBuffer(length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"'); + } // Return an augmented `Uint8Array` instance + + + var buf = new Uint8Array(length); + Object.setPrototypeOf(buf, Buffer.prototype); + return buf; + } + /** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + + + function Buffer(arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError('The "string" argument must be of type string. Received type number'); + } + + return allocUnsafe(arg); + } + + return from(arg, encodingOrOffset, length); + } + + Buffer.poolSize = 8192; // not used by this implementation + + function from(value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset); + } + + if (ArrayBuffer.isView(value)) { + return fromArrayView(value); + } + + if (value == null) { + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + babelHelpers["typeof"](value)); + } + + if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { + return fromArrayBuffer(value, encodingOrOffset, length); + } + + if (typeof SharedArrayBuffer !== 'undefined' && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length); + } + + if (typeof value === 'number') { + throw new TypeError('The "value" argument must not be of type number. Received type number'); + } + + var valueOf = value.valueOf && value.valueOf(); + + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length); + } + + var b = fromObject(value); + if (b) return b; + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length); + } + + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + babelHelpers["typeof"](value)); + } + /** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ + + + Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length); + }; // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: + // https://github.com/feross/buffer/pull/148 + + + Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer, Uint8Array); + + function assertSize(size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number'); + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"'); + } + } + + function alloc(size, fill, encoding) { + assertSize(size); + + if (size <= 0) { + return createBuffer(size); + } + + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpreted as a start offset. + return typeof encoding === 'string' ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill); + } + + return createBuffer(size); + } + /** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ + + + Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding); + }; + + function allocUnsafe(size) { + assertSize(size); + return createBuffer(size < 0 ? 0 : checked(size) | 0); + } + /** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ + + + Buffer.allocUnsafe = function (size) { + return allocUnsafe(size); + }; + /** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ + + + Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size); + }; + + function fromString(string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8'; + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding); + } + + var length = byteLength(string, encoding) | 0; + var buf = createBuffer(length); + var actual = buf.write(string, encoding); + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual); + } + + return buf; + } + + function fromArrayLike(array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0; + var buf = createBuffer(length); + + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255; + } + + return buf; + } + + function fromArrayView(arrayView) { + if (isInstance(arrayView, Uint8Array)) { + var copy = new Uint8Array(arrayView); + return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength); + } + + return fromArrayLike(arrayView); + } + + function fromArrayBuffer(array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds'); + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds'); + } + + var buf; + + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array); + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset); + } else { + buf = new Uint8Array(array, byteOffset, length); + } // Return an augmented `Uint8Array` instance + + + Object.setPrototypeOf(buf, Buffer.prototype); + return buf; + } + + function fromObject(obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0; + var buf = createBuffer(len); + + if (buf.length === 0) { + return buf; + } + + obj.copy(buf, 0, 0, len); + return buf; + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0); + } + + return fromArrayLike(obj); + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data); + } + } + + function checked(length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes'); + } + + return length | 0; + } + + function SlowBuffer(length) { + if (+length != length) { + // eslint-disable-line eqeqeq + length = 0; + } + + return Buffer.alloc(+length); + } + + Buffer.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false + }; + + Buffer.compare = function compare(a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength); + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength); + + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); + } + + if (a === b) return 0; + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) return -1; + if (y < x) return 1; + return 0; + }; + + Buffer.isEncoding = function isEncoding(encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true; + + default: + return false; + } + }; + + Buffer.concat = function concat(list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } + + if (list.length === 0) { + return Buffer.alloc(0); + } + + var i; + + if (length === undefined) { + length = 0; + + for (i = 0; i < list.length; ++i) { + length += list[i].length; + } + } + + var buffer = Buffer.allocUnsafe(length); + var pos = 0; + + for (i = 0; i < list.length; ++i) { + var buf = list[i]; + + if (isInstance(buf, Uint8Array)) { + if (pos + buf.length > buffer.length) { + Buffer.from(buf).copy(buffer, pos); + } else { + Uint8Array.prototype.set.call(buffer, buf, pos); + } + } else if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } else { + buf.copy(buffer, pos); + } + + pos += buf.length; + } + + return buffer; + }; + + function byteLength(string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length; + } + + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength; + } + + if (typeof string !== 'string') { + throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + 'Received type ' + babelHelpers["typeof"](string)); + } + + var len = string.length; + var mustMatch = arguments.length > 2 && arguments[2] === true; + if (!mustMatch && len === 0) return 0; // Use a for loop to avoid recursion + + var loweredCase = false; + + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len; + + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length; + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2; + + case 'hex': + return len >>> 1; + + case 'base64': + return base64ToBytes(string).length; + + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8 + } + + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } + } + + Buffer.byteLength = byteLength; + + function slowToString(encoding, start, end) { + var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + + if (start === undefined || start < 0) { + start = 0; + } // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + + + if (start > this.length) { + return ''; + } + + if (end === undefined || end > this.length) { + end = this.length; + } + + if (end <= 0) { + return ''; + } // Force coercion to uint32. This will also coerce falsey/NaN values to 0. + + + end >>>= 0; + start >>>= 0; + + if (end <= start) { + return ''; + } + + if (!encoding) encoding = 'utf8'; + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end); + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end); + + case 'ascii': + return asciiSlice(this, start, end); + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end); + + case 'base64': + return base64Slice(this, start, end); + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end); + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); + encoding = (encoding + '').toLowerCase(); + loweredCase = true; + } + } + } // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) + // to detect a Buffer instance. It's not possible to use `instanceof Buffer` + // reliably in a browserify context because there could be multiple different + // copies of the 'buffer' package in use. This method works even for Buffer + // instances that were created from another copy of the `buffer` package. + // See: https://github.com/feross/buffer/issues/154 + + + Buffer.prototype._isBuffer = true; + + function swap(b, n, m) { + var i = b[n]; + b[n] = b[m]; + b[m] = i; + } + + Buffer.prototype.swap16 = function swap16() { + var len = this.length; + + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits'); + } + + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1); + } + + return this; + }; + + Buffer.prototype.swap32 = function swap32() { + var len = this.length; + + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits'); + } + + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3); + swap(this, i + 1, i + 2); + } + + return this; + }; + + Buffer.prototype.swap64 = function swap64() { + var len = this.length; + + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits'); + } + + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7); + swap(this, i + 1, i + 6); + swap(this, i + 2, i + 5); + swap(this, i + 3, i + 4); + } + + return this; + }; + + Buffer.prototype.toString = function toString() { + var length = this.length; + if (length === 0) return ''; + if (arguments.length === 0) return utf8Slice(this, 0, length); + return slowToString.apply(this, arguments); + }; + + Buffer.prototype.toLocaleString = Buffer.prototype.toString; + + Buffer.prototype.equals = function equals(b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer'); + if (this === b) return true; + return Buffer.compare(this, b) === 0; + }; + + Buffer.prototype.inspect = function inspect() { + var str = ''; + var max = exports.INSPECT_MAX_BYTES; + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim(); + if (this.length > max) str += ' ... '; + return ''; + }; + + if (customInspectSymbol) { + Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; + } + + Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength); + } + + if (!Buffer.isBuffer(target)) { + throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. ' + 'Received type ' + babelHelpers["typeof"](target)); + } + + if (start === undefined) { + start = 0; + } + + if (end === undefined) { + end = target ? target.length : 0; + } + + if (thisStart === undefined) { + thisStart = 0; + } + + if (thisEnd === undefined) { + thisEnd = this.length; + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index'); + } + + if (thisStart >= thisEnd && start >= end) { + return 0; + } + + if (thisStart >= thisEnd) { + return -1; + } + + if (start >= end) { + return 1; + } + + start >>>= 0; + end >>>= 0; + thisStart >>>= 0; + thisEnd >>>= 0; + if (this === target) return 0; + var x = thisEnd - thisStart; + var y = end - start; + var len = Math.min(x, y); + var thisCopy = this.slice(thisStart, thisEnd); + var targetCopy = target.slice(start, end); + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i]; + y = targetCopy[i]; + break; + } + } + + if (x < y) return -1; + if (y < x) return 1; + return 0; + }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, + // OR the last index of `val` in `buffer` at offset <= `byteOffset`. + // + // Arguments: + // - buffer - a Buffer to search + // - val - a string, Buffer, or number + // - byteOffset - an index into `buffer`; will be clamped to an int32 + // - encoding - an optional encoding, relevant is val is a string + // - dir - true for indexOf, false for lastIndexOf + + + function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1; // Normalize byteOffset + + if (typeof byteOffset === 'string') { + encoding = byteOffset; + byteOffset = 0; + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff; + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000; + } + + byteOffset = +byteOffset; // Coerce to Number. + + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : buffer.length - 1; + } // Normalize byteOffset: negative offsets start from the end of the buffer + + + if (byteOffset < 0) byteOffset = buffer.length + byteOffset; + + if (byteOffset >= buffer.length) { + if (dir) return -1;else byteOffset = buffer.length - 1; + } else if (byteOffset < 0) { + if (dir) byteOffset = 0;else return -1; + } // Normalize val + + + if (typeof val === 'string') { + val = Buffer.from(val, encoding); + } // Finally, search either indexOf (if dir is true) or lastIndexOf + + + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1; + } + + return arrayIndexOf(buffer, val, byteOffset, encoding, dir); + } else if (typeof val === 'number') { + val = val & 0xFF; // Search for a byte value [0-255] + + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); + } + } + + return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); + } + + throw new TypeError('val must be string, number or Buffer'); + } + + function arrayIndexOf(arr, val, byteOffset, encoding, dir) { + var indexSize = 1; + var arrLength = arr.length; + var valLength = val.length; + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase(); + + if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1; + } + + indexSize = 2; + arrLength /= 2; + valLength /= 2; + byteOffset /= 2; + } + } + + function read(buf, i) { + if (indexSize === 1) { + return buf[i]; + } else { + return buf.readUInt16BE(i * indexSize); + } + } + + var i; + + if (dir) { + var foundIndex = -1; + + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i; + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; + } else { + if (foundIndex !== -1) i -= i - foundIndex; + foundIndex = -1; + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; + + for (i = byteOffset; i >= 0; i--) { + var found = true; + + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false; + break; + } + } + + if (found) return i; + } + } + + return -1; + } + + Buffer.prototype.includes = function includes(val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1; + }; + + Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true); + }; + + Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false); + }; + + function hexWrite(buf, string, offset, length) { + offset = Number(offset) || 0; + var remaining = buf.length - offset; + + if (!length) { + length = remaining; + } else { + length = Number(length); + + if (length > remaining) { + length = remaining; + } + } + + var strLen = string.length; + + if (length > strLen / 2) { + length = strLen / 2; + } + + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16); + if (numberIsNaN(parsed)) return i; + buf[offset + i] = parsed; + } + + return i; + } + + function utf8Write(buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); + } + + function asciiWrite(buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length); + } + + function base64Write(buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length); + } + + function ucs2Write(buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); + } + + Buffer.prototype.write = function write(string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8'; + length = this.length; + offset = 0; // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset; + length = this.length; + offset = 0; // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0; + + if (isFinite(length)) { + length = length >>> 0; + if (encoding === undefined) encoding = 'utf8'; + } else { + encoding = length; + length = undefined; + } + } else { + throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported'); + } + + var remaining = this.length - offset; + if (length === undefined || length > remaining) length = remaining; + + if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds'); + } + + if (!encoding) encoding = 'utf8'; + var loweredCase = false; + + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length); + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length); + + case 'ascii': + case 'latin1': + case 'binary': + return asciiWrite(this, string, offset, length); + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length); + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length); + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } + }; + + Buffer.prototype.toJSON = function toJSON() { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + }; + }; + + function base64Slice(buf, start, end) { + if (start === 0 && end === buf.length) { + return base64Js.fromByteArray(buf); + } else { + return base64Js.fromByteArray(buf.slice(start, end)); + } + } + + function utf8Slice(buf, start, end) { + end = Math.min(buf.length, end); + var res = []; + var i = start; + + while (i < end) { + var firstByte = buf[i]; + var codePoint = null; + var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1; + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint; + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte; + } + + break; + + case 2: + secondByte = buf[i + 1]; + + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F; + + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint; + } + } + + break; + + case 3: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F; + + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint; + } + } + + break; + + case 4: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + fourthByte = buf[i + 3]; + + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F; + + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint; + } + } + + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD; + bytesPerSequence = 1; + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000; + res.push(codePoint >>> 10 & 0x3FF | 0xD800); + codePoint = 0xDC00 | codePoint & 0x3FF; + } + + res.push(codePoint); + i += bytesPerSequence; + } + + return decodeCodePointsArray(res); + } // Based on http://stackoverflow.com/a/22747272/680742, the browser with + // the lowest limit is Chrome, with 0x10000 args. + // We go 1 magnitude less, for safety + + + var MAX_ARGUMENTS_LENGTH = 0x1000; + + function decodeCodePointsArray(codePoints) { + var len = codePoints.length; + + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints); // avoid extra slice() + } // Decode in chunks to avoid "call stack size exceeded". + + + var res = ''; + var i = 0; + + while (i < len) { + res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)); + } + + return res; + } + + function asciiSlice(buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F); + } + + return ret; + } + + function latin1Slice(buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]); + } + + return ret; + } + + function hexSlice(buf, start, end) { + var len = buf.length; + if (!start || start < 0) start = 0; + if (!end || end < 0 || end > len) end = len; + var out = ''; + + for (var i = start; i < end; ++i) { + out += hexSliceLookupTable[buf[i]]; + } + + return out; + } + + function utf16leSlice(buf, start, end) { + var bytes = buf.slice(start, end); + var res = ''; // If bytes.length is odd, the last 8 bits must be ignored (same as node.js) + + for (var i = 0; i < bytes.length - 1; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); + } + + return res; + } + + Buffer.prototype.slice = function slice(start, end) { + var len = this.length; + start = ~~start; + end = end === undefined ? len : ~~end; + + if (start < 0) { + start += len; + if (start < 0) start = 0; + } else if (start > len) { + start = len; + } + + if (end < 0) { + end += len; + if (end < 0) end = 0; + } else if (end > len) { + end = len; + } + + if (end < start) end = start; + var newBuf = this.subarray(start, end); // Return an augmented `Uint8Array` instance + + Object.setPrototypeOf(newBuf, Buffer.prototype); + return newBuf; + }; + /* + * Need to make sure that buffer isn't trying to write out of bounds. + */ + + + function checkOffset(offset, ext, length) { + if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint'); + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length'); + } + + Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + var val = this[offset]; + var mul = 1; + var i = 0; + + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + return val; + }; + + Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + + if (!noAssert) { + checkOffset(offset, byteLength, this.length); + } + + var val = this[offset + --byteLength]; + var mul = 1; + + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul; + } + + return val; + }; + + Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 1, this.length); + return this[offset]; + }; + + Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] | this[offset + 1] << 8; + }; + + Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] << 8 | this[offset + 1]; + }; + + Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000; + }; + + Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); + }; + + Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + var val = this[offset]; + var mul = 1; + var i = 0; + + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + mul *= 0x80; + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + return val; + }; + + Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + var i = byteLength; + var mul = 1; + var val = this[offset + --i]; + + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul; + } + + mul *= 0x80; + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + return val; + }; + + Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 1, this.length); + if (!(this[offset] & 0x80)) return this[offset]; + return (0xff - this[offset] + 1) * -1; + }; + + Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset] | this[offset + 1] << 8; + return val & 0x8000 ? val | 0xFFFF0000 : val; + }; + + Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset + 1] | this[offset] << 8; + return val & 0x8000 ? val | 0xFFFF0000 : val; + }; + + Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; + }; + + Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; + }; + + Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return ieee754.read(this, offset, true, 23, 4); + }; + + Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return ieee754.read(this, offset, false, 23, 4); + }; + + Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 8, this.length); + return ieee754.read(this, offset, true, 52, 8); + }; + + Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 8, this.length); + return ieee754.read(this, offset, false, 52, 8); + }; + + function checkInt(buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); + if (offset + ext > buf.length) throw new RangeError('Index out of range'); + } + + Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + byteLength = byteLength >>> 0; + + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var mul = 1; + var i = 0; + this[offset] = value & 0xFF; + + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = value / mul & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + byteLength = byteLength >>> 0; + + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var i = byteLength - 1; + var mul = 1; + this[offset + i] = value & 0xFF; + + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = value / mul & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); + this[offset] = value & 0xff; + return offset + 1; + }; + + Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + return offset + 2; + }; + + Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + this[offset] = value >>> 8; + this[offset + 1] = value & 0xff; + return offset + 2; + }; + + Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + this[offset + 3] = value >>> 24; + this[offset + 2] = value >>> 16; + this[offset + 1] = value >>> 8; + this[offset] = value & 0xff; + return offset + 4; + }; + + Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + this[offset] = value >>> 24; + this[offset + 1] = value >>> 16; + this[offset + 2] = value >>> 8; + this[offset + 3] = value & 0xff; + return offset + 4; + }; + + Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = 0; + var mul = 1; + var sub = 0; + this[offset] = value & 0xFF; + + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1; + } + + this[offset + i] = (value / mul >> 0) - sub & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = byteLength - 1; + var mul = 1; + var sub = 0; + this[offset + i] = value & 0xFF; + + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1; + } + + this[offset + i] = (value / mul >> 0) - sub & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); + if (value < 0) value = 0xff + value + 1; + this[offset] = value & 0xff; + return offset + 1; + }; + + Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + return offset + 2; + }; + + Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + this[offset] = value >>> 8; + this[offset + 1] = value & 0xff; + return offset + 2; + }; + + Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + this[offset + 2] = value >>> 16; + this[offset + 3] = value >>> 24; + return offset + 4; + }; + + Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + if (value < 0) value = 0xffffffff + value + 1; + this[offset] = value >>> 24; + this[offset + 1] = value >>> 16; + this[offset + 2] = value >>> 8; + this[offset + 3] = value & 0xff; + return offset + 4; + }; + + function checkIEEE754(buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range'); + if (offset < 0) throw new RangeError('Index out of range'); + } + + function writeFloat(buf, value, offset, littleEndian, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + checkIEEE754(buf, value, offset, 4); + } + + ieee754.write(buf, value, offset, littleEndian, 23, 4); + return offset + 4; + } + + Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert); + }; + + Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert); + }; + + function writeDouble(buf, value, offset, littleEndian, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + checkIEEE754(buf, value, offset, 8); + } + + ieee754.write(buf, value, offset, littleEndian, 52, 8); + return offset + 8; + } + + Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert); + }; + + Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert); + }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) + + + Buffer.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer'); + if (!start) start = 0; + if (!end && end !== 0) end = this.length; + if (targetStart >= target.length) targetStart = target.length; + if (!targetStart) targetStart = 0; + if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done + + if (end === start) return 0; + if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions + + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds'); + } + + if (start < 0 || start >= this.length) throw new RangeError('Index out of range'); + if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob? + + if (end > this.length) end = this.length; + + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start; + } + + var len = end - start; + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end); + } else { + Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart); + } + + return len; + }; // Usage: + // buffer.fill(number[, offset[, end]]) + // buffer.fill(buffer[, offset[, end]]) + // buffer.fill(string[, offset[, end]][, encoding]) + + + Buffer.prototype.fill = function fill(val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start; + start = 0; + end = this.length; + } else if (typeof end === 'string') { + encoding = end; + end = this.length; + } + + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string'); + } + + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding); + } + + if (val.length === 1) { + var code = val.charCodeAt(0); + + if (encoding === 'utf8' && code < 128 || encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code; + } + } + } else if (typeof val === 'number') { + val = val & 255; + } else if (typeof val === 'boolean') { + val = Number(val); + } // Invalid ranges are not set to a default, so can range check early. + + + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index'); + } + + if (end <= start) { + return this; + } + + start = start >>> 0; + end = end === undefined ? this.length : end >>> 0; + if (!val) val = 0; + var i; + + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val; + } + } else { + var bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); + var len = bytes.length; + + if (len === 0) { + throw new TypeError('The value "' + val + '" is invalid for argument "value"'); + } + + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len]; + } + } + + return this; + }; // HELPER FUNCTIONS + // ================ + + + var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; + + function base64clean(str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0]; // Node strips out invalid characters like \n and \t from the string, base64-js does not + + str = str.trim().replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to '' + + if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + + while (str.length % 4 !== 0) { + str = str + '='; + } + + return str; + } + + function utf8ToBytes(string, units) { + units = units || Infinity; + var codePoint; + var length = string.length; + var leadSurrogate = null; + var bytes = []; + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i); // is surrogate component + + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue; + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue; + } // valid lead + + + leadSurrogate = codePoint; + continue; + } // 2 leads in a row + + + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + leadSurrogate = codePoint; + continue; + } // valid surrogate pair + + + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + } + + leadSurrogate = null; // encode utf8 + + if (codePoint < 0x80) { + if ((units -= 1) < 0) break; + bytes.push(codePoint); + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break; + bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80); + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break; + bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break; + bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); + } else { + throw new Error('Invalid code point'); + } + } + + return bytes; + } + + function asciiToBytes(str) { + var byteArray = []; + + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF); + } + + return byteArray; + } + + function utf16leToBytes(str, units) { + var c, hi, lo; + var byteArray = []; + + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break; + c = str.charCodeAt(i); + hi = c >> 8; + lo = c % 256; + byteArray.push(lo); + byteArray.push(hi); + } + + return byteArray; + } + + function base64ToBytes(str) { + return base64Js.toByteArray(base64clean(str)); + } + + function blitBuffer(src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if (i + offset >= dst.length || i >= src.length) break; + dst[i + offset] = src[i]; + } + + return i; + } // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass + // the `instanceof` check but they should be treated as of that type. + // See: https://github.com/feross/buffer/issues/166 + + + function isInstance(obj, type) { + return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name; + } + + function numberIsNaN(obj) { + // For IE11 support + return obj !== obj; // eslint-disable-line no-self-compare + } // Create lookup table for `toString('hex')` + // See: https://github.com/feross/buffer/issues/219 + + + var hexSliceLookupTable = function () { + var alphabet = '0123456789abcdef'; + var table = new Array(256); + + for (var i = 0; i < 16; ++i) { + var i16 = i * 16; + + for (var j = 0; j < 16; ++j) { + table[i16 + j] = alphabet[i] + alphabet[j]; + } + } + + return table; + }(); +}); +var buffer_1 = buffer$1.Buffer; +buffer$1.SlowBuffer; +buffer$1.INSPECT_MAX_BYTES; +buffer$1.kMaxLength; + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ + +/* global Reflect, Promise */ +var _extendStatics = function extendStatics(d, b) { + _extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) { + if (b.hasOwnProperty(p)) d[p] = b[p]; + } + }; + + return _extendStatics(d, b); +}; + +function __extends(d, b) { + _extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var _assign = function __assign() { + _assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) { + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + } + + return t; + }; + + return _assign.apply(this, arguments); +}; + +/** @public */ +var BSONError = /** @class */ (function (_super) { + __extends(BSONError, _super); + function BSONError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONError.prototype); + return _this; + } + Object.defineProperty(BSONError.prototype, "name", { + get: function () { + return 'BSONError'; + }, + enumerable: false, + configurable: true + }); + return BSONError; +}(Error)); +/** @public */ +var BSONTypeError = /** @class */ (function (_super) { + __extends(BSONTypeError, _super); + function BSONTypeError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONTypeError.prototype); + return _this; + } + Object.defineProperty(BSONTypeError.prototype, "name", { + get: function () { + return 'BSONTypeError'; + }, + enumerable: false, + configurable: true + }); + return BSONTypeError; +}(TypeError)); + +function checkForMath(potentialGlobal) { + // eslint-disable-next-line eqeqeq + return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal; +} +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +function getGlobal() { + return (checkForMath(typeof globalThis === 'object' && globalThis) || + checkForMath(typeof window === 'object' && window) || + checkForMath(typeof self === 'object' && self) || + checkForMath(typeof global === 'object' && global) || + // eslint-disable-next-line @typescript-eslint/no-implied-eval + Function('return this')()); +} + +/** + * Normalizes our expected stringified form of a function across versions of node + * @param fn - The function to stringify + */ +function normalizedFunctionString(fn) { + return fn.toString().replace('function(', 'function ('); +} +function isReactNative() { + var g = getGlobal(); + return typeof g.navigator === 'object' && g.navigator.product === 'ReactNative'; +} +var insecureRandomBytes = function insecureRandomBytes(size) { + var insecureWarning = isReactNative() + ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.' + : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.'; + console.warn(insecureWarning); + var result = buffer_1.alloc(size); + for (var i = 0; i < size; ++i) + result[i] = Math.floor(Math.random() * 256); + return result; +}; +var detectRandomBytes = function () { + { + if (typeof window !== 'undefined') { + // browser crypto implementation(s) + var target_1 = window.crypto || window.msCrypto; // allow for IE11 + if (target_1 && target_1.getRandomValues) { + return function (size) { return target_1.getRandomValues(buffer_1.alloc(size)); }; + } + } + if (typeof global !== 'undefined' && global.crypto && global.crypto.getRandomValues) { + // allow for RN packages such as https://www.npmjs.com/package/react-native-get-random-values to populate global + return function (size) { return global.crypto.getRandomValues(buffer_1.alloc(size)); }; + } + return insecureRandomBytes; + } +}; +var randomBytes = detectRandomBytes(); +function isAnyArrayBuffer(value) { + return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value)); +} +function isUint8Array(value) { + return Object.prototype.toString.call(value) === '[object Uint8Array]'; +} +function isBigInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigInt64Array]'; +} +function isBigUInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigUint64Array]'; +} +function isRegExp(d) { + return Object.prototype.toString.call(d) === '[object RegExp]'; +} +function isMap(d) { + return Object.prototype.toString.call(d) === '[object Map]'; +} +// To ensure that 0.4 of node works correctly +function isDate(d) { + return isObjectLike(d) && Object.prototype.toString.call(d) === '[object Date]'; +} +/** + * @internal + * this is to solve the `'someKey' in x` problem where x is unknown. + * https://github.com/typescript-eslint/typescript-eslint/issues/1071#issuecomment-541955753 + */ +function isObjectLike(candidate) { + return typeof candidate === 'object' && candidate !== null; +} +function deprecate(fn, message) { + var warned = false; + function deprecated() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!warned) { + console.warn(message); + warned = true; + } + return fn.apply(this, args); + } + return deprecated; +} + +/** + * Makes sure that, if a Uint8Array is passed in, it is wrapped in a Buffer. + * + * @param potentialBuffer - The potential buffer + * @returns Buffer the input if potentialBuffer is a buffer, or a buffer that + * wraps a passed in Uint8Array + * @throws BSONTypeError If anything other than a Buffer or Uint8Array is passed in + */ +function ensureBuffer(potentialBuffer) { + if (ArrayBuffer.isView(potentialBuffer)) { + return buffer_1.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength); + } + if (isAnyArrayBuffer(potentialBuffer)) { + return buffer_1.from(potentialBuffer); + } + throw new BSONTypeError('Must use either Buffer or TypedArray'); +} + +// Validation regex for v4 uuid (validates with or without dashes) +var VALIDATION_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i; +var uuidValidateString = function (str) { + return typeof str === 'string' && VALIDATION_REGEX.test(str); +}; +var uuidHexStringToBuffer = function (hexString) { + if (!uuidValidateString(hexString)) { + throw new BSONTypeError('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".'); + } + var sanitizedHexString = hexString.replace(/-/g, ''); + return buffer_1.from(sanitizedHexString, 'hex'); +}; +var bufferToUuidHexString = function (buffer, includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + return includeDashes + ? buffer.toString('hex', 0, 4) + + '-' + + buffer.toString('hex', 4, 6) + + '-' + + buffer.toString('hex', 6, 8) + + '-' + + buffer.toString('hex', 8, 10) + + '-' + + buffer.toString('hex', 10, 16) + : buffer.toString('hex'); +}; + +/** @internal */ +var BSON_INT32_MAX$1 = 0x7fffffff; +/** @internal */ +var BSON_INT32_MIN$1 = -0x80000000; +/** @internal */ +var BSON_INT64_MAX$1 = Math.pow(2, 63) - 1; +/** @internal */ +var BSON_INT64_MIN$1 = -Math.pow(2, 63); +/** + * Any integer up to 2^53 can be precisely represented by a double. + * @internal + */ +var JS_INT_MAX = Math.pow(2, 53); +/** + * Any integer down to -2^53 can be precisely represented by a double. + * @internal + */ +var JS_INT_MIN = -Math.pow(2, 53); +/** Number BSON Type @internal */ +var BSON_DATA_NUMBER = 1; +/** String BSON Type @internal */ +var BSON_DATA_STRING = 2; +/** Object BSON Type @internal */ +var BSON_DATA_OBJECT = 3; +/** Array BSON Type @internal */ +var BSON_DATA_ARRAY = 4; +/** Binary BSON Type @internal */ +var BSON_DATA_BINARY = 5; +/** Binary BSON Type @internal */ +var BSON_DATA_UNDEFINED = 6; +/** ObjectId BSON Type @internal */ +var BSON_DATA_OID = 7; +/** Boolean BSON Type @internal */ +var BSON_DATA_BOOLEAN = 8; +/** Date BSON Type @internal */ +var BSON_DATA_DATE = 9; +/** null BSON Type @internal */ +var BSON_DATA_NULL = 10; +/** RegExp BSON Type @internal */ +var BSON_DATA_REGEXP = 11; +/** Code BSON Type @internal */ +var BSON_DATA_DBPOINTER = 12; +/** Code BSON Type @internal */ +var BSON_DATA_CODE = 13; +/** Symbol BSON Type @internal */ +var BSON_DATA_SYMBOL = 14; +/** Code with Scope BSON Type @internal */ +var BSON_DATA_CODE_W_SCOPE = 15; +/** 32 bit Integer BSON Type @internal */ +var BSON_DATA_INT = 16; +/** Timestamp BSON Type @internal */ +var BSON_DATA_TIMESTAMP = 17; +/** Long BSON Type @internal */ +var BSON_DATA_LONG = 18; +/** Decimal128 BSON Type @internal */ +var BSON_DATA_DECIMAL128 = 19; +/** MinKey BSON Type @internal */ +var BSON_DATA_MIN_KEY = 0xff; +/** MaxKey BSON Type @internal */ +var BSON_DATA_MAX_KEY = 0x7f; +/** Binary Default Type @internal */ +var BSON_BINARY_SUBTYPE_DEFAULT = 0; +/** Binary Function Type @internal */ +var BSON_BINARY_SUBTYPE_FUNCTION = 1; +/** Binary Byte Array Type @internal */ +var BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; +/** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */ +var BSON_BINARY_SUBTYPE_UUID = 3; +/** Binary UUID Type @internal */ +var BSON_BINARY_SUBTYPE_UUID_NEW = 4; +/** Binary MD5 Type @internal */ +var BSON_BINARY_SUBTYPE_MD5 = 5; +/** Encrypted BSON type @internal */ +var BSON_BINARY_SUBTYPE_ENCRYPTED = 6; +/** Column BSON type @internal */ +var BSON_BINARY_SUBTYPE_COLUMN = 7; +/** Binary User Defined Type @internal */ +var BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + +/** + * A class representation of the BSON Binary type. + * @public + * @category BSONType + */ +var Binary = /** @class */ (function () { + /** + * Create a new Binary instance. + * + * This constructor can accept a string as its first argument. In this case, + * this string will be encoded using ISO-8859-1, **not** using UTF-8. + * This is almost certainly not what you want. Use `new Binary(Buffer.from(string))` + * instead to convert the string to a Buffer using UTF-8 first. + * + * @param buffer - a buffer object containing the binary data. + * @param subType - the option binary type. + */ + function Binary(buffer, subType) { + if (!(this instanceof Binary)) + return new Binary(buffer, subType); + if (!(buffer == null) && + !(typeof buffer === 'string') && + !ArrayBuffer.isView(buffer) && + !(buffer instanceof ArrayBuffer) && + !Array.isArray(buffer)) { + throw new BSONTypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array'); + } + this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT; + if (buffer == null) { + // create an empty binary buffer + this.buffer = buffer_1.alloc(Binary.BUFFER_SIZE); + this.position = 0; + } + else { + if (typeof buffer === 'string') { + // string + this.buffer = buffer_1.from(buffer, 'binary'); + } + else if (Array.isArray(buffer)) { + // number[] + this.buffer = buffer_1.from(buffer); + } + else { + // Buffer | TypedArray | ArrayBuffer + this.buffer = ensureBuffer(buffer); + } + this.position = this.buffer.byteLength; + } + } + /** + * Updates this binary with byte_value. + * + * @param byteValue - a single byte we wish to write. + */ + Binary.prototype.put = function (byteValue) { + // If it's a string and a has more than one character throw an error + if (typeof byteValue === 'string' && byteValue.length !== 1) { + throw new BSONTypeError('only accepts single character String'); + } + else if (typeof byteValue !== 'number' && byteValue.length !== 1) + throw new BSONTypeError('only accepts single character Uint8Array or Array'); + // Decode the byte value once + var decodedByte; + if (typeof byteValue === 'string') { + decodedByte = byteValue.charCodeAt(0); + } + else if (typeof byteValue === 'number') { + decodedByte = byteValue; + } + else { + decodedByte = byteValue[0]; + } + if (decodedByte < 0 || decodedByte > 255) { + throw new BSONTypeError('only accepts number in a valid unsigned byte range 0-255'); + } + if (this.buffer.length > this.position) { + this.buffer[this.position++] = decodedByte; + } + else { + var buffer = buffer_1.alloc(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++] = decodedByte; + } + }; + /** + * Writes a buffer or string to the binary. + * + * @param sequence - a string or buffer to be written to the Binary BSON object. + * @param offset - specify the binary of where to write the content. + */ + Binary.prototype.write = function (sequence, offset) { + offset = typeof offset === 'number' ? offset : this.position; + // If the buffer is to small let's extend the buffer + if (this.buffer.length < offset + sequence.length) { + var buffer = buffer_1.alloc(this.buffer.length + sequence.length); + this.buffer.copy(buffer, 0, 0, this.buffer.length); + // Assign the new buffer + this.buffer = buffer; + } + if (ArrayBuffer.isView(sequence)) { + this.buffer.set(ensureBuffer(sequence), offset); + this.position = + offset + sequence.byteLength > this.position ? offset + sequence.length : this.position; + } + else if (typeof sequence === 'string') { + this.buffer.write(sequence, offset, sequence.length, 'binary'); + this.position = + offset + sequence.length > this.position ? offset + sequence.length : this.position; + } + }; + /** + * Reads **length** bytes starting at **position**. + * + * @param position - read from the given position in the Binary. + * @param length - the number of bytes to read. + */ + Binary.prototype.read = function (position, length) { + length = length && length > 0 ? length : this.position; + // Let's return the data based on the type we have + return this.buffer.slice(position, position + length); + }; + /** + * Returns the value of this binary as a string. + * @param asRaw - Will skip converting to a string + * @remarks + * This is handy when calling this function conditionally for some key value pairs and not others + */ + Binary.prototype.value = function (asRaw) { + asRaw = !!asRaw; + // Optimize to serialize for the situation where the data == size of buffer + if (asRaw && this.buffer.length === this.position) { + return this.buffer; + } + // If it's a node.js buffer object + if (asRaw) { + return this.buffer.slice(0, this.position); + } + return this.buffer.toString('binary', 0, this.position); + }; + /** the length of the binary sequence */ + Binary.prototype.length = function () { + return this.position; + }; + Binary.prototype.toJSON = function () { + return this.buffer.toString('base64'); + }; + Binary.prototype.toString = function (format) { + return this.buffer.toString(format); + }; + /** @internal */ + Binary.prototype.toExtendedJSON = function (options) { + options = options || {}; + var base64String = this.buffer.toString('base64'); + var subType = Number(this.sub_type).toString(16); + if (options.legacy) { + return { + $binary: base64String, + $type: subType.length === 1 ? '0' + subType : subType + }; + } + return { + $binary: { + base64: base64String, + subType: subType.length === 1 ? '0' + subType : subType + } + }; + }; + Binary.prototype.toUUID = function () { + if (this.sub_type === Binary.SUBTYPE_UUID) { + return new UUID(this.buffer.slice(0, this.position)); + } + throw new BSONError("Binary sub_type \"".concat(this.sub_type, "\" is not supported for converting to UUID. Only \"").concat(Binary.SUBTYPE_UUID, "\" is currently supported.")); + }; + /** @internal */ + Binary.fromExtendedJSON = function (doc, options) { + options = options || {}; + var data; + var type; + if ('$binary' in doc) { + if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) { + type = doc.$type ? parseInt(doc.$type, 16) : 0; + data = buffer_1.from(doc.$binary, 'base64'); + } + else { + if (typeof doc.$binary !== 'string') { + type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0; + data = buffer_1.from(doc.$binary.base64, 'base64'); + } + } + } + else if ('$uuid' in doc) { + type = 4; + data = uuidHexStringToBuffer(doc.$uuid); + } + if (!data) { + throw new BSONTypeError("Unexpected Binary Extended JSON format ".concat(JSON.stringify(doc))); + } + return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type); + }; + /** @internal */ + Binary.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Binary.prototype.inspect = function () { + var asBuffer = this.value(true); + return "new Binary(Buffer.from(\"".concat(asBuffer.toString('hex'), "\", \"hex\"), ").concat(this.sub_type, ")"); + }; + /** + * Binary default subtype + * @internal + */ + Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** Initial buffer default size */ + Binary.BUFFER_SIZE = 256; + /** Default BSON type */ + Binary.SUBTYPE_DEFAULT = 0; + /** Function BSON type */ + Binary.SUBTYPE_FUNCTION = 1; + /** Byte Array BSON type */ + Binary.SUBTYPE_BYTE_ARRAY = 2; + /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */ + Binary.SUBTYPE_UUID_OLD = 3; + /** UUID BSON type */ + Binary.SUBTYPE_UUID = 4; + /** MD5 BSON type */ + Binary.SUBTYPE_MD5 = 5; + /** Encrypted BSON type */ + Binary.SUBTYPE_ENCRYPTED = 6; + /** Column BSON type */ + Binary.SUBTYPE_COLUMN = 7; + /** User BSON type */ + Binary.SUBTYPE_USER_DEFINED = 128; + return Binary; +}()); +Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' }); +var UUID_BYTE_LENGTH = 16; +/** + * A class representation of the BSON UUID type. + * @public + */ +var UUID = /** @class */ (function (_super) { + __extends(UUID, _super); + /** + * Create an UUID type + * + * @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer. + */ + function UUID(input) { + var _this = this; + var bytes; + var hexStr; + if (input == null) { + bytes = UUID.generate(); + } + else if (input instanceof UUID) { + bytes = buffer_1.from(input.buffer); + hexStr = input.__id; + } + else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) { + bytes = ensureBuffer(input); + } + else if (typeof input === 'string') { + bytes = uuidHexStringToBuffer(input); + } + else { + throw new BSONTypeError('Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'); + } + _this = _super.call(this, bytes, BSON_BINARY_SUBTYPE_UUID_NEW) || this; + _this.__id = hexStr; + return _this; + } + Object.defineProperty(UUID.prototype, "id", { + /** + * The UUID bytes + * @readonly + */ + get: function () { + return this.buffer; + }, + set: function (value) { + this.buffer = value; + if (UUID.cacheHexString) { + this.__id = bufferToUuidHexString(value); + } + }, + enumerable: false, + configurable: true + }); + /** + * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated) + * @param includeDashes - should the string exclude dash-separators. + * */ + UUID.prototype.toHexString = function (includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + if (UUID.cacheHexString && this.__id) { + return this.__id; + } + var uuidHexString = bufferToUuidHexString(this.id, includeDashes); + if (UUID.cacheHexString) { + this.__id = uuidHexString; + } + return uuidHexString; + }; + /** + * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified. + */ + UUID.prototype.toString = function (encoding) { + return encoding ? this.id.toString(encoding) : this.toHexString(); + }; + /** + * Converts the id into its JSON string representation. + * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + */ + UUID.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this UUID with `otherID`. + * + * @param otherId - UUID instance to compare against. + */ + UUID.prototype.equals = function (otherId) { + if (!otherId) { + return false; + } + if (otherId instanceof UUID) { + return otherId.id.equals(this.id); + } + try { + return new UUID(otherId).id.equals(this.id); + } + catch (_a) { + return false; + } + }; + /** + * Creates a Binary instance from the current UUID. + */ + UUID.prototype.toBinary = function () { + return new Binary(this.id, Binary.SUBTYPE_UUID); + }; + /** + * Generates a populated buffer containing a v4 uuid + */ + UUID.generate = function () { + var bytes = randomBytes(UUID_BYTE_LENGTH); + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + // Kindly borrowed from https://github.com/uuidjs/uuid/blob/master/src/v4.js + bytes[6] = (bytes[6] & 0x0f) | 0x40; + bytes[8] = (bytes[8] & 0x3f) | 0x80; + return buffer_1.from(bytes); + }; + /** + * Checks if a value is a valid bson UUID + * @param input - UUID, string or Buffer to validate. + */ + UUID.isValid = function (input) { + if (!input) { + return false; + } + if (input instanceof UUID) { + return true; + } + if (typeof input === 'string') { + return uuidValidateString(input); + } + if (isUint8Array(input)) { + // check for length & uuid version (https://tools.ietf.org/html/rfc4122#section-4.1.3) + if (input.length !== UUID_BYTE_LENGTH) { + return false; + } + return (input[6] & 0xf0) === 0x40 && (input[8] & 0x80) === 0x80; + } + return false; + }; + /** + * Creates an UUID from a hex string representation of an UUID. + * @param hexString - 32 or 36 character hex string (dashes excluded/included). + */ + UUID.createFromHexString = function (hexString) { + var buffer = uuidHexStringToBuffer(hexString); + return new UUID(buffer); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 36 character hex string representation. + * @internal + */ + UUID.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + UUID.prototype.inspect = function () { + return "new UUID(\"".concat(this.toHexString(), "\")"); + }; + return UUID; +}(Binary)); + +/** + * A class representation of the BSON Code type. + * @public + * @category BSONType + */ +var Code = /** @class */ (function () { + /** + * @param code - a string or function. + * @param scope - an optional scope for the function. + */ + function Code(code, scope) { + if (!(this instanceof Code)) + return new Code(code, scope); + this.code = code; + this.scope = scope; + } + Code.prototype.toJSON = function () { + return { code: this.code, scope: this.scope }; + }; + /** @internal */ + Code.prototype.toExtendedJSON = function () { + if (this.scope) { + return { $code: this.code, $scope: this.scope }; + } + return { $code: this.code }; + }; + /** @internal */ + Code.fromExtendedJSON = function (doc) { + return new Code(doc.$code, doc.$scope); + }; + /** @internal */ + Code.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Code.prototype.inspect = function () { + var codeJson = this.toJSON(); + return "new Code(\"".concat(String(codeJson.code), "\"").concat(codeJson.scope ? ", ".concat(JSON.stringify(codeJson.scope)) : '', ")"); + }; + return Code; +}()); +Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' }); + +/** @internal */ +function isDBRefLike(value) { + return (isObjectLike(value) && + value.$id != null && + typeof value.$ref === 'string' && + (value.$db == null || typeof value.$db === 'string')); +} +/** + * A class representation of the BSON DBRef type. + * @public + * @category BSONType + */ +var DBRef = /** @class */ (function () { + /** + * @param collection - the collection name. + * @param oid - the reference ObjectId. + * @param db - optional db name, if omitted the reference is local to the current db. + */ + function DBRef(collection, oid, db, fields) { + if (!(this instanceof DBRef)) + return new DBRef(collection, oid, db, fields); + // check if namespace has been provided + var parts = collection.split('.'); + if (parts.length === 2) { + db = parts.shift(); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + collection = parts.shift(); + } + this.collection = collection; + this.oid = oid; + this.db = db; + this.fields = fields || {}; + } + Object.defineProperty(DBRef.prototype, "namespace", { + // Property provided for compatibility with the 1.x parser + // the 1.x parser used a "namespace" property, while 4.x uses "collection" + /** @internal */ + get: function () { + return this.collection; + }, + set: function (value) { + this.collection = value; + }, + enumerable: false, + configurable: true + }); + DBRef.prototype.toJSON = function () { + var o = Object.assign({ + $ref: this.collection, + $id: this.oid + }, this.fields); + if (this.db != null) + o.$db = this.db; + return o; + }; + /** @internal */ + DBRef.prototype.toExtendedJSON = function (options) { + options = options || {}; + var o = { + $ref: this.collection, + $id: this.oid + }; + if (options.legacy) { + return o; + } + if (this.db) + o.$db = this.db; + o = Object.assign(o, this.fields); + return o; + }; + /** @internal */ + DBRef.fromExtendedJSON = function (doc) { + var copy = Object.assign({}, doc); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(doc.$ref, doc.$id, doc.$db, copy); + }; + /** @internal */ + DBRef.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + DBRef.prototype.inspect = function () { + // NOTE: if OID is an ObjectId class it will just print the oid string. + var oid = this.oid === undefined || this.oid.toString === undefined ? this.oid : this.oid.toString(); + return "new DBRef(\"".concat(this.namespace, "\", new ObjectId(\"").concat(String(oid), "\")").concat(this.db ? ", \"".concat(this.db, "\"") : '', ")"); + }; + return DBRef; +}()); +Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' }); + +/** + * wasm optimizations, to do native i64 multiplication and divide + */ +var wasm = undefined; +try { + wasm = new WebAssembly.Instance(new WebAssembly.Module( + // prettier-ignore + new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports; +} +catch (_a) { + // no wasm support +} +var TWO_PWR_16_DBL = 1 << 16; +var TWO_PWR_24_DBL = 1 << 24; +var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL; +var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL; +var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2; +/** A cache of the Long representations of small integer values. */ +var INT_CACHE = {}; +/** A cache of the Long representations of small unsigned integer values. */ +var UINT_CACHE = {}; +/** + * A class representing a 64-bit integer + * @public + * @category BSONType + * @remarks + * 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. + * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class. + */ +var Long = /** @class */ (function () { + /** + * 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. + * + * Acceptable signatures are: + * - Long(low, high, unsigned?) + * - Long(bigint, unsigned?) + * - Long(string, unsigned?) + * + * @param low - The low (signed) 32 bits of the long + * @param high - The high (signed) 32 bits of the long + * @param unsigned - Whether unsigned or not, defaults to signed + */ + function Long(low, high, unsigned) { + if (low === void 0) { low = 0; } + if (!(this instanceof Long)) + return new Long(low, high, unsigned); + if (typeof low === 'bigint') { + Object.assign(this, Long.fromBigInt(low, !!high)); + } + else if (typeof low === 'string') { + Object.assign(this, Long.fromString(low, !!high)); + } + else { + this.low = low | 0; + this.high = high | 0; + this.unsigned = !!unsigned; + } + Object.defineProperty(this, '__isLong__', { + value: true, + configurable: false, + writable: false, + enumerable: false + }); + } + /** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. + * Each is assumed to use 32 bits. + * @param lowBits - The low 32 bits + * @param highBits - The high 32 bits + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBits = function (lowBits, highBits, unsigned) { + return new Long(lowBits, highBits, unsigned); + }; + /** + * Returns a Long representing the given 32 bit integer value. + * @param value - The 32 bit integer in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromInt = function (value, unsigned) { + var obj, cachedObj, cache; + if (unsigned) { + value >>>= 0; + if ((cache = 0 <= value && value < 256)) { + cachedObj = UINT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true); + if (cache) + UINT_CACHE[value] = obj; + return obj; + } + else { + value |= 0; + if ((cache = -128 <= value && value < 128)) { + cachedObj = INT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, value < 0 ? -1 : 0, false); + if (cache) + INT_CACHE[value] = obj; + return obj; + } + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromNumber = function (value, unsigned) { + if (isNaN(value)) + return unsigned ? Long.UZERO : Long.ZERO; + if (unsigned) { + if (value < 0) + return Long.UZERO; + if (value >= TWO_PWR_64_DBL) + return Long.MAX_UNSIGNED_VALUE; + } + else { + if (value <= -TWO_PWR_63_DBL) + return Long.MIN_VALUE; + if (value + 1 >= TWO_PWR_63_DBL) + return Long.MAX_VALUE; + } + if (value < 0) + return Long.fromNumber(-value, unsigned).neg(); + return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned); + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBigInt = function (value, unsigned) { + return Long.fromString(value.toString(), unsigned); + }; + /** + * Returns a Long representation of the given string, written using the specified radix. + * @param str - The textual representation of the Long + * @param unsigned - Whether unsigned or not, defaults to signed + * @param radix - The radix in which the text is written (2-36), defaults to 10 + * @returns The corresponding Long value + */ + Long.fromString = function (str, unsigned, radix) { + if (str.length === 0) + throw Error('empty string'); + if (str === 'NaN' || str === 'Infinity' || str === '+Infinity' || str === '-Infinity') + return Long.ZERO; + if (typeof unsigned === 'number') { + // For goog.math.long compatibility + (radix = unsigned), (unsigned = false); + } + else { + unsigned = !!unsigned; + } + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + var p; + if ((p = str.indexOf('-')) > 0) + throw Error('interior hyphen'); + else if (p === 0) { + return Long.fromString(str.substring(1), unsigned, radix).neg(); + } + // 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), value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Long.fromNumber(Math.pow(radix, size)); + result = result.mul(power).add(Long.fromNumber(value)); + } + else { + result = result.mul(radixToPower); + result = result.add(Long.fromNumber(value)); + } + } + result.unsigned = unsigned; + return result; + }; + /** + * Creates a Long from its byte representation. + * @param bytes - Byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @param le - Whether little or big endian, defaults to big endian + * @returns The corresponding Long value + */ + Long.fromBytes = function (bytes, unsigned, le) { + return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned); + }; + /** + * Creates a Long from its little endian byte representation. + * @param bytes - Little endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesLE = function (bytes, unsigned) { + return new Long(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24), bytes[4] | (bytes[5] << 8) | (bytes[6] << 16) | (bytes[7] << 24), unsigned); + }; + /** + * Creates a Long from its big endian byte representation. + * @param bytes - Big endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesBE = function (bytes, unsigned) { + return new Long((bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7], (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3], unsigned); + }; + /** + * Tests if the specified object is a Long. + */ + Long.isLong = function (value) { + return isObjectLike(value) && value['__isLong__'] === true; + }; + /** + * Converts the specified value to a Long. + * @param unsigned - Whether unsigned or not, defaults to signed + */ + Long.fromValue = function (val, unsigned) { + if (typeof val === 'number') + return Long.fromNumber(val, unsigned); + if (typeof val === 'string') + return Long.fromString(val, unsigned); + // Throws for non-objects, converts non-instanceof Long: + return Long.fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned); + }; + /** Returns the sum of this and the specified Long. */ + Long.prototype.add = function (addend) { + if (!Long.isLong(addend)) + addend = Long.fromValue(addend); + // 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 = addend.high >>> 16; + var b32 = addend.high & 0xffff; + var b16 = addend.low >>> 16; + var b00 = addend.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, this.unsigned); + }; + /** + * Returns the sum of this and the specified Long. + * @returns Sum + */ + Long.prototype.and = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); + }; + /** + * Compares this Long's value with the specified's. + * @returns 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 (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.eq(other)) + return 0; + var thisNeg = this.isNegative(), otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) + return -1; + if (!thisNeg && otherNeg) + return 1; + // At this point the sign bits are the same + if (!this.unsigned) + return this.sub(other).isNegative() ? -1 : 1; + // Both are positive if at least one is unsigned + return other.high >>> 0 > this.high >>> 0 || + (other.high === this.high && other.low >>> 0 > this.low >>> 0) + ? -1 + : 1; + }; + /** This is an alias of {@link Long.compare} */ + Long.prototype.comp = function (other) { + return this.compare(other); + }; + /** + * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned. + * @returns Quotient + */ + Long.prototype.divide = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + if (divisor.isZero()) + throw Error('division by zero'); + // use wasm support if present + if (wasm) { + // guard against signed division overflow: the largest + // negative number / -1 would be 1 larger than the largest + // positive number, due to two's complement. + if (!this.unsigned && + this.high === -0x80000000 && + divisor.low === -1 && + divisor.high === -1) { + // be consistent with non-wasm code path + return this; + } + var low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (this.isZero()) + return this.unsigned ? Long.UZERO : Long.ZERO; + var approx, rem, res; + if (!this.unsigned) { + // This section is only relevant for signed longs and is derived from the + // closure library as a whole. + if (this.eq(Long.MIN_VALUE)) { + if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE)) + return Long.MIN_VALUE; + // recall that -MIN_VALUE == MIN_VALUE + else if (divisor.eq(Long.MIN_VALUE)) + return Long.ONE; + else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shr(1); + approx = halfThis.div(divisor).shl(1); + if (approx.eq(Long.ZERO)) { + return divisor.isNegative() ? Long.ONE : Long.NEG_ONE; + } + else { + rem = this.sub(divisor.mul(approx)); + res = approx.add(rem.div(divisor)); + return res; + } + } + } + else if (divisor.eq(Long.MIN_VALUE)) + return this.unsigned ? Long.UZERO : Long.ZERO; + if (this.isNegative()) { + if (divisor.isNegative()) + return this.neg().div(divisor.neg()); + return this.neg().div(divisor).neg(); + } + else if (divisor.isNegative()) + return this.div(divisor.neg()).neg(); + res = Long.ZERO; + } + else { + // The algorithm below has not been made for unsigned longs. It's therefore + // required to take special care of the MSB prior to running it. + if (!divisor.unsigned) + divisor = divisor.toUnsigned(); + if (divisor.gt(this)) + return Long.UZERO; + if (divisor.gt(this.shru(1))) + // 15 >>> 1 = 7 ; with divisor = 8 ; true + return Long.UONE; + res = Long.UZERO; + } + // 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. + // eslint-disable-next-line @typescript-eslint/no-this-alias + rem = this; + while (rem.gte(divisor)) { + // 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() / divisor.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.mul(divisor); + while (approxRem.isNegative() || approxRem.gt(rem)) { + approx -= delta; + approxRes = Long.fromNumber(approx, this.unsigned); + approxRem = approxRes.mul(divisor); + } + // 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.sub(approxRem); + } + return res; + }; + /**This is an alias of {@link Long.divide} */ + Long.prototype.div = function (divisor) { + return this.divide(divisor); + }; + /** + * Tests if this Long's value equals the specified's. + * @param other - Other value + */ + Long.prototype.equals = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1) + return false; + return this.high === other.high && this.low === other.low; + }; + /** This is an alias of {@link Long.equals} */ + Long.prototype.eq = function (other) { + return this.equals(other); + }; + /** Gets the high 32 bits as a signed integer. */ + Long.prototype.getHighBits = function () { + return this.high; + }; + /** Gets the high 32 bits as an unsigned integer. */ + Long.prototype.getHighBitsUnsigned = function () { + return this.high >>> 0; + }; + /** Gets the low 32 bits as a signed integer. */ + Long.prototype.getLowBits = function () { + return this.low; + }; + /** Gets the low 32 bits as an unsigned integer. */ + Long.prototype.getLowBitsUnsigned = function () { + return this.low >>> 0; + }; + /** Gets the number of bits needed to represent the absolute value of this Long. */ + Long.prototype.getNumBitsAbs = function () { + if (this.isNegative()) { + // Unsigned Longs are never negative + return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); + } + var val = this.high !== 0 ? this.high : this.low; + var bit; + for (bit = 31; bit > 0; bit--) + if ((val & (1 << bit)) !== 0) + break; + return this.high !== 0 ? bit + 33 : bit + 1; + }; + /** Tests if this Long's value is greater than the specified's. */ + Long.prototype.greaterThan = function (other) { + return this.comp(other) > 0; + }; + /** This is an alias of {@link Long.greaterThan} */ + Long.prototype.gt = function (other) { + return this.greaterThan(other); + }; + /** Tests if this Long's value is greater than or equal the specified's. */ + Long.prototype.greaterThanOrEqual = function (other) { + return this.comp(other) >= 0; + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.gte = function (other) { + return this.greaterThanOrEqual(other); + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.ge = function (other) { + return this.greaterThanOrEqual(other); + }; + /** Tests if this Long's value is even. */ + Long.prototype.isEven = function () { + return (this.low & 1) === 0; + }; + /** Tests if this Long's value is negative. */ + Long.prototype.isNegative = function () { + return !this.unsigned && this.high < 0; + }; + /** Tests if this Long's value is odd. */ + Long.prototype.isOdd = function () { + return (this.low & 1) === 1; + }; + /** Tests if this Long's value is positive. */ + Long.prototype.isPositive = function () { + return this.unsigned || this.high >= 0; + }; + /** Tests if this Long's value equals zero. */ + Long.prototype.isZero = function () { + return this.high === 0 && this.low === 0; + }; + /** Tests if this Long's value is less than the specified's. */ + Long.prototype.lessThan = function (other) { + return this.comp(other) < 0; + }; + /** This is an alias of {@link Long#lessThan}. */ + Long.prototype.lt = function (other) { + return this.lessThan(other); + }; + /** Tests if this Long's value is less than or equal the specified's. */ + Long.prototype.lessThanOrEqual = function (other) { + return this.comp(other) <= 0; + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.lte = function (other) { + return this.lessThanOrEqual(other); + }; + /** Returns this Long modulo the specified. */ + Long.prototype.modulo = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + // use wasm support if present + if (wasm) { + var low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + return this.sub(this.div(divisor).mul(divisor)); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.mod = function (divisor) { + return this.modulo(divisor); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.rem = function (divisor) { + return this.modulo(divisor); + }; + /** + * Returns the product of this and the specified Long. + * @param multiplier - Multiplier + * @returns Product + */ + Long.prototype.multiply = function (multiplier) { + if (this.isZero()) + return Long.ZERO; + if (!Long.isLong(multiplier)) + multiplier = Long.fromValue(multiplier); + // use wasm support if present + if (wasm) { + var low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (multiplier.isZero()) + return Long.ZERO; + if (this.eq(Long.MIN_VALUE)) + return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (multiplier.eq(Long.MIN_VALUE)) + return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (this.isNegative()) { + if (multiplier.isNegative()) + return this.neg().mul(multiplier.neg()); + else + return this.neg().mul(multiplier).neg(); + } + else if (multiplier.isNegative()) + return this.mul(multiplier.neg()).neg(); + // If both longs are small, use float multiplication + if (this.lt(Long.TWO_PWR_24) && multiplier.lt(Long.TWO_PWR_24)) + return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); + // 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 = multiplier.high >>> 16; + var b32 = multiplier.high & 0xffff; + var b16 = multiplier.low >>> 16; + var b00 = multiplier.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, this.unsigned); + }; + /** This is an alias of {@link Long.multiply} */ + Long.prototype.mul = function (multiplier) { + return this.multiply(multiplier); + }; + /** Returns the Negation of this Long's value. */ + Long.prototype.negate = function () { + if (!this.unsigned && this.eq(Long.MIN_VALUE)) + return Long.MIN_VALUE; + return this.not().add(Long.ONE); + }; + /** This is an alias of {@link Long.negate} */ + Long.prototype.neg = function () { + return this.negate(); + }; + /** Returns the bitwise NOT of this Long. */ + Long.prototype.not = function () { + return Long.fromBits(~this.low, ~this.high, this.unsigned); + }; + /** Tests if this Long's value differs from the specified's. */ + Long.prototype.notEquals = function (other) { + return !this.equals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.neq = function (other) { + return this.notEquals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.ne = function (other) { + return this.notEquals(other); + }; + /** + * Returns the bitwise OR of this Long and the specified. + */ + Long.prototype.or = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); + }; + /** + * Returns this Long with bits shifted to the left by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftLeft = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); + else + return Long.fromBits(0, this.low << (numBits - 32), this.unsigned); + }; + /** This is an alias of {@link Long.shiftLeft} */ + Long.prototype.shl = function (numBits) { + return this.shiftLeft(numBits); + }; + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRight = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); + else + return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); + }; + /** This is an alias of {@link Long.shiftRight} */ + Long.prototype.shr = function (numBits) { + return this.shiftRight(numBits); + }; + /** + * Returns this Long with bits logically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRightUnsigned = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + 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, this.unsigned); + } + else if (numBits === 32) + return Long.fromBits(high, 0, this.unsigned); + else + return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned); + } + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shr_u = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shru = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** + * Returns the difference of this and the specified Long. + * @param subtrahend - Subtrahend + * @returns Difference + */ + Long.prototype.subtract = function (subtrahend) { + if (!Long.isLong(subtrahend)) + subtrahend = Long.fromValue(subtrahend); + return this.add(subtrahend.neg()); + }; + /** This is an alias of {@link Long.subtract} */ + Long.prototype.sub = function (subtrahend) { + return this.subtract(subtrahend); + }; + /** Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. */ + Long.prototype.toInt = function () { + return this.unsigned ? this.low >>> 0 : this.low; + }; + /** Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). */ + Long.prototype.toNumber = function () { + if (this.unsigned) + return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0); + return this.high * TWO_PWR_32_DBL + (this.low >>> 0); + }; + /** Converts the Long to a BigInt (arbitrary precision). */ + Long.prototype.toBigInt = function () { + return BigInt(this.toString()); + }; + /** + * Converts this Long to its byte representation. + * @param le - Whether little or big endian, defaults to big endian + * @returns Byte representation + */ + Long.prototype.toBytes = function (le) { + return le ? this.toBytesLE() : this.toBytesBE(); + }; + /** + * Converts this Long to its little endian byte representation. + * @returns Little endian byte representation + */ + Long.prototype.toBytesLE = function () { + var hi = this.high, lo = this.low; + return [ + lo & 0xff, + (lo >>> 8) & 0xff, + (lo >>> 16) & 0xff, + lo >>> 24, + hi & 0xff, + (hi >>> 8) & 0xff, + (hi >>> 16) & 0xff, + hi >>> 24 + ]; + }; + /** + * Converts this Long to its big endian byte representation. + * @returns Big endian byte representation + */ + Long.prototype.toBytesBE = function () { + var hi = this.high, lo = this.low; + return [ + hi >>> 24, + (hi >>> 16) & 0xff, + (hi >>> 8) & 0xff, + hi & 0xff, + lo >>> 24, + (lo >>> 16) & 0xff, + (lo >>> 8) & 0xff, + lo & 0xff + ]; + }; + /** + * Converts this Long to signed. + */ + Long.prototype.toSigned = function () { + if (!this.unsigned) + return this; + return Long.fromBits(this.low, this.high, false); + }; + /** + * Converts the Long to a string written in the specified radix. + * @param radix - Radix (2-36), defaults to 10 + * @throws RangeError If `radix` is out of range + */ + Long.prototype.toString = function (radix) { + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + if (this.isZero()) + return '0'; + if (this.isNegative()) { + // Unsigned Longs are never negative + if (this.eq(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), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this); + return div.toString(radix) + rem1.toInt().toString(radix); + } + else + return '-' + this.neg().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), this.unsigned); + // eslint-disable-next-line @typescript-eslint/no-this-alias + var rem = this; + var result = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + var remDiv = rem.div(radixToPower); + var intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0; + var digits = intval.toString(radix); + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } + else { + while (digits.length < 6) + digits = '0' + digits; + result = '' + digits + result; + } + } + }; + /** Converts this Long to unsigned. */ + Long.prototype.toUnsigned = function () { + if (this.unsigned) + return this; + return Long.fromBits(this.low, this.high, true); + }; + /** Returns the bitwise XOR of this Long and the given one. */ + Long.prototype.xor = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); + }; + /** This is an alias of {@link Long.isZero} */ + Long.prototype.eqz = function () { + return this.isZero(); + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.le = function (other) { + return this.lessThanOrEqual(other); + }; + /* + **************************************************************** + * BSON SPECIFIC ADDITIONS * + **************************************************************** + */ + Long.prototype.toExtendedJSON = function (options) { + if (options && options.relaxed) + return this.toNumber(); + return { $numberLong: this.toString() }; + }; + Long.fromExtendedJSON = function (doc, options) { + var result = Long.fromString(doc.$numberLong); + return options && options.relaxed ? result.toNumber() : result; + }; + /** @internal */ + Long.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Long.prototype.inspect = function () { + return "new Long(\"".concat(this.toString(), "\"").concat(this.unsigned ? ', true' : '', ")"); + }; + Long.TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL); + /** Maximum unsigned value. */ + Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xffffffff | 0, 0xffffffff | 0, true); + /** Signed zero */ + Long.ZERO = Long.fromInt(0); + /** Unsigned zero. */ + Long.UZERO = Long.fromInt(0, true); + /** Signed one. */ + Long.ONE = Long.fromInt(1); + /** Unsigned one. */ + Long.UONE = Long.fromInt(1, true); + /** Signed negative one. */ + Long.NEG_ONE = Long.fromInt(-1); + /** Maximum signed value. */ + Long.MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0, false); + /** Minimum signed value. */ + Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false); + return Long; +}()); +Object.defineProperty(Long.prototype, '__isLong__', { value: true }); +Object.defineProperty(Long.prototype, '_bsontype', { value: '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+)?$/; +// 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; +// Detect if the value is a digit +function isDigit(value) { + return !isNaN(parseInt(value, 10)); +} +// Divide two uint128 values +function divideu128(value) { + var DIVISOR = Long.fromNumber(1000 * 1000 * 1000); + var _rem = Long.fromNumber(0); + if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) { + return { quotient: value, rem: _rem }; + } + for (var 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 +function multiply64x2(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 }; +} +function lessThan(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; +} +function invalidErr(string, message) { + throw new BSONTypeError("\"".concat(string, "\" is not a valid Decimal128 string - ").concat(message)); +} +/** + * A class representation of the BSON Decimal128 type. + * @public + * @category BSONType + */ +var Decimal128 = /** @class */ (function () { + /** + * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order, + * or a string representation as returned by .toString() + */ + function Decimal128(bytes) { + if (!(this instanceof Decimal128)) + return new Decimal128(bytes); + if (typeof bytes === 'string') { + this.bytes = Decimal128.fromString(bytes).bytes; + } + else if (isUint8Array(bytes)) { + if (bytes.byteLength !== 16) { + throw new BSONTypeError('Decimal128 must take a Buffer of 16 bytes'); + } + this.bytes = bytes; + } + else { + throw new BSONTypeError('Decimal128 must take a Buffer or string'); + } + } + /** + * Create a Decimal128 instance from a string representation + * + * @param representation - a numeric string representation. + */ + Decimal128.fromString = function (representation) { + // 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 = new Long(0, 0); + // The low 17 digits of the significand + var significandLow = new Long(0, 0); + // The biased exponent + var biasedExponent = 0; + // Read index + var index = 0; + // Naively prevent against REDOS attacks. + // TODO: implementing a custom parsing for this, or refactoring the regex would yield + // further gains. + if (representation.length >= 7000) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + // Results + var stringMatch = representation.match(PARSE_STRING_REGEXP); + var infMatch = representation.match(PARSE_INF_REGEXP); + var nanMatch = representation.match(PARSE_NAN_REGEXP); + // Validate the string + if ((!stringMatch && !infMatch && !nanMatch) || representation.length === 0) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + if (stringMatch) { + // full_match = stringMatch[0] + // sign = stringMatch[1] + var unsignedNumber = stringMatch[2]; + // stringMatch[3] is undefined if a whole number (ex "1", 12") + // but defined if a number w/ decimal in it (ex "1.0, 12.2") + var e = stringMatch[4]; + var expSign = stringMatch[5]; + var expNumber = stringMatch[6]; + // they provided e, but didn't give an exponent number. for ex "1e" + if (e && expNumber === undefined) + invalidErr(representation, 'missing exponent power'); + // they provided e, but didn't give a number before it. for ex "e1" + if (e && unsignedNumber === undefined) + invalidErr(representation, 'missing exponent base'); + if (e === undefined && (expSign || expNumber)) { + invalidErr(representation, 'missing e before exponent'); + } + } + // Get the negative or positive sign + if (representation[index] === '+' || representation[index] === '-') { + isNegative = representation[index++] === '-'; + } + // Check if user passed Infinity or NaN + if (!isDigit(representation[index]) && representation[index] !== '.') { + if (representation[index] === 'i' || representation[index] === 'I') { + return new Decimal128(buffer_1.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + else if (representation[index] === 'N') { + return new Decimal128(buffer_1.from(NAN_BUFFER)); + } + } + // Read all the digits + while (isDigit(representation[index]) || representation[index] === '.') { + if (representation[index] === '.') { + if (sawRadix) + invalidErr(representation, 'contains multiple periods'); + sawRadix = true; + index = index + 1; + continue; + } + if (nDigitsStored < 34) { + if (representation[index] !== '0' || foundNonZero) { + if (!foundNonZero) { + firstNonZero = nDigitsRead; + } + foundNonZero = true; + // Only store 34 digits + digits[digitsInsert++] = parseInt(representation[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 BSONTypeError('' + representation + ' not a valid Decimal128 string'); + // Read exponent if exists + if (representation[index] === 'e' || representation[index] === 'E') { + // Read exponent digits + var match = representation.substr(++index).match(EXPONENT_REGEX); + // No digits read + if (!match || !match[2]) + return new Decimal128(buffer_1.from(NAN_BUFFER)); + // Get exponent + exponent = parseInt(match[0], 10); + // Adjust the index + index = index + match[0].length; + } + // Return not a number + if (representation[index]) + return new Decimal128(buffer_1.from(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 (significantDigits !== 1) { + while (digits[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; + } + invalidErr(representation, 'overflow'); + } + exponent = exponent - 1; + } + while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { + // Shift last digit. can only do this if < significant digits than # stored. + if (lastDigit === 0 && significantDigits < nDigitsStored) { + 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 + var digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } + invalidErr(representation, 'overflow'); + } + } + // Round + // We've normalized the exponent, but might still need to round. + if (lastDigit - firstDigit + 1 < significantDigits) { + 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) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + // if negative, we need to increment again to account for - sign at start. + if (isNegative) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + var roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10); + var roundBit = 0; + if (roundDigit >= 5) { + roundBit = 1; + if (roundDigit === 5) { + roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0; + for (i = firstNonZero + lastDigit + 2; i < endOfString; i++) { + if (parseInt(representation[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(buffer_1.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + } + } + } + } + // 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) { + var 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 { + var 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(1))) { + // 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 = buffer_1.alloc(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); + }; + /** Create a string representation of the raw Decimal128 value */ + Decimal128.prototype.toString = function () { + // Note: bits in this routine are referred to starting at 0, + // from the sign bit, towards the coefficient. + // 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; + // true if the number is zero + var is_zero = false; + // the most significant significand bits (50-46) + var significand_msb; + // temporary storage for significand decoding + var significand128 = { parts: [0, 0, 0, 0] }; + // indexing variables + var j, k; + // Output string + var string = []; + // Unpack index + index = 0; + // Buffer reference + var buffer = this.bytes; + // Unpack the low 64bits into a long + // bits 96 - 127 + var low = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 64 - 95 + var midl = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // Unpack the high 64bits into a long + // bits 32 - 63 + var midh = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 0 - 31 + var 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 + // bits 1 - 5 + var 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; + } + // unbiased exponent + var 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; + // Perform 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; + while (!significand[index]) { + significand_digits = significand_digits - 1; + index = index + 1; + } + } + // the exponent if scientific notation is used + var 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 + // if there are too many significant digits, we should just be treating numbers + // as + or - 0 and using the non-scientific exponent (this is for the "invalid + // representation should be treated as 0/-0" spec cases in decimal128-1.json) + if (significand_digits > 34) { + string.push("".concat(0)); + if (exponent > 0) + string.push("E+".concat(exponent)); + else if (exponent < 0) + string.push("E".concat(exponent)); + return string.join(''); + } + string.push("".concat(significand[index++])); + significand_digits = significand_digits - 1; + if (significand_digits) { + string.push('.'); + } + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + // Exponent + string.push('E'); + if (scientific_exponent > 0) { + string.push("+".concat(scientific_exponent)); + } + else { + string.push("".concat(scientific_exponent)); + } + } + else { + // Regular format with no decimal place + if (exponent >= 0) { + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + } + else { + var radix_position = significand_digits + exponent; + // non-zero digits before radix + if (radix_position > 0) { + for (var i = 0; i < radix_position; i++) { + string.push("".concat(significand[index++])); + } + } + else { + string.push('0'); + } + string.push('.'); + // add leading zeros after radix + while (radix_position++ < 0) { + string.push('0'); + } + for (var i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) { + string.push("".concat(significand[index++])); + } + } + } + return string.join(''); + }; + Decimal128.prototype.toJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.prototype.toExtendedJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.fromExtendedJSON = function (doc) { + return Decimal128.fromString(doc.$numberDecimal); + }; + /** @internal */ + Decimal128.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Decimal128.prototype.inspect = function () { + return "new Decimal128(\"".concat(this.toString(), "\")"); + }; + return Decimal128; +}()); +Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' }); + +/** + * A class representation of the BSON Double type. + * @public + * @category BSONType + */ +var Double = /** @class */ (function () { + /** + * Create a Double type + * + * @param value - the number we want to represent as a double. + */ + function Double(value) { + if (!(this instanceof Double)) + return new Double(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value; + } + /** + * Access the number value. + * + * @returns returns the wrapped double number. + */ + Double.prototype.valueOf = function () { + return this.value; + }; + Double.prototype.toJSON = function () { + return this.value; + }; + Double.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + /** @internal */ + Double.prototype.toExtendedJSON = function (options) { + if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) { + return this.value; + } + // NOTE: JavaScript has +0 and -0, apparently to model limit calculations. If a user + // explicitly provided `-0` then we need to ensure the sign makes it into the output + if (Object.is(Math.sign(this.value), -0)) { + return { $numberDouble: "-".concat(this.value.toFixed(1)) }; + } + var $numberDouble; + if (Number.isInteger(this.value)) { + $numberDouble = this.value.toFixed(1); + if ($numberDouble.length >= 13) { + $numberDouble = this.value.toExponential(13).toUpperCase(); + } + } + else { + $numberDouble = this.value.toString(); + } + return { $numberDouble: $numberDouble }; + }; + /** @internal */ + Double.fromExtendedJSON = function (doc, options) { + var doubleValue = parseFloat(doc.$numberDouble); + return options && options.relaxed ? doubleValue : new Double(doubleValue); + }; + /** @internal */ + Double.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Double.prototype.inspect = function () { + var eJSON = this.toExtendedJSON(); + return "new Double(".concat(eJSON.$numberDouble, ")"); + }; + return Double; +}()); +Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' }); + +/** + * A class representation of a BSON Int32 type. + * @public + * @category BSONType + */ +var Int32 = /** @class */ (function () { + /** + * Create an Int32 type + * + * @param value - the number we want to represent as an int32. + */ + function Int32(value) { + if (!(this instanceof Int32)) + return new Int32(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value | 0; + } + /** + * Access the number value. + * + * @returns returns the wrapped int32 number. + */ + Int32.prototype.valueOf = function () { + return this.value; + }; + Int32.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + Int32.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + Int32.prototype.toExtendedJSON = function (options) { + if (options && (options.relaxed || options.legacy)) + return this.value; + return { $numberInt: this.value.toString() }; + }; + /** @internal */ + Int32.fromExtendedJSON = function (doc, options) { + return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new Int32(doc.$numberInt); + }; + /** @internal */ + Int32.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Int32.prototype.inspect = function () { + return "new Int32(".concat(this.valueOf(), ")"); + }; + return Int32; +}()); +Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' }); + +/** + * A class representation of the BSON MaxKey type. + * @public + * @category BSONType + */ +var MaxKey = /** @class */ (function () { + function MaxKey() { + if (!(this instanceof MaxKey)) + return new MaxKey(); + } + /** @internal */ + MaxKey.prototype.toExtendedJSON = function () { + return { $maxKey: 1 }; + }; + /** @internal */ + MaxKey.fromExtendedJSON = function () { + return new MaxKey(); + }; + /** @internal */ + MaxKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MaxKey.prototype.inspect = function () { + return 'new MaxKey()'; + }; + return MaxKey; +}()); +Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' }); + +/** + * A class representation of the BSON MinKey type. + * @public + * @category BSONType + */ +var MinKey = /** @class */ (function () { + function MinKey() { + if (!(this instanceof MinKey)) + return new MinKey(); + } + /** @internal */ + MinKey.prototype.toExtendedJSON = function () { + return { $minKey: 1 }; + }; + /** @internal */ + MinKey.fromExtendedJSON = function () { + return new MinKey(); + }; + /** @internal */ + MinKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MinKey.prototype.inspect = function () { + return 'new MinKey()'; + }; + return MinKey; +}()); +Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' }); + +// Regular expression that checks for hex value +var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$'); +// Unique sequence for the current process (initialized on first use) +var PROCESS_UNIQUE = null; +var kId = Symbol('id'); +/** + * A class representation of the BSON ObjectId type. + * @public + * @category BSONType + */ +var ObjectId = /** @class */ (function () { + /** + * Create an ObjectId type + * + * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number. + */ + function ObjectId(inputId) { + if (!(this instanceof ObjectId)) + return new ObjectId(inputId); + // workingId is set based on type of input and whether valid id exists for the input + var workingId; + if (typeof inputId === 'object' && inputId && 'id' in inputId) { + if (typeof inputId.id !== 'string' && !ArrayBuffer.isView(inputId.id)) { + throw new BSONTypeError('Argument passed in must have an id that is of type string or Buffer'); + } + if ('toHexString' in inputId && typeof inputId.toHexString === 'function') { + workingId = buffer_1.from(inputId.toHexString(), 'hex'); + } + else { + workingId = inputId.id; + } + } + else { + workingId = inputId; + } + // the following cases use workingId to construct an ObjectId + if (workingId == null || typeof workingId === 'number') { + // The most common use case (blank id, new objectId instance) + // Generate a new id + this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined); + } + else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) { + // If intstanceof matches we can escape calling ensure buffer in Node.js environments + this[kId] = workingId instanceof buffer_1 ? workingId : ensureBuffer(workingId); + } + else if (typeof workingId === 'string') { + if (workingId.length === 12) { + var bytes = buffer_1.from(workingId); + if (bytes.byteLength === 12) { + this[kId] = bytes; + } + else { + throw new BSONTypeError('Argument passed in must be a string of 12 bytes'); + } + } + else if (workingId.length === 24 && checkForHexRegExp.test(workingId)) { + this[kId] = buffer_1.from(workingId, 'hex'); + } + else { + throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer'); + } + } + else { + throw new BSONTypeError('Argument passed in does not match the accepted types'); + } + // If we are caching the hex string + if (ObjectId.cacheHexString) { + this.__id = this.id.toString('hex'); + } + } + Object.defineProperty(ObjectId.prototype, "id", { + /** + * The ObjectId bytes + * @readonly + */ + get: function () { + return this[kId]; + }, + set: function (value) { + this[kId] = value; + if (ObjectId.cacheHexString) { + this.__id = value.toString('hex'); + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(ObjectId.prototype, "generationTime", { + /** + * The generation time of this ObjectId instance + * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch + */ + get: function () { + return this.id.readInt32BE(0); + }, + set: function (value) { + // Encode time into first 4 bytes + this.id.writeUInt32BE(value, 0); + }, + enumerable: false, + configurable: true + }); + /** Returns the ObjectId id as a 24 character hex string representation */ + ObjectId.prototype.toHexString = function () { + if (ObjectId.cacheHexString && this.__id) { + return this.__id; + } + var hexString = this.id.toString('hex'); + if (ObjectId.cacheHexString && !this.__id) { + this.__id = hexString; + } + return hexString; + }; + /** + * Update the ObjectId index + * @privateRemarks + * Used in generating new ObjectId's on the driver + * @internal + */ + ObjectId.getInc = function () { + return (ObjectId.index = (ObjectId.index + 1) % 0xffffff); + }; + /** + * Generate a 12 byte id buffer used in ObjectId's + * + * @param time - pass in a second based timestamp. + */ + ObjectId.generate = function (time) { + if ('number' !== typeof time) { + time = Math.floor(Date.now() / 1000); + } + var inc = ObjectId.getInc(); + var buffer = buffer_1.alloc(12); + // 4-byte timestamp + buffer.writeUInt32BE(time, 0); + // set PROCESS_UNIQUE if yet not initialized + if (PROCESS_UNIQUE === null) { + PROCESS_UNIQUE = randomBytes(5); + } + // 5-byte process unique + buffer[4] = PROCESS_UNIQUE[0]; + buffer[5] = PROCESS_UNIQUE[1]; + buffer[6] = PROCESS_UNIQUE[2]; + buffer[7] = PROCESS_UNIQUE[3]; + buffer[8] = PROCESS_UNIQUE[4]; + // 3-byte counter + buffer[11] = inc & 0xff; + buffer[10] = (inc >> 8) & 0xff; + buffer[9] = (inc >> 16) & 0xff; + return buffer; + }; + /** + * Converts the id into a 24 character hex string for printing + * + * @param format - The Buffer toString format parameter. + */ + ObjectId.prototype.toString = function (format) { + // Is the id a buffer then use the buffer toString method to return the format + if (format) + return this.id.toString(format); + return this.toHexString(); + }; + /** Converts to its JSON the 24 character hex string representation. */ + ObjectId.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this ObjectId with `otherID`. + * + * @param otherId - ObjectId instance to compare against. + */ + ObjectId.prototype.equals = function (otherId) { + if (otherId === undefined || otherId === null) { + return false; + } + if (otherId instanceof ObjectId) { + return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]); + } + if (typeof otherId === 'string' && + ObjectId.isValid(otherId) && + otherId.length === 12 && + isUint8Array(this.id)) { + return otherId === buffer_1.prototype.toString.call(this.id, 'latin1'); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 24) { + return otherId.toLowerCase() === this.toHexString(); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 12) { + return buffer_1.from(otherId).equals(this.id); + } + if (typeof otherId === 'object' && + 'toHexString' in otherId && + typeof otherId.toHexString === 'function') { + var otherIdString = otherId.toHexString(); + var thisIdString = this.toHexString().toLowerCase(); + return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString; + } + return false; + }; + /** Returns the generation date (accurate up to the second) that this ID was generated. */ + ObjectId.prototype.getTimestamp = function () { + var timestamp = new Date(); + var time = this.id.readUInt32BE(0); + timestamp.setTime(Math.floor(time) * 1000); + return timestamp; + }; + /** @internal */ + ObjectId.createPk = function () { + 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. + * + * @param time - an integer number representing a number of seconds. + */ + ObjectId.createFromTime = function (time) { + var buffer = buffer_1.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Encode time into first 4 bytes + buffer.writeUInt32BE(time, 0); + // Return the new objectId + return new ObjectId(buffer); + }; + /** + * Creates an ObjectId from a hex string representation of an ObjectId. + * + * @param hexString - create a ObjectId from a passed in 24 character hexstring. + */ + ObjectId.createFromHexString = function (hexString) { + // Throw an error if it's not a valid setup + if (typeof hexString === 'undefined' || (hexString != null && hexString.length !== 24)) { + throw new BSONTypeError('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'); + } + return new ObjectId(buffer_1.from(hexString, 'hex')); + }; + /** + * Checks if a value is a valid bson ObjectId + * + * @param id - ObjectId instance to validate. + */ + ObjectId.isValid = function (id) { + if (id == null) + return false; + try { + new ObjectId(id); + return true; + } + catch (_a) { + return false; + } + }; + /** @internal */ + ObjectId.prototype.toExtendedJSON = function () { + if (this.toHexString) + return { $oid: this.toHexString() }; + return { $oid: this.toString('hex') }; + }; + /** @internal */ + ObjectId.fromExtendedJSON = function (doc) { + return new ObjectId(doc.$oid); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 24 character hex string representation. + * @internal + */ + ObjectId.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + ObjectId.prototype.inspect = function () { + return "new ObjectId(\"".concat(this.toHexString(), "\")"); + }; + /** @internal */ + ObjectId.index = Math.floor(Math.random() * 0xffffff); + return ObjectId; +}()); +// Deprecated methods +Object.defineProperty(ObjectId.prototype, 'generate', { + value: deprecate(function (time) { return ObjectId.generate(time); }, 'Please use the static `ObjectId.generate(time)` instead') +}); +Object.defineProperty(ObjectId.prototype, 'getInc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') +}); +Object.defineProperty(ObjectId.prototype, 'get_inc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') +}); +Object.defineProperty(ObjectId, 'get_inc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') +}); +Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' }); + +function alphabetize(str) { + return str.split('').sort().join(''); +} +/** + * A class representation of the BSON RegExp type. + * @public + * @category BSONType + */ +var BSONRegExp = /** @class */ (function () { + /** + * @param pattern - The regular expression pattern to match + * @param options - The regular expression options + */ + function BSONRegExp(pattern, options) { + if (!(this instanceof BSONRegExp)) + return new BSONRegExp(pattern, options); + this.pattern = pattern; + this.options = alphabetize(options !== null && options !== void 0 ? options : ''); + if (this.pattern.indexOf('\x00') !== -1) { + throw new BSONError("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern))); + } + if (this.options.indexOf('\x00') !== -1) { + throw new BSONError("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.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 BSONError("The regular expression option [".concat(this.options[i], "] is not supported")); + } + } + } + BSONRegExp.parseOptions = function (options) { + return options ? options.split('').sort().join('') : ''; + }; + /** @internal */ + BSONRegExp.prototype.toExtendedJSON = function (options) { + options = options || {}; + if (options.legacy) { + return { $regex: this.pattern, $options: this.options }; + } + return { $regularExpression: { pattern: this.pattern, options: this.options } }; + }; + /** @internal */ + BSONRegExp.fromExtendedJSON = function (doc) { + if ('$regex' in doc) { + if (typeof doc.$regex !== 'string') { + // This is for $regex query operators that have extended json values. + if (doc.$regex._bsontype === 'BSONRegExp') { + return doc; + } + } + else { + return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options)); + } + } + if ('$regularExpression' in doc) { + return new BSONRegExp(doc.$regularExpression.pattern, BSONRegExp.parseOptions(doc.$regularExpression.options)); + } + throw new BSONTypeError("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(doc))); + }; + return BSONRegExp; +}()); +Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' }); + +/** + * A class representation of the BSON Symbol type. + * @public + * @category BSONType + */ +var BSONSymbol = /** @class */ (function () { + /** + * @param value - the string representing the symbol. + */ + function BSONSymbol(value) { + if (!(this instanceof BSONSymbol)) + return new BSONSymbol(value); + this.value = value; + } + /** Access the wrapped string value. */ + BSONSymbol.prototype.valueOf = function () { + return this.value; + }; + BSONSymbol.prototype.toString = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.inspect = function () { + return "new BSONSymbol(\"".concat(this.value, "\")"); + }; + BSONSymbol.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.toExtendedJSON = function () { + return { $symbol: this.value }; + }; + /** @internal */ + BSONSymbol.fromExtendedJSON = function (doc) { + return new BSONSymbol(doc.$symbol); + }; + /** @internal */ + BSONSymbol.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + return BSONSymbol; +}()); +Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' }); + +/** @public */ +var LongWithoutOverridesClass = Long; +/** + * @public + * @category BSONType + * */ +var Timestamp = /** @class */ (function (_super) { + __extends(Timestamp, _super); + function Timestamp(low, high) { + var _this = this; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + if (!(_this instanceof Timestamp)) + return new Timestamp(low, high); + if (Long.isLong(low)) { + _this = _super.call(this, low.low, low.high, true) || this; + } + else if (isObjectLike(low) && typeof low.t !== 'undefined' && typeof low.i !== 'undefined') { + _this = _super.call(this, low.i, low.t, true) || this; + } + else { + _this = _super.call(this, low, high, true) || this; + } + Object.defineProperty(_this, '_bsontype', { + value: 'Timestamp', + writable: false, + configurable: false, + enumerable: false + }); + return _this; + } + Timestamp.prototype.toJSON = function () { + return { + $timestamp: this.toString() + }; + }; + /** Returns a Timestamp represented by the given (32-bit) integer value. */ + Timestamp.fromInt = function (value) { + return new Timestamp(Long.fromInt(value, true)); + }; + /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */ + Timestamp.fromNumber = function (value) { + return new Timestamp(Long.fromNumber(value, true)); + }; + /** + * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits. + * + * @param lowBits - the low 32-bits. + * @param highBits - the high 32-bits. + */ + Timestamp.fromBits = function (lowBits, highBits) { + return new Timestamp(lowBits, highBits); + }; + /** + * Returns a Timestamp from the given string, optionally using the given radix. + * + * @param str - the textual representation of the Timestamp. + * @param optRadix - the radix in which the text is written. + */ + Timestamp.fromString = function (str, optRadix) { + return new Timestamp(Long.fromString(str, true, optRadix)); + }; + /** @internal */ + Timestamp.prototype.toExtendedJSON = function () { + return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } }; + }; + /** @internal */ + Timestamp.fromExtendedJSON = function (doc) { + return new Timestamp(doc.$timestamp); + }; + /** @internal */ + Timestamp.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Timestamp.prototype.inspect = function () { + return "new Timestamp({ t: ".concat(this.getHighBits(), ", i: ").concat(this.getLowBits(), " })"); + }; + Timestamp.MAX_VALUE = Long.MAX_UNSIGNED_VALUE; + return Timestamp; +}(LongWithoutOverridesClass)); + +function isBSONType(value) { + return (isObjectLike(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string'); +} +// INT32 boundaries +var BSON_INT32_MAX = 0x7fffffff; +var BSON_INT32_MIN = -0x80000000; +// INT64 boundaries +// const BSON_INT64_MAX = 0x7fffffffffffffff; // TODO(NODE-4377): This number cannot be precisely represented in JS +var BSON_INT64_MAX = 0x8000000000000000; +var BSON_INT64_MIN = -0x8000000000000000; +// all the types where we don't need to do any special processing and can just pass the EJSON +//straight to type.fromExtendedJSON +var keysToCodecs = { + $oid: ObjectId, + $binary: Binary, + $uuid: Binary, + $symbol: BSONSymbol, + $numberInt: Int32, + $numberDecimal: Decimal128, + $numberDouble: Double, + $numberLong: Long, + $minKey: MinKey, + $maxKey: MaxKey, + $regex: BSONRegExp, + $regularExpression: BSONRegExp, + $timestamp: Timestamp +}; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function deserializeValue(value, options) { + if (options === void 0) { options = {}; } + if (typeof value === 'number') { + if (options.relaxed || options.legacy) { + return value; + } + // if it's an integer, should interpret as smallest BSON integer + // that can represent it exactly. (if out of range, interpret as double.) + if (Math.floor(value) === value) { + if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) + return new Int32(value); + if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) + return Long.fromNumber(value); + } + // If the number is a non-integer or out of integer range, should interpret as BSON Double. + return new Double(value); + } + // from here on out we're looking for bson types, so bail if its not an object + if (value == null || typeof value !== 'object') + return value; + // upgrade deprecated undefined to null + if (value.$undefined) + return null; + var keys = Object.keys(value).filter(function (k) { return k.startsWith('$') && value[k] != null; }); + for (var i = 0; i < keys.length; i++) { + var c = keysToCodecs[keys[i]]; + if (c) + return c.fromExtendedJSON(value, options); + } + if (value.$date != null) { + var d = value.$date; + var date = new Date(); + if (options.legacy) { + if (typeof d === 'number') + date.setTime(d); + else if (typeof d === 'string') + date.setTime(Date.parse(d)); + } + else { + if (typeof d === 'string') + date.setTime(Date.parse(d)); + else if (Long.isLong(d)) + date.setTime(d.toNumber()); + else if (typeof d === 'number' && options.relaxed) + date.setTime(d); + } + return date; + } + if (value.$code != null) { + var copy = Object.assign({}, value); + if (value.$scope) { + copy.$scope = deserializeValue(value.$scope); + } + return Code.fromExtendedJSON(value); + } + if (isDBRefLike(value) || value.$dbPointer) { + var v = value.$ref ? value : value.$dbPointer; + // we run into this in a "degenerate EJSON" case (with $id and $ref order flipped) + // because of the order JSON.parse goes through the document + if (v instanceof DBRef) + return v; + var dollarKeys = Object.keys(v).filter(function (k) { return k.startsWith('$'); }); + var valid_1 = true; + dollarKeys.forEach(function (k) { + if (['$ref', '$id', '$db'].indexOf(k) === -1) + valid_1 = false; + }); + // only make DBRef if $ keys are all valid + if (valid_1) + return DBRef.fromExtendedJSON(v); + } + return value; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeArray(array, options) { + return array.map(function (v, index) { + options.seenObjects.push({ propertyName: "index ".concat(index), obj: null }); + try { + return serializeValue(v, options); + } + finally { + options.seenObjects.pop(); + } + }); +} +function getISOString(date) { + var isoStr = date.toISOString(); + // we should only show milliseconds in timestamp if they're non-zero + return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + 'Z'; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeValue(value, options) { + if ((typeof value === 'object' || typeof value === 'function') && value !== null) { + var index = options.seenObjects.findIndex(function (entry) { return entry.obj === value; }); + if (index !== -1) { + var props = options.seenObjects.map(function (entry) { return entry.propertyName; }); + var leadingPart = props + .slice(0, index) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var alreadySeen = props[index]; + var circularPart = ' -> ' + + props + .slice(index + 1, props.length - 1) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var current = props[props.length - 1]; + var leadingSpace = ' '.repeat(leadingPart.length + alreadySeen.length / 2); + var dashes = '-'.repeat(circularPart.length + (alreadySeen.length + current.length) / 2 - 1); + throw new BSONTypeError('Converting circular structure to EJSON:\n' + + " ".concat(leadingPart).concat(alreadySeen).concat(circularPart).concat(current, "\n") + + " ".concat(leadingSpace, "\\").concat(dashes, "/")); + } + options.seenObjects[options.seenObjects.length - 1].obj = value; + } + if (Array.isArray(value)) + return serializeArray(value, options); + if (value === undefined) + return null; + if (value instanceof Date || isDate(value)) { + var dateNum = value.getTime(), + // is it in year range 1970-9999? + inRange = dateNum > -1 && dateNum < 253402318800000; + if (options.legacy) { + return options.relaxed && inRange + ? { $date: value.getTime() } + : { $date: getISOString(value) }; + } + return options.relaxed && inRange + ? { $date: getISOString(value) } + : { $date: { $numberLong: value.getTime().toString() } }; + } + if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) { + // it's an integer + if (Math.floor(value) === value) { + var int32Range = value >= BSON_INT32_MIN && value <= BSON_INT32_MAX, int64Range = value >= BSON_INT64_MIN && value <= BSON_INT64_MAX; + // interpret as being of the smallest BSON integer type that can represent the number exactly + if (int32Range) + return { $numberInt: value.toString() }; + if (int64Range) + return { $numberLong: value.toString() }; + } + return { $numberDouble: value.toString() }; + } + if (value instanceof RegExp || isRegExp(value)) { + var flags = value.flags; + if (flags === undefined) { + var match = value.toString().match(/[gimuy]*$/); + if (match) { + flags = match[0]; + } + } + var rx = new BSONRegExp(value.source, flags); + return rx.toExtendedJSON(options); + } + if (value != null && typeof value === 'object') + return serializeDocument(value, options); + return value; +} +var BSON_TYPE_MAPPINGS = { + Binary: function (o) { return new Binary(o.value(), o.sub_type); }, + Code: function (o) { return new Code(o.code, o.scope); }, + DBRef: function (o) { return new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields); }, + Decimal128: function (o) { return new Decimal128(o.bytes); }, + Double: function (o) { return new Double(o.value); }, + Int32: function (o) { return new Int32(o.value); }, + Long: function (o) { + return Long.fromBits( + // underscore variants for 1.x backwards compatibility + o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_); + }, + MaxKey: function () { return new MaxKey(); }, + MinKey: function () { return new MinKey(); }, + ObjectID: function (o) { return new ObjectId(o); }, + ObjectId: function (o) { return new ObjectId(o); }, + BSONRegExp: function (o) { return new BSONRegExp(o.pattern, o.options); }, + Symbol: function (o) { return new BSONSymbol(o.value); }, + Timestamp: function (o) { return Timestamp.fromBits(o.low, o.high); } +}; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeDocument(doc, options) { + if (doc == null || typeof doc !== 'object') + throw new BSONError('not an object instance'); + var bsontype = doc._bsontype; + if (typeof bsontype === 'undefined') { + // It's a regular object. Recursively serialize its property values. + var _doc = {}; + for (var name in doc) { + options.seenObjects.push({ propertyName: name, obj: null }); + try { + var value = serializeValue(doc[name], options); + if (name === '__proto__') { + Object.defineProperty(_doc, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + _doc[name] = value; + } + } + finally { + options.seenObjects.pop(); + } + } + return _doc; + } + else if (isBSONType(doc)) { + // the "document" is really just a BSON type object + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var outDoc = doc; + if (typeof outDoc.toExtendedJSON !== 'function') { + // There's no EJSON serialization function on the object. It's probably an + // object created by a previous version of this library (or another library) + // that's duck-typing objects to look like they were generated by this library). + // Copy the object into this library's version of that type. + var mapper = BSON_TYPE_MAPPINGS[doc._bsontype]; + if (!mapper) { + throw new BSONTypeError('Unrecognized or invalid _bsontype: ' + doc._bsontype); + } + outDoc = mapper(outDoc); + } + // Two BSON types may have nested objects that may need to be serialized too + if (bsontype === 'Code' && outDoc.scope) { + outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options)); + } + else if (bsontype === 'DBRef' && outDoc.oid) { + outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options)); + } + return outDoc.toExtendedJSON(options); + } + else { + throw new BSONError('_bsontype must be a string, but was: ' + typeof bsontype); + } +} +/** + * EJSON parse / stringify API + * @public + */ +// the namespace here is used to emulate `export * as EJSON from '...'` +// which as of now (sept 2020) api-extractor does not support +// eslint-disable-next-line @typescript-eslint/no-namespace +var EJSON; +(function (EJSON) { + /** + * Parse an Extended JSON string, constructing the JavaScript value or object described by that + * string. + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const text = '{ "int32": { "$numberInt": "10" } }'; + * + * // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } } + * console.log(EJSON.parse(text, { relaxed: false })); + * + * // prints { int32: 10 } + * console.log(EJSON.parse(text)); + * ``` + */ + function parse(text, options) { + var finalOptions = Object.assign({}, { relaxed: true, legacy: false }, options); + // relaxed implies not strict + if (typeof finalOptions.relaxed === 'boolean') + finalOptions.strict = !finalOptions.relaxed; + if (typeof finalOptions.strict === 'boolean') + finalOptions.relaxed = !finalOptions.strict; + return JSON.parse(text, function (key, value) { + if (key.indexOf('\x00') !== -1) { + throw new BSONError("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(key))); + } + return deserializeValue(value, finalOptions); + }); + } + EJSON.parse = parse; + /** + * Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer + * function is specified or optionally including only the specified properties if a replacer array + * is specified. + * + * @param value - The value to convert to extended JSON + * @param replacer - A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string + * @param space - A String or Number object that's used to insert white space into the output JSON string for readability purposes. + * @param options - Optional settings + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const Int32 = require('mongodb').Int32; + * const doc = { int32: new Int32(10) }; + * + * // prints '{"int32":{"$numberInt":"10"}}' + * console.log(EJSON.stringify(doc, { relaxed: false })); + * + * // prints '{"int32":10}' + * console.log(EJSON.stringify(doc)); + * ``` + */ + function stringify(value, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + replacer, space, options) { + if (space != null && typeof space === 'object') { + options = space; + space = 0; + } + if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) { + options = replacer; + replacer = undefined; + space = 0; + } + var serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, { + seenObjects: [{ propertyName: '(root)', obj: null }] + }); + var doc = serializeValue(value, serializeOptions); + return JSON.stringify(doc, replacer, space); + } + EJSON.stringify = stringify; + /** + * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object. + * + * @param value - The object to serialize + * @param options - Optional settings passed to the `stringify` function + */ + function serialize(value, options) { + options = options || {}; + return JSON.parse(stringify(value, options)); + } + EJSON.serialize = serialize; + /** + * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types + * + * @param ejson - The Extended JSON object to deserialize + * @param options - Optional settings passed to the parse method + */ + function deserialize(ejson, options) { + options = options || {}; + return parse(JSON.stringify(ejson), options); + } + EJSON.deserialize = deserialize; +})(EJSON || (EJSON = {})); + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** @public */ +var bsonMap; +var bsonGlobal = getGlobal(); +if (bsonGlobal.Map) { + bsonMap = bsonGlobal.Map; +} +else { + // We will return a polyfill + bsonMap = /** @class */ (function () { + function Map(array) { + if (array === void 0) { 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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? [key, _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? _this._values[key].v : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + Object.defineProperty(Map.prototype, "size", { + get: function () { + return this._keys.length; + }, + enumerable: false, + configurable: true + }); + return Map; + }()); +} + +function calculateObjectSize$1(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 (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + object = object.toBSON(); + } + // Calculate size + for (var key in object) { + totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined); + } + } + return totalLength; +} +/** @internal */ +function calculateElement(name, +// eslint-disable-next-line @typescript-eslint/no-explicit-any +value, serializeFunctions, isArray, ignoreUndefined) { + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (isArray === void 0) { isArray = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = false; } + // If we have toBSON defined, override the current object + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + switch (typeof value) { + case 'string': + return 1 + buffer_1.byteLength(name, 'utf8') + 1 + 4 + buffer_1.byteLength(value, 'utf8') + 1; + case 'number': + if (Math.floor(value) === value && + value >= JS_INT_MIN && + value <= JS_INT_MAX) { + if (value >= BSON_INT32_MIN$1 && value <= BSON_INT32_MAX$1) { + // 32 bit + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (4 + 1); + } + else { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + } + else { + // 64 bit + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + case 'undefined': + if (isArray || !ignoreUndefined) + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + 1; + return 0; + case 'boolean': + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (1 + 1); + case 'object': + if (value == null || value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + 1; + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (12 + 1); + } + else if (value instanceof Date || isDate(value)) { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + else if (ArrayBuffer.isView(value) || + value instanceof ArrayBuffer || + isAnyArrayBuffer(value)) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength); + } + else if (value['_bsontype'] === 'Long' || + value['_bsontype'] === 'Double' || + value['_bsontype'] === 'Timestamp') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + else if (value['_bsontype'] === 'Decimal128') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (16 + 1); + } + else if (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_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + buffer_1.byteLength(value.code.toString(), 'utf8') + + 1 + + calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined)); + } + else { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + buffer_1.byteLength(value.code.toString(), 'utf8') + + 1); + } + } + else if (value['_bsontype'] === 'Binary') { + var binary = value; + // Check what kind of subtype we have + if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + (binary.position + 1 + 4 + 1 + 4)); + } + else { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (binary.position + 1 + 4 + 1)); + } + } + else if (value['_bsontype'] === 'Symbol') { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + buffer_1.byteLength(value.value, 'utf8') + + 4 + + 1 + + 1); + } + else if (value['_bsontype'] === 'DBRef') { + // Set up correct object for serialization + var ordered_values = Object.assign({ + $ref: value.collection, + $id: value.oid + }, value.fields); + // Add db reference if it exists + if (value.db != null) { + ordered_values['$db'] = value.db; + } + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + calculateObjectSize$1(ordered_values, serializeFunctions, ignoreUndefined)); + } + else if (value instanceof RegExp || isRegExp(value)) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.byteLength(value.source, 'utf8') + + 1 + + (value.global ? 1 : 0) + + (value.ignoreCase ? 1 : 0) + + (value.multiline ? 1 : 0) + + 1); + } + else if (value['_bsontype'] === 'BSONRegExp') { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.byteLength(value.pattern, 'utf8') + + 1 + + buffer_1.byteLength(value.options, 'utf8') + + 1); + } + else { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + calculateObjectSize$1(value, serializeFunctions, ignoreUndefined) + + 1); + } + case 'function': + // WTF for 0.4.X where typeof /someregexp/ === 'function' + if (value instanceof RegExp || isRegExp(value) || String.call(value) === '[object RegExp]') { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.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_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + buffer_1.byteLength(normalizedFunctionString(value), 'utf8') + + 1 + + calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined)); + } + else if (serializeFunctions) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + buffer_1.byteLength(normalizedFunctionString(value), 'utf8') + + 1); + } + } + } + return 0; +} + +var FIRST_BIT = 0x80; +var FIRST_TWO_BITS = 0xc0; +var FIRST_THREE_BITS = 0xe0; +var FIRST_FOUR_BITS = 0xf0; +var FIRST_FIVE_BITS = 0xf8; +var TWO_BIT_CHAR = 0xc0; +var THREE_BIT_CHAR = 0xe0; +var FOUR_BIT_CHAR = 0xf0; +var CONTINUING_CHAR = 0x80; +/** + * Determines if the passed in bytes are valid utf8 + * @param bytes - An array of 8-bit bytes. Must be indexable and have length property + * @param start - The index to start validating + * @param end - The index to end validating + */ +function validateUtf8(bytes, start, end) { + var continuation = 0; + for (var i = start; i < end; i += 1) { + var byte = bytes[i]; + if (continuation) { + if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) { + return false; + } + continuation -= 1; + } + else if (byte & FIRST_BIT) { + if ((byte & FIRST_THREE_BITS) === TWO_BIT_CHAR) { + continuation = 1; + } + else if ((byte & FIRST_FOUR_BITS) === THREE_BIT_CHAR) { + continuation = 2; + } + else if ((byte & FIRST_FIVE_BITS) === FOUR_BIT_CHAR) { + continuation = 3; + } + else { + return false; + } + } + } + return !continuation; +} + +// Internal long versions +var JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX); +var JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN); +var functionCache = {}; +function deserialize$1(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); + if (size < 5) { + throw new BSONError("bson size must be >= 5, is ".concat(size)); + } + if (options.allowObjectSmallerThanBufferSize && buffer.length < size) { + throw new BSONError("buffer length ".concat(buffer.length, " must be >= bson size ").concat(size)); + } + if (!options.allowObjectSmallerThanBufferSize && buffer.length !== size) { + throw new BSONError("buffer length ".concat(buffer.length, " must === bson size ").concat(size)); + } + if (size + index > buffer.byteLength) { + throw new BSONError("(bson size ".concat(size, " + options.index ").concat(index, " must be <= buffer length ").concat(buffer.byteLength, ")")); + } + // Illegal end value + if (buffer[index + size - 1] !== 0) { + throw new BSONError("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 allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/; +function deserializeObject(buffer, index, options, isArray) { + if (isArray === void 0) { isArray = false; } + var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; + var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions']; + 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']; + // Ensures default validation option if none given + var validation = options.validation == null ? { utf8: true } : options.validation; + // Shows if global utf-8 validation is enabled or disabled + var globalUTFValidation = true; + // Reflects utf-8 validation setting regardless of global or specific key validation + var validationSetting; + // Set of keys either to enable or disable validation on + var utf8KeysSet = new Set(); + // Check for boolean uniformity and empty validation option + var utf8ValidatedKeys = validation.utf8; + if (typeof utf8ValidatedKeys === 'boolean') { + validationSetting = utf8ValidatedKeys; + } + else { + globalUTFValidation = false; + var utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function (key) { + return utf8ValidatedKeys[key]; + }); + if (utf8ValidationValues.length === 0) { + throw new BSONError('UTF-8 validation setting cannot be empty'); + } + if (typeof utf8ValidationValues[0] !== 'boolean') { + throw new BSONError('Invalid UTF-8 validation option, must specify boolean values'); + } + validationSetting = utf8ValidationValues[0]; + // Ensures boolean uniformity in utf-8 validation (all true or all false) + if (!utf8ValidationValues.every(function (item) { return item === validationSetting; })) { + throw new BSONError('Invalid UTF-8 validation option - keys must be all true or all false'); + } + } + // Add keys to set that will either be validated or not based on validationSetting + if (!globalUTFValidation) { + for (var _i = 0, _a = Object.keys(utf8ValidatedKeys); _i < _a.length; _i++) { + var key = _a[_i]; + utf8KeysSet.add(key); + } + } + // Set the start index + var startIndex = index; + // Validate that we have at least 4 bytes of buffer + if (buffer.length < 5) + throw new BSONError('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 BSONError('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; + var isPossibleDBRef = isArray ? false : null; + // While we have more left data left keep parsing + var dataview = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength); + 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.byteLength) + throw new BSONError('Bad BSON Document: illegal CString'); + // Represents the key + var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i); + // shouldValidateKey is true if the key should be validated, false otherwise + var shouldValidateKey = true; + if (globalUTFValidation || utf8KeysSet.has(name)) { + shouldValidateKey = validationSetting; + } + else { + shouldValidateKey = !validationSetting; + } + if (isPossibleDBRef !== false && name[0] === '$') { + isPossibleDBRef = allowedDBRefKeys.test(name); + } + var value = void 0; + index = i + 1; + if (elementType === 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 BSONError('bad string length in bson'); + } + value = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + index = index + stringSize; + } + else if (elementType === BSON_DATA_OID) { + var oid = buffer_1.alloc(12); + buffer.copy(oid, 0, index, index + 12); + value = new ObjectId(oid); + index = index + 12; + } + else if (elementType === BSON_DATA_INT && promoteValues === false) { + value = new Int32(buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24)); + } + else if (elementType === BSON_DATA_INT) { + value = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + } + else if (elementType === BSON_DATA_NUMBER && promoteValues === false) { + value = new Double(dataview.getFloat64(index, true)); + index = index + 8; + } + else if (elementType === BSON_DATA_NUMBER) { + value = dataview.getFloat64(index, true); + index = index + 8; + } + else if (elementType === 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); + value = new Date(new Long(lowBits, highBits).toNumber()); + } + else if (elementType === BSON_DATA_BOOLEAN) { + if (buffer[index] !== 0 && buffer[index] !== 1) + throw new BSONError('illegal boolean type value'); + value = buffer[index++] === 1; + } + else if (elementType === 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 BSONError('bad embedded document length in bson'); + // We have a raw value + if (raw) { + value = buffer.slice(index, index + objectSize); + } + else { + var objectOptions = options; + if (!globalUTFValidation) { + objectOptions = _assign(_assign({}, options), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, objectOptions, false); + } + index = index + objectSize; + } + else if (elementType === BSON_DATA_ARRAY) { + var _index = index; + var 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; + } + if (!globalUTFValidation) { + arrayOptions = _assign(_assign({}, arrayOptions), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, arrayOptions, true); + index = index + objectSize; + if (buffer[index - 1] !== 0) + throw new BSONError('invalid array terminator byte'); + if (index !== stopIndex) + throw new BSONError('corrupted array bson'); + } + else if (elementType === BSON_DATA_UNDEFINED) { + value = undefined; + } + else if (elementType === BSON_DATA_NULL) { + value = null; + } + else if (elementType === BSON_DATA_LONG) { + // Unpack the low and high bits + 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); + var long = new Long(lowBits, highBits); + // Promote the long if possible + if (promoteLongs && promoteValues === true) { + value = + long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) + ? long.toNumber() + : long; + } + else { + value = long; + } + } + else if (elementType === BSON_DATA_DECIMAL128) { + // Buffer to contain the decimal bytes + var bytes = buffer_1.alloc(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 + if ('toObject' in decimal128 && typeof decimal128.toObject === 'function') { + value = decimal128.toObject(); + } + else { + value = decimal128; + } + } + else if (elementType === 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 BSONError('Negative binary type element size found'); + // Is the length longer than the document + if (binarySize > buffer.byteLength) + throw new BSONError('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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + if (promoteBuffers && promoteValues) { + value = buffer.slice(index, index + binarySize); + } + else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) { + value = value.toUUID(); + } + } + } + else { + var _buffer = buffer_1.alloc(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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + // Copy the data + for (i = 0; i < binarySize; i++) { + _buffer[i] = buffer[index + i]; + } + if (promoteBuffers && promoteValues) { + value = _buffer; + } + else if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) { + value = new Binary(buffer.slice(index, index + binarySize), subType).toUUID(); + } + else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + } + } + // Update the index + index = index + binarySize; + } + else if (elementType === 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 BSONError('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 BSONError('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; + } + } + value = new RegExp(source, optionsArray.join('')); + } + else if (elementType === 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + // Set the object + value = new BSONRegExp(source, regExpOptions); + } + else if (elementType === BSON_DATA_SYMBOL) { + 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 BSONError('bad string length in bson'); + } + var symbol = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + value = promoteValues ? symbol : new BSONSymbol(symbol); + index = index + stringSize; + } + else if (elementType === BSON_DATA_TIMESTAMP) { + 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); + value = new Timestamp(lowBits, highBits); + } + else if (elementType === BSON_DATA_MIN_KEY) { + value = new MinKey(); + } + else if (elementType === BSON_DATA_MAX_KEY) { + value = new MaxKey(); + } + else if (elementType === BSON_DATA_CODE) { + 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 BSONError('bad string length in bson'); + } + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + } + else { + value = new Code(functionString); + } + // Update parse index position + index = index + stringSize; + } + else if (elementType === 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 BSONError('code_w_scope total size shorter minimum expected length'); + } + // Get the code string size + var 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 BSONError('bad string length in bson'); + } + // Javascript function + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // Update parse index position + index = index + stringSize; + // Parse the element + var _index = index; + // Decode the size of the object document + var 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 too short + if (totalSize < 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too short, truncating scope'); + } + // Check if totalSize field is too long + if (totalSize > 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + value.scope = scopeObject; + } + else { + value = new Code(functionString, scopeObject); + } + } + else if (elementType === BSON_DATA_DBPOINTER) { + // Get the code string size + var 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 BSONError('bad string length in bson'); + // Namespace + if (validation != null && validation.utf8) { + if (!validateUtf8(buffer, index, index + stringSize - 1)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + } + var namespace = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + // Read the oid + var oidBuffer = buffer_1.alloc(12); + buffer.copy(oidBuffer, 0, index, index + 12); + var oid = new ObjectId(oidBuffer); + // Update the index + index = index + 12; + // Upgrade to DBRef type + value = new DBRef(namespace, oid); + } + else { + throw new BSONError("Detected unknown BSON type ".concat(elementType.toString(16), " for fieldname \"").concat(name, "\"")); + } + if (name === '__proto__') { + Object.defineProperty(object, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + object[name] = value; + } + } + // Check if the deserialization was against a valid array/object + if (size !== index - startIndex) { + if (isArray) + throw new BSONError('corrupt array bson'); + throw new BSONError('corrupt object bson'); + } + // if we did not find "$ref", "$id", "$db", or found an extraneous $key, don't make a DBRef + if (!isPossibleDBRef) + return object; + if (isDBRefLike(object)) { + var copy = Object.assign({}, object); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(object.$ref, object.$id, object.$db, copy); + } + return object; +} +/** + * Ensure eval is isolated, store the result in functionCache. + * + * @internal + */ +function isolateEval(functionString, functionCache, object) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + if (!functionCache) + return new Function(functionString); + // Check for cache hit, eval if missing and return cached function + if (functionCache[functionString] == null) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + functionCache[functionString] = new Function(functionString); + } + // Set the object + return functionCache[functionString].bind(object); +} +function getValidatedString(buffer, start, end, shouldValidateUtf8) { + var value = buffer.toString('utf8', start, end); + // if utf8 validation is on, do the check + if (shouldValidateUtf8) { + for (var i = 0; i < value.length; i++) { + if (value.charCodeAt(i) === 0xfffd) { + if (!validateUtf8(buffer, start, end)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + break; + } + } + } + return value; +} + +var regexp = /\x00/; // eslint-disable-line no-control-regex +var ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']); +/* + * isArray indicates if we are writing to a BSON array (type 0x04) + * which forces the "key" which really an array index as a string to be written as ascii + * This will catch any errors in index as a string generation + */ +function serializeString(buffer, key, value, index, isArray) { + // Encode String type + buffer[index++] = BSON_DATA_STRING; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes + 1; + buffer[index - 1] = 0; + // Write the string + var size = buffer.write(value, index + 4, undefined, 'utf8'); + // Write the size of the string to buffer + buffer[index + 3] = ((size + 1) >> 24) & 0xff; + buffer[index + 2] = ((size + 1) >> 16) & 0xff; + buffer[index + 1] = ((size + 1) >> 8) & 0xff; + buffer[index] = (size + 1) & 0xff; + // Update index + index = index + 4 + size; + // Write zero + buffer[index++] = 0; + return index; +} +var SPACE_FOR_FLOAT64 = new Uint8Array(8); +var DV_FOR_FLOAT64 = new DataView(SPACE_FOR_FLOAT64.buffer, SPACE_FOR_FLOAT64.byteOffset, SPACE_FOR_FLOAT64.byteLength); +function serializeNumber(buffer, key, value, index, isArray) { + // We have an integer value + // TODO(NODE-2529): Add support for big int + if (Number.isInteger(value) && + value >= BSON_INT32_MIN$1 && + value <= BSON_INT32_MAX$1) { + // If the value fits in 32 bits encode as int32 + // Set int type 32 bits or less + buffer[index++] = BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + } + else { + // Encode as double + buffer[index++] = BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + } + return index; +} +function serializeNull(buffer, key, _, index, isArray) { + // Set long type + buffer[index++] = BSON_DATA_NULL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +} +function serializeBoolean(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BOOLEAN; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Encode the boolean value + buffer[index++] = value ? 1 : 0; + return index; +} +function serializeDate(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_DATE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var dateInMilis = Long.fromNumber(value.getTime()); + var lowBits = dateInMilis.getLowBits(); + var highBits = dateInMilis.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +} +function serializeRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + if (value.source && value.source.match(regexp) != null) { + throw Error('value ' + value.source + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.source, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the parameters + if (value.ignoreCase) + buffer[index++] = 0x69; // i + if (value.global) + buffer[index++] = 0x73; // s + if (value.multiline) + buffer[index++] = 0x6d; // m + // Add ending zero + buffer[index++] = 0x00; + return index; +} +function serializeBSONRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Check the pattern for 0 bytes + if (value.pattern.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('pattern ' + value.pattern + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.pattern, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the options + index = index + buffer.write(value.options.split('').sort().join(''), index, undefined, 'utf8'); + // Add ending zero + buffer[index++] = 0x00; + return index; +} +function serializeMinMax(buffer, key, value, index, isArray) { + // Write the type of either min or max key + if (value === null) { + buffer[index++] = BSON_DATA_NULL; + } + else if (value._bsontype === 'MinKey') { + buffer[index++] = BSON_DATA_MIN_KEY; + } + else { + buffer[index++] = BSON_DATA_MAX_KEY; + } + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +} +function serializeObjectId(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_OID; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the objectId into the shared buffer + if (typeof value.id === 'string') { + buffer.write(value.id, index, undefined, 'binary'); + } + else if (isUint8Array(value.id)) { + // Use the standard JS methods here because buffer.copy() is buggy with the + // browser polyfill + buffer.set(value.id.subarray(0, 12), index); + } + else { + throw new BSONTypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId'); + } + // Adjust index + return index + 12; +} +function serializeBuffer(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Get size of the buffer (current write point) + var size = value.length; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the default subtype + buffer[index++] = BSON_BINARY_SUBTYPE_DEFAULT; + // Copy the content form the binary field to the buffer + buffer.set(ensureBuffer(value), index); + // Adjust the index + index = index + size; + return index; +} +function serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (path === void 0) { path = []; } + for (var i = 0; i < path.length; i++) { + if (path[i] === value) + throw new BSONError('cyclic dependency detected'); + } + // Push value to stack + path.push(value); + // Write the type + buffer[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var endIndex = serializeInto(buffer, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path); + // Pop stack + path.pop(); + return endIndex; +} +function serializeDecimal128(buffer, key, value, index, isArray) { + buffer[index++] = BSON_DATA_DECIMAL128; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the data from the value + // Prefer the standard JS methods because their typechecking is not buggy, + // unlike the `buffer` polyfill's. + buffer.set(value.bytes.subarray(0, 16), index); + return index + 16; +} +function serializeLong(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = + value._bsontype === 'Long' ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var lowBits = value.getLowBits(); + var highBits = value.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +} +function serializeInt32(buffer, key, value, index, isArray) { + value = value.valueOf(); + // Set int type 32 bits or less + buffer[index++] = BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + return index; +} +function serializeDouble(buffer, key, value, index, isArray) { + // Encode as double + buffer[index++] = BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value.value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + return index; +} +function serializeFunction(buffer, key, value, index, _checkKeys, _depth, isArray) { + buffer[index++] = BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = normalizedFunctionString(value); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + return index; +} +function serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (value.scope && typeof value.scope === 'object') { + // Write the type + buffer[index++] = BSON_DATA_CODE_W_SCOPE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Starting index + var startIndex = index; + // Serialize the function + // Get the function string + var functionString = typeof value.code === 'string' ? value.code : value.code.toString(); + // Index adjustment + index = index + 4; + // Write string into buffer + var codeSize = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = codeSize & 0xff; + buffer[index + 1] = (codeSize >> 8) & 0xff; + buffer[index + 2] = (codeSize >> 16) & 0xff; + buffer[index + 3] = (codeSize >> 24) & 0xff; + // Write end 0 + buffer[index + 4 + codeSize - 1] = 0; + // Write the + index = index + codeSize + 4; + // + // Serialize the scope value + var endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined); + index = endIndex - 1; + // Writ the total + var totalSize = endIndex - startIndex; + // Write the total size of the object + buffer[startIndex++] = totalSize & 0xff; + buffer[startIndex++] = (totalSize >> 8) & 0xff; + buffer[startIndex++] = (totalSize >> 16) & 0xff; + buffer[startIndex++] = (totalSize >> 24) & 0xff; + // Write trailing zero + buffer[index++] = 0; + } + else { + buffer[index++] = BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = value.code.toString(); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + } + return index; +} +function serializeBinary(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Extract the buffer + var data = value.value(true); + // Calculate size + var size = value.position; + // Add the deprecated 02 type 4 bytes of size to total + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) + size = size + 4; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the subtype to the buffer + buffer[index++] = value.sub_type; + // If we have binary type 2 the 4 first bytes are the size + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + size = size - 4; + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + } + // Write the data to the object + buffer.set(data, index); + // Adjust the index + index = index + value.position; + return index; +} +function serializeSymbol(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_SYMBOL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the string + var size = buffer.write(value.value, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0x00; + return index; +} +function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, isArray) { + // Write the type + buffer[index++] = BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var startIndex = index; + var output = { + $ref: value.collection || value.namespace, + $id: value.oid + }; + if (value.db != null) { + output.$db = value.db; + } + output = Object.assign(output, value.fields); + var endIndex = serializeInto(buffer, output, false, index, depth + 1, serializeFunctions); + // Calculate object size + var size = endIndex - startIndex; + // Write the size + buffer[startIndex++] = size & 0xff; + buffer[startIndex++] = (size >> 8) & 0xff; + buffer[startIndex++] = (size >> 16) & 0xff; + buffer[startIndex++] = (size >> 24) & 0xff; + // Set index + return endIndex; +} +function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (startingIndex === void 0) { startingIndex = 0; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (path === void 0) { path = []; } + startingIndex = startingIndex || 0; + path = path || []; + // Push the object to the path + path.push(object); + // Start place to serialize into + var index = startingIndex + 4; + // Special case isArray + if (Array.isArray(object)) { + // Get object keys + for (var i = 0; i < object.length; i++) { + var key = "".concat(i); + var value = object[i]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + if (typeof value === 'string') { + index = serializeString(buffer, key, value, index, true); + } + else if (typeof value === 'number') { + index = serializeNumber(buffer, key, value, index, true); + } + else if (typeof value === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (typeof value === 'boolean') { + index = serializeBoolean(buffer, key, value, index, true); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index, true); + } + else if (value === undefined) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index, true); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index, true); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index, true); + } + else if (typeof value === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true, path); + } + else if (typeof value === 'object' && + isBSONType(value) && + value._bsontype === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index, true); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, true); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, true); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index, true); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else if (object instanceof bsonMap || isMap(object)) { + var iterator = object.entries(); + var done = false; + while (!done) { + // Unpack the next entry + var entry = iterator.next(); + done = !!entry.done; + // Are we done, then skip and terminate + if (done) + continue; + // Get the entry values + var key = entry.value[0]; + var value = entry.value[1]; + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint' || isBigInt64Array(value) || isBigUInt64Array(value)) { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === null || (value === undefined && ignoreUndefined === false)) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else { + if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + // Provided a custom serialization method + object = object.toBSON(); + if (object != null && typeof object !== 'object') { + throw new BSONTypeError('toBSON function did not return an object'); + } + } + // Iterate over all the keys + for (var key in object) { + var value = object[key]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === undefined) { + if (ignoreUndefined === false) + index = serializeNull(buffer, key, value, index); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + // Remove the path + path.pop(); + // Final padding byte for object + buffer[index++] = 0x00; + // Final size + var size = index - startingIndex; + // Write the size of the object + buffer[startingIndex++] = size & 0xff; + buffer[startingIndex++] = (size >> 8) & 0xff; + buffer[startingIndex++] = (size >> 16) & 0xff; + buffer[startingIndex++] = (size >> 24) & 0xff; + return index; +} + +/** @internal */ +// Default Max Size +var MAXSIZE = 1024 * 1024 * 17; +// Current Internal Temporary Serialization Buffer +var buffer = buffer_1.alloc(MAXSIZE); +/** + * Sets the size of the internal serialization buffer. + * + * @param size - The desired size for the internal serialization buffer + * @public + */ +function setInternalBufferSize(size) { + // Resize the internal serialization buffer if needed + if (buffer.length < size) { + buffer = buffer_1.alloc(size); + } +} +/** + * Serialize a Javascript object. + * + * @param object - the Javascript object to serialize. + * @returns Buffer object containing the serialized object. + * @public + */ +function serialize(object, options) { + if (options === void 0) { 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 = buffer_1.alloc(minInternalBufferSize); + } + // Attempt to serialize + var serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []); + // Create the final buffer + var finishedBuffer = buffer_1.alloc(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 - the Javascript object to serialize. + * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object. + * @returns the index pointing to the last written byte in the buffer. + * @public + */ +function serializeWithBufferAndIndex(object, finalBuffer, options) { + if (options === void 0) { 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 = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined); + buffer.copy(finalBuffer, startIndex, 0, serializationIndex); + // Return the index + return startIndex + serializationIndex - 1; +} +/** + * Deserialize data as BSON. + * + * @param buffer - the buffer containing the serialized set of BSON documents. + * @returns returns the deserialized Javascript Object. + * @public + */ +function deserialize(buffer, options) { + if (options === void 0) { options = {}; } + return deserialize$1(buffer instanceof buffer_1 ? buffer : ensureBuffer(buffer), options); +} +/** + * Calculate the bson size for a passed in Javascript object. + * + * @param object - the Javascript object to calculate the BSON byte size for + * @returns size of BSON object in bytes + * @public + */ +function calculateObjectSize(object, options) { + if (options === void 0) { options = {}; } + options = options || {}; + var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + return calculateObjectSize$1(object, serializeFunctions, ignoreUndefined); +} +/** + * Deserialize stream data as BSON documents. + * + * @param data - the buffer containing the serialized set of BSON documents. + * @param startIndex - the start index in the data Buffer where the deserialization is to start. + * @param numberOfDocuments - number of documents to deserialize. + * @param documents - an array where to store the deserialized documents. + * @param docStartIndex - the index in the documents array from where to start inserting documents. + * @param options - additional options used for the deserialization. + * @returns next index in the buffer after deserialization **x** numbers of documents. + * @public + */ +function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) { + var internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options); + var bufferData = ensureBuffer(data); + var index = startIndex; + // Loop over all documents + for (var i = 0; i < numberOfDocuments; i++) { + // Find size of the document + var size = bufferData[index] | + (bufferData[index + 1] << 8) | + (bufferData[index + 2] << 16) | + (bufferData[index + 3] << 24); + // Update options with index + internalOptions.index = index; + // Parse the document at this point + documents[docStartIndex + i] = deserialize$1(bufferData, internalOptions); + // Adjust index by the document size + index = index + size; + } + // Return object containing end index of parsing and list of documents + return index; +} +/** + * BSON default export + * @deprecated Please use named exports + * @privateRemarks + * We want to someday deprecate the default export, + * so none of the new TS types are being exported on the default + * @public + */ +var BSON = { + Binary: Binary, + Code: Code, + DBRef: DBRef, + Decimal128: Decimal128, + Double: Double, + Int32: Int32, + Long: Long, + UUID: UUID, + Map: bsonMap, + MaxKey: MaxKey, + MinKey: MinKey, + ObjectId: ObjectId, + ObjectID: ObjectId, + BSONRegExp: BSONRegExp, + BSONSymbol: BSONSymbol, + Timestamp: Timestamp, + EJSON: EJSON, + setInternalBufferSize: setInternalBufferSize, + serialize: serialize, + serializeWithBufferAndIndex: serializeWithBufferAndIndex, + deserialize: deserialize, + calculateObjectSize: calculateObjectSize, + deserializeStream: deserializeStream, + BSONError: BSONError, + BSONTypeError: BSONTypeError +}; + +export default BSON; +export { BSONError, BSONRegExp, BSONSymbol, BSONTypeError, BSON_BINARY_SUBTYPE_BYTE_ARRAY, BSON_BINARY_SUBTYPE_COLUMN, BSON_BINARY_SUBTYPE_DEFAULT, BSON_BINARY_SUBTYPE_ENCRYPTED, BSON_BINARY_SUBTYPE_FUNCTION, BSON_BINARY_SUBTYPE_MD5, BSON_BINARY_SUBTYPE_USER_DEFINED, BSON_BINARY_SUBTYPE_UUID, BSON_BINARY_SUBTYPE_UUID_NEW, BSON_DATA_ARRAY, BSON_DATA_BINARY, BSON_DATA_BOOLEAN, BSON_DATA_CODE, BSON_DATA_CODE_W_SCOPE, BSON_DATA_DATE, BSON_DATA_DBPOINTER, BSON_DATA_DECIMAL128, BSON_DATA_INT, BSON_DATA_LONG, BSON_DATA_MAX_KEY, BSON_DATA_MIN_KEY, BSON_DATA_NULL, BSON_DATA_NUMBER, BSON_DATA_OBJECT, BSON_DATA_OID, BSON_DATA_REGEXP, BSON_DATA_STRING, BSON_DATA_SYMBOL, BSON_DATA_TIMESTAMP, BSON_DATA_UNDEFINED, BSON_INT32_MAX$1 as BSON_INT32_MAX, BSON_INT32_MIN$1 as BSON_INT32_MIN, BSON_INT64_MAX$1 as BSON_INT64_MAX, BSON_INT64_MIN$1 as BSON_INT64_MIN, Binary, Code, DBRef, Decimal128, Double, EJSON, Int32, Long, LongWithoutOverridesClass, bsonMap as Map, MaxKey, MinKey, ObjectId as ObjectID, ObjectId, Timestamp, UUID, calculateObjectSize, deserialize, deserializeStream, serialize, serializeWithBufferAndIndex, setInternalBufferSize }; +//# sourceMappingURL=bson.browser.esm.js.map diff --git a/node_modules/bson/dist/bson.browser.esm.js.map b/node_modules/bson/dist/bson.browser.esm.js.map new file mode 100644 index 0000000..779cc8c --- /dev/null +++ b/node_modules/bson/dist/bson.browser.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bson.browser.esm.js","sources":["../node_modules/base64-js/index.js","../node_modules/ieee754/index.js","../node_modules/buffer/index.js","../node_modules/tslib/tslib.es6.js","../src/error.ts","../src/utils/global.ts","../src/parser/utils.ts","../src/ensure_buffer.ts","../src/uuid_utils.ts","../src/constants.ts","../src/binary.ts","../src/code.ts","../src/db_ref.ts","../src/long.ts","../src/decimal128.ts","../src/double.ts","../src/int_32.ts","../src/max_key.ts","../src/min_key.ts","../src/objectid.ts","../src/regexp.ts","../src/symbol.ts","../src/timestamp.ts","../src/extended_json.ts","../src/map.ts","../src/parser/calculate_size.ts","../src/validate_utf8.ts","../src/parser/deserializer.ts","../src/parser/serializer.ts","../src/bson.ts"],"sourcesContent":["'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar customInspectSymbol =\n (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nvar K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n var arr = new Uint8Array(1)\n var proto = { foo: function () { return 42 } }\n Object.setPrototypeOf(proto, Uint8Array.prototype)\n Object.setPrototypeOf(arr, proto)\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n var buf = new Uint8Array(length)\n Object.setPrototypeOf(buf, Buffer.prototype)\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayView(value)\n }\n\n if (value == null) {\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof SharedArrayBuffer !== 'undefined' &&\n (isInstance(value, SharedArrayBuffer) ||\n (value && isInstance(value.buffer, SharedArrayBuffer)))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n var valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n var b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(\n value[Symbol.toPrimitive]('string'), encodingOrOffset, length\n )\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)\nObject.setPrototypeOf(Buffer, Uint8Array)\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n var length = byteLength(string, encoding) | 0\n var buf = createBuffer(length)\n\n var actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n var buf = createBuffer(length)\n for (var i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayView (arrayView) {\n if (isInstance(arrayView, Uint8Array)) {\n var copy = new Uint8Array(arrayView)\n return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)\n }\n return fromArrayLike(arrayView)\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n var buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, Buffer.prototype)\n\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n var buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n Buffer.from(buf).copy(buffer, pos)\n } else {\n Uint8Array.prototype.set.call(\n buffer,\n buf,\n pos\n )\n }\n } else if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n } else {\n buf.copy(buffer, pos)\n }\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n var len = string.length\n var mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return ''\n}\nif (customInspectSymbol) {\n Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n var strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n case 'latin1':\n case 'binary':\n return asciiWrite(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF)\n ? 4\n : (firstByte > 0xDF)\n ? 3\n : (firstByte > 0xBF)\n ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += hexSliceLookupTable[buf[i]]\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for (var i = 0; i < bytes.length - 1; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, Buffer.prototype)\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUintLE =\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUintBE =\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUint8 =\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUint16LE =\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUint16BE =\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUint32LE =\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUint32BE =\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUintLE =\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUintBE =\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUint8 =\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUint16LE =\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUint16BE =\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUint32LE =\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUint32BE =\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n var limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n var limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n } else if (typeof val === 'boolean') {\n val = Number(val)\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n var len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nvar hexSliceLookupTable = (function () {\n var alphabet = '0123456789abcdef'\n var table = new Array(256)\n for (var i = 0; i < 16; ++i) {\n var i16 = i * 16\n for (var j = 0; j < 16; ++j) {\n table[i16 + j] = alphabet[i] + alphabet[j]\n }\n }\n return table\n})()\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["byteLength","toByteArray","fromByteArray","lookup","revLookup","Arr","Uint8Array","Array","code","i","len","length","charCodeAt","getLens","b64","Error","validLen","indexOf","placeHoldersLen","lens","_byteLength","tmp","arr","curByte","tripletToBase64","num","encodeChunk","uint8","start","end","output","push","join","extraBytes","parts","maxChunkLength","len2","buffer","offset","isLE","mLen","nBytes","e","m","eLen","eMax","eBias","nBits","d","s","NaN","Infinity","Math","pow","value","c","rt","abs","isNaN","floor","log","LN2","customInspectSymbol","Symbol","exports","Buffer","SlowBuffer","K_MAX_LENGTH","TYPED_ARRAY_SUPPORT","typedArraySupport","console","error","proto","foo","Object","setPrototypeOf","prototype","defineProperty","enumerable","get","isBuffer","undefined","byteOffset","createBuffer","RangeError","buf","arg","encodingOrOffset","TypeError","allocUnsafe","from","poolSize","fromString","ArrayBuffer","isView","fromArrayView","isInstance","fromArrayBuffer","SharedArrayBuffer","valueOf","b","fromObject","toPrimitive","assertSize","size","alloc","fill","encoding","checked","allocUnsafeSlow","string","isEncoding","actual","write","slice","fromArrayLike","array","arrayView","copy","obj","numberIsNaN","type","isArray","data","toString","_isBuffer","compare","a","x","y","min","String","toLowerCase","concat","list","pos","set","call","mustMatch","arguments","loweredCase","utf8ToBytes","base64ToBytes","slowToString","hexSlice","utf8Slice","asciiSlice","latin1Slice","base64Slice","utf16leSlice","swap","n","swap16","swap32","swap64","apply","toLocaleString","equals","inspect","str","max","INSPECT_MAX_BYTES","replace","trim","target","thisStart","thisEnd","thisCopy","targetCopy","bidirectionalIndexOf","val","dir","arrayIndexOf","lastIndexOf","indexSize","arrLength","valLength","read","readUInt16BE","foundIndex","found","j","includes","hexWrite","Number","remaining","strLen","parsed","parseInt","substr","utf8Write","blitBuffer","asciiWrite","asciiToBytes","base64Write","ucs2Write","utf16leToBytes","isFinite","toJSON","_arr","base64","res","firstByte","codePoint","bytesPerSequence","secondByte","thirdByte","fourthByte","tempCodePoint","decodeCodePointsArray","MAX_ARGUMENTS_LENGTH","codePoints","fromCharCode","ret","out","hexSliceLookupTable","bytes","newBuf","subarray","checkOffset","ext","readUintLE","readUIntLE","noAssert","mul","readUintBE","readUIntBE","readUint8","readUInt8","readUint16LE","readUInt16LE","readUint16BE","readUint32LE","readUInt32LE","readUint32BE","readUInt32BE","readIntLE","readIntBE","readInt8","readInt16LE","readInt16BE","readInt32LE","readInt32BE","readFloatLE","ieee754","readFloatBE","readDoubleLE","readDoubleBE","checkInt","writeUintLE","writeUIntLE","maxBytes","writeUintBE","writeUIntBE","writeUint8","writeUInt8","writeUint16LE","writeUInt16LE","writeUint16BE","writeUInt16BE","writeUint32LE","writeUInt32LE","writeUint32BE","writeUInt32BE","writeIntLE","limit","sub","writeIntBE","writeInt8","writeInt16LE","writeInt16BE","writeInt32LE","writeInt32BE","checkIEEE754","writeFloat","littleEndian","writeFloatLE","writeFloatBE","writeDouble","writeDoubleLE","writeDoubleBE","targetStart","copyWithin","INVALID_BASE64_RE","base64clean","split","units","leadSurrogate","byteArray","hi","lo","src","dst","constructor","name","alphabet","table","i16","extendStatics","__proto__","p","hasOwnProperty","__extends","__","create","__assign","assign","t","BSON_INT32_MAX","BSON_INT32_MIN","BSON_INT64_MAX","BSON_INT64_MIN","calculateObjectSize","constants.JS_INT_MIN","constants.JS_INT_MAX","constants.BSON_INT32_MIN","constants.BSON_INT32_MAX","deserialize","constants.BSON_DATA_STRING","constants.BSON_DATA_OID","constants.BSON_DATA_INT","constants.BSON_DATA_NUMBER","constants.BSON_DATA_DATE","constants.BSON_DATA_BOOLEAN","constants.BSON_DATA_OBJECT","constants.BSON_DATA_ARRAY","constants.BSON_DATA_UNDEFINED","constants.BSON_DATA_NULL","constants.BSON_DATA_LONG","constants.BSON_DATA_DECIMAL128","constants.BSON_DATA_BINARY","constants.BSON_BINARY_SUBTYPE_UUID_NEW","constants.BSON_DATA_REGEXP","constants.BSON_DATA_SYMBOL","constants.BSON_DATA_TIMESTAMP","constants.BSON_DATA_MIN_KEY","constants.BSON_DATA_MAX_KEY","constants.BSON_DATA_CODE","constants.BSON_DATA_CODE_W_SCOPE","constants.BSON_DATA_DBPOINTER","constants.BSON_BINARY_SUBTYPE_DEFAULT","Map","internalSerialize","internalDeserialize","internalCalculateObjectSize"],"mappings":";;;;AAEA,gBAAkB,GAAGA,UAArB;AACA,iBAAmB,GAAGC,WAAtB;AACA,mBAAqB,GAAGC,aAAxB;AAEA,IAAIC,MAAM,GAAG,EAAb;AACA,IAAIC,SAAS,GAAG,EAAhB;AACA,IAAIC,GAAG,GAAG,OAAOC,UAAP,KAAsB,WAAtB,GAAoCA,UAApC,GAAiDC,KAA3D;AAEA,IAAIC,IAAI,GAAG,kEAAX;;AACA,KAAK,IAAIC,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAGF,IAAI,CAACG,MAA3B,EAAmCF,CAAC,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,KAAK,GAAG,KAAK,CAAC;;QAE9B,SAAS,CAAC,aAAa,GAAG,CAAC,CAAC,GAAGD,aAAmB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;;QAEhF,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;KACtB;;IAGD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;IAQM,IAAI,GAAG;IACX,MAAM,QAAA;IACN,IAAI,MAAA;IACJ,KAAK,OAAA;IACL,UAAU,YAAA;IACV,MAAM,QAAA;IACN,KAAK,OAAA;IACL,IAAI,MAAA;IACJ,IAAI,MAAA;IACJ,GAAG,SAAA;IACH,MAAM,QAAA;IACN,MAAM,QAAA;IACN,QAAQ,UAAA;IACR,QAAQ,EAAE,QAAQ;IAClB,UAAU,YAAA;IACV,UAAU,YAAA;IACV,SAAS,WAAA;IACT,KAAK,OAAA;IACL,qBAAqB,uBAAA;IACrB,SAAS,WAAA;IACT,2BAA2B,6BAAA;IAC3B,WAAW,aAAA;IACX,mBAAmB,qBAAA;IACnB,iBAAiB,mBAAA;IACjB,SAAS,WAAA;IACT,aAAa,eAAA;;;;;;"} \ No newline at end of file diff --git a/node_modules/bson/dist/bson.browser.umd.js b/node_modules/bson/dist/bson.browser.umd.js new file mode 100644 index 0000000..9a512b3 --- /dev/null +++ b/node_modules/bson/dist/bson.browser.umd.js @@ -0,0 +1,7537 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BSON = {})); +}(this, (function (exports) { 'use strict'; + + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } + + var byteLength_1 = byteLength; + var toByteArray_1 = toByteArray; + var fromByteArray_1 = fromByteArray; + var lookup = []; + var revLookup = []; + var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i]; + revLookup[code.charCodeAt(i)] = i; + } // Support decoding URL-safe base64 strings, as Node.js does. + // See: https://en.wikipedia.org/wiki/Base64#URL_applications + + + revLookup['-'.charCodeAt(0)] = 62; + revLookup['_'.charCodeAt(0)] = 63; + + function getLens(b64) { + var len = b64.length; + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4'); + } // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + + + var validLen = b64.indexOf('='); + if (validLen === -1) validLen = len; + var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; + return [validLen, placeHoldersLen]; + } // base64 is 4/3 + up to two characters of the original data + + + function byteLength(b64) { + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; + } + + function _byteLength(b64, validLen, placeHoldersLen) { + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; + } + + function toByteArray(b64) { + var tmp; + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); + var curByte = 0; // if there are placeholders, only get up to the last complete 4 chars + + var len = placeHoldersLen > 0 ? validLen - 4 : validLen; + var i; + + for (i = 0; i < len; i += 4) { + tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; + arr[curByte++] = tmp >> 16 & 0xFF; + arr[curByte++] = tmp >> 8 & 0xFF; + arr[curByte++] = tmp & 0xFF; + } + + if (placeHoldersLen === 2) { + tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; + arr[curByte++] = tmp & 0xFF; + } + + if (placeHoldersLen === 1) { + tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; + arr[curByte++] = tmp >> 8 & 0xFF; + arr[curByte++] = tmp & 0xFF; + } + + return arr; + } + + function tripletToBase64(num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; + } + + function encodeChunk(uint8, start, end) { + var tmp; + var output = []; + + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16 & 0xFF0000) + (uint8[i + 1] << 8 & 0xFF00) + (uint8[i + 2] & 0xFF); + output.push(tripletToBase64(tmp)); + } + + return output.join(''); + } + + function fromByteArray(uint8) { + var tmp; + var len = uint8.length; + var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes + + var parts = []; + var maxChunkLength = 16383; // must be multiple of 3 + // go through the array every three bytes, we'll deal with trailing stuff later + + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); + } // pad the end with zeros, but make sure to not forget the extra bytes + + + if (extraBytes === 1) { + tmp = uint8[len - 1]; + parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 0x3F] + '=='); + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1]; + parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 0x3F] + lookup[tmp << 2 & 0x3F] + '='); + } + + return parts.join(''); + } + + var base64Js = { + byteLength: byteLength_1, + toByteArray: toByteArray_1, + fromByteArray: fromByteArray_1 + }; + + /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ + var read = function read(buffer, offset, isLE, mLen, nBytes) { + var e, m; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i = isLE ? nBytes - 1 : 0; + var d = isLE ? -1 : 1; + var 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 write = function write(buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; + var i = isLE ? 0 : nBytes - 1; + var d = isLE ? 1 : -1; + var 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; + }; + + var ieee754 = { + read: read, + write: write + }; + + var buffer$1 = createCommonjsModule(function (module, exports) { + + var customInspectSymbol = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' ? // eslint-disable-line dot-notation + Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation + : null; + exports.Buffer = Buffer; + exports.SlowBuffer = SlowBuffer; + exports.INSPECT_MAX_BYTES = 50; + var K_MAX_LENGTH = 0x7fffffff; + exports.kMaxLength = K_MAX_LENGTH; + /** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ + + Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport(); + + if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && typeof console.error === 'function') { + console.error('This browser lacks typed array (Uint8Array) support which is required by ' + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'); + } + + function typedArraySupport() { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1); + var proto = { + foo: function foo() { + return 42; + } + }; + Object.setPrototypeOf(proto, Uint8Array.prototype); + Object.setPrototypeOf(arr, proto); + return arr.foo() === 42; + } catch (e) { + return false; + } + } + + Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function get() { + if (!Buffer.isBuffer(this)) return undefined; + return this.buffer; + } + }); + Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function get() { + if (!Buffer.isBuffer(this)) return undefined; + return this.byteOffset; + } + }); + + function createBuffer(length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"'); + } // Return an augmented `Uint8Array` instance + + + var buf = new Uint8Array(length); + Object.setPrototypeOf(buf, Buffer.prototype); + return buf; + } + /** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + + + function Buffer(arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError('The "string" argument must be of type string. Received type number'); + } + + return allocUnsafe(arg); + } + + return from(arg, encodingOrOffset, length); + } + + Buffer.poolSize = 8192; // not used by this implementation + + function from(value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset); + } + + if (ArrayBuffer.isView(value)) { + return fromArrayView(value); + } + + if (value == null) { + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + babelHelpers["typeof"](value)); + } + + if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { + return fromArrayBuffer(value, encodingOrOffset, length); + } + + if (typeof SharedArrayBuffer !== 'undefined' && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length); + } + + if (typeof value === 'number') { + throw new TypeError('The "value" argument must not be of type number. Received type number'); + } + + var valueOf = value.valueOf && value.valueOf(); + + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length); + } + + var b = fromObject(value); + if (b) return b; + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length); + } + + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + babelHelpers["typeof"](value)); + } + /** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ + + + Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length); + }; // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: + // https://github.com/feross/buffer/pull/148 + + + Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer, Uint8Array); + + function assertSize(size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number'); + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"'); + } + } + + function alloc(size, fill, encoding) { + assertSize(size); + + if (size <= 0) { + return createBuffer(size); + } + + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpreted as a start offset. + return typeof encoding === 'string' ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill); + } + + return createBuffer(size); + } + /** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ + + + Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding); + }; + + function allocUnsafe(size) { + assertSize(size); + return createBuffer(size < 0 ? 0 : checked(size) | 0); + } + /** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ + + + Buffer.allocUnsafe = function (size) { + return allocUnsafe(size); + }; + /** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ + + + Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size); + }; + + function fromString(string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8'; + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding); + } + + var length = byteLength(string, encoding) | 0; + var buf = createBuffer(length); + var actual = buf.write(string, encoding); + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual); + } + + return buf; + } + + function fromArrayLike(array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0; + var buf = createBuffer(length); + + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255; + } + + return buf; + } + + function fromArrayView(arrayView) { + if (isInstance(arrayView, Uint8Array)) { + var copy = new Uint8Array(arrayView); + return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength); + } + + return fromArrayLike(arrayView); + } + + function fromArrayBuffer(array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds'); + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds'); + } + + var buf; + + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array); + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset); + } else { + buf = new Uint8Array(array, byteOffset, length); + } // Return an augmented `Uint8Array` instance + + + Object.setPrototypeOf(buf, Buffer.prototype); + return buf; + } + + function fromObject(obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0; + var buf = createBuffer(len); + + if (buf.length === 0) { + return buf; + } + + obj.copy(buf, 0, 0, len); + return buf; + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0); + } + + return fromArrayLike(obj); + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data); + } + } + + function checked(length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes'); + } + + return length | 0; + } + + function SlowBuffer(length) { + if (+length != length) { + // eslint-disable-line eqeqeq + length = 0; + } + + return Buffer.alloc(+length); + } + + Buffer.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false + }; + + Buffer.compare = function compare(a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength); + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength); + + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); + } + + if (a === b) return 0; + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) return -1; + if (y < x) return 1; + return 0; + }; + + Buffer.isEncoding = function isEncoding(encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true; + + default: + return false; + } + }; + + Buffer.concat = function concat(list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } + + if (list.length === 0) { + return Buffer.alloc(0); + } + + var i; + + if (length === undefined) { + length = 0; + + for (i = 0; i < list.length; ++i) { + length += list[i].length; + } + } + + var buffer = Buffer.allocUnsafe(length); + var pos = 0; + + for (i = 0; i < list.length; ++i) { + var buf = list[i]; + + if (isInstance(buf, Uint8Array)) { + if (pos + buf.length > buffer.length) { + Buffer.from(buf).copy(buffer, pos); + } else { + Uint8Array.prototype.set.call(buffer, buf, pos); + } + } else if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } else { + buf.copy(buffer, pos); + } + + pos += buf.length; + } + + return buffer; + }; + + function byteLength(string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length; + } + + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength; + } + + if (typeof string !== 'string') { + throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + 'Received type ' + babelHelpers["typeof"](string)); + } + + var len = string.length; + var mustMatch = arguments.length > 2 && arguments[2] === true; + if (!mustMatch && len === 0) return 0; // Use a for loop to avoid recursion + + var loweredCase = false; + + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len; + + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length; + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2; + + case 'hex': + return len >>> 1; + + case 'base64': + return base64ToBytes(string).length; + + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8 + } + + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } + } + + Buffer.byteLength = byteLength; + + function slowToString(encoding, start, end) { + var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + + if (start === undefined || start < 0) { + start = 0; + } // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + + + if (start > this.length) { + return ''; + } + + if (end === undefined || end > this.length) { + end = this.length; + } + + if (end <= 0) { + return ''; + } // Force coercion to uint32. This will also coerce falsey/NaN values to 0. + + + end >>>= 0; + start >>>= 0; + + if (end <= start) { + return ''; + } + + if (!encoding) encoding = 'utf8'; + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end); + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end); + + case 'ascii': + return asciiSlice(this, start, end); + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end); + + case 'base64': + return base64Slice(this, start, end); + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end); + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); + encoding = (encoding + '').toLowerCase(); + loweredCase = true; + } + } + } // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) + // to detect a Buffer instance. It's not possible to use `instanceof Buffer` + // reliably in a browserify context because there could be multiple different + // copies of the 'buffer' package in use. This method works even for Buffer + // instances that were created from another copy of the `buffer` package. + // See: https://github.com/feross/buffer/issues/154 + + + Buffer.prototype._isBuffer = true; + + function swap(b, n, m) { + var i = b[n]; + b[n] = b[m]; + b[m] = i; + } + + Buffer.prototype.swap16 = function swap16() { + var len = this.length; + + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits'); + } + + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1); + } + + return this; + }; + + Buffer.prototype.swap32 = function swap32() { + var len = this.length; + + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits'); + } + + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3); + swap(this, i + 1, i + 2); + } + + return this; + }; + + Buffer.prototype.swap64 = function swap64() { + var len = this.length; + + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits'); + } + + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7); + swap(this, i + 1, i + 6); + swap(this, i + 2, i + 5); + swap(this, i + 3, i + 4); + } + + return this; + }; + + Buffer.prototype.toString = function toString() { + var length = this.length; + if (length === 0) return ''; + if (arguments.length === 0) return utf8Slice(this, 0, length); + return slowToString.apply(this, arguments); + }; + + Buffer.prototype.toLocaleString = Buffer.prototype.toString; + + Buffer.prototype.equals = function equals(b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer'); + if (this === b) return true; + return Buffer.compare(this, b) === 0; + }; + + Buffer.prototype.inspect = function inspect() { + var str = ''; + var max = exports.INSPECT_MAX_BYTES; + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim(); + if (this.length > max) str += ' ... '; + return ''; + }; + + if (customInspectSymbol) { + Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; + } + + Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength); + } + + if (!Buffer.isBuffer(target)) { + throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. ' + 'Received type ' + babelHelpers["typeof"](target)); + } + + if (start === undefined) { + start = 0; + } + + if (end === undefined) { + end = target ? target.length : 0; + } + + if (thisStart === undefined) { + thisStart = 0; + } + + if (thisEnd === undefined) { + thisEnd = this.length; + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index'); + } + + if (thisStart >= thisEnd && start >= end) { + return 0; + } + + if (thisStart >= thisEnd) { + return -1; + } + + if (start >= end) { + return 1; + } + + start >>>= 0; + end >>>= 0; + thisStart >>>= 0; + thisEnd >>>= 0; + if (this === target) return 0; + var x = thisEnd - thisStart; + var y = end - start; + var len = Math.min(x, y); + var thisCopy = this.slice(thisStart, thisEnd); + var targetCopy = target.slice(start, end); + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i]; + y = targetCopy[i]; + break; + } + } + + if (x < y) return -1; + if (y < x) return 1; + return 0; + }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, + // OR the last index of `val` in `buffer` at offset <= `byteOffset`. + // + // Arguments: + // - buffer - a Buffer to search + // - val - a string, Buffer, or number + // - byteOffset - an index into `buffer`; will be clamped to an int32 + // - encoding - an optional encoding, relevant is val is a string + // - dir - true for indexOf, false for lastIndexOf + + + function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1; // Normalize byteOffset + + if (typeof byteOffset === 'string') { + encoding = byteOffset; + byteOffset = 0; + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff; + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000; + } + + byteOffset = +byteOffset; // Coerce to Number. + + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : buffer.length - 1; + } // Normalize byteOffset: negative offsets start from the end of the buffer + + + if (byteOffset < 0) byteOffset = buffer.length + byteOffset; + + if (byteOffset >= buffer.length) { + if (dir) return -1;else byteOffset = buffer.length - 1; + } else if (byteOffset < 0) { + if (dir) byteOffset = 0;else return -1; + } // Normalize val + + + if (typeof val === 'string') { + val = Buffer.from(val, encoding); + } // Finally, search either indexOf (if dir is true) or lastIndexOf + + + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1; + } + + return arrayIndexOf(buffer, val, byteOffset, encoding, dir); + } else if (typeof val === 'number') { + val = val & 0xFF; // Search for a byte value [0-255] + + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); + } + } + + return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); + } + + throw new TypeError('val must be string, number or Buffer'); + } + + function arrayIndexOf(arr, val, byteOffset, encoding, dir) { + var indexSize = 1; + var arrLength = arr.length; + var valLength = val.length; + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase(); + + if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1; + } + + indexSize = 2; + arrLength /= 2; + valLength /= 2; + byteOffset /= 2; + } + } + + function read(buf, i) { + if (indexSize === 1) { + return buf[i]; + } else { + return buf.readUInt16BE(i * indexSize); + } + } + + var i; + + if (dir) { + var foundIndex = -1; + + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i; + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; + } else { + if (foundIndex !== -1) i -= i - foundIndex; + foundIndex = -1; + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; + + for (i = byteOffset; i >= 0; i--) { + var found = true; + + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false; + break; + } + } + + if (found) return i; + } + } + + return -1; + } + + Buffer.prototype.includes = function includes(val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1; + }; + + Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true); + }; + + Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false); + }; + + function hexWrite(buf, string, offset, length) { + offset = Number(offset) || 0; + var remaining = buf.length - offset; + + if (!length) { + length = remaining; + } else { + length = Number(length); + + if (length > remaining) { + length = remaining; + } + } + + var strLen = string.length; + + if (length > strLen / 2) { + length = strLen / 2; + } + + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16); + if (numberIsNaN(parsed)) return i; + buf[offset + i] = parsed; + } + + return i; + } + + function utf8Write(buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); + } + + function asciiWrite(buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length); + } + + function base64Write(buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length); + } + + function ucs2Write(buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); + } + + Buffer.prototype.write = function write(string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8'; + length = this.length; + offset = 0; // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset; + length = this.length; + offset = 0; // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0; + + if (isFinite(length)) { + length = length >>> 0; + if (encoding === undefined) encoding = 'utf8'; + } else { + encoding = length; + length = undefined; + } + } else { + throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported'); + } + + var remaining = this.length - offset; + if (length === undefined || length > remaining) length = remaining; + + if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds'); + } + + if (!encoding) encoding = 'utf8'; + var loweredCase = false; + + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length); + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length); + + case 'ascii': + case 'latin1': + case 'binary': + return asciiWrite(this, string, offset, length); + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length); + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length); + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } + }; + + Buffer.prototype.toJSON = function toJSON() { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + }; + }; + + function base64Slice(buf, start, end) { + if (start === 0 && end === buf.length) { + return base64Js.fromByteArray(buf); + } else { + return base64Js.fromByteArray(buf.slice(start, end)); + } + } + + function utf8Slice(buf, start, end) { + end = Math.min(buf.length, end); + var res = []; + var i = start; + + while (i < end) { + var firstByte = buf[i]; + var codePoint = null; + var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1; + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint; + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte; + } + + break; + + case 2: + secondByte = buf[i + 1]; + + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F; + + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint; + } + } + + break; + + case 3: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F; + + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint; + } + } + + break; + + case 4: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + fourthByte = buf[i + 3]; + + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F; + + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint; + } + } + + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD; + bytesPerSequence = 1; + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000; + res.push(codePoint >>> 10 & 0x3FF | 0xD800); + codePoint = 0xDC00 | codePoint & 0x3FF; + } + + res.push(codePoint); + i += bytesPerSequence; + } + + return decodeCodePointsArray(res); + } // Based on http://stackoverflow.com/a/22747272/680742, the browser with + // the lowest limit is Chrome, with 0x10000 args. + // We go 1 magnitude less, for safety + + + var MAX_ARGUMENTS_LENGTH = 0x1000; + + function decodeCodePointsArray(codePoints) { + var len = codePoints.length; + + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints); // avoid extra slice() + } // Decode in chunks to avoid "call stack size exceeded". + + + var res = ''; + var i = 0; + + while (i < len) { + res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)); + } + + return res; + } + + function asciiSlice(buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F); + } + + return ret; + } + + function latin1Slice(buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]); + } + + return ret; + } + + function hexSlice(buf, start, end) { + var len = buf.length; + if (!start || start < 0) start = 0; + if (!end || end < 0 || end > len) end = len; + var out = ''; + + for (var i = start; i < end; ++i) { + out += hexSliceLookupTable[buf[i]]; + } + + return out; + } + + function utf16leSlice(buf, start, end) { + var bytes = buf.slice(start, end); + var res = ''; // If bytes.length is odd, the last 8 bits must be ignored (same as node.js) + + for (var i = 0; i < bytes.length - 1; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); + } + + return res; + } + + Buffer.prototype.slice = function slice(start, end) { + var len = this.length; + start = ~~start; + end = end === undefined ? len : ~~end; + + if (start < 0) { + start += len; + if (start < 0) start = 0; + } else if (start > len) { + start = len; + } + + if (end < 0) { + end += len; + if (end < 0) end = 0; + } else if (end > len) { + end = len; + } + + if (end < start) end = start; + var newBuf = this.subarray(start, end); // Return an augmented `Uint8Array` instance + + Object.setPrototypeOf(newBuf, Buffer.prototype); + return newBuf; + }; + /* + * Need to make sure that buffer isn't trying to write out of bounds. + */ + + + function checkOffset(offset, ext, length) { + if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint'); + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length'); + } + + Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + var val = this[offset]; + var mul = 1; + var i = 0; + + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + return val; + }; + + Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + + if (!noAssert) { + checkOffset(offset, byteLength, this.length); + } + + var val = this[offset + --byteLength]; + var mul = 1; + + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul; + } + + return val; + }; + + Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 1, this.length); + return this[offset]; + }; + + Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] | this[offset + 1] << 8; + }; + + Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] << 8 | this[offset + 1]; + }; + + Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000; + }; + + Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); + }; + + Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + var val = this[offset]; + var mul = 1; + var i = 0; + + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + mul *= 0x80; + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + return val; + }; + + Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + var i = byteLength; + var mul = 1; + var val = this[offset + --i]; + + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul; + } + + mul *= 0x80; + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + return val; + }; + + Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 1, this.length); + if (!(this[offset] & 0x80)) return this[offset]; + return (0xff - this[offset] + 1) * -1; + }; + + Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset] | this[offset + 1] << 8; + return val & 0x8000 ? val | 0xFFFF0000 : val; + }; + + Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset + 1] | this[offset] << 8; + return val & 0x8000 ? val | 0xFFFF0000 : val; + }; + + Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; + }; + + Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; + }; + + Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return ieee754.read(this, offset, true, 23, 4); + }; + + Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return ieee754.read(this, offset, false, 23, 4); + }; + + Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 8, this.length); + return ieee754.read(this, offset, true, 52, 8); + }; + + Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 8, this.length); + return ieee754.read(this, offset, false, 52, 8); + }; + + function checkInt(buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); + if (offset + ext > buf.length) throw new RangeError('Index out of range'); + } + + Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + byteLength = byteLength >>> 0; + + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var mul = 1; + var i = 0; + this[offset] = value & 0xFF; + + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = value / mul & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + byteLength = byteLength >>> 0; + + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var i = byteLength - 1; + var mul = 1; + this[offset + i] = value & 0xFF; + + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = value / mul & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); + this[offset] = value & 0xff; + return offset + 1; + }; + + Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + return offset + 2; + }; + + Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + this[offset] = value >>> 8; + this[offset + 1] = value & 0xff; + return offset + 2; + }; + + Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + this[offset + 3] = value >>> 24; + this[offset + 2] = value >>> 16; + this[offset + 1] = value >>> 8; + this[offset] = value & 0xff; + return offset + 4; + }; + + Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + this[offset] = value >>> 24; + this[offset + 1] = value >>> 16; + this[offset + 2] = value >>> 8; + this[offset + 3] = value & 0xff; + return offset + 4; + }; + + Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = 0; + var mul = 1; + var sub = 0; + this[offset] = value & 0xFF; + + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1; + } + + this[offset + i] = (value / mul >> 0) - sub & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = byteLength - 1; + var mul = 1; + var sub = 0; + this[offset + i] = value & 0xFF; + + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1; + } + + this[offset + i] = (value / mul >> 0) - sub & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); + if (value < 0) value = 0xff + value + 1; + this[offset] = value & 0xff; + return offset + 1; + }; + + Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + return offset + 2; + }; + + Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + this[offset] = value >>> 8; + this[offset + 1] = value & 0xff; + return offset + 2; + }; + + Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + this[offset + 2] = value >>> 16; + this[offset + 3] = value >>> 24; + return offset + 4; + }; + + Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + if (value < 0) value = 0xffffffff + value + 1; + this[offset] = value >>> 24; + this[offset + 1] = value >>> 16; + this[offset + 2] = value >>> 8; + this[offset + 3] = value & 0xff; + return offset + 4; + }; + + function checkIEEE754(buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range'); + if (offset < 0) throw new RangeError('Index out of range'); + } + + function writeFloat(buf, value, offset, littleEndian, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + checkIEEE754(buf, value, offset, 4); + } + + ieee754.write(buf, value, offset, littleEndian, 23, 4); + return offset + 4; + } + + Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert); + }; + + Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert); + }; + + function writeDouble(buf, value, offset, littleEndian, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + checkIEEE754(buf, value, offset, 8); + } + + ieee754.write(buf, value, offset, littleEndian, 52, 8); + return offset + 8; + } + + Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert); + }; + + Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert); + }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) + + + Buffer.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer'); + if (!start) start = 0; + if (!end && end !== 0) end = this.length; + if (targetStart >= target.length) targetStart = target.length; + if (!targetStart) targetStart = 0; + if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done + + if (end === start) return 0; + if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions + + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds'); + } + + if (start < 0 || start >= this.length) throw new RangeError('Index out of range'); + if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob? + + if (end > this.length) end = this.length; + + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start; + } + + var len = end - start; + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end); + } else { + Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart); + } + + return len; + }; // Usage: + // buffer.fill(number[, offset[, end]]) + // buffer.fill(buffer[, offset[, end]]) + // buffer.fill(string[, offset[, end]][, encoding]) + + + Buffer.prototype.fill = function fill(val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start; + start = 0; + end = this.length; + } else if (typeof end === 'string') { + encoding = end; + end = this.length; + } + + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string'); + } + + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding); + } + + if (val.length === 1) { + var code = val.charCodeAt(0); + + if (encoding === 'utf8' && code < 128 || encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code; + } + } + } else if (typeof val === 'number') { + val = val & 255; + } else if (typeof val === 'boolean') { + val = Number(val); + } // Invalid ranges are not set to a default, so can range check early. + + + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index'); + } + + if (end <= start) { + return this; + } + + start = start >>> 0; + end = end === undefined ? this.length : end >>> 0; + if (!val) val = 0; + var i; + + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val; + } + } else { + var bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); + var len = bytes.length; + + if (len === 0) { + throw new TypeError('The value "' + val + '" is invalid for argument "value"'); + } + + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len]; + } + } + + return this; + }; // HELPER FUNCTIONS + // ================ + + + var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; + + function base64clean(str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0]; // Node strips out invalid characters like \n and \t from the string, base64-js does not + + str = str.trim().replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to '' + + if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + + while (str.length % 4 !== 0) { + str = str + '='; + } + + return str; + } + + function utf8ToBytes(string, units) { + units = units || Infinity; + var codePoint; + var length = string.length; + var leadSurrogate = null; + var bytes = []; + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i); // is surrogate component + + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue; + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue; + } // valid lead + + + leadSurrogate = codePoint; + continue; + } // 2 leads in a row + + + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + leadSurrogate = codePoint; + continue; + } // valid surrogate pair + + + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + } + + leadSurrogate = null; // encode utf8 + + if (codePoint < 0x80) { + if ((units -= 1) < 0) break; + bytes.push(codePoint); + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break; + bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80); + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break; + bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break; + bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); + } else { + throw new Error('Invalid code point'); + } + } + + return bytes; + } + + function asciiToBytes(str) { + var byteArray = []; + + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF); + } + + return byteArray; + } + + function utf16leToBytes(str, units) { + var c, hi, lo; + var byteArray = []; + + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break; + c = str.charCodeAt(i); + hi = c >> 8; + lo = c % 256; + byteArray.push(lo); + byteArray.push(hi); + } + + return byteArray; + } + + function base64ToBytes(str) { + return base64Js.toByteArray(base64clean(str)); + } + + function blitBuffer(src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if (i + offset >= dst.length || i >= src.length) break; + dst[i + offset] = src[i]; + } + + return i; + } // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass + // the `instanceof` check but they should be treated as of that type. + // See: https://github.com/feross/buffer/issues/166 + + + function isInstance(obj, type) { + return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name; + } + + function numberIsNaN(obj) { + // For IE11 support + return obj !== obj; // eslint-disable-line no-self-compare + } // Create lookup table for `toString('hex')` + // See: https://github.com/feross/buffer/issues/219 + + + var hexSliceLookupTable = function () { + var alphabet = '0123456789abcdef'; + var table = new Array(256); + + for (var i = 0; i < 16; ++i) { + var i16 = i * 16; + + for (var j = 0; j < 16; ++j) { + table[i16 + j] = alphabet[i] + alphabet[j]; + } + } + + return table; + }(); + }); + var buffer_1 = buffer$1.Buffer; + buffer$1.SlowBuffer; + buffer$1.INSPECT_MAX_BYTES; + buffer$1.kMaxLength; + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + + /* global Reflect, Promise */ + var _extendStatics = function extendStatics(d, b) { + _extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) { + if (b.hasOwnProperty(p)) d[p] = b[p]; + } + }; + + return _extendStatics(d, b); + }; + + function __extends(d, b) { + _extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + var _assign = function __assign() { + _assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) { + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + } + + return t; + }; + + return _assign.apply(this, arguments); + }; + + /** @public */ + var BSONError = /** @class */ (function (_super) { + __extends(BSONError, _super); + function BSONError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONError.prototype); + return _this; + } + Object.defineProperty(BSONError.prototype, "name", { + get: function () { + return 'BSONError'; + }, + enumerable: false, + configurable: true + }); + return BSONError; + }(Error)); + /** @public */ + var BSONTypeError = /** @class */ (function (_super) { + __extends(BSONTypeError, _super); + function BSONTypeError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONTypeError.prototype); + return _this; + } + Object.defineProperty(BSONTypeError.prototype, "name", { + get: function () { + return 'BSONTypeError'; + }, + enumerable: false, + configurable: true + }); + return BSONTypeError; + }(TypeError)); + + function checkForMath(potentialGlobal) { + // eslint-disable-next-line eqeqeq + return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal; + } + // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + function getGlobal() { + return (checkForMath(typeof globalThis === 'object' && globalThis) || + checkForMath(typeof window === 'object' && window) || + checkForMath(typeof self === 'object' && self) || + checkForMath(typeof global === 'object' && global) || + // eslint-disable-next-line @typescript-eslint/no-implied-eval + Function('return this')()); + } + + /** + * Normalizes our expected stringified form of a function across versions of node + * @param fn - The function to stringify + */ + function normalizedFunctionString(fn) { + return fn.toString().replace('function(', 'function ('); + } + function isReactNative() { + var g = getGlobal(); + return typeof g.navigator === 'object' && g.navigator.product === 'ReactNative'; + } + var insecureRandomBytes = function insecureRandomBytes(size) { + var insecureWarning = isReactNative() + ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.' + : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.'; + console.warn(insecureWarning); + var result = buffer_1.alloc(size); + for (var i = 0; i < size; ++i) + result[i] = Math.floor(Math.random() * 256); + return result; + }; + var detectRandomBytes = function () { + { + if (typeof window !== 'undefined') { + // browser crypto implementation(s) + var target_1 = window.crypto || window.msCrypto; // allow for IE11 + if (target_1 && target_1.getRandomValues) { + return function (size) { return target_1.getRandomValues(buffer_1.alloc(size)); }; + } + } + if (typeof global !== 'undefined' && global.crypto && global.crypto.getRandomValues) { + // allow for RN packages such as https://www.npmjs.com/package/react-native-get-random-values to populate global + return function (size) { return global.crypto.getRandomValues(buffer_1.alloc(size)); }; + } + return insecureRandomBytes; + } + }; + var randomBytes = detectRandomBytes(); + function isAnyArrayBuffer(value) { + return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value)); + } + function isUint8Array(value) { + return Object.prototype.toString.call(value) === '[object Uint8Array]'; + } + function isBigInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigInt64Array]'; + } + function isBigUInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigUint64Array]'; + } + function isRegExp(d) { + return Object.prototype.toString.call(d) === '[object RegExp]'; + } + function isMap(d) { + return Object.prototype.toString.call(d) === '[object Map]'; + } + // To ensure that 0.4 of node works correctly + function isDate(d) { + return isObjectLike(d) && Object.prototype.toString.call(d) === '[object Date]'; + } + /** + * @internal + * this is to solve the `'someKey' in x` problem where x is unknown. + * https://github.com/typescript-eslint/typescript-eslint/issues/1071#issuecomment-541955753 + */ + function isObjectLike(candidate) { + return typeof candidate === 'object' && candidate !== null; + } + function deprecate(fn, message) { + var warned = false; + function deprecated() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!warned) { + console.warn(message); + warned = true; + } + return fn.apply(this, args); + } + return deprecated; + } + + /** + * Makes sure that, if a Uint8Array is passed in, it is wrapped in a Buffer. + * + * @param potentialBuffer - The potential buffer + * @returns Buffer the input if potentialBuffer is a buffer, or a buffer that + * wraps a passed in Uint8Array + * @throws BSONTypeError If anything other than a Buffer or Uint8Array is passed in + */ + function ensureBuffer(potentialBuffer) { + if (ArrayBuffer.isView(potentialBuffer)) { + return buffer_1.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength); + } + if (isAnyArrayBuffer(potentialBuffer)) { + return buffer_1.from(potentialBuffer); + } + throw new BSONTypeError('Must use either Buffer or TypedArray'); + } + + // Validation regex for v4 uuid (validates with or without dashes) + var VALIDATION_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i; + var uuidValidateString = function (str) { + return typeof str === 'string' && VALIDATION_REGEX.test(str); + }; + var uuidHexStringToBuffer = function (hexString) { + if (!uuidValidateString(hexString)) { + throw new BSONTypeError('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".'); + } + var sanitizedHexString = hexString.replace(/-/g, ''); + return buffer_1.from(sanitizedHexString, 'hex'); + }; + var bufferToUuidHexString = function (buffer, includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + return includeDashes + ? buffer.toString('hex', 0, 4) + + '-' + + buffer.toString('hex', 4, 6) + + '-' + + buffer.toString('hex', 6, 8) + + '-' + + buffer.toString('hex', 8, 10) + + '-' + + buffer.toString('hex', 10, 16) + : buffer.toString('hex'); + }; + + /** @internal */ + var BSON_INT32_MAX$1 = 0x7fffffff; + /** @internal */ + var BSON_INT32_MIN$1 = -0x80000000; + /** @internal */ + var BSON_INT64_MAX$1 = Math.pow(2, 63) - 1; + /** @internal */ + var BSON_INT64_MIN$1 = -Math.pow(2, 63); + /** + * Any integer up to 2^53 can be precisely represented by a double. + * @internal + */ + var JS_INT_MAX = Math.pow(2, 53); + /** + * Any integer down to -2^53 can be precisely represented by a double. + * @internal + */ + var JS_INT_MIN = -Math.pow(2, 53); + /** Number BSON Type @internal */ + var BSON_DATA_NUMBER = 1; + /** String BSON Type @internal */ + var BSON_DATA_STRING = 2; + /** Object BSON Type @internal */ + var BSON_DATA_OBJECT = 3; + /** Array BSON Type @internal */ + var BSON_DATA_ARRAY = 4; + /** Binary BSON Type @internal */ + var BSON_DATA_BINARY = 5; + /** Binary BSON Type @internal */ + var BSON_DATA_UNDEFINED = 6; + /** ObjectId BSON Type @internal */ + var BSON_DATA_OID = 7; + /** Boolean BSON Type @internal */ + var BSON_DATA_BOOLEAN = 8; + /** Date BSON Type @internal */ + var BSON_DATA_DATE = 9; + /** null BSON Type @internal */ + var BSON_DATA_NULL = 10; + /** RegExp BSON Type @internal */ + var BSON_DATA_REGEXP = 11; + /** Code BSON Type @internal */ + var BSON_DATA_DBPOINTER = 12; + /** Code BSON Type @internal */ + var BSON_DATA_CODE = 13; + /** Symbol BSON Type @internal */ + var BSON_DATA_SYMBOL = 14; + /** Code with Scope BSON Type @internal */ + var BSON_DATA_CODE_W_SCOPE = 15; + /** 32 bit Integer BSON Type @internal */ + var BSON_DATA_INT = 16; + /** Timestamp BSON Type @internal */ + var BSON_DATA_TIMESTAMP = 17; + /** Long BSON Type @internal */ + var BSON_DATA_LONG = 18; + /** Decimal128 BSON Type @internal */ + var BSON_DATA_DECIMAL128 = 19; + /** MinKey BSON Type @internal */ + var BSON_DATA_MIN_KEY = 0xff; + /** MaxKey BSON Type @internal */ + var BSON_DATA_MAX_KEY = 0x7f; + /** Binary Default Type @internal */ + var BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** Binary Function Type @internal */ + var BSON_BINARY_SUBTYPE_FUNCTION = 1; + /** Binary Byte Array Type @internal */ + var BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; + /** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */ + var BSON_BINARY_SUBTYPE_UUID = 3; + /** Binary UUID Type @internal */ + var BSON_BINARY_SUBTYPE_UUID_NEW = 4; + /** Binary MD5 Type @internal */ + var BSON_BINARY_SUBTYPE_MD5 = 5; + /** Encrypted BSON type @internal */ + var BSON_BINARY_SUBTYPE_ENCRYPTED = 6; + /** Column BSON type @internal */ + var BSON_BINARY_SUBTYPE_COLUMN = 7; + /** Binary User Defined Type @internal */ + var BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + + /** + * A class representation of the BSON Binary type. + * @public + * @category BSONType + */ + var Binary = /** @class */ (function () { + /** + * Create a new Binary instance. + * + * This constructor can accept a string as its first argument. In this case, + * this string will be encoded using ISO-8859-1, **not** using UTF-8. + * This is almost certainly not what you want. Use `new Binary(Buffer.from(string))` + * instead to convert the string to a Buffer using UTF-8 first. + * + * @param buffer - a buffer object containing the binary data. + * @param subType - the option binary type. + */ + function Binary(buffer, subType) { + if (!(this instanceof Binary)) + return new Binary(buffer, subType); + if (!(buffer == null) && + !(typeof buffer === 'string') && + !ArrayBuffer.isView(buffer) && + !(buffer instanceof ArrayBuffer) && + !Array.isArray(buffer)) { + throw new BSONTypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array'); + } + this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT; + if (buffer == null) { + // create an empty binary buffer + this.buffer = buffer_1.alloc(Binary.BUFFER_SIZE); + this.position = 0; + } + else { + if (typeof buffer === 'string') { + // string + this.buffer = buffer_1.from(buffer, 'binary'); + } + else if (Array.isArray(buffer)) { + // number[] + this.buffer = buffer_1.from(buffer); + } + else { + // Buffer | TypedArray | ArrayBuffer + this.buffer = ensureBuffer(buffer); + } + this.position = this.buffer.byteLength; + } + } + /** + * Updates this binary with byte_value. + * + * @param byteValue - a single byte we wish to write. + */ + Binary.prototype.put = function (byteValue) { + // If it's a string and a has more than one character throw an error + if (typeof byteValue === 'string' && byteValue.length !== 1) { + throw new BSONTypeError('only accepts single character String'); + } + else if (typeof byteValue !== 'number' && byteValue.length !== 1) + throw new BSONTypeError('only accepts single character Uint8Array or Array'); + // Decode the byte value once + var decodedByte; + if (typeof byteValue === 'string') { + decodedByte = byteValue.charCodeAt(0); + } + else if (typeof byteValue === 'number') { + decodedByte = byteValue; + } + else { + decodedByte = byteValue[0]; + } + if (decodedByte < 0 || decodedByte > 255) { + throw new BSONTypeError('only accepts number in a valid unsigned byte range 0-255'); + } + if (this.buffer.length > this.position) { + this.buffer[this.position++] = decodedByte; + } + else { + var buffer = buffer_1.alloc(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++] = decodedByte; + } + }; + /** + * Writes a buffer or string to the binary. + * + * @param sequence - a string or buffer to be written to the Binary BSON object. + * @param offset - specify the binary of where to write the content. + */ + Binary.prototype.write = function (sequence, offset) { + offset = typeof offset === 'number' ? offset : this.position; + // If the buffer is to small let's extend the buffer + if (this.buffer.length < offset + sequence.length) { + var buffer = buffer_1.alloc(this.buffer.length + sequence.length); + this.buffer.copy(buffer, 0, 0, this.buffer.length); + // Assign the new buffer + this.buffer = buffer; + } + if (ArrayBuffer.isView(sequence)) { + this.buffer.set(ensureBuffer(sequence), offset); + this.position = + offset + sequence.byteLength > this.position ? offset + sequence.length : this.position; + } + else if (typeof sequence === 'string') { + this.buffer.write(sequence, offset, sequence.length, 'binary'); + this.position = + offset + sequence.length > this.position ? offset + sequence.length : this.position; + } + }; + /** + * Reads **length** bytes starting at **position**. + * + * @param position - read from the given position in the Binary. + * @param length - the number of bytes to read. + */ + Binary.prototype.read = function (position, length) { + length = length && length > 0 ? length : this.position; + // Let's return the data based on the type we have + return this.buffer.slice(position, position + length); + }; + /** + * Returns the value of this binary as a string. + * @param asRaw - Will skip converting to a string + * @remarks + * This is handy when calling this function conditionally for some key value pairs and not others + */ + Binary.prototype.value = function (asRaw) { + asRaw = !!asRaw; + // Optimize to serialize for the situation where the data == size of buffer + if (asRaw && this.buffer.length === this.position) { + return this.buffer; + } + // If it's a node.js buffer object + if (asRaw) { + return this.buffer.slice(0, this.position); + } + return this.buffer.toString('binary', 0, this.position); + }; + /** the length of the binary sequence */ + Binary.prototype.length = function () { + return this.position; + }; + Binary.prototype.toJSON = function () { + return this.buffer.toString('base64'); + }; + Binary.prototype.toString = function (format) { + return this.buffer.toString(format); + }; + /** @internal */ + Binary.prototype.toExtendedJSON = function (options) { + options = options || {}; + var base64String = this.buffer.toString('base64'); + var subType = Number(this.sub_type).toString(16); + if (options.legacy) { + return { + $binary: base64String, + $type: subType.length === 1 ? '0' + subType : subType + }; + } + return { + $binary: { + base64: base64String, + subType: subType.length === 1 ? '0' + subType : subType + } + }; + }; + Binary.prototype.toUUID = function () { + if (this.sub_type === Binary.SUBTYPE_UUID) { + return new UUID(this.buffer.slice(0, this.position)); + } + throw new BSONError("Binary sub_type \"".concat(this.sub_type, "\" is not supported for converting to UUID. Only \"").concat(Binary.SUBTYPE_UUID, "\" is currently supported.")); + }; + /** @internal */ + Binary.fromExtendedJSON = function (doc, options) { + options = options || {}; + var data; + var type; + if ('$binary' in doc) { + if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) { + type = doc.$type ? parseInt(doc.$type, 16) : 0; + data = buffer_1.from(doc.$binary, 'base64'); + } + else { + if (typeof doc.$binary !== 'string') { + type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0; + data = buffer_1.from(doc.$binary.base64, 'base64'); + } + } + } + else if ('$uuid' in doc) { + type = 4; + data = uuidHexStringToBuffer(doc.$uuid); + } + if (!data) { + throw new BSONTypeError("Unexpected Binary Extended JSON format ".concat(JSON.stringify(doc))); + } + return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type); + }; + /** @internal */ + Binary.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Binary.prototype.inspect = function () { + var asBuffer = this.value(true); + return "new Binary(Buffer.from(\"".concat(asBuffer.toString('hex'), "\", \"hex\"), ").concat(this.sub_type, ")"); + }; + /** + * Binary default subtype + * @internal + */ + Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** Initial buffer default size */ + Binary.BUFFER_SIZE = 256; + /** Default BSON type */ + Binary.SUBTYPE_DEFAULT = 0; + /** Function BSON type */ + Binary.SUBTYPE_FUNCTION = 1; + /** Byte Array BSON type */ + Binary.SUBTYPE_BYTE_ARRAY = 2; + /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */ + Binary.SUBTYPE_UUID_OLD = 3; + /** UUID BSON type */ + Binary.SUBTYPE_UUID = 4; + /** MD5 BSON type */ + Binary.SUBTYPE_MD5 = 5; + /** Encrypted BSON type */ + Binary.SUBTYPE_ENCRYPTED = 6; + /** Column BSON type */ + Binary.SUBTYPE_COLUMN = 7; + /** User BSON type */ + Binary.SUBTYPE_USER_DEFINED = 128; + return Binary; + }()); + Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' }); + var UUID_BYTE_LENGTH = 16; + /** + * A class representation of the BSON UUID type. + * @public + */ + var UUID = /** @class */ (function (_super) { + __extends(UUID, _super); + /** + * Create an UUID type + * + * @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer. + */ + function UUID(input) { + var _this = this; + var bytes; + var hexStr; + if (input == null) { + bytes = UUID.generate(); + } + else if (input instanceof UUID) { + bytes = buffer_1.from(input.buffer); + hexStr = input.__id; + } + else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) { + bytes = ensureBuffer(input); + } + else if (typeof input === 'string') { + bytes = uuidHexStringToBuffer(input); + } + else { + throw new BSONTypeError('Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'); + } + _this = _super.call(this, bytes, BSON_BINARY_SUBTYPE_UUID_NEW) || this; + _this.__id = hexStr; + return _this; + } + Object.defineProperty(UUID.prototype, "id", { + /** + * The UUID bytes + * @readonly + */ + get: function () { + return this.buffer; + }, + set: function (value) { + this.buffer = value; + if (UUID.cacheHexString) { + this.__id = bufferToUuidHexString(value); + } + }, + enumerable: false, + configurable: true + }); + /** + * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated) + * @param includeDashes - should the string exclude dash-separators. + * */ + UUID.prototype.toHexString = function (includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + if (UUID.cacheHexString && this.__id) { + return this.__id; + } + var uuidHexString = bufferToUuidHexString(this.id, includeDashes); + if (UUID.cacheHexString) { + this.__id = uuidHexString; + } + return uuidHexString; + }; + /** + * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified. + */ + UUID.prototype.toString = function (encoding) { + return encoding ? this.id.toString(encoding) : this.toHexString(); + }; + /** + * Converts the id into its JSON string representation. + * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + */ + UUID.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this UUID with `otherID`. + * + * @param otherId - UUID instance to compare against. + */ + UUID.prototype.equals = function (otherId) { + if (!otherId) { + return false; + } + if (otherId instanceof UUID) { + return otherId.id.equals(this.id); + } + try { + return new UUID(otherId).id.equals(this.id); + } + catch (_a) { + return false; + } + }; + /** + * Creates a Binary instance from the current UUID. + */ + UUID.prototype.toBinary = function () { + return new Binary(this.id, Binary.SUBTYPE_UUID); + }; + /** + * Generates a populated buffer containing a v4 uuid + */ + UUID.generate = function () { + var bytes = randomBytes(UUID_BYTE_LENGTH); + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + // Kindly borrowed from https://github.com/uuidjs/uuid/blob/master/src/v4.js + bytes[6] = (bytes[6] & 0x0f) | 0x40; + bytes[8] = (bytes[8] & 0x3f) | 0x80; + return buffer_1.from(bytes); + }; + /** + * Checks if a value is a valid bson UUID + * @param input - UUID, string or Buffer to validate. + */ + UUID.isValid = function (input) { + if (!input) { + return false; + } + if (input instanceof UUID) { + return true; + } + if (typeof input === 'string') { + return uuidValidateString(input); + } + if (isUint8Array(input)) { + // check for length & uuid version (https://tools.ietf.org/html/rfc4122#section-4.1.3) + if (input.length !== UUID_BYTE_LENGTH) { + return false; + } + return (input[6] & 0xf0) === 0x40 && (input[8] & 0x80) === 0x80; + } + return false; + }; + /** + * Creates an UUID from a hex string representation of an UUID. + * @param hexString - 32 or 36 character hex string (dashes excluded/included). + */ + UUID.createFromHexString = function (hexString) { + var buffer = uuidHexStringToBuffer(hexString); + return new UUID(buffer); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 36 character hex string representation. + * @internal + */ + UUID.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + UUID.prototype.inspect = function () { + return "new UUID(\"".concat(this.toHexString(), "\")"); + }; + return UUID; + }(Binary)); + + /** + * A class representation of the BSON Code type. + * @public + * @category BSONType + */ + var Code = /** @class */ (function () { + /** + * @param code - a string or function. + * @param scope - an optional scope for the function. + */ + function Code(code, scope) { + if (!(this instanceof Code)) + return new Code(code, scope); + this.code = code; + this.scope = scope; + } + Code.prototype.toJSON = function () { + return { code: this.code, scope: this.scope }; + }; + /** @internal */ + Code.prototype.toExtendedJSON = function () { + if (this.scope) { + return { $code: this.code, $scope: this.scope }; + } + return { $code: this.code }; + }; + /** @internal */ + Code.fromExtendedJSON = function (doc) { + return new Code(doc.$code, doc.$scope); + }; + /** @internal */ + Code.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Code.prototype.inspect = function () { + var codeJson = this.toJSON(); + return "new Code(\"".concat(String(codeJson.code), "\"").concat(codeJson.scope ? ", ".concat(JSON.stringify(codeJson.scope)) : '', ")"); + }; + return Code; + }()); + Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' }); + + /** @internal */ + function isDBRefLike(value) { + return (isObjectLike(value) && + value.$id != null && + typeof value.$ref === 'string' && + (value.$db == null || typeof value.$db === 'string')); + } + /** + * A class representation of the BSON DBRef type. + * @public + * @category BSONType + */ + var DBRef = /** @class */ (function () { + /** + * @param collection - the collection name. + * @param oid - the reference ObjectId. + * @param db - optional db name, if omitted the reference is local to the current db. + */ + function DBRef(collection, oid, db, fields) { + if (!(this instanceof DBRef)) + return new DBRef(collection, oid, db, fields); + // check if namespace has been provided + var parts = collection.split('.'); + if (parts.length === 2) { + db = parts.shift(); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + collection = parts.shift(); + } + this.collection = collection; + this.oid = oid; + this.db = db; + this.fields = fields || {}; + } + Object.defineProperty(DBRef.prototype, "namespace", { + // Property provided for compatibility with the 1.x parser + // the 1.x parser used a "namespace" property, while 4.x uses "collection" + /** @internal */ + get: function () { + return this.collection; + }, + set: function (value) { + this.collection = value; + }, + enumerable: false, + configurable: true + }); + DBRef.prototype.toJSON = function () { + var o = Object.assign({ + $ref: this.collection, + $id: this.oid + }, this.fields); + if (this.db != null) + o.$db = this.db; + return o; + }; + /** @internal */ + DBRef.prototype.toExtendedJSON = function (options) { + options = options || {}; + var o = { + $ref: this.collection, + $id: this.oid + }; + if (options.legacy) { + return o; + } + if (this.db) + o.$db = this.db; + o = Object.assign(o, this.fields); + return o; + }; + /** @internal */ + DBRef.fromExtendedJSON = function (doc) { + var copy = Object.assign({}, doc); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(doc.$ref, doc.$id, doc.$db, copy); + }; + /** @internal */ + DBRef.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + DBRef.prototype.inspect = function () { + // NOTE: if OID is an ObjectId class it will just print the oid string. + var oid = this.oid === undefined || this.oid.toString === undefined ? this.oid : this.oid.toString(); + return "new DBRef(\"".concat(this.namespace, "\", new ObjectId(\"").concat(String(oid), "\")").concat(this.db ? ", \"".concat(this.db, "\"") : '', ")"); + }; + return DBRef; + }()); + Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' }); + + /** + * wasm optimizations, to do native i64 multiplication and divide + */ + var wasm = undefined; + try { + wasm = new WebAssembly.Instance(new WebAssembly.Module( + // prettier-ignore + new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports; + } + catch (_a) { + // no wasm support + } + var TWO_PWR_16_DBL = 1 << 16; + var TWO_PWR_24_DBL = 1 << 24; + var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL; + var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL; + var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2; + /** A cache of the Long representations of small integer values. */ + var INT_CACHE = {}; + /** A cache of the Long representations of small unsigned integer values. */ + var UINT_CACHE = {}; + /** + * A class representing a 64-bit integer + * @public + * @category BSONType + * @remarks + * 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. + * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class. + */ + var Long = /** @class */ (function () { + /** + * 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. + * + * Acceptable signatures are: + * - Long(low, high, unsigned?) + * - Long(bigint, unsigned?) + * - Long(string, unsigned?) + * + * @param low - The low (signed) 32 bits of the long + * @param high - The high (signed) 32 bits of the long + * @param unsigned - Whether unsigned or not, defaults to signed + */ + function Long(low, high, unsigned) { + if (low === void 0) { low = 0; } + if (!(this instanceof Long)) + return new Long(low, high, unsigned); + if (typeof low === 'bigint') { + Object.assign(this, Long.fromBigInt(low, !!high)); + } + else if (typeof low === 'string') { + Object.assign(this, Long.fromString(low, !!high)); + } + else { + this.low = low | 0; + this.high = high | 0; + this.unsigned = !!unsigned; + } + Object.defineProperty(this, '__isLong__', { + value: true, + configurable: false, + writable: false, + enumerable: false + }); + } + /** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. + * Each is assumed to use 32 bits. + * @param lowBits - The low 32 bits + * @param highBits - The high 32 bits + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBits = function (lowBits, highBits, unsigned) { + return new Long(lowBits, highBits, unsigned); + }; + /** + * Returns a Long representing the given 32 bit integer value. + * @param value - The 32 bit integer in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromInt = function (value, unsigned) { + var obj, cachedObj, cache; + if (unsigned) { + value >>>= 0; + if ((cache = 0 <= value && value < 256)) { + cachedObj = UINT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true); + if (cache) + UINT_CACHE[value] = obj; + return obj; + } + else { + value |= 0; + if ((cache = -128 <= value && value < 128)) { + cachedObj = INT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, value < 0 ? -1 : 0, false); + if (cache) + INT_CACHE[value] = obj; + return obj; + } + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromNumber = function (value, unsigned) { + if (isNaN(value)) + return unsigned ? Long.UZERO : Long.ZERO; + if (unsigned) { + if (value < 0) + return Long.UZERO; + if (value >= TWO_PWR_64_DBL) + return Long.MAX_UNSIGNED_VALUE; + } + else { + if (value <= -TWO_PWR_63_DBL) + return Long.MIN_VALUE; + if (value + 1 >= TWO_PWR_63_DBL) + return Long.MAX_VALUE; + } + if (value < 0) + return Long.fromNumber(-value, unsigned).neg(); + return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned); + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBigInt = function (value, unsigned) { + return Long.fromString(value.toString(), unsigned); + }; + /** + * Returns a Long representation of the given string, written using the specified radix. + * @param str - The textual representation of the Long + * @param unsigned - Whether unsigned or not, defaults to signed + * @param radix - The radix in which the text is written (2-36), defaults to 10 + * @returns The corresponding Long value + */ + Long.fromString = function (str, unsigned, radix) { + if (str.length === 0) + throw Error('empty string'); + if (str === 'NaN' || str === 'Infinity' || str === '+Infinity' || str === '-Infinity') + return Long.ZERO; + if (typeof unsigned === 'number') { + // For goog.math.long compatibility + (radix = unsigned), (unsigned = false); + } + else { + unsigned = !!unsigned; + } + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + var p; + if ((p = str.indexOf('-')) > 0) + throw Error('interior hyphen'); + else if (p === 0) { + return Long.fromString(str.substring(1), unsigned, radix).neg(); + } + // 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), value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Long.fromNumber(Math.pow(radix, size)); + result = result.mul(power).add(Long.fromNumber(value)); + } + else { + result = result.mul(radixToPower); + result = result.add(Long.fromNumber(value)); + } + } + result.unsigned = unsigned; + return result; + }; + /** + * Creates a Long from its byte representation. + * @param bytes - Byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @param le - Whether little or big endian, defaults to big endian + * @returns The corresponding Long value + */ + Long.fromBytes = function (bytes, unsigned, le) { + return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned); + }; + /** + * Creates a Long from its little endian byte representation. + * @param bytes - Little endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesLE = function (bytes, unsigned) { + return new Long(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24), bytes[4] | (bytes[5] << 8) | (bytes[6] << 16) | (bytes[7] << 24), unsigned); + }; + /** + * Creates a Long from its big endian byte representation. + * @param bytes - Big endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesBE = function (bytes, unsigned) { + return new Long((bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7], (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3], unsigned); + }; + /** + * Tests if the specified object is a Long. + */ + Long.isLong = function (value) { + return isObjectLike(value) && value['__isLong__'] === true; + }; + /** + * Converts the specified value to a Long. + * @param unsigned - Whether unsigned or not, defaults to signed + */ + Long.fromValue = function (val, unsigned) { + if (typeof val === 'number') + return Long.fromNumber(val, unsigned); + if (typeof val === 'string') + return Long.fromString(val, unsigned); + // Throws for non-objects, converts non-instanceof Long: + return Long.fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned); + }; + /** Returns the sum of this and the specified Long. */ + Long.prototype.add = function (addend) { + if (!Long.isLong(addend)) + addend = Long.fromValue(addend); + // 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 = addend.high >>> 16; + var b32 = addend.high & 0xffff; + var b16 = addend.low >>> 16; + var b00 = addend.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, this.unsigned); + }; + /** + * Returns the sum of this and the specified Long. + * @returns Sum + */ + Long.prototype.and = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); + }; + /** + * Compares this Long's value with the specified's. + * @returns 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 (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.eq(other)) + return 0; + var thisNeg = this.isNegative(), otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) + return -1; + if (!thisNeg && otherNeg) + return 1; + // At this point the sign bits are the same + if (!this.unsigned) + return this.sub(other).isNegative() ? -1 : 1; + // Both are positive if at least one is unsigned + return other.high >>> 0 > this.high >>> 0 || + (other.high === this.high && other.low >>> 0 > this.low >>> 0) + ? -1 + : 1; + }; + /** This is an alias of {@link Long.compare} */ + Long.prototype.comp = function (other) { + return this.compare(other); + }; + /** + * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned. + * @returns Quotient + */ + Long.prototype.divide = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + if (divisor.isZero()) + throw Error('division by zero'); + // use wasm support if present + if (wasm) { + // guard against signed division overflow: the largest + // negative number / -1 would be 1 larger than the largest + // positive number, due to two's complement. + if (!this.unsigned && + this.high === -0x80000000 && + divisor.low === -1 && + divisor.high === -1) { + // be consistent with non-wasm code path + return this; + } + var low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (this.isZero()) + return this.unsigned ? Long.UZERO : Long.ZERO; + var approx, rem, res; + if (!this.unsigned) { + // This section is only relevant for signed longs and is derived from the + // closure library as a whole. + if (this.eq(Long.MIN_VALUE)) { + if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE)) + return Long.MIN_VALUE; + // recall that -MIN_VALUE == MIN_VALUE + else if (divisor.eq(Long.MIN_VALUE)) + return Long.ONE; + else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shr(1); + approx = halfThis.div(divisor).shl(1); + if (approx.eq(Long.ZERO)) { + return divisor.isNegative() ? Long.ONE : Long.NEG_ONE; + } + else { + rem = this.sub(divisor.mul(approx)); + res = approx.add(rem.div(divisor)); + return res; + } + } + } + else if (divisor.eq(Long.MIN_VALUE)) + return this.unsigned ? Long.UZERO : Long.ZERO; + if (this.isNegative()) { + if (divisor.isNegative()) + return this.neg().div(divisor.neg()); + return this.neg().div(divisor).neg(); + } + else if (divisor.isNegative()) + return this.div(divisor.neg()).neg(); + res = Long.ZERO; + } + else { + // The algorithm below has not been made for unsigned longs. It's therefore + // required to take special care of the MSB prior to running it. + if (!divisor.unsigned) + divisor = divisor.toUnsigned(); + if (divisor.gt(this)) + return Long.UZERO; + if (divisor.gt(this.shru(1))) + // 15 >>> 1 = 7 ; with divisor = 8 ; true + return Long.UONE; + res = Long.UZERO; + } + // 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. + // eslint-disable-next-line @typescript-eslint/no-this-alias + rem = this; + while (rem.gte(divisor)) { + // 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() / divisor.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.mul(divisor); + while (approxRem.isNegative() || approxRem.gt(rem)) { + approx -= delta; + approxRes = Long.fromNumber(approx, this.unsigned); + approxRem = approxRes.mul(divisor); + } + // 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.sub(approxRem); + } + return res; + }; + /**This is an alias of {@link Long.divide} */ + Long.prototype.div = function (divisor) { + return this.divide(divisor); + }; + /** + * Tests if this Long's value equals the specified's. + * @param other - Other value + */ + Long.prototype.equals = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1) + return false; + return this.high === other.high && this.low === other.low; + }; + /** This is an alias of {@link Long.equals} */ + Long.prototype.eq = function (other) { + return this.equals(other); + }; + /** Gets the high 32 bits as a signed integer. */ + Long.prototype.getHighBits = function () { + return this.high; + }; + /** Gets the high 32 bits as an unsigned integer. */ + Long.prototype.getHighBitsUnsigned = function () { + return this.high >>> 0; + }; + /** Gets the low 32 bits as a signed integer. */ + Long.prototype.getLowBits = function () { + return this.low; + }; + /** Gets the low 32 bits as an unsigned integer. */ + Long.prototype.getLowBitsUnsigned = function () { + return this.low >>> 0; + }; + /** Gets the number of bits needed to represent the absolute value of this Long. */ + Long.prototype.getNumBitsAbs = function () { + if (this.isNegative()) { + // Unsigned Longs are never negative + return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); + } + var val = this.high !== 0 ? this.high : this.low; + var bit; + for (bit = 31; bit > 0; bit--) + if ((val & (1 << bit)) !== 0) + break; + return this.high !== 0 ? bit + 33 : bit + 1; + }; + /** Tests if this Long's value is greater than the specified's. */ + Long.prototype.greaterThan = function (other) { + return this.comp(other) > 0; + }; + /** This is an alias of {@link Long.greaterThan} */ + Long.prototype.gt = function (other) { + return this.greaterThan(other); + }; + /** Tests if this Long's value is greater than or equal the specified's. */ + Long.prototype.greaterThanOrEqual = function (other) { + return this.comp(other) >= 0; + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.gte = function (other) { + return this.greaterThanOrEqual(other); + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.ge = function (other) { + return this.greaterThanOrEqual(other); + }; + /** Tests if this Long's value is even. */ + Long.prototype.isEven = function () { + return (this.low & 1) === 0; + }; + /** Tests if this Long's value is negative. */ + Long.prototype.isNegative = function () { + return !this.unsigned && this.high < 0; + }; + /** Tests if this Long's value is odd. */ + Long.prototype.isOdd = function () { + return (this.low & 1) === 1; + }; + /** Tests if this Long's value is positive. */ + Long.prototype.isPositive = function () { + return this.unsigned || this.high >= 0; + }; + /** Tests if this Long's value equals zero. */ + Long.prototype.isZero = function () { + return this.high === 0 && this.low === 0; + }; + /** Tests if this Long's value is less than the specified's. */ + Long.prototype.lessThan = function (other) { + return this.comp(other) < 0; + }; + /** This is an alias of {@link Long#lessThan}. */ + Long.prototype.lt = function (other) { + return this.lessThan(other); + }; + /** Tests if this Long's value is less than or equal the specified's. */ + Long.prototype.lessThanOrEqual = function (other) { + return this.comp(other) <= 0; + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.lte = function (other) { + return this.lessThanOrEqual(other); + }; + /** Returns this Long modulo the specified. */ + Long.prototype.modulo = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + // use wasm support if present + if (wasm) { + var low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + return this.sub(this.div(divisor).mul(divisor)); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.mod = function (divisor) { + return this.modulo(divisor); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.rem = function (divisor) { + return this.modulo(divisor); + }; + /** + * Returns the product of this and the specified Long. + * @param multiplier - Multiplier + * @returns Product + */ + Long.prototype.multiply = function (multiplier) { + if (this.isZero()) + return Long.ZERO; + if (!Long.isLong(multiplier)) + multiplier = Long.fromValue(multiplier); + // use wasm support if present + if (wasm) { + var low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (multiplier.isZero()) + return Long.ZERO; + if (this.eq(Long.MIN_VALUE)) + return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (multiplier.eq(Long.MIN_VALUE)) + return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (this.isNegative()) { + if (multiplier.isNegative()) + return this.neg().mul(multiplier.neg()); + else + return this.neg().mul(multiplier).neg(); + } + else if (multiplier.isNegative()) + return this.mul(multiplier.neg()).neg(); + // If both longs are small, use float multiplication + if (this.lt(Long.TWO_PWR_24) && multiplier.lt(Long.TWO_PWR_24)) + return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); + // 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 = multiplier.high >>> 16; + var b32 = multiplier.high & 0xffff; + var b16 = multiplier.low >>> 16; + var b00 = multiplier.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, this.unsigned); + }; + /** This is an alias of {@link Long.multiply} */ + Long.prototype.mul = function (multiplier) { + return this.multiply(multiplier); + }; + /** Returns the Negation of this Long's value. */ + Long.prototype.negate = function () { + if (!this.unsigned && this.eq(Long.MIN_VALUE)) + return Long.MIN_VALUE; + return this.not().add(Long.ONE); + }; + /** This is an alias of {@link Long.negate} */ + Long.prototype.neg = function () { + return this.negate(); + }; + /** Returns the bitwise NOT of this Long. */ + Long.prototype.not = function () { + return Long.fromBits(~this.low, ~this.high, this.unsigned); + }; + /** Tests if this Long's value differs from the specified's. */ + Long.prototype.notEquals = function (other) { + return !this.equals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.neq = function (other) { + return this.notEquals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.ne = function (other) { + return this.notEquals(other); + }; + /** + * Returns the bitwise OR of this Long and the specified. + */ + Long.prototype.or = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); + }; + /** + * Returns this Long with bits shifted to the left by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftLeft = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); + else + return Long.fromBits(0, this.low << (numBits - 32), this.unsigned); + }; + /** This is an alias of {@link Long.shiftLeft} */ + Long.prototype.shl = function (numBits) { + return this.shiftLeft(numBits); + }; + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRight = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); + else + return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); + }; + /** This is an alias of {@link Long.shiftRight} */ + Long.prototype.shr = function (numBits) { + return this.shiftRight(numBits); + }; + /** + * Returns this Long with bits logically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRightUnsigned = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + 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, this.unsigned); + } + else if (numBits === 32) + return Long.fromBits(high, 0, this.unsigned); + else + return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned); + } + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shr_u = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shru = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** + * Returns the difference of this and the specified Long. + * @param subtrahend - Subtrahend + * @returns Difference + */ + Long.prototype.subtract = function (subtrahend) { + if (!Long.isLong(subtrahend)) + subtrahend = Long.fromValue(subtrahend); + return this.add(subtrahend.neg()); + }; + /** This is an alias of {@link Long.subtract} */ + Long.prototype.sub = function (subtrahend) { + return this.subtract(subtrahend); + }; + /** Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. */ + Long.prototype.toInt = function () { + return this.unsigned ? this.low >>> 0 : this.low; + }; + /** Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). */ + Long.prototype.toNumber = function () { + if (this.unsigned) + return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0); + return this.high * TWO_PWR_32_DBL + (this.low >>> 0); + }; + /** Converts the Long to a BigInt (arbitrary precision). */ + Long.prototype.toBigInt = function () { + return BigInt(this.toString()); + }; + /** + * Converts this Long to its byte representation. + * @param le - Whether little or big endian, defaults to big endian + * @returns Byte representation + */ + Long.prototype.toBytes = function (le) { + return le ? this.toBytesLE() : this.toBytesBE(); + }; + /** + * Converts this Long to its little endian byte representation. + * @returns Little endian byte representation + */ + Long.prototype.toBytesLE = function () { + var hi = this.high, lo = this.low; + return [ + lo & 0xff, + (lo >>> 8) & 0xff, + (lo >>> 16) & 0xff, + lo >>> 24, + hi & 0xff, + (hi >>> 8) & 0xff, + (hi >>> 16) & 0xff, + hi >>> 24 + ]; + }; + /** + * Converts this Long to its big endian byte representation. + * @returns Big endian byte representation + */ + Long.prototype.toBytesBE = function () { + var hi = this.high, lo = this.low; + return [ + hi >>> 24, + (hi >>> 16) & 0xff, + (hi >>> 8) & 0xff, + hi & 0xff, + lo >>> 24, + (lo >>> 16) & 0xff, + (lo >>> 8) & 0xff, + lo & 0xff + ]; + }; + /** + * Converts this Long to signed. + */ + Long.prototype.toSigned = function () { + if (!this.unsigned) + return this; + return Long.fromBits(this.low, this.high, false); + }; + /** + * Converts the Long to a string written in the specified radix. + * @param radix - Radix (2-36), defaults to 10 + * @throws RangeError If `radix` is out of range + */ + Long.prototype.toString = function (radix) { + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + if (this.isZero()) + return '0'; + if (this.isNegative()) { + // Unsigned Longs are never negative + if (this.eq(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), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this); + return div.toString(radix) + rem1.toInt().toString(radix); + } + else + return '-' + this.neg().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), this.unsigned); + // eslint-disable-next-line @typescript-eslint/no-this-alias + var rem = this; + var result = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + var remDiv = rem.div(radixToPower); + var intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0; + var digits = intval.toString(radix); + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } + else { + while (digits.length < 6) + digits = '0' + digits; + result = '' + digits + result; + } + } + }; + /** Converts this Long to unsigned. */ + Long.prototype.toUnsigned = function () { + if (this.unsigned) + return this; + return Long.fromBits(this.low, this.high, true); + }; + /** Returns the bitwise XOR of this Long and the given one. */ + Long.prototype.xor = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); + }; + /** This is an alias of {@link Long.isZero} */ + Long.prototype.eqz = function () { + return this.isZero(); + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.le = function (other) { + return this.lessThanOrEqual(other); + }; + /* + **************************************************************** + * BSON SPECIFIC ADDITIONS * + **************************************************************** + */ + Long.prototype.toExtendedJSON = function (options) { + if (options && options.relaxed) + return this.toNumber(); + return { $numberLong: this.toString() }; + }; + Long.fromExtendedJSON = function (doc, options) { + var result = Long.fromString(doc.$numberLong); + return options && options.relaxed ? result.toNumber() : result; + }; + /** @internal */ + Long.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Long.prototype.inspect = function () { + return "new Long(\"".concat(this.toString(), "\"").concat(this.unsigned ? ', true' : '', ")"); + }; + Long.TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL); + /** Maximum unsigned value. */ + Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xffffffff | 0, 0xffffffff | 0, true); + /** Signed zero */ + Long.ZERO = Long.fromInt(0); + /** Unsigned zero. */ + Long.UZERO = Long.fromInt(0, true); + /** Signed one. */ + Long.ONE = Long.fromInt(1); + /** Unsigned one. */ + Long.UONE = Long.fromInt(1, true); + /** Signed negative one. */ + Long.NEG_ONE = Long.fromInt(-1); + /** Maximum signed value. */ + Long.MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0, false); + /** Minimum signed value. */ + Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false); + return Long; + }()); + Object.defineProperty(Long.prototype, '__isLong__', { value: true }); + Object.defineProperty(Long.prototype, '_bsontype', { value: '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+)?$/; + // 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; + // Detect if the value is a digit + function isDigit(value) { + return !isNaN(parseInt(value, 10)); + } + // Divide two uint128 values + function divideu128(value) { + var DIVISOR = Long.fromNumber(1000 * 1000 * 1000); + var _rem = Long.fromNumber(0); + if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) { + return { quotient: value, rem: _rem }; + } + for (var 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 + function multiply64x2(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 }; + } + function lessThan(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; + } + function invalidErr(string, message) { + throw new BSONTypeError("\"".concat(string, "\" is not a valid Decimal128 string - ").concat(message)); + } + /** + * A class representation of the BSON Decimal128 type. + * @public + * @category BSONType + */ + var Decimal128 = /** @class */ (function () { + /** + * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order, + * or a string representation as returned by .toString() + */ + function Decimal128(bytes) { + if (!(this instanceof Decimal128)) + return new Decimal128(bytes); + if (typeof bytes === 'string') { + this.bytes = Decimal128.fromString(bytes).bytes; + } + else if (isUint8Array(bytes)) { + if (bytes.byteLength !== 16) { + throw new BSONTypeError('Decimal128 must take a Buffer of 16 bytes'); + } + this.bytes = bytes; + } + else { + throw new BSONTypeError('Decimal128 must take a Buffer or string'); + } + } + /** + * Create a Decimal128 instance from a string representation + * + * @param representation - a numeric string representation. + */ + Decimal128.fromString = function (representation) { + // 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 = new Long(0, 0); + // The low 17 digits of the significand + var significandLow = new Long(0, 0); + // The biased exponent + var biasedExponent = 0; + // Read index + var index = 0; + // Naively prevent against REDOS attacks. + // TODO: implementing a custom parsing for this, or refactoring the regex would yield + // further gains. + if (representation.length >= 7000) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + // Results + var stringMatch = representation.match(PARSE_STRING_REGEXP); + var infMatch = representation.match(PARSE_INF_REGEXP); + var nanMatch = representation.match(PARSE_NAN_REGEXP); + // Validate the string + if ((!stringMatch && !infMatch && !nanMatch) || representation.length === 0) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + if (stringMatch) { + // full_match = stringMatch[0] + // sign = stringMatch[1] + var unsignedNumber = stringMatch[2]; + // stringMatch[3] is undefined if a whole number (ex "1", 12") + // but defined if a number w/ decimal in it (ex "1.0, 12.2") + var e = stringMatch[4]; + var expSign = stringMatch[5]; + var expNumber = stringMatch[6]; + // they provided e, but didn't give an exponent number. for ex "1e" + if (e && expNumber === undefined) + invalidErr(representation, 'missing exponent power'); + // they provided e, but didn't give a number before it. for ex "e1" + if (e && unsignedNumber === undefined) + invalidErr(representation, 'missing exponent base'); + if (e === undefined && (expSign || expNumber)) { + invalidErr(representation, 'missing e before exponent'); + } + } + // Get the negative or positive sign + if (representation[index] === '+' || representation[index] === '-') { + isNegative = representation[index++] === '-'; + } + // Check if user passed Infinity or NaN + if (!isDigit(representation[index]) && representation[index] !== '.') { + if (representation[index] === 'i' || representation[index] === 'I') { + return new Decimal128(buffer_1.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + else if (representation[index] === 'N') { + return new Decimal128(buffer_1.from(NAN_BUFFER)); + } + } + // Read all the digits + while (isDigit(representation[index]) || representation[index] === '.') { + if (representation[index] === '.') { + if (sawRadix) + invalidErr(representation, 'contains multiple periods'); + sawRadix = true; + index = index + 1; + continue; + } + if (nDigitsStored < 34) { + if (representation[index] !== '0' || foundNonZero) { + if (!foundNonZero) { + firstNonZero = nDigitsRead; + } + foundNonZero = true; + // Only store 34 digits + digits[digitsInsert++] = parseInt(representation[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 BSONTypeError('' + representation + ' not a valid Decimal128 string'); + // Read exponent if exists + if (representation[index] === 'e' || representation[index] === 'E') { + // Read exponent digits + var match = representation.substr(++index).match(EXPONENT_REGEX); + // No digits read + if (!match || !match[2]) + return new Decimal128(buffer_1.from(NAN_BUFFER)); + // Get exponent + exponent = parseInt(match[0], 10); + // Adjust the index + index = index + match[0].length; + } + // Return not a number + if (representation[index]) + return new Decimal128(buffer_1.from(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 (significantDigits !== 1) { + while (digits[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; + } + invalidErr(representation, 'overflow'); + } + exponent = exponent - 1; + } + while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { + // Shift last digit. can only do this if < significant digits than # stored. + if (lastDigit === 0 && significantDigits < nDigitsStored) { + 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 + var digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } + invalidErr(representation, 'overflow'); + } + } + // Round + // We've normalized the exponent, but might still need to round. + if (lastDigit - firstDigit + 1 < significantDigits) { + 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) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + // if negative, we need to increment again to account for - sign at start. + if (isNegative) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + var roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10); + var roundBit = 0; + if (roundDigit >= 5) { + roundBit = 1; + if (roundDigit === 5) { + roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0; + for (i = firstNonZero + lastDigit + 2; i < endOfString; i++) { + if (parseInt(representation[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(buffer_1.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + } + } + } + } + // 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) { + var 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 { + var 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(1))) { + // 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 = buffer_1.alloc(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); + }; + /** Create a string representation of the raw Decimal128 value */ + Decimal128.prototype.toString = function () { + // Note: bits in this routine are referred to starting at 0, + // from the sign bit, towards the coefficient. + // 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; + // true if the number is zero + var is_zero = false; + // the most significant significand bits (50-46) + var significand_msb; + // temporary storage for significand decoding + var significand128 = { parts: [0, 0, 0, 0] }; + // indexing variables + var j, k; + // Output string + var string = []; + // Unpack index + index = 0; + // Buffer reference + var buffer = this.bytes; + // Unpack the low 64bits into a long + // bits 96 - 127 + var low = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 64 - 95 + var midl = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // Unpack the high 64bits into a long + // bits 32 - 63 + var midh = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 0 - 31 + var 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 + // bits 1 - 5 + var 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; + } + // unbiased exponent + var 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; + // Perform 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; + while (!significand[index]) { + significand_digits = significand_digits - 1; + index = index + 1; + } + } + // the exponent if scientific notation is used + var 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 + // if there are too many significant digits, we should just be treating numbers + // as + or - 0 and using the non-scientific exponent (this is for the "invalid + // representation should be treated as 0/-0" spec cases in decimal128-1.json) + if (significand_digits > 34) { + string.push("".concat(0)); + if (exponent > 0) + string.push("E+".concat(exponent)); + else if (exponent < 0) + string.push("E".concat(exponent)); + return string.join(''); + } + string.push("".concat(significand[index++])); + significand_digits = significand_digits - 1; + if (significand_digits) { + string.push('.'); + } + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + // Exponent + string.push('E'); + if (scientific_exponent > 0) { + string.push("+".concat(scientific_exponent)); + } + else { + string.push("".concat(scientific_exponent)); + } + } + else { + // Regular format with no decimal place + if (exponent >= 0) { + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + } + else { + var radix_position = significand_digits + exponent; + // non-zero digits before radix + if (radix_position > 0) { + for (var i = 0; i < radix_position; i++) { + string.push("".concat(significand[index++])); + } + } + else { + string.push('0'); + } + string.push('.'); + // add leading zeros after radix + while (radix_position++ < 0) { + string.push('0'); + } + for (var i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) { + string.push("".concat(significand[index++])); + } + } + } + return string.join(''); + }; + Decimal128.prototype.toJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.prototype.toExtendedJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.fromExtendedJSON = function (doc) { + return Decimal128.fromString(doc.$numberDecimal); + }; + /** @internal */ + Decimal128.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Decimal128.prototype.inspect = function () { + return "new Decimal128(\"".concat(this.toString(), "\")"); + }; + return Decimal128; + }()); + Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' }); + + /** + * A class representation of the BSON Double type. + * @public + * @category BSONType + */ + var Double = /** @class */ (function () { + /** + * Create a Double type + * + * @param value - the number we want to represent as a double. + */ + function Double(value) { + if (!(this instanceof Double)) + return new Double(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value; + } + /** + * Access the number value. + * + * @returns returns the wrapped double number. + */ + Double.prototype.valueOf = function () { + return this.value; + }; + Double.prototype.toJSON = function () { + return this.value; + }; + Double.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + /** @internal */ + Double.prototype.toExtendedJSON = function (options) { + if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) { + return this.value; + } + // NOTE: JavaScript has +0 and -0, apparently to model limit calculations. If a user + // explicitly provided `-0` then we need to ensure the sign makes it into the output + if (Object.is(Math.sign(this.value), -0)) { + return { $numberDouble: "-".concat(this.value.toFixed(1)) }; + } + var $numberDouble; + if (Number.isInteger(this.value)) { + $numberDouble = this.value.toFixed(1); + if ($numberDouble.length >= 13) { + $numberDouble = this.value.toExponential(13).toUpperCase(); + } + } + else { + $numberDouble = this.value.toString(); + } + return { $numberDouble: $numberDouble }; + }; + /** @internal */ + Double.fromExtendedJSON = function (doc, options) { + var doubleValue = parseFloat(doc.$numberDouble); + return options && options.relaxed ? doubleValue : new Double(doubleValue); + }; + /** @internal */ + Double.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Double.prototype.inspect = function () { + var eJSON = this.toExtendedJSON(); + return "new Double(".concat(eJSON.$numberDouble, ")"); + }; + return Double; + }()); + Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' }); + + /** + * A class representation of a BSON Int32 type. + * @public + * @category BSONType + */ + var Int32 = /** @class */ (function () { + /** + * Create an Int32 type + * + * @param value - the number we want to represent as an int32. + */ + function Int32(value) { + if (!(this instanceof Int32)) + return new Int32(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value | 0; + } + /** + * Access the number value. + * + * @returns returns the wrapped int32 number. + */ + Int32.prototype.valueOf = function () { + return this.value; + }; + Int32.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + Int32.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + Int32.prototype.toExtendedJSON = function (options) { + if (options && (options.relaxed || options.legacy)) + return this.value; + return { $numberInt: this.value.toString() }; + }; + /** @internal */ + Int32.fromExtendedJSON = function (doc, options) { + return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new Int32(doc.$numberInt); + }; + /** @internal */ + Int32.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Int32.prototype.inspect = function () { + return "new Int32(".concat(this.valueOf(), ")"); + }; + return Int32; + }()); + Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' }); + + /** + * A class representation of the BSON MaxKey type. + * @public + * @category BSONType + */ + var MaxKey = /** @class */ (function () { + function MaxKey() { + if (!(this instanceof MaxKey)) + return new MaxKey(); + } + /** @internal */ + MaxKey.prototype.toExtendedJSON = function () { + return { $maxKey: 1 }; + }; + /** @internal */ + MaxKey.fromExtendedJSON = function () { + return new MaxKey(); + }; + /** @internal */ + MaxKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MaxKey.prototype.inspect = function () { + return 'new MaxKey()'; + }; + return MaxKey; + }()); + Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' }); + + /** + * A class representation of the BSON MinKey type. + * @public + * @category BSONType + */ + var MinKey = /** @class */ (function () { + function MinKey() { + if (!(this instanceof MinKey)) + return new MinKey(); + } + /** @internal */ + MinKey.prototype.toExtendedJSON = function () { + return { $minKey: 1 }; + }; + /** @internal */ + MinKey.fromExtendedJSON = function () { + return new MinKey(); + }; + /** @internal */ + MinKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MinKey.prototype.inspect = function () { + return 'new MinKey()'; + }; + return MinKey; + }()); + Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' }); + + // Regular expression that checks for hex value + var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$'); + // Unique sequence for the current process (initialized on first use) + var PROCESS_UNIQUE = null; + var kId = Symbol('id'); + /** + * A class representation of the BSON ObjectId type. + * @public + * @category BSONType + */ + var ObjectId = /** @class */ (function () { + /** + * Create an ObjectId type + * + * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number. + */ + function ObjectId(inputId) { + if (!(this instanceof ObjectId)) + return new ObjectId(inputId); + // workingId is set based on type of input and whether valid id exists for the input + var workingId; + if (typeof inputId === 'object' && inputId && 'id' in inputId) { + if (typeof inputId.id !== 'string' && !ArrayBuffer.isView(inputId.id)) { + throw new BSONTypeError('Argument passed in must have an id that is of type string or Buffer'); + } + if ('toHexString' in inputId && typeof inputId.toHexString === 'function') { + workingId = buffer_1.from(inputId.toHexString(), 'hex'); + } + else { + workingId = inputId.id; + } + } + else { + workingId = inputId; + } + // the following cases use workingId to construct an ObjectId + if (workingId == null || typeof workingId === 'number') { + // The most common use case (blank id, new objectId instance) + // Generate a new id + this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined); + } + else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) { + // If intstanceof matches we can escape calling ensure buffer in Node.js environments + this[kId] = workingId instanceof buffer_1 ? workingId : ensureBuffer(workingId); + } + else if (typeof workingId === 'string') { + if (workingId.length === 12) { + var bytes = buffer_1.from(workingId); + if (bytes.byteLength === 12) { + this[kId] = bytes; + } + else { + throw new BSONTypeError('Argument passed in must be a string of 12 bytes'); + } + } + else if (workingId.length === 24 && checkForHexRegExp.test(workingId)) { + this[kId] = buffer_1.from(workingId, 'hex'); + } + else { + throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer'); + } + } + else { + throw new BSONTypeError('Argument passed in does not match the accepted types'); + } + // If we are caching the hex string + if (ObjectId.cacheHexString) { + this.__id = this.id.toString('hex'); + } + } + Object.defineProperty(ObjectId.prototype, "id", { + /** + * The ObjectId bytes + * @readonly + */ + get: function () { + return this[kId]; + }, + set: function (value) { + this[kId] = value; + if (ObjectId.cacheHexString) { + this.__id = value.toString('hex'); + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(ObjectId.prototype, "generationTime", { + /** + * The generation time of this ObjectId instance + * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch + */ + get: function () { + return this.id.readInt32BE(0); + }, + set: function (value) { + // Encode time into first 4 bytes + this.id.writeUInt32BE(value, 0); + }, + enumerable: false, + configurable: true + }); + /** Returns the ObjectId id as a 24 character hex string representation */ + ObjectId.prototype.toHexString = function () { + if (ObjectId.cacheHexString && this.__id) { + return this.__id; + } + var hexString = this.id.toString('hex'); + if (ObjectId.cacheHexString && !this.__id) { + this.__id = hexString; + } + return hexString; + }; + /** + * Update the ObjectId index + * @privateRemarks + * Used in generating new ObjectId's on the driver + * @internal + */ + ObjectId.getInc = function () { + return (ObjectId.index = (ObjectId.index + 1) % 0xffffff); + }; + /** + * Generate a 12 byte id buffer used in ObjectId's + * + * @param time - pass in a second based timestamp. + */ + ObjectId.generate = function (time) { + if ('number' !== typeof time) { + time = Math.floor(Date.now() / 1000); + } + var inc = ObjectId.getInc(); + var buffer = buffer_1.alloc(12); + // 4-byte timestamp + buffer.writeUInt32BE(time, 0); + // set PROCESS_UNIQUE if yet not initialized + if (PROCESS_UNIQUE === null) { + PROCESS_UNIQUE = randomBytes(5); + } + // 5-byte process unique + buffer[4] = PROCESS_UNIQUE[0]; + buffer[5] = PROCESS_UNIQUE[1]; + buffer[6] = PROCESS_UNIQUE[2]; + buffer[7] = PROCESS_UNIQUE[3]; + buffer[8] = PROCESS_UNIQUE[4]; + // 3-byte counter + buffer[11] = inc & 0xff; + buffer[10] = (inc >> 8) & 0xff; + buffer[9] = (inc >> 16) & 0xff; + return buffer; + }; + /** + * Converts the id into a 24 character hex string for printing + * + * @param format - The Buffer toString format parameter. + */ + ObjectId.prototype.toString = function (format) { + // Is the id a buffer then use the buffer toString method to return the format + if (format) + return this.id.toString(format); + return this.toHexString(); + }; + /** Converts to its JSON the 24 character hex string representation. */ + ObjectId.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this ObjectId with `otherID`. + * + * @param otherId - ObjectId instance to compare against. + */ + ObjectId.prototype.equals = function (otherId) { + if (otherId === undefined || otherId === null) { + return false; + } + if (otherId instanceof ObjectId) { + return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]); + } + if (typeof otherId === 'string' && + ObjectId.isValid(otherId) && + otherId.length === 12 && + isUint8Array(this.id)) { + return otherId === buffer_1.prototype.toString.call(this.id, 'latin1'); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 24) { + return otherId.toLowerCase() === this.toHexString(); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 12) { + return buffer_1.from(otherId).equals(this.id); + } + if (typeof otherId === 'object' && + 'toHexString' in otherId && + typeof otherId.toHexString === 'function') { + var otherIdString = otherId.toHexString(); + var thisIdString = this.toHexString().toLowerCase(); + return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString; + } + return false; + }; + /** Returns the generation date (accurate up to the second) that this ID was generated. */ + ObjectId.prototype.getTimestamp = function () { + var timestamp = new Date(); + var time = this.id.readUInt32BE(0); + timestamp.setTime(Math.floor(time) * 1000); + return timestamp; + }; + /** @internal */ + ObjectId.createPk = function () { + 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. + * + * @param time - an integer number representing a number of seconds. + */ + ObjectId.createFromTime = function (time) { + var buffer = buffer_1.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Encode time into first 4 bytes + buffer.writeUInt32BE(time, 0); + // Return the new objectId + return new ObjectId(buffer); + }; + /** + * Creates an ObjectId from a hex string representation of an ObjectId. + * + * @param hexString - create a ObjectId from a passed in 24 character hexstring. + */ + ObjectId.createFromHexString = function (hexString) { + // Throw an error if it's not a valid setup + if (typeof hexString === 'undefined' || (hexString != null && hexString.length !== 24)) { + throw new BSONTypeError('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'); + } + return new ObjectId(buffer_1.from(hexString, 'hex')); + }; + /** + * Checks if a value is a valid bson ObjectId + * + * @param id - ObjectId instance to validate. + */ + ObjectId.isValid = function (id) { + if (id == null) + return false; + try { + new ObjectId(id); + return true; + } + catch (_a) { + return false; + } + }; + /** @internal */ + ObjectId.prototype.toExtendedJSON = function () { + if (this.toHexString) + return { $oid: this.toHexString() }; + return { $oid: this.toString('hex') }; + }; + /** @internal */ + ObjectId.fromExtendedJSON = function (doc) { + return new ObjectId(doc.$oid); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 24 character hex string representation. + * @internal + */ + ObjectId.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + ObjectId.prototype.inspect = function () { + return "new ObjectId(\"".concat(this.toHexString(), "\")"); + }; + /** @internal */ + ObjectId.index = Math.floor(Math.random() * 0xffffff); + return ObjectId; + }()); + // Deprecated methods + Object.defineProperty(ObjectId.prototype, 'generate', { + value: deprecate(function (time) { return ObjectId.generate(time); }, 'Please use the static `ObjectId.generate(time)` instead') + }); + Object.defineProperty(ObjectId.prototype, 'getInc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') + }); + Object.defineProperty(ObjectId.prototype, 'get_inc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') + }); + Object.defineProperty(ObjectId, 'get_inc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') + }); + Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' }); + + function alphabetize(str) { + return str.split('').sort().join(''); + } + /** + * A class representation of the BSON RegExp type. + * @public + * @category BSONType + */ + var BSONRegExp = /** @class */ (function () { + /** + * @param pattern - The regular expression pattern to match + * @param options - The regular expression options + */ + function BSONRegExp(pattern, options) { + if (!(this instanceof BSONRegExp)) + return new BSONRegExp(pattern, options); + this.pattern = pattern; + this.options = alphabetize(options !== null && options !== void 0 ? options : ''); + if (this.pattern.indexOf('\x00') !== -1) { + throw new BSONError("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern))); + } + if (this.options.indexOf('\x00') !== -1) { + throw new BSONError("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.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 BSONError("The regular expression option [".concat(this.options[i], "] is not supported")); + } + } + } + BSONRegExp.parseOptions = function (options) { + return options ? options.split('').sort().join('') : ''; + }; + /** @internal */ + BSONRegExp.prototype.toExtendedJSON = function (options) { + options = options || {}; + if (options.legacy) { + return { $regex: this.pattern, $options: this.options }; + } + return { $regularExpression: { pattern: this.pattern, options: this.options } }; + }; + /** @internal */ + BSONRegExp.fromExtendedJSON = function (doc) { + if ('$regex' in doc) { + if (typeof doc.$regex !== 'string') { + // This is for $regex query operators that have extended json values. + if (doc.$regex._bsontype === 'BSONRegExp') { + return doc; + } + } + else { + return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options)); + } + } + if ('$regularExpression' in doc) { + return new BSONRegExp(doc.$regularExpression.pattern, BSONRegExp.parseOptions(doc.$regularExpression.options)); + } + throw new BSONTypeError("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(doc))); + }; + return BSONRegExp; + }()); + Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' }); + + /** + * A class representation of the BSON Symbol type. + * @public + * @category BSONType + */ + var BSONSymbol = /** @class */ (function () { + /** + * @param value - the string representing the symbol. + */ + function BSONSymbol(value) { + if (!(this instanceof BSONSymbol)) + return new BSONSymbol(value); + this.value = value; + } + /** Access the wrapped string value. */ + BSONSymbol.prototype.valueOf = function () { + return this.value; + }; + BSONSymbol.prototype.toString = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.inspect = function () { + return "new BSONSymbol(\"".concat(this.value, "\")"); + }; + BSONSymbol.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.toExtendedJSON = function () { + return { $symbol: this.value }; + }; + /** @internal */ + BSONSymbol.fromExtendedJSON = function (doc) { + return new BSONSymbol(doc.$symbol); + }; + /** @internal */ + BSONSymbol.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + return BSONSymbol; + }()); + Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' }); + + /** @public */ + var LongWithoutOverridesClass = Long; + /** + * @public + * @category BSONType + * */ + var Timestamp = /** @class */ (function (_super) { + __extends(Timestamp, _super); + function Timestamp(low, high) { + var _this = this; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + if (!(_this instanceof Timestamp)) + return new Timestamp(low, high); + if (Long.isLong(low)) { + _this = _super.call(this, low.low, low.high, true) || this; + } + else if (isObjectLike(low) && typeof low.t !== 'undefined' && typeof low.i !== 'undefined') { + _this = _super.call(this, low.i, low.t, true) || this; + } + else { + _this = _super.call(this, low, high, true) || this; + } + Object.defineProperty(_this, '_bsontype', { + value: 'Timestamp', + writable: false, + configurable: false, + enumerable: false + }); + return _this; + } + Timestamp.prototype.toJSON = function () { + return { + $timestamp: this.toString() + }; + }; + /** Returns a Timestamp represented by the given (32-bit) integer value. */ + Timestamp.fromInt = function (value) { + return new Timestamp(Long.fromInt(value, true)); + }; + /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */ + Timestamp.fromNumber = function (value) { + return new Timestamp(Long.fromNumber(value, true)); + }; + /** + * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits. + * + * @param lowBits - the low 32-bits. + * @param highBits - the high 32-bits. + */ + Timestamp.fromBits = function (lowBits, highBits) { + return new Timestamp(lowBits, highBits); + }; + /** + * Returns a Timestamp from the given string, optionally using the given radix. + * + * @param str - the textual representation of the Timestamp. + * @param optRadix - the radix in which the text is written. + */ + Timestamp.fromString = function (str, optRadix) { + return new Timestamp(Long.fromString(str, true, optRadix)); + }; + /** @internal */ + Timestamp.prototype.toExtendedJSON = function () { + return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } }; + }; + /** @internal */ + Timestamp.fromExtendedJSON = function (doc) { + return new Timestamp(doc.$timestamp); + }; + /** @internal */ + Timestamp.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Timestamp.prototype.inspect = function () { + return "new Timestamp({ t: ".concat(this.getHighBits(), ", i: ").concat(this.getLowBits(), " })"); + }; + Timestamp.MAX_VALUE = Long.MAX_UNSIGNED_VALUE; + return Timestamp; + }(LongWithoutOverridesClass)); + + function isBSONType(value) { + return (isObjectLike(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string'); + } + // INT32 boundaries + var BSON_INT32_MAX = 0x7fffffff; + var BSON_INT32_MIN = -0x80000000; + // INT64 boundaries + // const BSON_INT64_MAX = 0x7fffffffffffffff; // TODO(NODE-4377): This number cannot be precisely represented in JS + var BSON_INT64_MAX = 0x8000000000000000; + var BSON_INT64_MIN = -0x8000000000000000; + // all the types where we don't need to do any special processing and can just pass the EJSON + //straight to type.fromExtendedJSON + var keysToCodecs = { + $oid: ObjectId, + $binary: Binary, + $uuid: Binary, + $symbol: BSONSymbol, + $numberInt: Int32, + $numberDecimal: Decimal128, + $numberDouble: Double, + $numberLong: Long, + $minKey: MinKey, + $maxKey: MaxKey, + $regex: BSONRegExp, + $regularExpression: BSONRegExp, + $timestamp: Timestamp + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function deserializeValue(value, options) { + if (options === void 0) { options = {}; } + if (typeof value === 'number') { + if (options.relaxed || options.legacy) { + return value; + } + // if it's an integer, should interpret as smallest BSON integer + // that can represent it exactly. (if out of range, interpret as double.) + if (Math.floor(value) === value) { + if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) + return new Int32(value); + if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) + return Long.fromNumber(value); + } + // If the number is a non-integer or out of integer range, should interpret as BSON Double. + return new Double(value); + } + // from here on out we're looking for bson types, so bail if its not an object + if (value == null || typeof value !== 'object') + return value; + // upgrade deprecated undefined to null + if (value.$undefined) + return null; + var keys = Object.keys(value).filter(function (k) { return k.startsWith('$') && value[k] != null; }); + for (var i = 0; i < keys.length; i++) { + var c = keysToCodecs[keys[i]]; + if (c) + return c.fromExtendedJSON(value, options); + } + if (value.$date != null) { + var d = value.$date; + var date = new Date(); + if (options.legacy) { + if (typeof d === 'number') + date.setTime(d); + else if (typeof d === 'string') + date.setTime(Date.parse(d)); + } + else { + if (typeof d === 'string') + date.setTime(Date.parse(d)); + else if (Long.isLong(d)) + date.setTime(d.toNumber()); + else if (typeof d === 'number' && options.relaxed) + date.setTime(d); + } + return date; + } + if (value.$code != null) { + var copy = Object.assign({}, value); + if (value.$scope) { + copy.$scope = deserializeValue(value.$scope); + } + return Code.fromExtendedJSON(value); + } + if (isDBRefLike(value) || value.$dbPointer) { + var v = value.$ref ? value : value.$dbPointer; + // we run into this in a "degenerate EJSON" case (with $id and $ref order flipped) + // because of the order JSON.parse goes through the document + if (v instanceof DBRef) + return v; + var dollarKeys = Object.keys(v).filter(function (k) { return k.startsWith('$'); }); + var valid_1 = true; + dollarKeys.forEach(function (k) { + if (['$ref', '$id', '$db'].indexOf(k) === -1) + valid_1 = false; + }); + // only make DBRef if $ keys are all valid + if (valid_1) + return DBRef.fromExtendedJSON(v); + } + return value; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function serializeArray(array, options) { + return array.map(function (v, index) { + options.seenObjects.push({ propertyName: "index ".concat(index), obj: null }); + try { + return serializeValue(v, options); + } + finally { + options.seenObjects.pop(); + } + }); + } + function getISOString(date) { + var isoStr = date.toISOString(); + // we should only show milliseconds in timestamp if they're non-zero + return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + 'Z'; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function serializeValue(value, options) { + if ((typeof value === 'object' || typeof value === 'function') && value !== null) { + var index = options.seenObjects.findIndex(function (entry) { return entry.obj === value; }); + if (index !== -1) { + var props = options.seenObjects.map(function (entry) { return entry.propertyName; }); + var leadingPart = props + .slice(0, index) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var alreadySeen = props[index]; + var circularPart = ' -> ' + + props + .slice(index + 1, props.length - 1) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var current = props[props.length - 1]; + var leadingSpace = ' '.repeat(leadingPart.length + alreadySeen.length / 2); + var dashes = '-'.repeat(circularPart.length + (alreadySeen.length + current.length) / 2 - 1); + throw new BSONTypeError('Converting circular structure to EJSON:\n' + + " ".concat(leadingPart).concat(alreadySeen).concat(circularPart).concat(current, "\n") + + " ".concat(leadingSpace, "\\").concat(dashes, "/")); + } + options.seenObjects[options.seenObjects.length - 1].obj = value; + } + if (Array.isArray(value)) + return serializeArray(value, options); + if (value === undefined) + return null; + if (value instanceof Date || isDate(value)) { + var dateNum = value.getTime(), + // is it in year range 1970-9999? + inRange = dateNum > -1 && dateNum < 253402318800000; + if (options.legacy) { + return options.relaxed && inRange + ? { $date: value.getTime() } + : { $date: getISOString(value) }; + } + return options.relaxed && inRange + ? { $date: getISOString(value) } + : { $date: { $numberLong: value.getTime().toString() } }; + } + if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) { + // it's an integer + if (Math.floor(value) === value) { + var int32Range = value >= BSON_INT32_MIN && value <= BSON_INT32_MAX, int64Range = value >= BSON_INT64_MIN && value <= BSON_INT64_MAX; + // interpret as being of the smallest BSON integer type that can represent the number exactly + if (int32Range) + return { $numberInt: value.toString() }; + if (int64Range) + return { $numberLong: value.toString() }; + } + return { $numberDouble: value.toString() }; + } + if (value instanceof RegExp || isRegExp(value)) { + var flags = value.flags; + if (flags === undefined) { + var match = value.toString().match(/[gimuy]*$/); + if (match) { + flags = match[0]; + } + } + var rx = new BSONRegExp(value.source, flags); + return rx.toExtendedJSON(options); + } + if (value != null && typeof value === 'object') + return serializeDocument(value, options); + return value; + } + var BSON_TYPE_MAPPINGS = { + Binary: function (o) { return new Binary(o.value(), o.sub_type); }, + Code: function (o) { return new Code(o.code, o.scope); }, + DBRef: function (o) { return new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields); }, + Decimal128: function (o) { return new Decimal128(o.bytes); }, + Double: function (o) { return new Double(o.value); }, + Int32: function (o) { return new Int32(o.value); }, + Long: function (o) { + return Long.fromBits( + // underscore variants for 1.x backwards compatibility + o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_); + }, + MaxKey: function () { return new MaxKey(); }, + MinKey: function () { return new MinKey(); }, + ObjectID: function (o) { return new ObjectId(o); }, + ObjectId: function (o) { return new ObjectId(o); }, + BSONRegExp: function (o) { return new BSONRegExp(o.pattern, o.options); }, + Symbol: function (o) { return new BSONSymbol(o.value); }, + Timestamp: function (o) { return Timestamp.fromBits(o.low, o.high); } + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function serializeDocument(doc, options) { + if (doc == null || typeof doc !== 'object') + throw new BSONError('not an object instance'); + var bsontype = doc._bsontype; + if (typeof bsontype === 'undefined') { + // It's a regular object. Recursively serialize its property values. + var _doc = {}; + for (var name in doc) { + options.seenObjects.push({ propertyName: name, obj: null }); + try { + var value = serializeValue(doc[name], options); + if (name === '__proto__') { + Object.defineProperty(_doc, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + _doc[name] = value; + } + } + finally { + options.seenObjects.pop(); + } + } + return _doc; + } + else if (isBSONType(doc)) { + // the "document" is really just a BSON type object + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var outDoc = doc; + if (typeof outDoc.toExtendedJSON !== 'function') { + // There's no EJSON serialization function on the object. It's probably an + // object created by a previous version of this library (or another library) + // that's duck-typing objects to look like they were generated by this library). + // Copy the object into this library's version of that type. + var mapper = BSON_TYPE_MAPPINGS[doc._bsontype]; + if (!mapper) { + throw new BSONTypeError('Unrecognized or invalid _bsontype: ' + doc._bsontype); + } + outDoc = mapper(outDoc); + } + // Two BSON types may have nested objects that may need to be serialized too + if (bsontype === 'Code' && outDoc.scope) { + outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options)); + } + else if (bsontype === 'DBRef' && outDoc.oid) { + outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options)); + } + return outDoc.toExtendedJSON(options); + } + else { + throw new BSONError('_bsontype must be a string, but was: ' + typeof bsontype); + } + } + /** + * EJSON parse / stringify API + * @public + */ + // the namespace here is used to emulate `export * as EJSON from '...'` + // which as of now (sept 2020) api-extractor does not support + // eslint-disable-next-line @typescript-eslint/no-namespace + exports.EJSON = void 0; + (function (EJSON) { + /** + * Parse an Extended JSON string, constructing the JavaScript value or object described by that + * string. + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const text = '{ "int32": { "$numberInt": "10" } }'; + * + * // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } } + * console.log(EJSON.parse(text, { relaxed: false })); + * + * // prints { int32: 10 } + * console.log(EJSON.parse(text)); + * ``` + */ + function parse(text, options) { + var finalOptions = Object.assign({}, { relaxed: true, legacy: false }, options); + // relaxed implies not strict + if (typeof finalOptions.relaxed === 'boolean') + finalOptions.strict = !finalOptions.relaxed; + if (typeof finalOptions.strict === 'boolean') + finalOptions.relaxed = !finalOptions.strict; + return JSON.parse(text, function (key, value) { + if (key.indexOf('\x00') !== -1) { + throw new BSONError("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(key))); + } + return deserializeValue(value, finalOptions); + }); + } + EJSON.parse = parse; + /** + * Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer + * function is specified or optionally including only the specified properties if a replacer array + * is specified. + * + * @param value - The value to convert to extended JSON + * @param replacer - A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string + * @param space - A String or Number object that's used to insert white space into the output JSON string for readability purposes. + * @param options - Optional settings + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const Int32 = require('mongodb').Int32; + * const doc = { int32: new Int32(10) }; + * + * // prints '{"int32":{"$numberInt":"10"}}' + * console.log(EJSON.stringify(doc, { relaxed: false })); + * + * // prints '{"int32":10}' + * console.log(EJSON.stringify(doc)); + * ``` + */ + function stringify(value, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + replacer, space, options) { + if (space != null && typeof space === 'object') { + options = space; + space = 0; + } + if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) { + options = replacer; + replacer = undefined; + space = 0; + } + var serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, { + seenObjects: [{ propertyName: '(root)', obj: null }] + }); + var doc = serializeValue(value, serializeOptions); + return JSON.stringify(doc, replacer, space); + } + EJSON.stringify = stringify; + /** + * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object. + * + * @param value - The object to serialize + * @param options - Optional settings passed to the `stringify` function + */ + function serialize(value, options) { + options = options || {}; + return JSON.parse(stringify(value, options)); + } + EJSON.serialize = serialize; + /** + * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types + * + * @param ejson - The Extended JSON object to deserialize + * @param options - Optional settings passed to the parse method + */ + function deserialize(ejson, options) { + options = options || {}; + return parse(JSON.stringify(ejson), options); + } + EJSON.deserialize = deserialize; + })(exports.EJSON || (exports.EJSON = {})); + + /* eslint-disable @typescript-eslint/no-explicit-any */ + /** @public */ + exports.Map = void 0; + var bsonGlobal = getGlobal(); + if (bsonGlobal.Map) { + exports.Map = bsonGlobal.Map; + } + else { + // We will return a polyfill + exports.Map = /** @class */ (function () { + function Map(array) { + if (array === void 0) { 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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? [key, _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? _this._values[key].v : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + Object.defineProperty(Map.prototype, "size", { + get: function () { + return this._keys.length; + }, + enumerable: false, + configurable: true + }); + return Map; + }()); + } + + function calculateObjectSize$1(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 (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + object = object.toBSON(); + } + // Calculate size + for (var key in object) { + totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined); + } + } + return totalLength; + } + /** @internal */ + function calculateElement(name, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + value, serializeFunctions, isArray, ignoreUndefined) { + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (isArray === void 0) { isArray = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = false; } + // If we have toBSON defined, override the current object + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + switch (typeof value) { + case 'string': + return 1 + buffer_1.byteLength(name, 'utf8') + 1 + 4 + buffer_1.byteLength(value, 'utf8') + 1; + case 'number': + if (Math.floor(value) === value && + value >= JS_INT_MIN && + value <= JS_INT_MAX) { + if (value >= BSON_INT32_MIN$1 && value <= BSON_INT32_MAX$1) { + // 32 bit + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (4 + 1); + } + else { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + } + else { + // 64 bit + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + case 'undefined': + if (isArray || !ignoreUndefined) + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + 1; + return 0; + case 'boolean': + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (1 + 1); + case 'object': + if (value == null || value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + 1; + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (12 + 1); + } + else if (value instanceof Date || isDate(value)) { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + else if (ArrayBuffer.isView(value) || + value instanceof ArrayBuffer || + isAnyArrayBuffer(value)) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength); + } + else if (value['_bsontype'] === 'Long' || + value['_bsontype'] === 'Double' || + value['_bsontype'] === 'Timestamp') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + else if (value['_bsontype'] === 'Decimal128') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (16 + 1); + } + else if (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_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + buffer_1.byteLength(value.code.toString(), 'utf8') + + 1 + + calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined)); + } + else { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + buffer_1.byteLength(value.code.toString(), 'utf8') + + 1); + } + } + else if (value['_bsontype'] === 'Binary') { + var binary = value; + // Check what kind of subtype we have + if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + (binary.position + 1 + 4 + 1 + 4)); + } + else { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (binary.position + 1 + 4 + 1)); + } + } + else if (value['_bsontype'] === 'Symbol') { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + buffer_1.byteLength(value.value, 'utf8') + + 4 + + 1 + + 1); + } + else if (value['_bsontype'] === 'DBRef') { + // Set up correct object for serialization + var ordered_values = Object.assign({ + $ref: value.collection, + $id: value.oid + }, value.fields); + // Add db reference if it exists + if (value.db != null) { + ordered_values['$db'] = value.db; + } + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + calculateObjectSize$1(ordered_values, serializeFunctions, ignoreUndefined)); + } + else if (value instanceof RegExp || isRegExp(value)) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.byteLength(value.source, 'utf8') + + 1 + + (value.global ? 1 : 0) + + (value.ignoreCase ? 1 : 0) + + (value.multiline ? 1 : 0) + + 1); + } + else if (value['_bsontype'] === 'BSONRegExp') { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.byteLength(value.pattern, 'utf8') + + 1 + + buffer_1.byteLength(value.options, 'utf8') + + 1); + } + else { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + calculateObjectSize$1(value, serializeFunctions, ignoreUndefined) + + 1); + } + case 'function': + // WTF for 0.4.X where typeof /someregexp/ === 'function' + if (value instanceof RegExp || isRegExp(value) || String.call(value) === '[object RegExp]') { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.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_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + buffer_1.byteLength(normalizedFunctionString(value), 'utf8') + + 1 + + calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined)); + } + else if (serializeFunctions) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + buffer_1.byteLength(normalizedFunctionString(value), 'utf8') + + 1); + } + } + } + return 0; + } + + var FIRST_BIT = 0x80; + var FIRST_TWO_BITS = 0xc0; + var FIRST_THREE_BITS = 0xe0; + var FIRST_FOUR_BITS = 0xf0; + var FIRST_FIVE_BITS = 0xf8; + var TWO_BIT_CHAR = 0xc0; + var THREE_BIT_CHAR = 0xe0; + var FOUR_BIT_CHAR = 0xf0; + var CONTINUING_CHAR = 0x80; + /** + * Determines if the passed in bytes are valid utf8 + * @param bytes - An array of 8-bit bytes. Must be indexable and have length property + * @param start - The index to start validating + * @param end - The index to end validating + */ + function validateUtf8(bytes, start, end) { + var continuation = 0; + for (var i = start; i < end; i += 1) { + var byte = bytes[i]; + if (continuation) { + if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) { + return false; + } + continuation -= 1; + } + else if (byte & FIRST_BIT) { + if ((byte & FIRST_THREE_BITS) === TWO_BIT_CHAR) { + continuation = 1; + } + else if ((byte & FIRST_FOUR_BITS) === THREE_BIT_CHAR) { + continuation = 2; + } + else if ((byte & FIRST_FIVE_BITS) === FOUR_BIT_CHAR) { + continuation = 3; + } + else { + return false; + } + } + } + return !continuation; + } + + // Internal long versions + var JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX); + var JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN); + var functionCache = {}; + function deserialize$1(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); + if (size < 5) { + throw new BSONError("bson size must be >= 5, is ".concat(size)); + } + if (options.allowObjectSmallerThanBufferSize && buffer.length < size) { + throw new BSONError("buffer length ".concat(buffer.length, " must be >= bson size ").concat(size)); + } + if (!options.allowObjectSmallerThanBufferSize && buffer.length !== size) { + throw new BSONError("buffer length ".concat(buffer.length, " must === bson size ").concat(size)); + } + if (size + index > buffer.byteLength) { + throw new BSONError("(bson size ".concat(size, " + options.index ").concat(index, " must be <= buffer length ").concat(buffer.byteLength, ")")); + } + // Illegal end value + if (buffer[index + size - 1] !== 0) { + throw new BSONError("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 allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/; + function deserializeObject(buffer, index, options, isArray) { + if (isArray === void 0) { isArray = false; } + var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; + var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions']; + 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']; + // Ensures default validation option if none given + var validation = options.validation == null ? { utf8: true } : options.validation; + // Shows if global utf-8 validation is enabled or disabled + var globalUTFValidation = true; + // Reflects utf-8 validation setting regardless of global or specific key validation + var validationSetting; + // Set of keys either to enable or disable validation on + var utf8KeysSet = new Set(); + // Check for boolean uniformity and empty validation option + var utf8ValidatedKeys = validation.utf8; + if (typeof utf8ValidatedKeys === 'boolean') { + validationSetting = utf8ValidatedKeys; + } + else { + globalUTFValidation = false; + var utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function (key) { + return utf8ValidatedKeys[key]; + }); + if (utf8ValidationValues.length === 0) { + throw new BSONError('UTF-8 validation setting cannot be empty'); + } + if (typeof utf8ValidationValues[0] !== 'boolean') { + throw new BSONError('Invalid UTF-8 validation option, must specify boolean values'); + } + validationSetting = utf8ValidationValues[0]; + // Ensures boolean uniformity in utf-8 validation (all true or all false) + if (!utf8ValidationValues.every(function (item) { return item === validationSetting; })) { + throw new BSONError('Invalid UTF-8 validation option - keys must be all true or all false'); + } + } + // Add keys to set that will either be validated or not based on validationSetting + if (!globalUTFValidation) { + for (var _i = 0, _a = Object.keys(utf8ValidatedKeys); _i < _a.length; _i++) { + var key = _a[_i]; + utf8KeysSet.add(key); + } + } + // Set the start index + var startIndex = index; + // Validate that we have at least 4 bytes of buffer + if (buffer.length < 5) + throw new BSONError('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 BSONError('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; + var isPossibleDBRef = isArray ? false : null; + // While we have more left data left keep parsing + var dataview = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength); + 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.byteLength) + throw new BSONError('Bad BSON Document: illegal CString'); + // Represents the key + var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i); + // shouldValidateKey is true if the key should be validated, false otherwise + var shouldValidateKey = true; + if (globalUTFValidation || utf8KeysSet.has(name)) { + shouldValidateKey = validationSetting; + } + else { + shouldValidateKey = !validationSetting; + } + if (isPossibleDBRef !== false && name[0] === '$') { + isPossibleDBRef = allowedDBRefKeys.test(name); + } + var value = void 0; + index = i + 1; + if (elementType === 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 BSONError('bad string length in bson'); + } + value = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + index = index + stringSize; + } + else if (elementType === BSON_DATA_OID) { + var oid = buffer_1.alloc(12); + buffer.copy(oid, 0, index, index + 12); + value = new ObjectId(oid); + index = index + 12; + } + else if (elementType === BSON_DATA_INT && promoteValues === false) { + value = new Int32(buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24)); + } + else if (elementType === BSON_DATA_INT) { + value = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + } + else if (elementType === BSON_DATA_NUMBER && promoteValues === false) { + value = new Double(dataview.getFloat64(index, true)); + index = index + 8; + } + else if (elementType === BSON_DATA_NUMBER) { + value = dataview.getFloat64(index, true); + index = index + 8; + } + else if (elementType === 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); + value = new Date(new Long(lowBits, highBits).toNumber()); + } + else if (elementType === BSON_DATA_BOOLEAN) { + if (buffer[index] !== 0 && buffer[index] !== 1) + throw new BSONError('illegal boolean type value'); + value = buffer[index++] === 1; + } + else if (elementType === 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 BSONError('bad embedded document length in bson'); + // We have a raw value + if (raw) { + value = buffer.slice(index, index + objectSize); + } + else { + var objectOptions = options; + if (!globalUTFValidation) { + objectOptions = _assign(_assign({}, options), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, objectOptions, false); + } + index = index + objectSize; + } + else if (elementType === BSON_DATA_ARRAY) { + var _index = index; + var 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; + } + if (!globalUTFValidation) { + arrayOptions = _assign(_assign({}, arrayOptions), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, arrayOptions, true); + index = index + objectSize; + if (buffer[index - 1] !== 0) + throw new BSONError('invalid array terminator byte'); + if (index !== stopIndex) + throw new BSONError('corrupted array bson'); + } + else if (elementType === BSON_DATA_UNDEFINED) { + value = undefined; + } + else if (elementType === BSON_DATA_NULL) { + value = null; + } + else if (elementType === BSON_DATA_LONG) { + // Unpack the low and high bits + 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); + var long = new Long(lowBits, highBits); + // Promote the long if possible + if (promoteLongs && promoteValues === true) { + value = + long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) + ? long.toNumber() + : long; + } + else { + value = long; + } + } + else if (elementType === BSON_DATA_DECIMAL128) { + // Buffer to contain the decimal bytes + var bytes = buffer_1.alloc(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 + if ('toObject' in decimal128 && typeof decimal128.toObject === 'function') { + value = decimal128.toObject(); + } + else { + value = decimal128; + } + } + else if (elementType === 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 BSONError('Negative binary type element size found'); + // Is the length longer than the document + if (binarySize > buffer.byteLength) + throw new BSONError('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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + if (promoteBuffers && promoteValues) { + value = buffer.slice(index, index + binarySize); + } + else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) { + value = value.toUUID(); + } + } + } + else { + var _buffer = buffer_1.alloc(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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + // Copy the data + for (i = 0; i < binarySize; i++) { + _buffer[i] = buffer[index + i]; + } + if (promoteBuffers && promoteValues) { + value = _buffer; + } + else if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) { + value = new Binary(buffer.slice(index, index + binarySize), subType).toUUID(); + } + else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + } + } + // Update the index + index = index + binarySize; + } + else if (elementType === 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 BSONError('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 BSONError('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; + } + } + value = new RegExp(source, optionsArray.join('')); + } + else if (elementType === 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + // Set the object + value = new BSONRegExp(source, regExpOptions); + } + else if (elementType === BSON_DATA_SYMBOL) { + 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 BSONError('bad string length in bson'); + } + var symbol = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + value = promoteValues ? symbol : new BSONSymbol(symbol); + index = index + stringSize; + } + else if (elementType === BSON_DATA_TIMESTAMP) { + 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); + value = new Timestamp(lowBits, highBits); + } + else if (elementType === BSON_DATA_MIN_KEY) { + value = new MinKey(); + } + else if (elementType === BSON_DATA_MAX_KEY) { + value = new MaxKey(); + } + else if (elementType === BSON_DATA_CODE) { + 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 BSONError('bad string length in bson'); + } + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + } + else { + value = new Code(functionString); + } + // Update parse index position + index = index + stringSize; + } + else if (elementType === 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 BSONError('code_w_scope total size shorter minimum expected length'); + } + // Get the code string size + var 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 BSONError('bad string length in bson'); + } + // Javascript function + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // Update parse index position + index = index + stringSize; + // Parse the element + var _index = index; + // Decode the size of the object document + var 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 too short + if (totalSize < 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too short, truncating scope'); + } + // Check if totalSize field is too long + if (totalSize > 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + value.scope = scopeObject; + } + else { + value = new Code(functionString, scopeObject); + } + } + else if (elementType === BSON_DATA_DBPOINTER) { + // Get the code string size + var 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 BSONError('bad string length in bson'); + // Namespace + if (validation != null && validation.utf8) { + if (!validateUtf8(buffer, index, index + stringSize - 1)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + } + var namespace = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + // Read the oid + var oidBuffer = buffer_1.alloc(12); + buffer.copy(oidBuffer, 0, index, index + 12); + var oid = new ObjectId(oidBuffer); + // Update the index + index = index + 12; + // Upgrade to DBRef type + value = new DBRef(namespace, oid); + } + else { + throw new BSONError("Detected unknown BSON type ".concat(elementType.toString(16), " for fieldname \"").concat(name, "\"")); + } + if (name === '__proto__') { + Object.defineProperty(object, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + object[name] = value; + } + } + // Check if the deserialization was against a valid array/object + if (size !== index - startIndex) { + if (isArray) + throw new BSONError('corrupt array bson'); + throw new BSONError('corrupt object bson'); + } + // if we did not find "$ref", "$id", "$db", or found an extraneous $key, don't make a DBRef + if (!isPossibleDBRef) + return object; + if (isDBRefLike(object)) { + var copy = Object.assign({}, object); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(object.$ref, object.$id, object.$db, copy); + } + return object; + } + /** + * Ensure eval is isolated, store the result in functionCache. + * + * @internal + */ + function isolateEval(functionString, functionCache, object) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + if (!functionCache) + return new Function(functionString); + // Check for cache hit, eval if missing and return cached function + if (functionCache[functionString] == null) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + functionCache[functionString] = new Function(functionString); + } + // Set the object + return functionCache[functionString].bind(object); + } + function getValidatedString(buffer, start, end, shouldValidateUtf8) { + var value = buffer.toString('utf8', start, end); + // if utf8 validation is on, do the check + if (shouldValidateUtf8) { + for (var i = 0; i < value.length; i++) { + if (value.charCodeAt(i) === 0xfffd) { + if (!validateUtf8(buffer, start, end)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + break; + } + } + } + return value; + } + + var regexp = /\x00/; // eslint-disable-line no-control-regex + var ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']); + /* + * isArray indicates if we are writing to a BSON array (type 0x04) + * which forces the "key" which really an array index as a string to be written as ascii + * This will catch any errors in index as a string generation + */ + function serializeString(buffer, key, value, index, isArray) { + // Encode String type + buffer[index++] = BSON_DATA_STRING; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes + 1; + buffer[index - 1] = 0; + // Write the string + var size = buffer.write(value, index + 4, undefined, 'utf8'); + // Write the size of the string to buffer + buffer[index + 3] = ((size + 1) >> 24) & 0xff; + buffer[index + 2] = ((size + 1) >> 16) & 0xff; + buffer[index + 1] = ((size + 1) >> 8) & 0xff; + buffer[index] = (size + 1) & 0xff; + // Update index + index = index + 4 + size; + // Write zero + buffer[index++] = 0; + return index; + } + var SPACE_FOR_FLOAT64 = new Uint8Array(8); + var DV_FOR_FLOAT64 = new DataView(SPACE_FOR_FLOAT64.buffer, SPACE_FOR_FLOAT64.byteOffset, SPACE_FOR_FLOAT64.byteLength); + function serializeNumber(buffer, key, value, index, isArray) { + // We have an integer value + // TODO(NODE-2529): Add support for big int + if (Number.isInteger(value) && + value >= BSON_INT32_MIN$1 && + value <= BSON_INT32_MAX$1) { + // If the value fits in 32 bits encode as int32 + // Set int type 32 bits or less + buffer[index++] = BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + } + else { + // Encode as double + buffer[index++] = BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + } + return index; + } + function serializeNull(buffer, key, _, index, isArray) { + // Set long type + buffer[index++] = BSON_DATA_NULL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; + } + function serializeBoolean(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BOOLEAN; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Encode the boolean value + buffer[index++] = value ? 1 : 0; + return index; + } + function serializeDate(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_DATE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var dateInMilis = Long.fromNumber(value.getTime()); + var lowBits = dateInMilis.getLowBits(); + var highBits = dateInMilis.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; + } + function serializeRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + if (value.source && value.source.match(regexp) != null) { + throw Error('value ' + value.source + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.source, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the parameters + if (value.ignoreCase) + buffer[index++] = 0x69; // i + if (value.global) + buffer[index++] = 0x73; // s + if (value.multiline) + buffer[index++] = 0x6d; // m + // Add ending zero + buffer[index++] = 0x00; + return index; + } + function serializeBSONRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Check the pattern for 0 bytes + if (value.pattern.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('pattern ' + value.pattern + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.pattern, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the options + index = index + buffer.write(value.options.split('').sort().join(''), index, undefined, 'utf8'); + // Add ending zero + buffer[index++] = 0x00; + return index; + } + function serializeMinMax(buffer, key, value, index, isArray) { + // Write the type of either min or max key + if (value === null) { + buffer[index++] = BSON_DATA_NULL; + } + else if (value._bsontype === 'MinKey') { + buffer[index++] = BSON_DATA_MIN_KEY; + } + else { + buffer[index++] = BSON_DATA_MAX_KEY; + } + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; + } + function serializeObjectId(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_OID; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the objectId into the shared buffer + if (typeof value.id === 'string') { + buffer.write(value.id, index, undefined, 'binary'); + } + else if (isUint8Array(value.id)) { + // Use the standard JS methods here because buffer.copy() is buggy with the + // browser polyfill + buffer.set(value.id.subarray(0, 12), index); + } + else { + throw new BSONTypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId'); + } + // Adjust index + return index + 12; + } + function serializeBuffer(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Get size of the buffer (current write point) + var size = value.length; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the default subtype + buffer[index++] = BSON_BINARY_SUBTYPE_DEFAULT; + // Copy the content form the binary field to the buffer + buffer.set(ensureBuffer(value), index); + // Adjust the index + index = index + size; + return index; + } + function serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (path === void 0) { path = []; } + for (var i = 0; i < path.length; i++) { + if (path[i] === value) + throw new BSONError('cyclic dependency detected'); + } + // Push value to stack + path.push(value); + // Write the type + buffer[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var endIndex = serializeInto(buffer, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path); + // Pop stack + path.pop(); + return endIndex; + } + function serializeDecimal128(buffer, key, value, index, isArray) { + buffer[index++] = BSON_DATA_DECIMAL128; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the data from the value + // Prefer the standard JS methods because their typechecking is not buggy, + // unlike the `buffer` polyfill's. + buffer.set(value.bytes.subarray(0, 16), index); + return index + 16; + } + function serializeLong(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = + value._bsontype === 'Long' ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var lowBits = value.getLowBits(); + var highBits = value.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; + } + function serializeInt32(buffer, key, value, index, isArray) { + value = value.valueOf(); + // Set int type 32 bits or less + buffer[index++] = BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + return index; + } + function serializeDouble(buffer, key, value, index, isArray) { + // Encode as double + buffer[index++] = BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value.value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + return index; + } + function serializeFunction(buffer, key, value, index, _checkKeys, _depth, isArray) { + buffer[index++] = BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = normalizedFunctionString(value); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + return index; + } + function serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (value.scope && typeof value.scope === 'object') { + // Write the type + buffer[index++] = BSON_DATA_CODE_W_SCOPE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Starting index + var startIndex = index; + // Serialize the function + // Get the function string + var functionString = typeof value.code === 'string' ? value.code : value.code.toString(); + // Index adjustment + index = index + 4; + // Write string into buffer + var codeSize = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = codeSize & 0xff; + buffer[index + 1] = (codeSize >> 8) & 0xff; + buffer[index + 2] = (codeSize >> 16) & 0xff; + buffer[index + 3] = (codeSize >> 24) & 0xff; + // Write end 0 + buffer[index + 4 + codeSize - 1] = 0; + // Write the + index = index + codeSize + 4; + // + // Serialize the scope value + var endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined); + index = endIndex - 1; + // Writ the total + var totalSize = endIndex - startIndex; + // Write the total size of the object + buffer[startIndex++] = totalSize & 0xff; + buffer[startIndex++] = (totalSize >> 8) & 0xff; + buffer[startIndex++] = (totalSize >> 16) & 0xff; + buffer[startIndex++] = (totalSize >> 24) & 0xff; + // Write trailing zero + buffer[index++] = 0; + } + else { + buffer[index++] = BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = value.code.toString(); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + } + return index; + } + function serializeBinary(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Extract the buffer + var data = value.value(true); + // Calculate size + var size = value.position; + // Add the deprecated 02 type 4 bytes of size to total + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) + size = size + 4; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the subtype to the buffer + buffer[index++] = value.sub_type; + // If we have binary type 2 the 4 first bytes are the size + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + size = size - 4; + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + } + // Write the data to the object + buffer.set(data, index); + // Adjust the index + index = index + value.position; + return index; + } + function serializeSymbol(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_SYMBOL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the string + var size = buffer.write(value.value, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0x00; + return index; + } + function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, isArray) { + // Write the type + buffer[index++] = BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var startIndex = index; + var output = { + $ref: value.collection || value.namespace, + $id: value.oid + }; + if (value.db != null) { + output.$db = value.db; + } + output = Object.assign(output, value.fields); + var endIndex = serializeInto(buffer, output, false, index, depth + 1, serializeFunctions); + // Calculate object size + var size = endIndex - startIndex; + // Write the size + buffer[startIndex++] = size & 0xff; + buffer[startIndex++] = (size >> 8) & 0xff; + buffer[startIndex++] = (size >> 16) & 0xff; + buffer[startIndex++] = (size >> 24) & 0xff; + // Set index + return endIndex; + } + function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (startingIndex === void 0) { startingIndex = 0; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (path === void 0) { path = []; } + startingIndex = startingIndex || 0; + path = path || []; + // Push the object to the path + path.push(object); + // Start place to serialize into + var index = startingIndex + 4; + // Special case isArray + if (Array.isArray(object)) { + // Get object keys + for (var i = 0; i < object.length; i++) { + var key = "".concat(i); + var value = object[i]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + if (typeof value === 'string') { + index = serializeString(buffer, key, value, index, true); + } + else if (typeof value === 'number') { + index = serializeNumber(buffer, key, value, index, true); + } + else if (typeof value === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (typeof value === 'boolean') { + index = serializeBoolean(buffer, key, value, index, true); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index, true); + } + else if (value === undefined) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index, true); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index, true); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index, true); + } + else if (typeof value === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true, path); + } + else if (typeof value === 'object' && + isBSONType(value) && + value._bsontype === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index, true); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, true); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, true); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index, true); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else if (object instanceof exports.Map || isMap(object)) { + var iterator = object.entries(); + var done = false; + while (!done) { + // Unpack the next entry + var entry = iterator.next(); + done = !!entry.done; + // Are we done, then skip and terminate + if (done) + continue; + // Get the entry values + var key = entry.value[0]; + var value = entry.value[1]; + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint' || isBigInt64Array(value) || isBigUInt64Array(value)) { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === null || (value === undefined && ignoreUndefined === false)) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else { + if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + // Provided a custom serialization method + object = object.toBSON(); + if (object != null && typeof object !== 'object') { + throw new BSONTypeError('toBSON function did not return an object'); + } + } + // Iterate over all the keys + for (var key in object) { + var value = object[key]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === undefined) { + if (ignoreUndefined === false) + index = serializeNull(buffer, key, value, index); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + // Remove the path + path.pop(); + // Final padding byte for object + buffer[index++] = 0x00; + // Final size + var size = index - startingIndex; + // Write the size of the object + buffer[startingIndex++] = size & 0xff; + buffer[startingIndex++] = (size >> 8) & 0xff; + buffer[startingIndex++] = (size >> 16) & 0xff; + buffer[startingIndex++] = (size >> 24) & 0xff; + return index; + } + + /** @internal */ + // Default Max Size + var MAXSIZE = 1024 * 1024 * 17; + // Current Internal Temporary Serialization Buffer + var buffer = buffer_1.alloc(MAXSIZE); + /** + * Sets the size of the internal serialization buffer. + * + * @param size - The desired size for the internal serialization buffer + * @public + */ + function setInternalBufferSize(size) { + // Resize the internal serialization buffer if needed + if (buffer.length < size) { + buffer = buffer_1.alloc(size); + } + } + /** + * Serialize a Javascript object. + * + * @param object - the Javascript object to serialize. + * @returns Buffer object containing the serialized object. + * @public + */ + function serialize(object, options) { + if (options === void 0) { 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 = buffer_1.alloc(minInternalBufferSize); + } + // Attempt to serialize + var serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []); + // Create the final buffer + var finishedBuffer = buffer_1.alloc(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 - the Javascript object to serialize. + * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object. + * @returns the index pointing to the last written byte in the buffer. + * @public + */ + function serializeWithBufferAndIndex(object, finalBuffer, options) { + if (options === void 0) { 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 = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined); + buffer.copy(finalBuffer, startIndex, 0, serializationIndex); + // Return the index + return startIndex + serializationIndex - 1; + } + /** + * Deserialize data as BSON. + * + * @param buffer - the buffer containing the serialized set of BSON documents. + * @returns returns the deserialized Javascript Object. + * @public + */ + function deserialize(buffer, options) { + if (options === void 0) { options = {}; } + return deserialize$1(buffer instanceof buffer_1 ? buffer : ensureBuffer(buffer), options); + } + /** + * Calculate the bson size for a passed in Javascript object. + * + * @param object - the Javascript object to calculate the BSON byte size for + * @returns size of BSON object in bytes + * @public + */ + function calculateObjectSize(object, options) { + if (options === void 0) { options = {}; } + options = options || {}; + var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + return calculateObjectSize$1(object, serializeFunctions, ignoreUndefined); + } + /** + * Deserialize stream data as BSON documents. + * + * @param data - the buffer containing the serialized set of BSON documents. + * @param startIndex - the start index in the data Buffer where the deserialization is to start. + * @param numberOfDocuments - number of documents to deserialize. + * @param documents - an array where to store the deserialized documents. + * @param docStartIndex - the index in the documents array from where to start inserting documents. + * @param options - additional options used for the deserialization. + * @returns next index in the buffer after deserialization **x** numbers of documents. + * @public + */ + function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) { + var internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options); + var bufferData = ensureBuffer(data); + var index = startIndex; + // Loop over all documents + for (var i = 0; i < numberOfDocuments; i++) { + // Find size of the document + var size = bufferData[index] | + (bufferData[index + 1] << 8) | + (bufferData[index + 2] << 16) | + (bufferData[index + 3] << 24); + // Update options with index + internalOptions.index = index; + // Parse the document at this point + documents[docStartIndex + i] = deserialize$1(bufferData, internalOptions); + // Adjust index by the document size + index = index + size; + } + // Return object containing end index of parsing and list of documents + return index; + } + /** + * BSON default export + * @deprecated Please use named exports + * @privateRemarks + * We want to someday deprecate the default export, + * so none of the new TS types are being exported on the default + * @public + */ + var BSON = { + Binary: Binary, + Code: Code, + DBRef: DBRef, + Decimal128: Decimal128, + Double: Double, + Int32: Int32, + Long: Long, + UUID: UUID, + Map: exports.Map, + MaxKey: MaxKey, + MinKey: MinKey, + ObjectId: ObjectId, + ObjectID: ObjectId, + BSONRegExp: BSONRegExp, + BSONSymbol: BSONSymbol, + Timestamp: Timestamp, + EJSON: exports.EJSON, + setInternalBufferSize: setInternalBufferSize, + serialize: serialize, + serializeWithBufferAndIndex: serializeWithBufferAndIndex, + deserialize: deserialize, + calculateObjectSize: calculateObjectSize, + deserializeStream: deserializeStream, + BSONError: BSONError, + BSONTypeError: BSONTypeError + }; + + exports.BSONError = BSONError; + exports.BSONRegExp = BSONRegExp; + exports.BSONSymbol = BSONSymbol; + exports.BSONTypeError = BSONTypeError; + exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = BSON_BINARY_SUBTYPE_BYTE_ARRAY; + exports.BSON_BINARY_SUBTYPE_COLUMN = BSON_BINARY_SUBTYPE_COLUMN; + exports.BSON_BINARY_SUBTYPE_DEFAULT = BSON_BINARY_SUBTYPE_DEFAULT; + exports.BSON_BINARY_SUBTYPE_ENCRYPTED = BSON_BINARY_SUBTYPE_ENCRYPTED; + exports.BSON_BINARY_SUBTYPE_FUNCTION = BSON_BINARY_SUBTYPE_FUNCTION; + exports.BSON_BINARY_SUBTYPE_MD5 = BSON_BINARY_SUBTYPE_MD5; + exports.BSON_BINARY_SUBTYPE_USER_DEFINED = BSON_BINARY_SUBTYPE_USER_DEFINED; + exports.BSON_BINARY_SUBTYPE_UUID = BSON_BINARY_SUBTYPE_UUID; + exports.BSON_BINARY_SUBTYPE_UUID_NEW = BSON_BINARY_SUBTYPE_UUID_NEW; + exports.BSON_DATA_ARRAY = BSON_DATA_ARRAY; + exports.BSON_DATA_BINARY = BSON_DATA_BINARY; + exports.BSON_DATA_BOOLEAN = BSON_DATA_BOOLEAN; + exports.BSON_DATA_CODE = BSON_DATA_CODE; + exports.BSON_DATA_CODE_W_SCOPE = BSON_DATA_CODE_W_SCOPE; + exports.BSON_DATA_DATE = BSON_DATA_DATE; + exports.BSON_DATA_DBPOINTER = BSON_DATA_DBPOINTER; + exports.BSON_DATA_DECIMAL128 = BSON_DATA_DECIMAL128; + exports.BSON_DATA_INT = BSON_DATA_INT; + exports.BSON_DATA_LONG = BSON_DATA_LONG; + exports.BSON_DATA_MAX_KEY = BSON_DATA_MAX_KEY; + exports.BSON_DATA_MIN_KEY = BSON_DATA_MIN_KEY; + exports.BSON_DATA_NULL = BSON_DATA_NULL; + exports.BSON_DATA_NUMBER = BSON_DATA_NUMBER; + exports.BSON_DATA_OBJECT = BSON_DATA_OBJECT; + exports.BSON_DATA_OID = BSON_DATA_OID; + exports.BSON_DATA_REGEXP = BSON_DATA_REGEXP; + exports.BSON_DATA_STRING = BSON_DATA_STRING; + exports.BSON_DATA_SYMBOL = BSON_DATA_SYMBOL; + exports.BSON_DATA_TIMESTAMP = BSON_DATA_TIMESTAMP; + exports.BSON_DATA_UNDEFINED = BSON_DATA_UNDEFINED; + exports.BSON_INT32_MAX = BSON_INT32_MAX$1; + exports.BSON_INT32_MIN = BSON_INT32_MIN$1; + exports.BSON_INT64_MAX = BSON_INT64_MAX$1; + exports.BSON_INT64_MIN = BSON_INT64_MIN$1; + exports.Binary = Binary; + exports.Code = Code; + exports.DBRef = DBRef; + exports.Decimal128 = Decimal128; + exports.Double = Double; + exports.Int32 = Int32; + exports.Long = Long; + exports.LongWithoutOverridesClass = LongWithoutOverridesClass; + exports.MaxKey = MaxKey; + exports.MinKey = MinKey; + exports.ObjectID = ObjectId; + exports.ObjectId = ObjectId; + exports.Timestamp = Timestamp; + exports.UUID = UUID; + exports.calculateObjectSize = calculateObjectSize; + exports.default = BSON; + exports.deserialize = deserialize; + exports.deserializeStream = deserializeStream; + exports.serialize = serialize; + exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex; + exports.setInternalBufferSize = setInternalBufferSize; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=bson.browser.umd.js.map diff --git a/node_modules/bson/dist/bson.browser.umd.js.map b/node_modules/bson/dist/bson.browser.umd.js.map new file mode 100644 index 0000000..33c8431 --- /dev/null +++ b/node_modules/bson/dist/bson.browser.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bson.browser.umd.js","sources":["../node_modules/base64-js/index.js","../node_modules/ieee754/index.js","../node_modules/buffer/index.js","../node_modules/tslib/tslib.es6.js","../src/error.ts","../src/utils/global.ts","../src/parser/utils.ts","../src/ensure_buffer.ts","../src/uuid_utils.ts","../src/constants.ts","../src/binary.ts","../src/code.ts","../src/db_ref.ts","../src/long.ts","../src/decimal128.ts","../src/double.ts","../src/int_32.ts","../src/max_key.ts","../src/min_key.ts","../src/objectid.ts","../src/regexp.ts","../src/symbol.ts","../src/timestamp.ts","../src/extended_json.ts","../src/map.ts","../src/parser/calculate_size.ts","../src/validate_utf8.ts","../src/parser/deserializer.ts","../src/parser/serializer.ts","../src/bson.ts"],"sourcesContent":["'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar customInspectSymbol =\n (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nvar K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n var arr = new Uint8Array(1)\n var proto = { foo: function () { return 42 } }\n Object.setPrototypeOf(proto, Uint8Array.prototype)\n Object.setPrototypeOf(arr, proto)\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n var buf = new Uint8Array(length)\n Object.setPrototypeOf(buf, Buffer.prototype)\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayView(value)\n }\n\n if (value == null) {\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof SharedArrayBuffer !== 'undefined' &&\n (isInstance(value, SharedArrayBuffer) ||\n (value && isInstance(value.buffer, SharedArrayBuffer)))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n var valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n var b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(\n value[Symbol.toPrimitive]('string'), encodingOrOffset, length\n )\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)\nObject.setPrototypeOf(Buffer, Uint8Array)\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n var length = byteLength(string, encoding) | 0\n var buf = createBuffer(length)\n\n var actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n var buf = createBuffer(length)\n for (var i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayView (arrayView) {\n if (isInstance(arrayView, Uint8Array)) {\n var copy = new Uint8Array(arrayView)\n return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)\n }\n return fromArrayLike(arrayView)\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n var buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, Buffer.prototype)\n\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n var buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n Buffer.from(buf).copy(buffer, pos)\n } else {\n Uint8Array.prototype.set.call(\n buffer,\n buf,\n pos\n )\n }\n } else if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n } else {\n buf.copy(buffer, pos)\n }\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n var len = string.length\n var mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return ''\n}\nif (customInspectSymbol) {\n Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n var strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n case 'latin1':\n case 'binary':\n return asciiWrite(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF)\n ? 4\n : (firstByte > 0xDF)\n ? 3\n : (firstByte > 0xBF)\n ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += hexSliceLookupTable[buf[i]]\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for (var i = 0; i < bytes.length - 1; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, Buffer.prototype)\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUintLE =\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUintBE =\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUint8 =\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUint16LE =\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUint16BE =\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUint32LE =\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUint32BE =\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUintLE =\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUintBE =\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUint8 =\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUint16LE =\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUint16BE =\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUint32LE =\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUint32BE =\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n var limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n var limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n } else if (typeof val === 'boolean') {\n val = Number(val)\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n var len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nvar hexSliceLookupTable = (function () {\n var alphabet = '0123456789abcdef'\n var table = new Array(256)\n for (var i = 0; i < 16; ++i) {\n var i16 = i * 16\n for (var j = 0; j < 16; ++j) {\n table[i16 + j] = alphabet[i] + alphabet[j]\n }\n }\n return table\n})()\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["byteLength","toByteArray","fromByteArray","lookup","revLookup","Arr","Uint8Array","Array","code","i","len","length","charCodeAt","getLens","b64","Error","validLen","indexOf","placeHoldersLen","lens","_byteLength","tmp","arr","curByte","tripletToBase64","num","encodeChunk","uint8","start","end","output","push","join","extraBytes","parts","maxChunkLength","len2","buffer","offset","isLE","mLen","nBytes","e","m","eLen","eMax","eBias","nBits","d","s","NaN","Infinity","Math","pow","value","c","rt","abs","isNaN","floor","log","LN2","customInspectSymbol","Symbol","exports","Buffer","SlowBuffer","K_MAX_LENGTH","TYPED_ARRAY_SUPPORT","typedArraySupport","console","error","proto","foo","Object","setPrototypeOf","prototype","defineProperty","enumerable","get","isBuffer","undefined","byteOffset","createBuffer","RangeError","buf","arg","encodingOrOffset","TypeError","allocUnsafe","from","poolSize","fromString","ArrayBuffer","isView","fromArrayView","isInstance","fromArrayBuffer","SharedArrayBuffer","valueOf","b","fromObject","toPrimitive","assertSize","size","alloc","fill","encoding","checked","allocUnsafeSlow","string","isEncoding","actual","write","slice","fromArrayLike","array","arrayView","copy","obj","numberIsNaN","type","isArray","data","toString","_isBuffer","compare","a","x","y","min","String","toLowerCase","concat","list","pos","set","call","mustMatch","arguments","loweredCase","utf8ToBytes","base64ToBytes","slowToString","hexSlice","utf8Slice","asciiSlice","latin1Slice","base64Slice","utf16leSlice","swap","n","swap16","swap32","swap64","apply","toLocaleString","equals","inspect","str","max","INSPECT_MAX_BYTES","replace","trim","target","thisStart","thisEnd","thisCopy","targetCopy","bidirectionalIndexOf","val","dir","arrayIndexOf","lastIndexOf","indexSize","arrLength","valLength","read","readUInt16BE","foundIndex","found","j","includes","hexWrite","Number","remaining","strLen","parsed","parseInt","substr","utf8Write","blitBuffer","asciiWrite","asciiToBytes","base64Write","ucs2Write","utf16leToBytes","isFinite","toJSON","_arr","base64","res","firstByte","codePoint","bytesPerSequence","secondByte","thirdByte","fourthByte","tempCodePoint","decodeCodePointsArray","MAX_ARGUMENTS_LENGTH","codePoints","fromCharCode","ret","out","hexSliceLookupTable","bytes","newBuf","subarray","checkOffset","ext","readUintLE","readUIntLE","noAssert","mul","readUintBE","readUIntBE","readUint8","readUInt8","readUint16LE","readUInt16LE","readUint16BE","readUint32LE","readUInt32LE","readUint32BE","readUInt32BE","readIntLE","readIntBE","readInt8","readInt16LE","readInt16BE","readInt32LE","readInt32BE","readFloatLE","ieee754","readFloatBE","readDoubleLE","readDoubleBE","checkInt","writeUintLE","writeUIntLE","maxBytes","writeUintBE","writeUIntBE","writeUint8","writeUInt8","writeUint16LE","writeUInt16LE","writeUint16BE","writeUInt16BE","writeUint32LE","writeUInt32LE","writeUint32BE","writeUInt32BE","writeIntLE","limit","sub","writeIntBE","writeInt8","writeInt16LE","writeInt16BE","writeInt32LE","writeInt32BE","checkIEEE754","writeFloat","littleEndian","writeFloatLE","writeFloatBE","writeDouble","writeDoubleLE","writeDoubleBE","targetStart","copyWithin","INVALID_BASE64_RE","base64clean","split","units","leadSurrogate","byteArray","hi","lo","src","dst","constructor","name","alphabet","table","i16","extendStatics","__proto__","p","hasOwnProperty","__extends","__","create","__assign","assign","t","BSON_INT32_MAX","BSON_INT32_MIN","BSON_INT64_MAX","BSON_INT64_MIN","EJSON","bsonMap","calculateObjectSize","constants.JS_INT_MIN","constants.JS_INT_MAX","constants.BSON_INT32_MIN","constants.BSON_INT32_MAX","deserialize","constants.BSON_DATA_STRING","constants.BSON_DATA_OID","constants.BSON_DATA_INT","constants.BSON_DATA_NUMBER","constants.BSON_DATA_DATE","constants.BSON_DATA_BOOLEAN","constants.BSON_DATA_OBJECT","constants.BSON_DATA_ARRAY","constants.BSON_DATA_UNDEFINED","constants.BSON_DATA_NULL","constants.BSON_DATA_LONG","constants.BSON_DATA_DECIMAL128","constants.BSON_DATA_BINARY","constants.BSON_BINARY_SUBTYPE_UUID_NEW","constants.BSON_DATA_REGEXP","constants.BSON_DATA_SYMBOL","constants.BSON_DATA_TIMESTAMP","constants.BSON_DATA_MIN_KEY","constants.BSON_DATA_MAX_KEY","constants.BSON_DATA_CODE","constants.BSON_DATA_CODE_W_SCOPE","constants.BSON_DATA_DBPOINTER","constants.BSON_BINARY_SUBTYPE_DEFAULT","Map","internalSerialize","internalDeserialize","internalCalculateObjectSize"],"mappings":";;;;;;;;;;CAEA,gBAAkB,GAAGA,UAArB;CACA,iBAAmB,GAAGC,WAAtB;CACA,mBAAqB,GAAGC,aAAxB;CAEA,IAAIC,MAAM,GAAG,EAAb;CACA,IAAIC,SAAS,GAAG,EAAhB;CACA,IAAIC,GAAG,GAAG,OAAOC,UAAP,KAAsB,WAAtB,GAAoCA,UAApC,GAAiDC,KAA3D;CAEA,IAAIC,IAAI,GAAG,kEAAX;;CACA,KAAK,IAAIC,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAGF,IAAI,CAACG,MAA3B,EAAmCF,CAAC,GAAGC,GAAvC,EAA4C,EAAED,CAA9C,EAAiD;CAC/CN,EAAAA,MAAM,CAACM,CAAD,CAAN,GAAYD,IAAI,CAACC,CAAD,CAAhB;CACAL,EAAAA,SAAS,CAACI,IAAI,CAACI,UAAL,CAAgBH,CAAhB,CAAD,CAAT,GAAgCA,CAAhC;CACD;CAGD;;;CACAL,SAAS,CAAC,IAAIQ,UAAJ,CAAe,CAAf,CAAD,CAAT,GAA+B,EAA/B;CACAR,SAAS,CAAC,IAAIQ,UAAJ,CAAe,CAAf,CAAD,CAAT,GAA+B,EAA/B;;CAEA,SAASC,OAAT,CAAkBC,GAAlB,EAAuB;CACrB,MAAIJ,GAAG,GAAGI,GAAG,CAACH,MAAd;;CAEA,MAAID,GAAG,GAAG,CAAN,GAAU,CAAd,EAAiB;CACf,UAAM,IAAIK,KAAJ,CAAU,gDAAV,CAAN;CACD,GALoB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ACL,qBAAqB,uBAAA;KACrB,SAAS,WAAA;KACT,2BAA2B,6BAAA;KAC3B,WAAW,aAAA;KACX,mBAAmB,qBAAA;KACnB,iBAAiB,mBAAA;KACjB,SAAS,WAAA;KACT,aAAa,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/bson/dist/bson.bundle.js b/node_modules/bson/dist/bson.bundle.js new file mode 100644 index 0000000..9c5c62a --- /dev/null +++ b/node_modules/bson/dist/bson.bundle.js @@ -0,0 +1,7536 @@ +var BSON = (function (exports) { + 'use strict'; + + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } + + var byteLength_1 = byteLength; + var toByteArray_1 = toByteArray; + var fromByteArray_1 = fromByteArray; + var lookup = []; + var revLookup = []; + var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i]; + revLookup[code.charCodeAt(i)] = i; + } // Support decoding URL-safe base64 strings, as Node.js does. + // See: https://en.wikipedia.org/wiki/Base64#URL_applications + + + revLookup['-'.charCodeAt(0)] = 62; + revLookup['_'.charCodeAt(0)] = 63; + + function getLens(b64) { + var len = b64.length; + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4'); + } // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + + + var validLen = b64.indexOf('='); + if (validLen === -1) validLen = len; + var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; + return [validLen, placeHoldersLen]; + } // base64 is 4/3 + up to two characters of the original data + + + function byteLength(b64) { + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; + } + + function _byteLength(b64, validLen, placeHoldersLen) { + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; + } + + function toByteArray(b64) { + var tmp; + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); + var curByte = 0; // if there are placeholders, only get up to the last complete 4 chars + + var len = placeHoldersLen > 0 ? validLen - 4 : validLen; + var i; + + for (i = 0; i < len; i += 4) { + tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; + arr[curByte++] = tmp >> 16 & 0xFF; + arr[curByte++] = tmp >> 8 & 0xFF; + arr[curByte++] = tmp & 0xFF; + } + + if (placeHoldersLen === 2) { + tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; + arr[curByte++] = tmp & 0xFF; + } + + if (placeHoldersLen === 1) { + tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; + arr[curByte++] = tmp >> 8 & 0xFF; + arr[curByte++] = tmp & 0xFF; + } + + return arr; + } + + function tripletToBase64(num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; + } + + function encodeChunk(uint8, start, end) { + var tmp; + var output = []; + + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16 & 0xFF0000) + (uint8[i + 1] << 8 & 0xFF00) + (uint8[i + 2] & 0xFF); + output.push(tripletToBase64(tmp)); + } + + return output.join(''); + } + + function fromByteArray(uint8) { + var tmp; + var len = uint8.length; + var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes + + var parts = []; + var maxChunkLength = 16383; // must be multiple of 3 + // go through the array every three bytes, we'll deal with trailing stuff later + + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); + } // pad the end with zeros, but make sure to not forget the extra bytes + + + if (extraBytes === 1) { + tmp = uint8[len - 1]; + parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 0x3F] + '=='); + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1]; + parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 0x3F] + lookup[tmp << 2 & 0x3F] + '='); + } + + return parts.join(''); + } + + var base64Js = { + byteLength: byteLength_1, + toByteArray: toByteArray_1, + fromByteArray: fromByteArray_1 + }; + + /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ + var read = function read(buffer, offset, isLE, mLen, nBytes) { + var e, m; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i = isLE ? nBytes - 1 : 0; + var d = isLE ? -1 : 1; + var 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 write = function write(buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; + var i = isLE ? 0 : nBytes - 1; + var d = isLE ? 1 : -1; + var 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; + }; + + var ieee754 = { + read: read, + write: write + }; + + var buffer$1 = createCommonjsModule(function (module, exports) { + + var customInspectSymbol = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' ? // eslint-disable-line dot-notation + Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation + : null; + exports.Buffer = Buffer; + exports.SlowBuffer = SlowBuffer; + exports.INSPECT_MAX_BYTES = 50; + var K_MAX_LENGTH = 0x7fffffff; + exports.kMaxLength = K_MAX_LENGTH; + /** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ + + Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport(); + + if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && typeof console.error === 'function') { + console.error('This browser lacks typed array (Uint8Array) support which is required by ' + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'); + } + + function typedArraySupport() { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1); + var proto = { + foo: function foo() { + return 42; + } + }; + Object.setPrototypeOf(proto, Uint8Array.prototype); + Object.setPrototypeOf(arr, proto); + return arr.foo() === 42; + } catch (e) { + return false; + } + } + + Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function get() { + if (!Buffer.isBuffer(this)) return undefined; + return this.buffer; + } + }); + Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function get() { + if (!Buffer.isBuffer(this)) return undefined; + return this.byteOffset; + } + }); + + function createBuffer(length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"'); + } // Return an augmented `Uint8Array` instance + + + var buf = new Uint8Array(length); + Object.setPrototypeOf(buf, Buffer.prototype); + return buf; + } + /** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + + + function Buffer(arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError('The "string" argument must be of type string. Received type number'); + } + + return allocUnsafe(arg); + } + + return from(arg, encodingOrOffset, length); + } + + Buffer.poolSize = 8192; // not used by this implementation + + function from(value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset); + } + + if (ArrayBuffer.isView(value)) { + return fromArrayView(value); + } + + if (value == null) { + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + babelHelpers["typeof"](value)); + } + + if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { + return fromArrayBuffer(value, encodingOrOffset, length); + } + + if (typeof SharedArrayBuffer !== 'undefined' && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length); + } + + if (typeof value === 'number') { + throw new TypeError('The "value" argument must not be of type number. Received type number'); + } + + var valueOf = value.valueOf && value.valueOf(); + + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length); + } + + var b = fromObject(value); + if (b) return b; + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length); + } + + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + babelHelpers["typeof"](value)); + } + /** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ + + + Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length); + }; // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: + // https://github.com/feross/buffer/pull/148 + + + Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer, Uint8Array); + + function assertSize(size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number'); + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"'); + } + } + + function alloc(size, fill, encoding) { + assertSize(size); + + if (size <= 0) { + return createBuffer(size); + } + + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpreted as a start offset. + return typeof encoding === 'string' ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill); + } + + return createBuffer(size); + } + /** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ + + + Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding); + }; + + function allocUnsafe(size) { + assertSize(size); + return createBuffer(size < 0 ? 0 : checked(size) | 0); + } + /** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ + + + Buffer.allocUnsafe = function (size) { + return allocUnsafe(size); + }; + /** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ + + + Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size); + }; + + function fromString(string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8'; + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding); + } + + var length = byteLength(string, encoding) | 0; + var buf = createBuffer(length); + var actual = buf.write(string, encoding); + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual); + } + + return buf; + } + + function fromArrayLike(array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0; + var buf = createBuffer(length); + + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255; + } + + return buf; + } + + function fromArrayView(arrayView) { + if (isInstance(arrayView, Uint8Array)) { + var copy = new Uint8Array(arrayView); + return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength); + } + + return fromArrayLike(arrayView); + } + + function fromArrayBuffer(array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds'); + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds'); + } + + var buf; + + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array); + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset); + } else { + buf = new Uint8Array(array, byteOffset, length); + } // Return an augmented `Uint8Array` instance + + + Object.setPrototypeOf(buf, Buffer.prototype); + return buf; + } + + function fromObject(obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0; + var buf = createBuffer(len); + + if (buf.length === 0) { + return buf; + } + + obj.copy(buf, 0, 0, len); + return buf; + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0); + } + + return fromArrayLike(obj); + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data); + } + } + + function checked(length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes'); + } + + return length | 0; + } + + function SlowBuffer(length) { + if (+length != length) { + // eslint-disable-line eqeqeq + length = 0; + } + + return Buffer.alloc(+length); + } + + Buffer.isBuffer = function isBuffer(b) { + return b != null && b._isBuffer === true && b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false + }; + + Buffer.compare = function compare(a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength); + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength); + + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); + } + + if (a === b) return 0; + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) return -1; + if (y < x) return 1; + return 0; + }; + + Buffer.isEncoding = function isEncoding(encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true; + + default: + return false; + } + }; + + Buffer.concat = function concat(list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } + + if (list.length === 0) { + return Buffer.alloc(0); + } + + var i; + + if (length === undefined) { + length = 0; + + for (i = 0; i < list.length; ++i) { + length += list[i].length; + } + } + + var buffer = Buffer.allocUnsafe(length); + var pos = 0; + + for (i = 0; i < list.length; ++i) { + var buf = list[i]; + + if (isInstance(buf, Uint8Array)) { + if (pos + buf.length > buffer.length) { + Buffer.from(buf).copy(buffer, pos); + } else { + Uint8Array.prototype.set.call(buffer, buf, pos); + } + } else if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } else { + buf.copy(buffer, pos); + } + + pos += buf.length; + } + + return buffer; + }; + + function byteLength(string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length; + } + + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength; + } + + if (typeof string !== 'string') { + throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + 'Received type ' + babelHelpers["typeof"](string)); + } + + var len = string.length; + var mustMatch = arguments.length > 2 && arguments[2] === true; + if (!mustMatch && len === 0) return 0; // Use a for loop to avoid recursion + + var loweredCase = false; + + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len; + + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length; + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2; + + case 'hex': + return len >>> 1; + + case 'base64': + return base64ToBytes(string).length; + + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8 + } + + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } + } + + Buffer.byteLength = byteLength; + + function slowToString(encoding, start, end) { + var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + + if (start === undefined || start < 0) { + start = 0; + } // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + + + if (start > this.length) { + return ''; + } + + if (end === undefined || end > this.length) { + end = this.length; + } + + if (end <= 0) { + return ''; + } // Force coercion to uint32. This will also coerce falsey/NaN values to 0. + + + end >>>= 0; + start >>>= 0; + + if (end <= start) { + return ''; + } + + if (!encoding) encoding = 'utf8'; + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end); + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end); + + case 'ascii': + return asciiSlice(this, start, end); + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end); + + case 'base64': + return base64Slice(this, start, end); + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end); + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); + encoding = (encoding + '').toLowerCase(); + loweredCase = true; + } + } + } // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) + // to detect a Buffer instance. It's not possible to use `instanceof Buffer` + // reliably in a browserify context because there could be multiple different + // copies of the 'buffer' package in use. This method works even for Buffer + // instances that were created from another copy of the `buffer` package. + // See: https://github.com/feross/buffer/issues/154 + + + Buffer.prototype._isBuffer = true; + + function swap(b, n, m) { + var i = b[n]; + b[n] = b[m]; + b[m] = i; + } + + Buffer.prototype.swap16 = function swap16() { + var len = this.length; + + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits'); + } + + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1); + } + + return this; + }; + + Buffer.prototype.swap32 = function swap32() { + var len = this.length; + + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits'); + } + + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3); + swap(this, i + 1, i + 2); + } + + return this; + }; + + Buffer.prototype.swap64 = function swap64() { + var len = this.length; + + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits'); + } + + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7); + swap(this, i + 1, i + 6); + swap(this, i + 2, i + 5); + swap(this, i + 3, i + 4); + } + + return this; + }; + + Buffer.prototype.toString = function toString() { + var length = this.length; + if (length === 0) return ''; + if (arguments.length === 0) return utf8Slice(this, 0, length); + return slowToString.apply(this, arguments); + }; + + Buffer.prototype.toLocaleString = Buffer.prototype.toString; + + Buffer.prototype.equals = function equals(b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer'); + if (this === b) return true; + return Buffer.compare(this, b) === 0; + }; + + Buffer.prototype.inspect = function inspect() { + var str = ''; + var max = exports.INSPECT_MAX_BYTES; + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim(); + if (this.length > max) str += ' ... '; + return ''; + }; + + if (customInspectSymbol) { + Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; + } + + Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength); + } + + if (!Buffer.isBuffer(target)) { + throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. ' + 'Received type ' + babelHelpers["typeof"](target)); + } + + if (start === undefined) { + start = 0; + } + + if (end === undefined) { + end = target ? target.length : 0; + } + + if (thisStart === undefined) { + thisStart = 0; + } + + if (thisEnd === undefined) { + thisEnd = this.length; + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index'); + } + + if (thisStart >= thisEnd && start >= end) { + return 0; + } + + if (thisStart >= thisEnd) { + return -1; + } + + if (start >= end) { + return 1; + } + + start >>>= 0; + end >>>= 0; + thisStart >>>= 0; + thisEnd >>>= 0; + if (this === target) return 0; + var x = thisEnd - thisStart; + var y = end - start; + var len = Math.min(x, y); + var thisCopy = this.slice(thisStart, thisEnd); + var targetCopy = target.slice(start, end); + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i]; + y = targetCopy[i]; + break; + } + } + + if (x < y) return -1; + if (y < x) return 1; + return 0; + }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, + // OR the last index of `val` in `buffer` at offset <= `byteOffset`. + // + // Arguments: + // - buffer - a Buffer to search + // - val - a string, Buffer, or number + // - byteOffset - an index into `buffer`; will be clamped to an int32 + // - encoding - an optional encoding, relevant is val is a string + // - dir - true for indexOf, false for lastIndexOf + + + function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1; // Normalize byteOffset + + if (typeof byteOffset === 'string') { + encoding = byteOffset; + byteOffset = 0; + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff; + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000; + } + + byteOffset = +byteOffset; // Coerce to Number. + + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : buffer.length - 1; + } // Normalize byteOffset: negative offsets start from the end of the buffer + + + if (byteOffset < 0) byteOffset = buffer.length + byteOffset; + + if (byteOffset >= buffer.length) { + if (dir) return -1;else byteOffset = buffer.length - 1; + } else if (byteOffset < 0) { + if (dir) byteOffset = 0;else return -1; + } // Normalize val + + + if (typeof val === 'string') { + val = Buffer.from(val, encoding); + } // Finally, search either indexOf (if dir is true) or lastIndexOf + + + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1; + } + + return arrayIndexOf(buffer, val, byteOffset, encoding, dir); + } else if (typeof val === 'number') { + val = val & 0xFF; // Search for a byte value [0-255] + + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); + } + } + + return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); + } + + throw new TypeError('val must be string, number or Buffer'); + } + + function arrayIndexOf(arr, val, byteOffset, encoding, dir) { + var indexSize = 1; + var arrLength = arr.length; + var valLength = val.length; + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase(); + + if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1; + } + + indexSize = 2; + arrLength /= 2; + valLength /= 2; + byteOffset /= 2; + } + } + + function read(buf, i) { + if (indexSize === 1) { + return buf[i]; + } else { + return buf.readUInt16BE(i * indexSize); + } + } + + var i; + + if (dir) { + var foundIndex = -1; + + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i; + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; + } else { + if (foundIndex !== -1) i -= i - foundIndex; + foundIndex = -1; + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; + + for (i = byteOffset; i >= 0; i--) { + var found = true; + + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false; + break; + } + } + + if (found) return i; + } + } + + return -1; + } + + Buffer.prototype.includes = function includes(val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1; + }; + + Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true); + }; + + Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false); + }; + + function hexWrite(buf, string, offset, length) { + offset = Number(offset) || 0; + var remaining = buf.length - offset; + + if (!length) { + length = remaining; + } else { + length = Number(length); + + if (length > remaining) { + length = remaining; + } + } + + var strLen = string.length; + + if (length > strLen / 2) { + length = strLen / 2; + } + + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16); + if (numberIsNaN(parsed)) return i; + buf[offset + i] = parsed; + } + + return i; + } + + function utf8Write(buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); + } + + function asciiWrite(buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length); + } + + function base64Write(buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length); + } + + function ucs2Write(buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); + } + + Buffer.prototype.write = function write(string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8'; + length = this.length; + offset = 0; // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset; + length = this.length; + offset = 0; // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0; + + if (isFinite(length)) { + length = length >>> 0; + if (encoding === undefined) encoding = 'utf8'; + } else { + encoding = length; + length = undefined; + } + } else { + throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported'); + } + + var remaining = this.length - offset; + if (length === undefined || length > remaining) length = remaining; + + if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds'); + } + + if (!encoding) encoding = 'utf8'; + var loweredCase = false; + + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length); + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length); + + case 'ascii': + case 'latin1': + case 'binary': + return asciiWrite(this, string, offset, length); + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length); + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length); + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); + encoding = ('' + encoding).toLowerCase(); + loweredCase = true; + } + } + }; + + Buffer.prototype.toJSON = function toJSON() { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + }; + }; + + function base64Slice(buf, start, end) { + if (start === 0 && end === buf.length) { + return base64Js.fromByteArray(buf); + } else { + return base64Js.fromByteArray(buf.slice(start, end)); + } + } + + function utf8Slice(buf, start, end) { + end = Math.min(buf.length, end); + var res = []; + var i = start; + + while (i < end) { + var firstByte = buf[i]; + var codePoint = null; + var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1; + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint; + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte; + } + + break; + + case 2: + secondByte = buf[i + 1]; + + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F; + + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint; + } + } + + break; + + case 3: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F; + + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint; + } + } + + break; + + case 4: + secondByte = buf[i + 1]; + thirdByte = buf[i + 2]; + fourthByte = buf[i + 3]; + + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F; + + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint; + } + } + + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD; + bytesPerSequence = 1; + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000; + res.push(codePoint >>> 10 & 0x3FF | 0xD800); + codePoint = 0xDC00 | codePoint & 0x3FF; + } + + res.push(codePoint); + i += bytesPerSequence; + } + + return decodeCodePointsArray(res); + } // Based on http://stackoverflow.com/a/22747272/680742, the browser with + // the lowest limit is Chrome, with 0x10000 args. + // We go 1 magnitude less, for safety + + + var MAX_ARGUMENTS_LENGTH = 0x1000; + + function decodeCodePointsArray(codePoints) { + var len = codePoints.length; + + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints); // avoid extra slice() + } // Decode in chunks to avoid "call stack size exceeded". + + + var res = ''; + var i = 0; + + while (i < len) { + res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)); + } + + return res; + } + + function asciiSlice(buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F); + } + + return ret; + } + + function latin1Slice(buf, start, end) { + var ret = ''; + end = Math.min(buf.length, end); + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]); + } + + return ret; + } + + function hexSlice(buf, start, end) { + var len = buf.length; + if (!start || start < 0) start = 0; + if (!end || end < 0 || end > len) end = len; + var out = ''; + + for (var i = start; i < end; ++i) { + out += hexSliceLookupTable[buf[i]]; + } + + return out; + } + + function utf16leSlice(buf, start, end) { + var bytes = buf.slice(start, end); + var res = ''; // If bytes.length is odd, the last 8 bits must be ignored (same as node.js) + + for (var i = 0; i < bytes.length - 1; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); + } + + return res; + } + + Buffer.prototype.slice = function slice(start, end) { + var len = this.length; + start = ~~start; + end = end === undefined ? len : ~~end; + + if (start < 0) { + start += len; + if (start < 0) start = 0; + } else if (start > len) { + start = len; + } + + if (end < 0) { + end += len; + if (end < 0) end = 0; + } else if (end > len) { + end = len; + } + + if (end < start) end = start; + var newBuf = this.subarray(start, end); // Return an augmented `Uint8Array` instance + + Object.setPrototypeOf(newBuf, Buffer.prototype); + return newBuf; + }; + /* + * Need to make sure that buffer isn't trying to write out of bounds. + */ + + + function checkOffset(offset, ext, length) { + if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint'); + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length'); + } + + Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + var val = this[offset]; + var mul = 1; + var i = 0; + + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + return val; + }; + + Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + + if (!noAssert) { + checkOffset(offset, byteLength, this.length); + } + + var val = this[offset + --byteLength]; + var mul = 1; + + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul; + } + + return val; + }; + + Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 1, this.length); + return this[offset]; + }; + + Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] | this[offset + 1] << 8; + }; + + Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + return this[offset] << 8 | this[offset + 1]; + }; + + Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000; + }; + + Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); + }; + + Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + var val = this[offset]; + var mul = 1; + var i = 0; + + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul; + } + + mul *= 0x80; + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + return val; + }; + + Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { + offset = offset >>> 0; + byteLength = byteLength >>> 0; + if (!noAssert) checkOffset(offset, byteLength, this.length); + var i = byteLength; + var mul = 1; + var val = this[offset + --i]; + + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul; + } + + mul *= 0x80; + if (val >= mul) val -= Math.pow(2, 8 * byteLength); + return val; + }; + + Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 1, this.length); + if (!(this[offset] & 0x80)) return this[offset]; + return (0xff - this[offset] + 1) * -1; + }; + + Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset] | this[offset + 1] << 8; + return val & 0x8000 ? val | 0xFFFF0000 : val; + }; + + Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 2, this.length); + var val = this[offset + 1] | this[offset] << 8; + return val & 0x8000 ? val | 0xFFFF0000 : val; + }; + + Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; + }; + + Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; + }; + + Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return ieee754.read(this, offset, true, 23, 4); + }; + + Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 4, this.length); + return ieee754.read(this, offset, false, 23, 4); + }; + + Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 8, this.length); + return ieee754.read(this, offset, true, 52, 8); + }; + + Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { + offset = offset >>> 0; + if (!noAssert) checkOffset(offset, 8, this.length); + return ieee754.read(this, offset, false, 52, 8); + }; + + function checkInt(buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); + if (offset + ext > buf.length) throw new RangeError('Index out of range'); + } + + Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + byteLength = byteLength >>> 0; + + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var mul = 1; + var i = 0; + this[offset] = value & 0xFF; + + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = value / mul & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + byteLength = byteLength >>> 0; + + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1; + checkInt(this, value, offset, byteLength, maxBytes, 0); + } + + var i = byteLength - 1; + var mul = 1; + this[offset + i] = value & 0xFF; + + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = value / mul & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); + this[offset] = value & 0xff; + return offset + 1; + }; + + Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + return offset + 2; + }; + + Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); + this[offset] = value >>> 8; + this[offset + 1] = value & 0xff; + return offset + 2; + }; + + Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + this[offset + 3] = value >>> 24; + this[offset + 2] = value >>> 16; + this[offset + 1] = value >>> 8; + this[offset] = value & 0xff; + return offset + 4; + }; + + Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); + this[offset] = value >>> 24; + this[offset + 1] = value >>> 16; + this[offset + 2] = value >>> 8; + this[offset + 3] = value & 0xff; + return offset + 4; + }; + + Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = 0; + var mul = 1; + var sub = 0; + this[offset] = value & 0xFF; + + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1; + } + + this[offset + i] = (value / mul >> 0) - sub & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1); + checkInt(this, value, offset, byteLength, limit - 1, -limit); + } + + var i = byteLength - 1; + var mul = 1; + var sub = 0; + this[offset + i] = value & 0xFF; + + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1; + } + + this[offset + i] = (value / mul >> 0) - sub & 0xFF; + } + + return offset + byteLength; + }; + + Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); + if (value < 0) value = 0xff + value + 1; + this[offset] = value & 0xff; + return offset + 1; + }; + + Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + return offset + 2; + }; + + Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); + this[offset] = value >>> 8; + this[offset + 1] = value & 0xff; + return offset + 2; + }; + + Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + this[offset] = value & 0xff; + this[offset + 1] = value >>> 8; + this[offset + 2] = value >>> 16; + this[offset + 3] = value >>> 24; + return offset + 4; + }; + + Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { + value = +value; + offset = offset >>> 0; + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); + if (value < 0) value = 0xffffffff + value + 1; + this[offset] = value >>> 24; + this[offset + 1] = value >>> 16; + this[offset + 2] = value >>> 8; + this[offset + 3] = value & 0xff; + return offset + 4; + }; + + function checkIEEE754(buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range'); + if (offset < 0) throw new RangeError('Index out of range'); + } + + function writeFloat(buf, value, offset, littleEndian, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + checkIEEE754(buf, value, offset, 4); + } + + ieee754.write(buf, value, offset, littleEndian, 23, 4); + return offset + 4; + } + + Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert); + }; + + Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert); + }; + + function writeDouble(buf, value, offset, littleEndian, noAssert) { + value = +value; + offset = offset >>> 0; + + if (!noAssert) { + checkIEEE754(buf, value, offset, 8); + } + + ieee754.write(buf, value, offset, littleEndian, 52, 8); + return offset + 8; + } + + Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert); + }; + + Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert); + }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) + + + Buffer.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer'); + if (!start) start = 0; + if (!end && end !== 0) end = this.length; + if (targetStart >= target.length) targetStart = target.length; + if (!targetStart) targetStart = 0; + if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done + + if (end === start) return 0; + if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions + + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds'); + } + + if (start < 0 || start >= this.length) throw new RangeError('Index out of range'); + if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob? + + if (end > this.length) end = this.length; + + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start; + } + + var len = end - start; + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end); + } else { + Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart); + } + + return len; + }; // Usage: + // buffer.fill(number[, offset[, end]]) + // buffer.fill(buffer[, offset[, end]]) + // buffer.fill(string[, offset[, end]][, encoding]) + + + Buffer.prototype.fill = function fill(val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start; + start = 0; + end = this.length; + } else if (typeof end === 'string') { + encoding = end; + end = this.length; + } + + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string'); + } + + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding); + } + + if (val.length === 1) { + var code = val.charCodeAt(0); + + if (encoding === 'utf8' && code < 128 || encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code; + } + } + } else if (typeof val === 'number') { + val = val & 255; + } else if (typeof val === 'boolean') { + val = Number(val); + } // Invalid ranges are not set to a default, so can range check early. + + + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index'); + } + + if (end <= start) { + return this; + } + + start = start >>> 0; + end = end === undefined ? this.length : end >>> 0; + if (!val) val = 0; + var i; + + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val; + } + } else { + var bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); + var len = bytes.length; + + if (len === 0) { + throw new TypeError('The value "' + val + '" is invalid for argument "value"'); + } + + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len]; + } + } + + return this; + }; // HELPER FUNCTIONS + // ================ + + + var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; + + function base64clean(str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0]; // Node strips out invalid characters like \n and \t from the string, base64-js does not + + str = str.trim().replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to '' + + if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + + while (str.length % 4 !== 0) { + str = str + '='; + } + + return str; + } + + function utf8ToBytes(string, units) { + units = units || Infinity; + var codePoint; + var length = string.length; + var leadSurrogate = null; + var bytes = []; + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i); // is surrogate component + + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue; + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + continue; + } // valid lead + + + leadSurrogate = codePoint; + continue; + } // 2 leads in a row + + + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + leadSurrogate = codePoint; + continue; + } // valid surrogate pair + + + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); + } + + leadSurrogate = null; // encode utf8 + + if (codePoint < 0x80) { + if ((units -= 1) < 0) break; + bytes.push(codePoint); + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break; + bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80); + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break; + bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break; + bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); + } else { + throw new Error('Invalid code point'); + } + } + + return bytes; + } + + function asciiToBytes(str) { + var byteArray = []; + + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF); + } + + return byteArray; + } + + function utf16leToBytes(str, units) { + var c, hi, lo; + var byteArray = []; + + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break; + c = str.charCodeAt(i); + hi = c >> 8; + lo = c % 256; + byteArray.push(lo); + byteArray.push(hi); + } + + return byteArray; + } + + function base64ToBytes(str) { + return base64Js.toByteArray(base64clean(str)); + } + + function blitBuffer(src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if (i + offset >= dst.length || i >= src.length) break; + dst[i + offset] = src[i]; + } + + return i; + } // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass + // the `instanceof` check but they should be treated as of that type. + // See: https://github.com/feross/buffer/issues/166 + + + function isInstance(obj, type) { + return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name; + } + + function numberIsNaN(obj) { + // For IE11 support + return obj !== obj; // eslint-disable-line no-self-compare + } // Create lookup table for `toString('hex')` + // See: https://github.com/feross/buffer/issues/219 + + + var hexSliceLookupTable = function () { + var alphabet = '0123456789abcdef'; + var table = new Array(256); + + for (var i = 0; i < 16; ++i) { + var i16 = i * 16; + + for (var j = 0; j < 16; ++j) { + table[i16 + j] = alphabet[i] + alphabet[j]; + } + } + + return table; + }(); + }); + var buffer_1 = buffer$1.Buffer; + buffer$1.SlowBuffer; + buffer$1.INSPECT_MAX_BYTES; + buffer$1.kMaxLength; + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + + /* global Reflect, Promise */ + var _extendStatics = function extendStatics(d, b) { + _extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) { + if (b.hasOwnProperty(p)) d[p] = b[p]; + } + }; + + return _extendStatics(d, b); + }; + + function __extends(d, b) { + _extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + var _assign = function __assign() { + _assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) { + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + } + + return t; + }; + + return _assign.apply(this, arguments); + }; + + /** @public */ + var BSONError = /** @class */ (function (_super) { + __extends(BSONError, _super); + function BSONError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONError.prototype); + return _this; + } + Object.defineProperty(BSONError.prototype, "name", { + get: function () { + return 'BSONError'; + }, + enumerable: false, + configurable: true + }); + return BSONError; + }(Error)); + /** @public */ + var BSONTypeError = /** @class */ (function (_super) { + __extends(BSONTypeError, _super); + function BSONTypeError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONTypeError.prototype); + return _this; + } + Object.defineProperty(BSONTypeError.prototype, "name", { + get: function () { + return 'BSONTypeError'; + }, + enumerable: false, + configurable: true + }); + return BSONTypeError; + }(TypeError)); + + function checkForMath(potentialGlobal) { + // eslint-disable-next-line eqeqeq + return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal; + } + // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + function getGlobal() { + return (checkForMath(typeof globalThis === 'object' && globalThis) || + checkForMath(typeof window === 'object' && window) || + checkForMath(typeof self === 'object' && self) || + checkForMath(typeof global === 'object' && global) || + // eslint-disable-next-line @typescript-eslint/no-implied-eval + Function('return this')()); + } + + /** + * Normalizes our expected stringified form of a function across versions of node + * @param fn - The function to stringify + */ + function normalizedFunctionString(fn) { + return fn.toString().replace('function(', 'function ('); + } + function isReactNative() { + var g = getGlobal(); + return typeof g.navigator === 'object' && g.navigator.product === 'ReactNative'; + } + var insecureRandomBytes = function insecureRandomBytes(size) { + var insecureWarning = isReactNative() + ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.' + : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.'; + console.warn(insecureWarning); + var result = buffer_1.alloc(size); + for (var i = 0; i < size; ++i) + result[i] = Math.floor(Math.random() * 256); + return result; + }; + var detectRandomBytes = function () { + { + if (typeof window !== 'undefined') { + // browser crypto implementation(s) + var target_1 = window.crypto || window.msCrypto; // allow for IE11 + if (target_1 && target_1.getRandomValues) { + return function (size) { return target_1.getRandomValues(buffer_1.alloc(size)); }; + } + } + if (typeof global !== 'undefined' && global.crypto && global.crypto.getRandomValues) { + // allow for RN packages such as https://www.npmjs.com/package/react-native-get-random-values to populate global + return function (size) { return global.crypto.getRandomValues(buffer_1.alloc(size)); }; + } + return insecureRandomBytes; + } + }; + var randomBytes = detectRandomBytes(); + function isAnyArrayBuffer(value) { + return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value)); + } + function isUint8Array(value) { + return Object.prototype.toString.call(value) === '[object Uint8Array]'; + } + function isBigInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigInt64Array]'; + } + function isBigUInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigUint64Array]'; + } + function isRegExp(d) { + return Object.prototype.toString.call(d) === '[object RegExp]'; + } + function isMap(d) { + return Object.prototype.toString.call(d) === '[object Map]'; + } + // To ensure that 0.4 of node works correctly + function isDate(d) { + return isObjectLike(d) && Object.prototype.toString.call(d) === '[object Date]'; + } + /** + * @internal + * this is to solve the `'someKey' in x` problem where x is unknown. + * https://github.com/typescript-eslint/typescript-eslint/issues/1071#issuecomment-541955753 + */ + function isObjectLike(candidate) { + return typeof candidate === 'object' && candidate !== null; + } + function deprecate(fn, message) { + var warned = false; + function deprecated() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!warned) { + console.warn(message); + warned = true; + } + return fn.apply(this, args); + } + return deprecated; + } + + /** + * Makes sure that, if a Uint8Array is passed in, it is wrapped in a Buffer. + * + * @param potentialBuffer - The potential buffer + * @returns Buffer the input if potentialBuffer is a buffer, or a buffer that + * wraps a passed in Uint8Array + * @throws BSONTypeError If anything other than a Buffer or Uint8Array is passed in + */ + function ensureBuffer(potentialBuffer) { + if (ArrayBuffer.isView(potentialBuffer)) { + return buffer_1.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength); + } + if (isAnyArrayBuffer(potentialBuffer)) { + return buffer_1.from(potentialBuffer); + } + throw new BSONTypeError('Must use either Buffer or TypedArray'); + } + + // Validation regex for v4 uuid (validates with or without dashes) + var VALIDATION_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i; + var uuidValidateString = function (str) { + return typeof str === 'string' && VALIDATION_REGEX.test(str); + }; + var uuidHexStringToBuffer = function (hexString) { + if (!uuidValidateString(hexString)) { + throw new BSONTypeError('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".'); + } + var sanitizedHexString = hexString.replace(/-/g, ''); + return buffer_1.from(sanitizedHexString, 'hex'); + }; + var bufferToUuidHexString = function (buffer, includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + return includeDashes + ? buffer.toString('hex', 0, 4) + + '-' + + buffer.toString('hex', 4, 6) + + '-' + + buffer.toString('hex', 6, 8) + + '-' + + buffer.toString('hex', 8, 10) + + '-' + + buffer.toString('hex', 10, 16) + : buffer.toString('hex'); + }; + + /** @internal */ + var BSON_INT32_MAX$1 = 0x7fffffff; + /** @internal */ + var BSON_INT32_MIN$1 = -0x80000000; + /** @internal */ + var BSON_INT64_MAX$1 = Math.pow(2, 63) - 1; + /** @internal */ + var BSON_INT64_MIN$1 = -Math.pow(2, 63); + /** + * Any integer up to 2^53 can be precisely represented by a double. + * @internal + */ + var JS_INT_MAX = Math.pow(2, 53); + /** + * Any integer down to -2^53 can be precisely represented by a double. + * @internal + */ + var JS_INT_MIN = -Math.pow(2, 53); + /** Number BSON Type @internal */ + var BSON_DATA_NUMBER = 1; + /** String BSON Type @internal */ + var BSON_DATA_STRING = 2; + /** Object BSON Type @internal */ + var BSON_DATA_OBJECT = 3; + /** Array BSON Type @internal */ + var BSON_DATA_ARRAY = 4; + /** Binary BSON Type @internal */ + var BSON_DATA_BINARY = 5; + /** Binary BSON Type @internal */ + var BSON_DATA_UNDEFINED = 6; + /** ObjectId BSON Type @internal */ + var BSON_DATA_OID = 7; + /** Boolean BSON Type @internal */ + var BSON_DATA_BOOLEAN = 8; + /** Date BSON Type @internal */ + var BSON_DATA_DATE = 9; + /** null BSON Type @internal */ + var BSON_DATA_NULL = 10; + /** RegExp BSON Type @internal */ + var BSON_DATA_REGEXP = 11; + /** Code BSON Type @internal */ + var BSON_DATA_DBPOINTER = 12; + /** Code BSON Type @internal */ + var BSON_DATA_CODE = 13; + /** Symbol BSON Type @internal */ + var BSON_DATA_SYMBOL = 14; + /** Code with Scope BSON Type @internal */ + var BSON_DATA_CODE_W_SCOPE = 15; + /** 32 bit Integer BSON Type @internal */ + var BSON_DATA_INT = 16; + /** Timestamp BSON Type @internal */ + var BSON_DATA_TIMESTAMP = 17; + /** Long BSON Type @internal */ + var BSON_DATA_LONG = 18; + /** Decimal128 BSON Type @internal */ + var BSON_DATA_DECIMAL128 = 19; + /** MinKey BSON Type @internal */ + var BSON_DATA_MIN_KEY = 0xff; + /** MaxKey BSON Type @internal */ + var BSON_DATA_MAX_KEY = 0x7f; + /** Binary Default Type @internal */ + var BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** Binary Function Type @internal */ + var BSON_BINARY_SUBTYPE_FUNCTION = 1; + /** Binary Byte Array Type @internal */ + var BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; + /** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */ + var BSON_BINARY_SUBTYPE_UUID = 3; + /** Binary UUID Type @internal */ + var BSON_BINARY_SUBTYPE_UUID_NEW = 4; + /** Binary MD5 Type @internal */ + var BSON_BINARY_SUBTYPE_MD5 = 5; + /** Encrypted BSON type @internal */ + var BSON_BINARY_SUBTYPE_ENCRYPTED = 6; + /** Column BSON type @internal */ + var BSON_BINARY_SUBTYPE_COLUMN = 7; + /** Binary User Defined Type @internal */ + var BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + + /** + * A class representation of the BSON Binary type. + * @public + * @category BSONType + */ + var Binary = /** @class */ (function () { + /** + * Create a new Binary instance. + * + * This constructor can accept a string as its first argument. In this case, + * this string will be encoded using ISO-8859-1, **not** using UTF-8. + * This is almost certainly not what you want. Use `new Binary(Buffer.from(string))` + * instead to convert the string to a Buffer using UTF-8 first. + * + * @param buffer - a buffer object containing the binary data. + * @param subType - the option binary type. + */ + function Binary(buffer, subType) { + if (!(this instanceof Binary)) + return new Binary(buffer, subType); + if (!(buffer == null) && + !(typeof buffer === 'string') && + !ArrayBuffer.isView(buffer) && + !(buffer instanceof ArrayBuffer) && + !Array.isArray(buffer)) { + throw new BSONTypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array'); + } + this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT; + if (buffer == null) { + // create an empty binary buffer + this.buffer = buffer_1.alloc(Binary.BUFFER_SIZE); + this.position = 0; + } + else { + if (typeof buffer === 'string') { + // string + this.buffer = buffer_1.from(buffer, 'binary'); + } + else if (Array.isArray(buffer)) { + // number[] + this.buffer = buffer_1.from(buffer); + } + else { + // Buffer | TypedArray | ArrayBuffer + this.buffer = ensureBuffer(buffer); + } + this.position = this.buffer.byteLength; + } + } + /** + * Updates this binary with byte_value. + * + * @param byteValue - a single byte we wish to write. + */ + Binary.prototype.put = function (byteValue) { + // If it's a string and a has more than one character throw an error + if (typeof byteValue === 'string' && byteValue.length !== 1) { + throw new BSONTypeError('only accepts single character String'); + } + else if (typeof byteValue !== 'number' && byteValue.length !== 1) + throw new BSONTypeError('only accepts single character Uint8Array or Array'); + // Decode the byte value once + var decodedByte; + if (typeof byteValue === 'string') { + decodedByte = byteValue.charCodeAt(0); + } + else if (typeof byteValue === 'number') { + decodedByte = byteValue; + } + else { + decodedByte = byteValue[0]; + } + if (decodedByte < 0 || decodedByte > 255) { + throw new BSONTypeError('only accepts number in a valid unsigned byte range 0-255'); + } + if (this.buffer.length > this.position) { + this.buffer[this.position++] = decodedByte; + } + else { + var buffer = buffer_1.alloc(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++] = decodedByte; + } + }; + /** + * Writes a buffer or string to the binary. + * + * @param sequence - a string or buffer to be written to the Binary BSON object. + * @param offset - specify the binary of where to write the content. + */ + Binary.prototype.write = function (sequence, offset) { + offset = typeof offset === 'number' ? offset : this.position; + // If the buffer is to small let's extend the buffer + if (this.buffer.length < offset + sequence.length) { + var buffer = buffer_1.alloc(this.buffer.length + sequence.length); + this.buffer.copy(buffer, 0, 0, this.buffer.length); + // Assign the new buffer + this.buffer = buffer; + } + if (ArrayBuffer.isView(sequence)) { + this.buffer.set(ensureBuffer(sequence), offset); + this.position = + offset + sequence.byteLength > this.position ? offset + sequence.length : this.position; + } + else if (typeof sequence === 'string') { + this.buffer.write(sequence, offset, sequence.length, 'binary'); + this.position = + offset + sequence.length > this.position ? offset + sequence.length : this.position; + } + }; + /** + * Reads **length** bytes starting at **position**. + * + * @param position - read from the given position in the Binary. + * @param length - the number of bytes to read. + */ + Binary.prototype.read = function (position, length) { + length = length && length > 0 ? length : this.position; + // Let's return the data based on the type we have + return this.buffer.slice(position, position + length); + }; + /** + * Returns the value of this binary as a string. + * @param asRaw - Will skip converting to a string + * @remarks + * This is handy when calling this function conditionally for some key value pairs and not others + */ + Binary.prototype.value = function (asRaw) { + asRaw = !!asRaw; + // Optimize to serialize for the situation where the data == size of buffer + if (asRaw && this.buffer.length === this.position) { + return this.buffer; + } + // If it's a node.js buffer object + if (asRaw) { + return this.buffer.slice(0, this.position); + } + return this.buffer.toString('binary', 0, this.position); + }; + /** the length of the binary sequence */ + Binary.prototype.length = function () { + return this.position; + }; + Binary.prototype.toJSON = function () { + return this.buffer.toString('base64'); + }; + Binary.prototype.toString = function (format) { + return this.buffer.toString(format); + }; + /** @internal */ + Binary.prototype.toExtendedJSON = function (options) { + options = options || {}; + var base64String = this.buffer.toString('base64'); + var subType = Number(this.sub_type).toString(16); + if (options.legacy) { + return { + $binary: base64String, + $type: subType.length === 1 ? '0' + subType : subType + }; + } + return { + $binary: { + base64: base64String, + subType: subType.length === 1 ? '0' + subType : subType + } + }; + }; + Binary.prototype.toUUID = function () { + if (this.sub_type === Binary.SUBTYPE_UUID) { + return new UUID(this.buffer.slice(0, this.position)); + } + throw new BSONError("Binary sub_type \"".concat(this.sub_type, "\" is not supported for converting to UUID. Only \"").concat(Binary.SUBTYPE_UUID, "\" is currently supported.")); + }; + /** @internal */ + Binary.fromExtendedJSON = function (doc, options) { + options = options || {}; + var data; + var type; + if ('$binary' in doc) { + if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) { + type = doc.$type ? parseInt(doc.$type, 16) : 0; + data = buffer_1.from(doc.$binary, 'base64'); + } + else { + if (typeof doc.$binary !== 'string') { + type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0; + data = buffer_1.from(doc.$binary.base64, 'base64'); + } + } + } + else if ('$uuid' in doc) { + type = 4; + data = uuidHexStringToBuffer(doc.$uuid); + } + if (!data) { + throw new BSONTypeError("Unexpected Binary Extended JSON format ".concat(JSON.stringify(doc))); + } + return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type); + }; + /** @internal */ + Binary.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Binary.prototype.inspect = function () { + var asBuffer = this.value(true); + return "new Binary(Buffer.from(\"".concat(asBuffer.toString('hex'), "\", \"hex\"), ").concat(this.sub_type, ")"); + }; + /** + * Binary default subtype + * @internal + */ + Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** Initial buffer default size */ + Binary.BUFFER_SIZE = 256; + /** Default BSON type */ + Binary.SUBTYPE_DEFAULT = 0; + /** Function BSON type */ + Binary.SUBTYPE_FUNCTION = 1; + /** Byte Array BSON type */ + Binary.SUBTYPE_BYTE_ARRAY = 2; + /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */ + Binary.SUBTYPE_UUID_OLD = 3; + /** UUID BSON type */ + Binary.SUBTYPE_UUID = 4; + /** MD5 BSON type */ + Binary.SUBTYPE_MD5 = 5; + /** Encrypted BSON type */ + Binary.SUBTYPE_ENCRYPTED = 6; + /** Column BSON type */ + Binary.SUBTYPE_COLUMN = 7; + /** User BSON type */ + Binary.SUBTYPE_USER_DEFINED = 128; + return Binary; + }()); + Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' }); + var UUID_BYTE_LENGTH = 16; + /** + * A class representation of the BSON UUID type. + * @public + */ + var UUID = /** @class */ (function (_super) { + __extends(UUID, _super); + /** + * Create an UUID type + * + * @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer. + */ + function UUID(input) { + var _this = this; + var bytes; + var hexStr; + if (input == null) { + bytes = UUID.generate(); + } + else if (input instanceof UUID) { + bytes = buffer_1.from(input.buffer); + hexStr = input.__id; + } + else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) { + bytes = ensureBuffer(input); + } + else if (typeof input === 'string') { + bytes = uuidHexStringToBuffer(input); + } + else { + throw new BSONTypeError('Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'); + } + _this = _super.call(this, bytes, BSON_BINARY_SUBTYPE_UUID_NEW) || this; + _this.__id = hexStr; + return _this; + } + Object.defineProperty(UUID.prototype, "id", { + /** + * The UUID bytes + * @readonly + */ + get: function () { + return this.buffer; + }, + set: function (value) { + this.buffer = value; + if (UUID.cacheHexString) { + this.__id = bufferToUuidHexString(value); + } + }, + enumerable: false, + configurable: true + }); + /** + * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated) + * @param includeDashes - should the string exclude dash-separators. + * */ + UUID.prototype.toHexString = function (includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + if (UUID.cacheHexString && this.__id) { + return this.__id; + } + var uuidHexString = bufferToUuidHexString(this.id, includeDashes); + if (UUID.cacheHexString) { + this.__id = uuidHexString; + } + return uuidHexString; + }; + /** + * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified. + */ + UUID.prototype.toString = function (encoding) { + return encoding ? this.id.toString(encoding) : this.toHexString(); + }; + /** + * Converts the id into its JSON string representation. + * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + */ + UUID.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this UUID with `otherID`. + * + * @param otherId - UUID instance to compare against. + */ + UUID.prototype.equals = function (otherId) { + if (!otherId) { + return false; + } + if (otherId instanceof UUID) { + return otherId.id.equals(this.id); + } + try { + return new UUID(otherId).id.equals(this.id); + } + catch (_a) { + return false; + } + }; + /** + * Creates a Binary instance from the current UUID. + */ + UUID.prototype.toBinary = function () { + return new Binary(this.id, Binary.SUBTYPE_UUID); + }; + /** + * Generates a populated buffer containing a v4 uuid + */ + UUID.generate = function () { + var bytes = randomBytes(UUID_BYTE_LENGTH); + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + // Kindly borrowed from https://github.com/uuidjs/uuid/blob/master/src/v4.js + bytes[6] = (bytes[6] & 0x0f) | 0x40; + bytes[8] = (bytes[8] & 0x3f) | 0x80; + return buffer_1.from(bytes); + }; + /** + * Checks if a value is a valid bson UUID + * @param input - UUID, string or Buffer to validate. + */ + UUID.isValid = function (input) { + if (!input) { + return false; + } + if (input instanceof UUID) { + return true; + } + if (typeof input === 'string') { + return uuidValidateString(input); + } + if (isUint8Array(input)) { + // check for length & uuid version (https://tools.ietf.org/html/rfc4122#section-4.1.3) + if (input.length !== UUID_BYTE_LENGTH) { + return false; + } + return (input[6] & 0xf0) === 0x40 && (input[8] & 0x80) === 0x80; + } + return false; + }; + /** + * Creates an UUID from a hex string representation of an UUID. + * @param hexString - 32 or 36 character hex string (dashes excluded/included). + */ + UUID.createFromHexString = function (hexString) { + var buffer = uuidHexStringToBuffer(hexString); + return new UUID(buffer); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 36 character hex string representation. + * @internal + */ + UUID.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + UUID.prototype.inspect = function () { + return "new UUID(\"".concat(this.toHexString(), "\")"); + }; + return UUID; + }(Binary)); + + /** + * A class representation of the BSON Code type. + * @public + * @category BSONType + */ + var Code = /** @class */ (function () { + /** + * @param code - a string or function. + * @param scope - an optional scope for the function. + */ + function Code(code, scope) { + if (!(this instanceof Code)) + return new Code(code, scope); + this.code = code; + this.scope = scope; + } + Code.prototype.toJSON = function () { + return { code: this.code, scope: this.scope }; + }; + /** @internal */ + Code.prototype.toExtendedJSON = function () { + if (this.scope) { + return { $code: this.code, $scope: this.scope }; + } + return { $code: this.code }; + }; + /** @internal */ + Code.fromExtendedJSON = function (doc) { + return new Code(doc.$code, doc.$scope); + }; + /** @internal */ + Code.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Code.prototype.inspect = function () { + var codeJson = this.toJSON(); + return "new Code(\"".concat(String(codeJson.code), "\"").concat(codeJson.scope ? ", ".concat(JSON.stringify(codeJson.scope)) : '', ")"); + }; + return Code; + }()); + Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' }); + + /** @internal */ + function isDBRefLike(value) { + return (isObjectLike(value) && + value.$id != null && + typeof value.$ref === 'string' && + (value.$db == null || typeof value.$db === 'string')); + } + /** + * A class representation of the BSON DBRef type. + * @public + * @category BSONType + */ + var DBRef = /** @class */ (function () { + /** + * @param collection - the collection name. + * @param oid - the reference ObjectId. + * @param db - optional db name, if omitted the reference is local to the current db. + */ + function DBRef(collection, oid, db, fields) { + if (!(this instanceof DBRef)) + return new DBRef(collection, oid, db, fields); + // check if namespace has been provided + var parts = collection.split('.'); + if (parts.length === 2) { + db = parts.shift(); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + collection = parts.shift(); + } + this.collection = collection; + this.oid = oid; + this.db = db; + this.fields = fields || {}; + } + Object.defineProperty(DBRef.prototype, "namespace", { + // Property provided for compatibility with the 1.x parser + // the 1.x parser used a "namespace" property, while 4.x uses "collection" + /** @internal */ + get: function () { + return this.collection; + }, + set: function (value) { + this.collection = value; + }, + enumerable: false, + configurable: true + }); + DBRef.prototype.toJSON = function () { + var o = Object.assign({ + $ref: this.collection, + $id: this.oid + }, this.fields); + if (this.db != null) + o.$db = this.db; + return o; + }; + /** @internal */ + DBRef.prototype.toExtendedJSON = function (options) { + options = options || {}; + var o = { + $ref: this.collection, + $id: this.oid + }; + if (options.legacy) { + return o; + } + if (this.db) + o.$db = this.db; + o = Object.assign(o, this.fields); + return o; + }; + /** @internal */ + DBRef.fromExtendedJSON = function (doc) { + var copy = Object.assign({}, doc); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(doc.$ref, doc.$id, doc.$db, copy); + }; + /** @internal */ + DBRef.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + DBRef.prototype.inspect = function () { + // NOTE: if OID is an ObjectId class it will just print the oid string. + var oid = this.oid === undefined || this.oid.toString === undefined ? this.oid : this.oid.toString(); + return "new DBRef(\"".concat(this.namespace, "\", new ObjectId(\"").concat(String(oid), "\")").concat(this.db ? ", \"".concat(this.db, "\"") : '', ")"); + }; + return DBRef; + }()); + Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' }); + + /** + * wasm optimizations, to do native i64 multiplication and divide + */ + var wasm = undefined; + try { + wasm = new WebAssembly.Instance(new WebAssembly.Module( + // prettier-ignore + new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports; + } + catch (_a) { + // no wasm support + } + var TWO_PWR_16_DBL = 1 << 16; + var TWO_PWR_24_DBL = 1 << 24; + var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL; + var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL; + var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2; + /** A cache of the Long representations of small integer values. */ + var INT_CACHE = {}; + /** A cache of the Long representations of small unsigned integer values. */ + var UINT_CACHE = {}; + /** + * A class representing a 64-bit integer + * @public + * @category BSONType + * @remarks + * 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. + * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class. + */ + var Long = /** @class */ (function () { + /** + * 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. + * + * Acceptable signatures are: + * - Long(low, high, unsigned?) + * - Long(bigint, unsigned?) + * - Long(string, unsigned?) + * + * @param low - The low (signed) 32 bits of the long + * @param high - The high (signed) 32 bits of the long + * @param unsigned - Whether unsigned or not, defaults to signed + */ + function Long(low, high, unsigned) { + if (low === void 0) { low = 0; } + if (!(this instanceof Long)) + return new Long(low, high, unsigned); + if (typeof low === 'bigint') { + Object.assign(this, Long.fromBigInt(low, !!high)); + } + else if (typeof low === 'string') { + Object.assign(this, Long.fromString(low, !!high)); + } + else { + this.low = low | 0; + this.high = high | 0; + this.unsigned = !!unsigned; + } + Object.defineProperty(this, '__isLong__', { + value: true, + configurable: false, + writable: false, + enumerable: false + }); + } + /** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. + * Each is assumed to use 32 bits. + * @param lowBits - The low 32 bits + * @param highBits - The high 32 bits + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBits = function (lowBits, highBits, unsigned) { + return new Long(lowBits, highBits, unsigned); + }; + /** + * Returns a Long representing the given 32 bit integer value. + * @param value - The 32 bit integer in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromInt = function (value, unsigned) { + var obj, cachedObj, cache; + if (unsigned) { + value >>>= 0; + if ((cache = 0 <= value && value < 256)) { + cachedObj = UINT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true); + if (cache) + UINT_CACHE[value] = obj; + return obj; + } + else { + value |= 0; + if ((cache = -128 <= value && value < 128)) { + cachedObj = INT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, value < 0 ? -1 : 0, false); + if (cache) + INT_CACHE[value] = obj; + return obj; + } + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromNumber = function (value, unsigned) { + if (isNaN(value)) + return unsigned ? Long.UZERO : Long.ZERO; + if (unsigned) { + if (value < 0) + return Long.UZERO; + if (value >= TWO_PWR_64_DBL) + return Long.MAX_UNSIGNED_VALUE; + } + else { + if (value <= -TWO_PWR_63_DBL) + return Long.MIN_VALUE; + if (value + 1 >= TWO_PWR_63_DBL) + return Long.MAX_VALUE; + } + if (value < 0) + return Long.fromNumber(-value, unsigned).neg(); + return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned); + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBigInt = function (value, unsigned) { + return Long.fromString(value.toString(), unsigned); + }; + /** + * Returns a Long representation of the given string, written using the specified radix. + * @param str - The textual representation of the Long + * @param unsigned - Whether unsigned or not, defaults to signed + * @param radix - The radix in which the text is written (2-36), defaults to 10 + * @returns The corresponding Long value + */ + Long.fromString = function (str, unsigned, radix) { + if (str.length === 0) + throw Error('empty string'); + if (str === 'NaN' || str === 'Infinity' || str === '+Infinity' || str === '-Infinity') + return Long.ZERO; + if (typeof unsigned === 'number') { + // For goog.math.long compatibility + (radix = unsigned), (unsigned = false); + } + else { + unsigned = !!unsigned; + } + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + var p; + if ((p = str.indexOf('-')) > 0) + throw Error('interior hyphen'); + else if (p === 0) { + return Long.fromString(str.substring(1), unsigned, radix).neg(); + } + // 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), value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Long.fromNumber(Math.pow(radix, size)); + result = result.mul(power).add(Long.fromNumber(value)); + } + else { + result = result.mul(radixToPower); + result = result.add(Long.fromNumber(value)); + } + } + result.unsigned = unsigned; + return result; + }; + /** + * Creates a Long from its byte representation. + * @param bytes - Byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @param le - Whether little or big endian, defaults to big endian + * @returns The corresponding Long value + */ + Long.fromBytes = function (bytes, unsigned, le) { + return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned); + }; + /** + * Creates a Long from its little endian byte representation. + * @param bytes - Little endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesLE = function (bytes, unsigned) { + return new Long(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24), bytes[4] | (bytes[5] << 8) | (bytes[6] << 16) | (bytes[7] << 24), unsigned); + }; + /** + * Creates a Long from its big endian byte representation. + * @param bytes - Big endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesBE = function (bytes, unsigned) { + return new Long((bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7], (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3], unsigned); + }; + /** + * Tests if the specified object is a Long. + */ + Long.isLong = function (value) { + return isObjectLike(value) && value['__isLong__'] === true; + }; + /** + * Converts the specified value to a Long. + * @param unsigned - Whether unsigned or not, defaults to signed + */ + Long.fromValue = function (val, unsigned) { + if (typeof val === 'number') + return Long.fromNumber(val, unsigned); + if (typeof val === 'string') + return Long.fromString(val, unsigned); + // Throws for non-objects, converts non-instanceof Long: + return Long.fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned); + }; + /** Returns the sum of this and the specified Long. */ + Long.prototype.add = function (addend) { + if (!Long.isLong(addend)) + addend = Long.fromValue(addend); + // 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 = addend.high >>> 16; + var b32 = addend.high & 0xffff; + var b16 = addend.low >>> 16; + var b00 = addend.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, this.unsigned); + }; + /** + * Returns the sum of this and the specified Long. + * @returns Sum + */ + Long.prototype.and = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); + }; + /** + * Compares this Long's value with the specified's. + * @returns 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 (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.eq(other)) + return 0; + var thisNeg = this.isNegative(), otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) + return -1; + if (!thisNeg && otherNeg) + return 1; + // At this point the sign bits are the same + if (!this.unsigned) + return this.sub(other).isNegative() ? -1 : 1; + // Both are positive if at least one is unsigned + return other.high >>> 0 > this.high >>> 0 || + (other.high === this.high && other.low >>> 0 > this.low >>> 0) + ? -1 + : 1; + }; + /** This is an alias of {@link Long.compare} */ + Long.prototype.comp = function (other) { + return this.compare(other); + }; + /** + * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned. + * @returns Quotient + */ + Long.prototype.divide = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + if (divisor.isZero()) + throw Error('division by zero'); + // use wasm support if present + if (wasm) { + // guard against signed division overflow: the largest + // negative number / -1 would be 1 larger than the largest + // positive number, due to two's complement. + if (!this.unsigned && + this.high === -0x80000000 && + divisor.low === -1 && + divisor.high === -1) { + // be consistent with non-wasm code path + return this; + } + var low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (this.isZero()) + return this.unsigned ? Long.UZERO : Long.ZERO; + var approx, rem, res; + if (!this.unsigned) { + // This section is only relevant for signed longs and is derived from the + // closure library as a whole. + if (this.eq(Long.MIN_VALUE)) { + if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE)) + return Long.MIN_VALUE; + // recall that -MIN_VALUE == MIN_VALUE + else if (divisor.eq(Long.MIN_VALUE)) + return Long.ONE; + else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shr(1); + approx = halfThis.div(divisor).shl(1); + if (approx.eq(Long.ZERO)) { + return divisor.isNegative() ? Long.ONE : Long.NEG_ONE; + } + else { + rem = this.sub(divisor.mul(approx)); + res = approx.add(rem.div(divisor)); + return res; + } + } + } + else if (divisor.eq(Long.MIN_VALUE)) + return this.unsigned ? Long.UZERO : Long.ZERO; + if (this.isNegative()) { + if (divisor.isNegative()) + return this.neg().div(divisor.neg()); + return this.neg().div(divisor).neg(); + } + else if (divisor.isNegative()) + return this.div(divisor.neg()).neg(); + res = Long.ZERO; + } + else { + // The algorithm below has not been made for unsigned longs. It's therefore + // required to take special care of the MSB prior to running it. + if (!divisor.unsigned) + divisor = divisor.toUnsigned(); + if (divisor.gt(this)) + return Long.UZERO; + if (divisor.gt(this.shru(1))) + // 15 >>> 1 = 7 ; with divisor = 8 ; true + return Long.UONE; + res = Long.UZERO; + } + // 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. + // eslint-disable-next-line @typescript-eslint/no-this-alias + rem = this; + while (rem.gte(divisor)) { + // 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() / divisor.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.mul(divisor); + while (approxRem.isNegative() || approxRem.gt(rem)) { + approx -= delta; + approxRes = Long.fromNumber(approx, this.unsigned); + approxRem = approxRes.mul(divisor); + } + // 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.sub(approxRem); + } + return res; + }; + /**This is an alias of {@link Long.divide} */ + Long.prototype.div = function (divisor) { + return this.divide(divisor); + }; + /** + * Tests if this Long's value equals the specified's. + * @param other - Other value + */ + Long.prototype.equals = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1) + return false; + return this.high === other.high && this.low === other.low; + }; + /** This is an alias of {@link Long.equals} */ + Long.prototype.eq = function (other) { + return this.equals(other); + }; + /** Gets the high 32 bits as a signed integer. */ + Long.prototype.getHighBits = function () { + return this.high; + }; + /** Gets the high 32 bits as an unsigned integer. */ + Long.prototype.getHighBitsUnsigned = function () { + return this.high >>> 0; + }; + /** Gets the low 32 bits as a signed integer. */ + Long.prototype.getLowBits = function () { + return this.low; + }; + /** Gets the low 32 bits as an unsigned integer. */ + Long.prototype.getLowBitsUnsigned = function () { + return this.low >>> 0; + }; + /** Gets the number of bits needed to represent the absolute value of this Long. */ + Long.prototype.getNumBitsAbs = function () { + if (this.isNegative()) { + // Unsigned Longs are never negative + return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); + } + var val = this.high !== 0 ? this.high : this.low; + var bit; + for (bit = 31; bit > 0; bit--) + if ((val & (1 << bit)) !== 0) + break; + return this.high !== 0 ? bit + 33 : bit + 1; + }; + /** Tests if this Long's value is greater than the specified's. */ + Long.prototype.greaterThan = function (other) { + return this.comp(other) > 0; + }; + /** This is an alias of {@link Long.greaterThan} */ + Long.prototype.gt = function (other) { + return this.greaterThan(other); + }; + /** Tests if this Long's value is greater than or equal the specified's. */ + Long.prototype.greaterThanOrEqual = function (other) { + return this.comp(other) >= 0; + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.gte = function (other) { + return this.greaterThanOrEqual(other); + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.ge = function (other) { + return this.greaterThanOrEqual(other); + }; + /** Tests if this Long's value is even. */ + Long.prototype.isEven = function () { + return (this.low & 1) === 0; + }; + /** Tests if this Long's value is negative. */ + Long.prototype.isNegative = function () { + return !this.unsigned && this.high < 0; + }; + /** Tests if this Long's value is odd. */ + Long.prototype.isOdd = function () { + return (this.low & 1) === 1; + }; + /** Tests if this Long's value is positive. */ + Long.prototype.isPositive = function () { + return this.unsigned || this.high >= 0; + }; + /** Tests if this Long's value equals zero. */ + Long.prototype.isZero = function () { + return this.high === 0 && this.low === 0; + }; + /** Tests if this Long's value is less than the specified's. */ + Long.prototype.lessThan = function (other) { + return this.comp(other) < 0; + }; + /** This is an alias of {@link Long#lessThan}. */ + Long.prototype.lt = function (other) { + return this.lessThan(other); + }; + /** Tests if this Long's value is less than or equal the specified's. */ + Long.prototype.lessThanOrEqual = function (other) { + return this.comp(other) <= 0; + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.lte = function (other) { + return this.lessThanOrEqual(other); + }; + /** Returns this Long modulo the specified. */ + Long.prototype.modulo = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + // use wasm support if present + if (wasm) { + var low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + return this.sub(this.div(divisor).mul(divisor)); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.mod = function (divisor) { + return this.modulo(divisor); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.rem = function (divisor) { + return this.modulo(divisor); + }; + /** + * Returns the product of this and the specified Long. + * @param multiplier - Multiplier + * @returns Product + */ + Long.prototype.multiply = function (multiplier) { + if (this.isZero()) + return Long.ZERO; + if (!Long.isLong(multiplier)) + multiplier = Long.fromValue(multiplier); + // use wasm support if present + if (wasm) { + var low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (multiplier.isZero()) + return Long.ZERO; + if (this.eq(Long.MIN_VALUE)) + return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (multiplier.eq(Long.MIN_VALUE)) + return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (this.isNegative()) { + if (multiplier.isNegative()) + return this.neg().mul(multiplier.neg()); + else + return this.neg().mul(multiplier).neg(); + } + else if (multiplier.isNegative()) + return this.mul(multiplier.neg()).neg(); + // If both longs are small, use float multiplication + if (this.lt(Long.TWO_PWR_24) && multiplier.lt(Long.TWO_PWR_24)) + return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); + // 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 = multiplier.high >>> 16; + var b32 = multiplier.high & 0xffff; + var b16 = multiplier.low >>> 16; + var b00 = multiplier.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, this.unsigned); + }; + /** This is an alias of {@link Long.multiply} */ + Long.prototype.mul = function (multiplier) { + return this.multiply(multiplier); + }; + /** Returns the Negation of this Long's value. */ + Long.prototype.negate = function () { + if (!this.unsigned && this.eq(Long.MIN_VALUE)) + return Long.MIN_VALUE; + return this.not().add(Long.ONE); + }; + /** This is an alias of {@link Long.negate} */ + Long.prototype.neg = function () { + return this.negate(); + }; + /** Returns the bitwise NOT of this Long. */ + Long.prototype.not = function () { + return Long.fromBits(~this.low, ~this.high, this.unsigned); + }; + /** Tests if this Long's value differs from the specified's. */ + Long.prototype.notEquals = function (other) { + return !this.equals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.neq = function (other) { + return this.notEquals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.ne = function (other) { + return this.notEquals(other); + }; + /** + * Returns the bitwise OR of this Long and the specified. + */ + Long.prototype.or = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); + }; + /** + * Returns this Long with bits shifted to the left by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftLeft = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); + else + return Long.fromBits(0, this.low << (numBits - 32), this.unsigned); + }; + /** This is an alias of {@link Long.shiftLeft} */ + Long.prototype.shl = function (numBits) { + return this.shiftLeft(numBits); + }; + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRight = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); + else + return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); + }; + /** This is an alias of {@link Long.shiftRight} */ + Long.prototype.shr = function (numBits) { + return this.shiftRight(numBits); + }; + /** + * Returns this Long with bits logically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRightUnsigned = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + 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, this.unsigned); + } + else if (numBits === 32) + return Long.fromBits(high, 0, this.unsigned); + else + return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned); + } + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shr_u = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shru = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** + * Returns the difference of this and the specified Long. + * @param subtrahend - Subtrahend + * @returns Difference + */ + Long.prototype.subtract = function (subtrahend) { + if (!Long.isLong(subtrahend)) + subtrahend = Long.fromValue(subtrahend); + return this.add(subtrahend.neg()); + }; + /** This is an alias of {@link Long.subtract} */ + Long.prototype.sub = function (subtrahend) { + return this.subtract(subtrahend); + }; + /** Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. */ + Long.prototype.toInt = function () { + return this.unsigned ? this.low >>> 0 : this.low; + }; + /** Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). */ + Long.prototype.toNumber = function () { + if (this.unsigned) + return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0); + return this.high * TWO_PWR_32_DBL + (this.low >>> 0); + }; + /** Converts the Long to a BigInt (arbitrary precision). */ + Long.prototype.toBigInt = function () { + return BigInt(this.toString()); + }; + /** + * Converts this Long to its byte representation. + * @param le - Whether little or big endian, defaults to big endian + * @returns Byte representation + */ + Long.prototype.toBytes = function (le) { + return le ? this.toBytesLE() : this.toBytesBE(); + }; + /** + * Converts this Long to its little endian byte representation. + * @returns Little endian byte representation + */ + Long.prototype.toBytesLE = function () { + var hi = this.high, lo = this.low; + return [ + lo & 0xff, + (lo >>> 8) & 0xff, + (lo >>> 16) & 0xff, + lo >>> 24, + hi & 0xff, + (hi >>> 8) & 0xff, + (hi >>> 16) & 0xff, + hi >>> 24 + ]; + }; + /** + * Converts this Long to its big endian byte representation. + * @returns Big endian byte representation + */ + Long.prototype.toBytesBE = function () { + var hi = this.high, lo = this.low; + return [ + hi >>> 24, + (hi >>> 16) & 0xff, + (hi >>> 8) & 0xff, + hi & 0xff, + lo >>> 24, + (lo >>> 16) & 0xff, + (lo >>> 8) & 0xff, + lo & 0xff + ]; + }; + /** + * Converts this Long to signed. + */ + Long.prototype.toSigned = function () { + if (!this.unsigned) + return this; + return Long.fromBits(this.low, this.high, false); + }; + /** + * Converts the Long to a string written in the specified radix. + * @param radix - Radix (2-36), defaults to 10 + * @throws RangeError If `radix` is out of range + */ + Long.prototype.toString = function (radix) { + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + if (this.isZero()) + return '0'; + if (this.isNegative()) { + // Unsigned Longs are never negative + if (this.eq(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), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this); + return div.toString(radix) + rem1.toInt().toString(radix); + } + else + return '-' + this.neg().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), this.unsigned); + // eslint-disable-next-line @typescript-eslint/no-this-alias + var rem = this; + var result = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + var remDiv = rem.div(radixToPower); + var intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0; + var digits = intval.toString(radix); + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } + else { + while (digits.length < 6) + digits = '0' + digits; + result = '' + digits + result; + } + } + }; + /** Converts this Long to unsigned. */ + Long.prototype.toUnsigned = function () { + if (this.unsigned) + return this; + return Long.fromBits(this.low, this.high, true); + }; + /** Returns the bitwise XOR of this Long and the given one. */ + Long.prototype.xor = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); + }; + /** This is an alias of {@link Long.isZero} */ + Long.prototype.eqz = function () { + return this.isZero(); + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.le = function (other) { + return this.lessThanOrEqual(other); + }; + /* + **************************************************************** + * BSON SPECIFIC ADDITIONS * + **************************************************************** + */ + Long.prototype.toExtendedJSON = function (options) { + if (options && options.relaxed) + return this.toNumber(); + return { $numberLong: this.toString() }; + }; + Long.fromExtendedJSON = function (doc, options) { + var result = Long.fromString(doc.$numberLong); + return options && options.relaxed ? result.toNumber() : result; + }; + /** @internal */ + Long.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Long.prototype.inspect = function () { + return "new Long(\"".concat(this.toString(), "\"").concat(this.unsigned ? ', true' : '', ")"); + }; + Long.TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL); + /** Maximum unsigned value. */ + Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xffffffff | 0, 0xffffffff | 0, true); + /** Signed zero */ + Long.ZERO = Long.fromInt(0); + /** Unsigned zero. */ + Long.UZERO = Long.fromInt(0, true); + /** Signed one. */ + Long.ONE = Long.fromInt(1); + /** Unsigned one. */ + Long.UONE = Long.fromInt(1, true); + /** Signed negative one. */ + Long.NEG_ONE = Long.fromInt(-1); + /** Maximum signed value. */ + Long.MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0, false); + /** Minimum signed value. */ + Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false); + return Long; + }()); + Object.defineProperty(Long.prototype, '__isLong__', { value: true }); + Object.defineProperty(Long.prototype, '_bsontype', { value: '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+)?$/; + // 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; + // Detect if the value is a digit + function isDigit(value) { + return !isNaN(parseInt(value, 10)); + } + // Divide two uint128 values + function divideu128(value) { + var DIVISOR = Long.fromNumber(1000 * 1000 * 1000); + var _rem = Long.fromNumber(0); + if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) { + return { quotient: value, rem: _rem }; + } + for (var 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 + function multiply64x2(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 }; + } + function lessThan(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; + } + function invalidErr(string, message) { + throw new BSONTypeError("\"".concat(string, "\" is not a valid Decimal128 string - ").concat(message)); + } + /** + * A class representation of the BSON Decimal128 type. + * @public + * @category BSONType + */ + var Decimal128 = /** @class */ (function () { + /** + * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order, + * or a string representation as returned by .toString() + */ + function Decimal128(bytes) { + if (!(this instanceof Decimal128)) + return new Decimal128(bytes); + if (typeof bytes === 'string') { + this.bytes = Decimal128.fromString(bytes).bytes; + } + else if (isUint8Array(bytes)) { + if (bytes.byteLength !== 16) { + throw new BSONTypeError('Decimal128 must take a Buffer of 16 bytes'); + } + this.bytes = bytes; + } + else { + throw new BSONTypeError('Decimal128 must take a Buffer or string'); + } + } + /** + * Create a Decimal128 instance from a string representation + * + * @param representation - a numeric string representation. + */ + Decimal128.fromString = function (representation) { + // 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 = new Long(0, 0); + // The low 17 digits of the significand + var significandLow = new Long(0, 0); + // The biased exponent + var biasedExponent = 0; + // Read index + var index = 0; + // Naively prevent against REDOS attacks. + // TODO: implementing a custom parsing for this, or refactoring the regex would yield + // further gains. + if (representation.length >= 7000) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + // Results + var stringMatch = representation.match(PARSE_STRING_REGEXP); + var infMatch = representation.match(PARSE_INF_REGEXP); + var nanMatch = representation.match(PARSE_NAN_REGEXP); + // Validate the string + if ((!stringMatch && !infMatch && !nanMatch) || representation.length === 0) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + if (stringMatch) { + // full_match = stringMatch[0] + // sign = stringMatch[1] + var unsignedNumber = stringMatch[2]; + // stringMatch[3] is undefined if a whole number (ex "1", 12") + // but defined if a number w/ decimal in it (ex "1.0, 12.2") + var e = stringMatch[4]; + var expSign = stringMatch[5]; + var expNumber = stringMatch[6]; + // they provided e, but didn't give an exponent number. for ex "1e" + if (e && expNumber === undefined) + invalidErr(representation, 'missing exponent power'); + // they provided e, but didn't give a number before it. for ex "e1" + if (e && unsignedNumber === undefined) + invalidErr(representation, 'missing exponent base'); + if (e === undefined && (expSign || expNumber)) { + invalidErr(representation, 'missing e before exponent'); + } + } + // Get the negative or positive sign + if (representation[index] === '+' || representation[index] === '-') { + isNegative = representation[index++] === '-'; + } + // Check if user passed Infinity or NaN + if (!isDigit(representation[index]) && representation[index] !== '.') { + if (representation[index] === 'i' || representation[index] === 'I') { + return new Decimal128(buffer_1.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + else if (representation[index] === 'N') { + return new Decimal128(buffer_1.from(NAN_BUFFER)); + } + } + // Read all the digits + while (isDigit(representation[index]) || representation[index] === '.') { + if (representation[index] === '.') { + if (sawRadix) + invalidErr(representation, 'contains multiple periods'); + sawRadix = true; + index = index + 1; + continue; + } + if (nDigitsStored < 34) { + if (representation[index] !== '0' || foundNonZero) { + if (!foundNonZero) { + firstNonZero = nDigitsRead; + } + foundNonZero = true; + // Only store 34 digits + digits[digitsInsert++] = parseInt(representation[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 BSONTypeError('' + representation + ' not a valid Decimal128 string'); + // Read exponent if exists + if (representation[index] === 'e' || representation[index] === 'E') { + // Read exponent digits + var match = representation.substr(++index).match(EXPONENT_REGEX); + // No digits read + if (!match || !match[2]) + return new Decimal128(buffer_1.from(NAN_BUFFER)); + // Get exponent + exponent = parseInt(match[0], 10); + // Adjust the index + index = index + match[0].length; + } + // Return not a number + if (representation[index]) + return new Decimal128(buffer_1.from(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 (significantDigits !== 1) { + while (digits[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; + } + invalidErr(representation, 'overflow'); + } + exponent = exponent - 1; + } + while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { + // Shift last digit. can only do this if < significant digits than # stored. + if (lastDigit === 0 && significantDigits < nDigitsStored) { + 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 + var digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } + invalidErr(representation, 'overflow'); + } + } + // Round + // We've normalized the exponent, but might still need to round. + if (lastDigit - firstDigit + 1 < significantDigits) { + 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) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + // if negative, we need to increment again to account for - sign at start. + if (isNegative) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + var roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10); + var roundBit = 0; + if (roundDigit >= 5) { + roundBit = 1; + if (roundDigit === 5) { + roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0; + for (i = firstNonZero + lastDigit + 2; i < endOfString; i++) { + if (parseInt(representation[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(buffer_1.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + } + } + } + } + // 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) { + var 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 { + var 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(1))) { + // 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 = buffer_1.alloc(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); + }; + /** Create a string representation of the raw Decimal128 value */ + Decimal128.prototype.toString = function () { + // Note: bits in this routine are referred to starting at 0, + // from the sign bit, towards the coefficient. + // 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; + // true if the number is zero + var is_zero = false; + // the most significant significand bits (50-46) + var significand_msb; + // temporary storage for significand decoding + var significand128 = { parts: [0, 0, 0, 0] }; + // indexing variables + var j, k; + // Output string + var string = []; + // Unpack index + index = 0; + // Buffer reference + var buffer = this.bytes; + // Unpack the low 64bits into a long + // bits 96 - 127 + var low = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 64 - 95 + var midl = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // Unpack the high 64bits into a long + // bits 32 - 63 + var midh = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 0 - 31 + var 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 + // bits 1 - 5 + var 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; + } + // unbiased exponent + var 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; + // Perform 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; + while (!significand[index]) { + significand_digits = significand_digits - 1; + index = index + 1; + } + } + // the exponent if scientific notation is used + var 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 + // if there are too many significant digits, we should just be treating numbers + // as + or - 0 and using the non-scientific exponent (this is for the "invalid + // representation should be treated as 0/-0" spec cases in decimal128-1.json) + if (significand_digits > 34) { + string.push("".concat(0)); + if (exponent > 0) + string.push("E+".concat(exponent)); + else if (exponent < 0) + string.push("E".concat(exponent)); + return string.join(''); + } + string.push("".concat(significand[index++])); + significand_digits = significand_digits - 1; + if (significand_digits) { + string.push('.'); + } + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + // Exponent + string.push('E'); + if (scientific_exponent > 0) { + string.push("+".concat(scientific_exponent)); + } + else { + string.push("".concat(scientific_exponent)); + } + } + else { + // Regular format with no decimal place + if (exponent >= 0) { + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + } + else { + var radix_position = significand_digits + exponent; + // non-zero digits before radix + if (radix_position > 0) { + for (var i = 0; i < radix_position; i++) { + string.push("".concat(significand[index++])); + } + } + else { + string.push('0'); + } + string.push('.'); + // add leading zeros after radix + while (radix_position++ < 0) { + string.push('0'); + } + for (var i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) { + string.push("".concat(significand[index++])); + } + } + } + return string.join(''); + }; + Decimal128.prototype.toJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.prototype.toExtendedJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.fromExtendedJSON = function (doc) { + return Decimal128.fromString(doc.$numberDecimal); + }; + /** @internal */ + Decimal128.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Decimal128.prototype.inspect = function () { + return "new Decimal128(\"".concat(this.toString(), "\")"); + }; + return Decimal128; + }()); + Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' }); + + /** + * A class representation of the BSON Double type. + * @public + * @category BSONType + */ + var Double = /** @class */ (function () { + /** + * Create a Double type + * + * @param value - the number we want to represent as a double. + */ + function Double(value) { + if (!(this instanceof Double)) + return new Double(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value; + } + /** + * Access the number value. + * + * @returns returns the wrapped double number. + */ + Double.prototype.valueOf = function () { + return this.value; + }; + Double.prototype.toJSON = function () { + return this.value; + }; + Double.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + /** @internal */ + Double.prototype.toExtendedJSON = function (options) { + if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) { + return this.value; + } + // NOTE: JavaScript has +0 and -0, apparently to model limit calculations. If a user + // explicitly provided `-0` then we need to ensure the sign makes it into the output + if (Object.is(Math.sign(this.value), -0)) { + return { $numberDouble: "-".concat(this.value.toFixed(1)) }; + } + var $numberDouble; + if (Number.isInteger(this.value)) { + $numberDouble = this.value.toFixed(1); + if ($numberDouble.length >= 13) { + $numberDouble = this.value.toExponential(13).toUpperCase(); + } + } + else { + $numberDouble = this.value.toString(); + } + return { $numberDouble: $numberDouble }; + }; + /** @internal */ + Double.fromExtendedJSON = function (doc, options) { + var doubleValue = parseFloat(doc.$numberDouble); + return options && options.relaxed ? doubleValue : new Double(doubleValue); + }; + /** @internal */ + Double.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Double.prototype.inspect = function () { + var eJSON = this.toExtendedJSON(); + return "new Double(".concat(eJSON.$numberDouble, ")"); + }; + return Double; + }()); + Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' }); + + /** + * A class representation of a BSON Int32 type. + * @public + * @category BSONType + */ + var Int32 = /** @class */ (function () { + /** + * Create an Int32 type + * + * @param value - the number we want to represent as an int32. + */ + function Int32(value) { + if (!(this instanceof Int32)) + return new Int32(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value | 0; + } + /** + * Access the number value. + * + * @returns returns the wrapped int32 number. + */ + Int32.prototype.valueOf = function () { + return this.value; + }; + Int32.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + Int32.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + Int32.prototype.toExtendedJSON = function (options) { + if (options && (options.relaxed || options.legacy)) + return this.value; + return { $numberInt: this.value.toString() }; + }; + /** @internal */ + Int32.fromExtendedJSON = function (doc, options) { + return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new Int32(doc.$numberInt); + }; + /** @internal */ + Int32.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Int32.prototype.inspect = function () { + return "new Int32(".concat(this.valueOf(), ")"); + }; + return Int32; + }()); + Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' }); + + /** + * A class representation of the BSON MaxKey type. + * @public + * @category BSONType + */ + var MaxKey = /** @class */ (function () { + function MaxKey() { + if (!(this instanceof MaxKey)) + return new MaxKey(); + } + /** @internal */ + MaxKey.prototype.toExtendedJSON = function () { + return { $maxKey: 1 }; + }; + /** @internal */ + MaxKey.fromExtendedJSON = function () { + return new MaxKey(); + }; + /** @internal */ + MaxKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MaxKey.prototype.inspect = function () { + return 'new MaxKey()'; + }; + return MaxKey; + }()); + Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' }); + + /** + * A class representation of the BSON MinKey type. + * @public + * @category BSONType + */ + var MinKey = /** @class */ (function () { + function MinKey() { + if (!(this instanceof MinKey)) + return new MinKey(); + } + /** @internal */ + MinKey.prototype.toExtendedJSON = function () { + return { $minKey: 1 }; + }; + /** @internal */ + MinKey.fromExtendedJSON = function () { + return new MinKey(); + }; + /** @internal */ + MinKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MinKey.prototype.inspect = function () { + return 'new MinKey()'; + }; + return MinKey; + }()); + Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' }); + + // Regular expression that checks for hex value + var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$'); + // Unique sequence for the current process (initialized on first use) + var PROCESS_UNIQUE = null; + var kId = Symbol('id'); + /** + * A class representation of the BSON ObjectId type. + * @public + * @category BSONType + */ + var ObjectId = /** @class */ (function () { + /** + * Create an ObjectId type + * + * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number. + */ + function ObjectId(inputId) { + if (!(this instanceof ObjectId)) + return new ObjectId(inputId); + // workingId is set based on type of input and whether valid id exists for the input + var workingId; + if (typeof inputId === 'object' && inputId && 'id' in inputId) { + if (typeof inputId.id !== 'string' && !ArrayBuffer.isView(inputId.id)) { + throw new BSONTypeError('Argument passed in must have an id that is of type string or Buffer'); + } + if ('toHexString' in inputId && typeof inputId.toHexString === 'function') { + workingId = buffer_1.from(inputId.toHexString(), 'hex'); + } + else { + workingId = inputId.id; + } + } + else { + workingId = inputId; + } + // the following cases use workingId to construct an ObjectId + if (workingId == null || typeof workingId === 'number') { + // The most common use case (blank id, new objectId instance) + // Generate a new id + this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined); + } + else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) { + // If intstanceof matches we can escape calling ensure buffer in Node.js environments + this[kId] = workingId instanceof buffer_1 ? workingId : ensureBuffer(workingId); + } + else if (typeof workingId === 'string') { + if (workingId.length === 12) { + var bytes = buffer_1.from(workingId); + if (bytes.byteLength === 12) { + this[kId] = bytes; + } + else { + throw new BSONTypeError('Argument passed in must be a string of 12 bytes'); + } + } + else if (workingId.length === 24 && checkForHexRegExp.test(workingId)) { + this[kId] = buffer_1.from(workingId, 'hex'); + } + else { + throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer'); + } + } + else { + throw new BSONTypeError('Argument passed in does not match the accepted types'); + } + // If we are caching the hex string + if (ObjectId.cacheHexString) { + this.__id = this.id.toString('hex'); + } + } + Object.defineProperty(ObjectId.prototype, "id", { + /** + * The ObjectId bytes + * @readonly + */ + get: function () { + return this[kId]; + }, + set: function (value) { + this[kId] = value; + if (ObjectId.cacheHexString) { + this.__id = value.toString('hex'); + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(ObjectId.prototype, "generationTime", { + /** + * The generation time of this ObjectId instance + * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch + */ + get: function () { + return this.id.readInt32BE(0); + }, + set: function (value) { + // Encode time into first 4 bytes + this.id.writeUInt32BE(value, 0); + }, + enumerable: false, + configurable: true + }); + /** Returns the ObjectId id as a 24 character hex string representation */ + ObjectId.prototype.toHexString = function () { + if (ObjectId.cacheHexString && this.__id) { + return this.__id; + } + var hexString = this.id.toString('hex'); + if (ObjectId.cacheHexString && !this.__id) { + this.__id = hexString; + } + return hexString; + }; + /** + * Update the ObjectId index + * @privateRemarks + * Used in generating new ObjectId's on the driver + * @internal + */ + ObjectId.getInc = function () { + return (ObjectId.index = (ObjectId.index + 1) % 0xffffff); + }; + /** + * Generate a 12 byte id buffer used in ObjectId's + * + * @param time - pass in a second based timestamp. + */ + ObjectId.generate = function (time) { + if ('number' !== typeof time) { + time = Math.floor(Date.now() / 1000); + } + var inc = ObjectId.getInc(); + var buffer = buffer_1.alloc(12); + // 4-byte timestamp + buffer.writeUInt32BE(time, 0); + // set PROCESS_UNIQUE if yet not initialized + if (PROCESS_UNIQUE === null) { + PROCESS_UNIQUE = randomBytes(5); + } + // 5-byte process unique + buffer[4] = PROCESS_UNIQUE[0]; + buffer[5] = PROCESS_UNIQUE[1]; + buffer[6] = PROCESS_UNIQUE[2]; + buffer[7] = PROCESS_UNIQUE[3]; + buffer[8] = PROCESS_UNIQUE[4]; + // 3-byte counter + buffer[11] = inc & 0xff; + buffer[10] = (inc >> 8) & 0xff; + buffer[9] = (inc >> 16) & 0xff; + return buffer; + }; + /** + * Converts the id into a 24 character hex string for printing + * + * @param format - The Buffer toString format parameter. + */ + ObjectId.prototype.toString = function (format) { + // Is the id a buffer then use the buffer toString method to return the format + if (format) + return this.id.toString(format); + return this.toHexString(); + }; + /** Converts to its JSON the 24 character hex string representation. */ + ObjectId.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this ObjectId with `otherID`. + * + * @param otherId - ObjectId instance to compare against. + */ + ObjectId.prototype.equals = function (otherId) { + if (otherId === undefined || otherId === null) { + return false; + } + if (otherId instanceof ObjectId) { + return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]); + } + if (typeof otherId === 'string' && + ObjectId.isValid(otherId) && + otherId.length === 12 && + isUint8Array(this.id)) { + return otherId === buffer_1.prototype.toString.call(this.id, 'latin1'); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 24) { + return otherId.toLowerCase() === this.toHexString(); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 12) { + return buffer_1.from(otherId).equals(this.id); + } + if (typeof otherId === 'object' && + 'toHexString' in otherId && + typeof otherId.toHexString === 'function') { + var otherIdString = otherId.toHexString(); + var thisIdString = this.toHexString().toLowerCase(); + return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString; + } + return false; + }; + /** Returns the generation date (accurate up to the second) that this ID was generated. */ + ObjectId.prototype.getTimestamp = function () { + var timestamp = new Date(); + var time = this.id.readUInt32BE(0); + timestamp.setTime(Math.floor(time) * 1000); + return timestamp; + }; + /** @internal */ + ObjectId.createPk = function () { + 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. + * + * @param time - an integer number representing a number of seconds. + */ + ObjectId.createFromTime = function (time) { + var buffer = buffer_1.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Encode time into first 4 bytes + buffer.writeUInt32BE(time, 0); + // Return the new objectId + return new ObjectId(buffer); + }; + /** + * Creates an ObjectId from a hex string representation of an ObjectId. + * + * @param hexString - create a ObjectId from a passed in 24 character hexstring. + */ + ObjectId.createFromHexString = function (hexString) { + // Throw an error if it's not a valid setup + if (typeof hexString === 'undefined' || (hexString != null && hexString.length !== 24)) { + throw new BSONTypeError('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'); + } + return new ObjectId(buffer_1.from(hexString, 'hex')); + }; + /** + * Checks if a value is a valid bson ObjectId + * + * @param id - ObjectId instance to validate. + */ + ObjectId.isValid = function (id) { + if (id == null) + return false; + try { + new ObjectId(id); + return true; + } + catch (_a) { + return false; + } + }; + /** @internal */ + ObjectId.prototype.toExtendedJSON = function () { + if (this.toHexString) + return { $oid: this.toHexString() }; + return { $oid: this.toString('hex') }; + }; + /** @internal */ + ObjectId.fromExtendedJSON = function (doc) { + return new ObjectId(doc.$oid); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 24 character hex string representation. + * @internal + */ + ObjectId.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + ObjectId.prototype.inspect = function () { + return "new ObjectId(\"".concat(this.toHexString(), "\")"); + }; + /** @internal */ + ObjectId.index = Math.floor(Math.random() * 0xffffff); + return ObjectId; + }()); + // Deprecated methods + Object.defineProperty(ObjectId.prototype, 'generate', { + value: deprecate(function (time) { return ObjectId.generate(time); }, 'Please use the static `ObjectId.generate(time)` instead') + }); + Object.defineProperty(ObjectId.prototype, 'getInc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') + }); + Object.defineProperty(ObjectId.prototype, 'get_inc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') + }); + Object.defineProperty(ObjectId, 'get_inc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') + }); + Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' }); + + function alphabetize(str) { + return str.split('').sort().join(''); + } + /** + * A class representation of the BSON RegExp type. + * @public + * @category BSONType + */ + var BSONRegExp = /** @class */ (function () { + /** + * @param pattern - The regular expression pattern to match + * @param options - The regular expression options + */ + function BSONRegExp(pattern, options) { + if (!(this instanceof BSONRegExp)) + return new BSONRegExp(pattern, options); + this.pattern = pattern; + this.options = alphabetize(options !== null && options !== void 0 ? options : ''); + if (this.pattern.indexOf('\x00') !== -1) { + throw new BSONError("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern))); + } + if (this.options.indexOf('\x00') !== -1) { + throw new BSONError("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.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 BSONError("The regular expression option [".concat(this.options[i], "] is not supported")); + } + } + } + BSONRegExp.parseOptions = function (options) { + return options ? options.split('').sort().join('') : ''; + }; + /** @internal */ + BSONRegExp.prototype.toExtendedJSON = function (options) { + options = options || {}; + if (options.legacy) { + return { $regex: this.pattern, $options: this.options }; + } + return { $regularExpression: { pattern: this.pattern, options: this.options } }; + }; + /** @internal */ + BSONRegExp.fromExtendedJSON = function (doc) { + if ('$regex' in doc) { + if (typeof doc.$regex !== 'string') { + // This is for $regex query operators that have extended json values. + if (doc.$regex._bsontype === 'BSONRegExp') { + return doc; + } + } + else { + return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options)); + } + } + if ('$regularExpression' in doc) { + return new BSONRegExp(doc.$regularExpression.pattern, BSONRegExp.parseOptions(doc.$regularExpression.options)); + } + throw new BSONTypeError("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(doc))); + }; + return BSONRegExp; + }()); + Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' }); + + /** + * A class representation of the BSON Symbol type. + * @public + * @category BSONType + */ + var BSONSymbol = /** @class */ (function () { + /** + * @param value - the string representing the symbol. + */ + function BSONSymbol(value) { + if (!(this instanceof BSONSymbol)) + return new BSONSymbol(value); + this.value = value; + } + /** Access the wrapped string value. */ + BSONSymbol.prototype.valueOf = function () { + return this.value; + }; + BSONSymbol.prototype.toString = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.inspect = function () { + return "new BSONSymbol(\"".concat(this.value, "\")"); + }; + BSONSymbol.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.toExtendedJSON = function () { + return { $symbol: this.value }; + }; + /** @internal */ + BSONSymbol.fromExtendedJSON = function (doc) { + return new BSONSymbol(doc.$symbol); + }; + /** @internal */ + BSONSymbol.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + return BSONSymbol; + }()); + Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' }); + + /** @public */ + var LongWithoutOverridesClass = Long; + /** + * @public + * @category BSONType + * */ + var Timestamp = /** @class */ (function (_super) { + __extends(Timestamp, _super); + function Timestamp(low, high) { + var _this = this; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + if (!(_this instanceof Timestamp)) + return new Timestamp(low, high); + if (Long.isLong(low)) { + _this = _super.call(this, low.low, low.high, true) || this; + } + else if (isObjectLike(low) && typeof low.t !== 'undefined' && typeof low.i !== 'undefined') { + _this = _super.call(this, low.i, low.t, true) || this; + } + else { + _this = _super.call(this, low, high, true) || this; + } + Object.defineProperty(_this, '_bsontype', { + value: 'Timestamp', + writable: false, + configurable: false, + enumerable: false + }); + return _this; + } + Timestamp.prototype.toJSON = function () { + return { + $timestamp: this.toString() + }; + }; + /** Returns a Timestamp represented by the given (32-bit) integer value. */ + Timestamp.fromInt = function (value) { + return new Timestamp(Long.fromInt(value, true)); + }; + /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */ + Timestamp.fromNumber = function (value) { + return new Timestamp(Long.fromNumber(value, true)); + }; + /** + * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits. + * + * @param lowBits - the low 32-bits. + * @param highBits - the high 32-bits. + */ + Timestamp.fromBits = function (lowBits, highBits) { + return new Timestamp(lowBits, highBits); + }; + /** + * Returns a Timestamp from the given string, optionally using the given radix. + * + * @param str - the textual representation of the Timestamp. + * @param optRadix - the radix in which the text is written. + */ + Timestamp.fromString = function (str, optRadix) { + return new Timestamp(Long.fromString(str, true, optRadix)); + }; + /** @internal */ + Timestamp.prototype.toExtendedJSON = function () { + return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } }; + }; + /** @internal */ + Timestamp.fromExtendedJSON = function (doc) { + return new Timestamp(doc.$timestamp); + }; + /** @internal */ + Timestamp.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Timestamp.prototype.inspect = function () { + return "new Timestamp({ t: ".concat(this.getHighBits(), ", i: ").concat(this.getLowBits(), " })"); + }; + Timestamp.MAX_VALUE = Long.MAX_UNSIGNED_VALUE; + return Timestamp; + }(LongWithoutOverridesClass)); + + function isBSONType(value) { + return (isObjectLike(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string'); + } + // INT32 boundaries + var BSON_INT32_MAX = 0x7fffffff; + var BSON_INT32_MIN = -0x80000000; + // INT64 boundaries + // const BSON_INT64_MAX = 0x7fffffffffffffff; // TODO(NODE-4377): This number cannot be precisely represented in JS + var BSON_INT64_MAX = 0x8000000000000000; + var BSON_INT64_MIN = -0x8000000000000000; + // all the types where we don't need to do any special processing and can just pass the EJSON + //straight to type.fromExtendedJSON + var keysToCodecs = { + $oid: ObjectId, + $binary: Binary, + $uuid: Binary, + $symbol: BSONSymbol, + $numberInt: Int32, + $numberDecimal: Decimal128, + $numberDouble: Double, + $numberLong: Long, + $minKey: MinKey, + $maxKey: MaxKey, + $regex: BSONRegExp, + $regularExpression: BSONRegExp, + $timestamp: Timestamp + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function deserializeValue(value, options) { + if (options === void 0) { options = {}; } + if (typeof value === 'number') { + if (options.relaxed || options.legacy) { + return value; + } + // if it's an integer, should interpret as smallest BSON integer + // that can represent it exactly. (if out of range, interpret as double.) + if (Math.floor(value) === value) { + if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) + return new Int32(value); + if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) + return Long.fromNumber(value); + } + // If the number is a non-integer or out of integer range, should interpret as BSON Double. + return new Double(value); + } + // from here on out we're looking for bson types, so bail if its not an object + if (value == null || typeof value !== 'object') + return value; + // upgrade deprecated undefined to null + if (value.$undefined) + return null; + var keys = Object.keys(value).filter(function (k) { return k.startsWith('$') && value[k] != null; }); + for (var i = 0; i < keys.length; i++) { + var c = keysToCodecs[keys[i]]; + if (c) + return c.fromExtendedJSON(value, options); + } + if (value.$date != null) { + var d = value.$date; + var date = new Date(); + if (options.legacy) { + if (typeof d === 'number') + date.setTime(d); + else if (typeof d === 'string') + date.setTime(Date.parse(d)); + } + else { + if (typeof d === 'string') + date.setTime(Date.parse(d)); + else if (Long.isLong(d)) + date.setTime(d.toNumber()); + else if (typeof d === 'number' && options.relaxed) + date.setTime(d); + } + return date; + } + if (value.$code != null) { + var copy = Object.assign({}, value); + if (value.$scope) { + copy.$scope = deserializeValue(value.$scope); + } + return Code.fromExtendedJSON(value); + } + if (isDBRefLike(value) || value.$dbPointer) { + var v = value.$ref ? value : value.$dbPointer; + // we run into this in a "degenerate EJSON" case (with $id and $ref order flipped) + // because of the order JSON.parse goes through the document + if (v instanceof DBRef) + return v; + var dollarKeys = Object.keys(v).filter(function (k) { return k.startsWith('$'); }); + var valid_1 = true; + dollarKeys.forEach(function (k) { + if (['$ref', '$id', '$db'].indexOf(k) === -1) + valid_1 = false; + }); + // only make DBRef if $ keys are all valid + if (valid_1) + return DBRef.fromExtendedJSON(v); + } + return value; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function serializeArray(array, options) { + return array.map(function (v, index) { + options.seenObjects.push({ propertyName: "index ".concat(index), obj: null }); + try { + return serializeValue(v, options); + } + finally { + options.seenObjects.pop(); + } + }); + } + function getISOString(date) { + var isoStr = date.toISOString(); + // we should only show milliseconds in timestamp if they're non-zero + return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + 'Z'; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function serializeValue(value, options) { + if ((typeof value === 'object' || typeof value === 'function') && value !== null) { + var index = options.seenObjects.findIndex(function (entry) { return entry.obj === value; }); + if (index !== -1) { + var props = options.seenObjects.map(function (entry) { return entry.propertyName; }); + var leadingPart = props + .slice(0, index) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var alreadySeen = props[index]; + var circularPart = ' -> ' + + props + .slice(index + 1, props.length - 1) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var current = props[props.length - 1]; + var leadingSpace = ' '.repeat(leadingPart.length + alreadySeen.length / 2); + var dashes = '-'.repeat(circularPart.length + (alreadySeen.length + current.length) / 2 - 1); + throw new BSONTypeError('Converting circular structure to EJSON:\n' + + " ".concat(leadingPart).concat(alreadySeen).concat(circularPart).concat(current, "\n") + + " ".concat(leadingSpace, "\\").concat(dashes, "/")); + } + options.seenObjects[options.seenObjects.length - 1].obj = value; + } + if (Array.isArray(value)) + return serializeArray(value, options); + if (value === undefined) + return null; + if (value instanceof Date || isDate(value)) { + var dateNum = value.getTime(), + // is it in year range 1970-9999? + inRange = dateNum > -1 && dateNum < 253402318800000; + if (options.legacy) { + return options.relaxed && inRange + ? { $date: value.getTime() } + : { $date: getISOString(value) }; + } + return options.relaxed && inRange + ? { $date: getISOString(value) } + : { $date: { $numberLong: value.getTime().toString() } }; + } + if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) { + // it's an integer + if (Math.floor(value) === value) { + var int32Range = value >= BSON_INT32_MIN && value <= BSON_INT32_MAX, int64Range = value >= BSON_INT64_MIN && value <= BSON_INT64_MAX; + // interpret as being of the smallest BSON integer type that can represent the number exactly + if (int32Range) + return { $numberInt: value.toString() }; + if (int64Range) + return { $numberLong: value.toString() }; + } + return { $numberDouble: value.toString() }; + } + if (value instanceof RegExp || isRegExp(value)) { + var flags = value.flags; + if (flags === undefined) { + var match = value.toString().match(/[gimuy]*$/); + if (match) { + flags = match[0]; + } + } + var rx = new BSONRegExp(value.source, flags); + return rx.toExtendedJSON(options); + } + if (value != null && typeof value === 'object') + return serializeDocument(value, options); + return value; + } + var BSON_TYPE_MAPPINGS = { + Binary: function (o) { return new Binary(o.value(), o.sub_type); }, + Code: function (o) { return new Code(o.code, o.scope); }, + DBRef: function (o) { return new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields); }, + Decimal128: function (o) { return new Decimal128(o.bytes); }, + Double: function (o) { return new Double(o.value); }, + Int32: function (o) { return new Int32(o.value); }, + Long: function (o) { + return Long.fromBits( + // underscore variants for 1.x backwards compatibility + o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_); + }, + MaxKey: function () { return new MaxKey(); }, + MinKey: function () { return new MinKey(); }, + ObjectID: function (o) { return new ObjectId(o); }, + ObjectId: function (o) { return new ObjectId(o); }, + BSONRegExp: function (o) { return new BSONRegExp(o.pattern, o.options); }, + Symbol: function (o) { return new BSONSymbol(o.value); }, + Timestamp: function (o) { return Timestamp.fromBits(o.low, o.high); } + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function serializeDocument(doc, options) { + if (doc == null || typeof doc !== 'object') + throw new BSONError('not an object instance'); + var bsontype = doc._bsontype; + if (typeof bsontype === 'undefined') { + // It's a regular object. Recursively serialize its property values. + var _doc = {}; + for (var name in doc) { + options.seenObjects.push({ propertyName: name, obj: null }); + try { + var value = serializeValue(doc[name], options); + if (name === '__proto__') { + Object.defineProperty(_doc, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + _doc[name] = value; + } + } + finally { + options.seenObjects.pop(); + } + } + return _doc; + } + else if (isBSONType(doc)) { + // the "document" is really just a BSON type object + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var outDoc = doc; + if (typeof outDoc.toExtendedJSON !== 'function') { + // There's no EJSON serialization function on the object. It's probably an + // object created by a previous version of this library (or another library) + // that's duck-typing objects to look like they were generated by this library). + // Copy the object into this library's version of that type. + var mapper = BSON_TYPE_MAPPINGS[doc._bsontype]; + if (!mapper) { + throw new BSONTypeError('Unrecognized or invalid _bsontype: ' + doc._bsontype); + } + outDoc = mapper(outDoc); + } + // Two BSON types may have nested objects that may need to be serialized too + if (bsontype === 'Code' && outDoc.scope) { + outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options)); + } + else if (bsontype === 'DBRef' && outDoc.oid) { + outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options)); + } + return outDoc.toExtendedJSON(options); + } + else { + throw new BSONError('_bsontype must be a string, but was: ' + typeof bsontype); + } + } + /** + * EJSON parse / stringify API + * @public + */ + // the namespace here is used to emulate `export * as EJSON from '...'` + // which as of now (sept 2020) api-extractor does not support + // eslint-disable-next-line @typescript-eslint/no-namespace + exports.EJSON = void 0; + (function (EJSON) { + /** + * Parse an Extended JSON string, constructing the JavaScript value or object described by that + * string. + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const text = '{ "int32": { "$numberInt": "10" } }'; + * + * // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } } + * console.log(EJSON.parse(text, { relaxed: false })); + * + * // prints { int32: 10 } + * console.log(EJSON.parse(text)); + * ``` + */ + function parse(text, options) { + var finalOptions = Object.assign({}, { relaxed: true, legacy: false }, options); + // relaxed implies not strict + if (typeof finalOptions.relaxed === 'boolean') + finalOptions.strict = !finalOptions.relaxed; + if (typeof finalOptions.strict === 'boolean') + finalOptions.relaxed = !finalOptions.strict; + return JSON.parse(text, function (key, value) { + if (key.indexOf('\x00') !== -1) { + throw new BSONError("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(key))); + } + return deserializeValue(value, finalOptions); + }); + } + EJSON.parse = parse; + /** + * Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer + * function is specified or optionally including only the specified properties if a replacer array + * is specified. + * + * @param value - The value to convert to extended JSON + * @param replacer - A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string + * @param space - A String or Number object that's used to insert white space into the output JSON string for readability purposes. + * @param options - Optional settings + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const Int32 = require('mongodb').Int32; + * const doc = { int32: new Int32(10) }; + * + * // prints '{"int32":{"$numberInt":"10"}}' + * console.log(EJSON.stringify(doc, { relaxed: false })); + * + * // prints '{"int32":10}' + * console.log(EJSON.stringify(doc)); + * ``` + */ + function stringify(value, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + replacer, space, options) { + if (space != null && typeof space === 'object') { + options = space; + space = 0; + } + if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) { + options = replacer; + replacer = undefined; + space = 0; + } + var serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, { + seenObjects: [{ propertyName: '(root)', obj: null }] + }); + var doc = serializeValue(value, serializeOptions); + return JSON.stringify(doc, replacer, space); + } + EJSON.stringify = stringify; + /** + * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object. + * + * @param value - The object to serialize + * @param options - Optional settings passed to the `stringify` function + */ + function serialize(value, options) { + options = options || {}; + return JSON.parse(stringify(value, options)); + } + EJSON.serialize = serialize; + /** + * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types + * + * @param ejson - The Extended JSON object to deserialize + * @param options - Optional settings passed to the parse method + */ + function deserialize(ejson, options) { + options = options || {}; + return parse(JSON.stringify(ejson), options); + } + EJSON.deserialize = deserialize; + })(exports.EJSON || (exports.EJSON = {})); + + /* eslint-disable @typescript-eslint/no-explicit-any */ + /** @public */ + exports.Map = void 0; + var bsonGlobal = getGlobal(); + if (bsonGlobal.Map) { + exports.Map = bsonGlobal.Map; + } + else { + // We will return a polyfill + exports.Map = /** @class */ (function () { + function Map(array) { + if (array === void 0) { 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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? [key, _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? _this._values[key].v : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + Object.defineProperty(Map.prototype, "size", { + get: function () { + return this._keys.length; + }, + enumerable: false, + configurable: true + }); + return Map; + }()); + } + + function calculateObjectSize$1(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 (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + object = object.toBSON(); + } + // Calculate size + for (var key in object) { + totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined); + } + } + return totalLength; + } + /** @internal */ + function calculateElement(name, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + value, serializeFunctions, isArray, ignoreUndefined) { + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (isArray === void 0) { isArray = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = false; } + // If we have toBSON defined, override the current object + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + switch (typeof value) { + case 'string': + return 1 + buffer_1.byteLength(name, 'utf8') + 1 + 4 + buffer_1.byteLength(value, 'utf8') + 1; + case 'number': + if (Math.floor(value) === value && + value >= JS_INT_MIN && + value <= JS_INT_MAX) { + if (value >= BSON_INT32_MIN$1 && value <= BSON_INT32_MAX$1) { + // 32 bit + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (4 + 1); + } + else { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + } + else { + // 64 bit + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + case 'undefined': + if (isArray || !ignoreUndefined) + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + 1; + return 0; + case 'boolean': + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (1 + 1); + case 'object': + if (value == null || value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + 1; + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (12 + 1); + } + else if (value instanceof Date || isDate(value)) { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + else if (ArrayBuffer.isView(value) || + value instanceof ArrayBuffer || + isAnyArrayBuffer(value)) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength); + } + else if (value['_bsontype'] === 'Long' || + value['_bsontype'] === 'Double' || + value['_bsontype'] === 'Timestamp') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + else if (value['_bsontype'] === 'Decimal128') { + return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (16 + 1); + } + else if (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_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + buffer_1.byteLength(value.code.toString(), 'utf8') + + 1 + + calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined)); + } + else { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + buffer_1.byteLength(value.code.toString(), 'utf8') + + 1); + } + } + else if (value['_bsontype'] === 'Binary') { + var binary = value; + // Check what kind of subtype we have + if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + (binary.position + 1 + 4 + 1 + 4)); + } + else { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (binary.position + 1 + 4 + 1)); + } + } + else if (value['_bsontype'] === 'Symbol') { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + buffer_1.byteLength(value.value, 'utf8') + + 4 + + 1 + + 1); + } + else if (value['_bsontype'] === 'DBRef') { + // Set up correct object for serialization + var ordered_values = Object.assign({ + $ref: value.collection, + $id: value.oid + }, value.fields); + // Add db reference if it exists + if (value.db != null) { + ordered_values['$db'] = value.db; + } + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + calculateObjectSize$1(ordered_values, serializeFunctions, ignoreUndefined)); + } + else if (value instanceof RegExp || isRegExp(value)) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.byteLength(value.source, 'utf8') + + 1 + + (value.global ? 1 : 0) + + (value.ignoreCase ? 1 : 0) + + (value.multiline ? 1 : 0) + + 1); + } + else if (value['_bsontype'] === 'BSONRegExp') { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.byteLength(value.pattern, 'utf8') + + 1 + + buffer_1.byteLength(value.options, 'utf8') + + 1); + } + else { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + calculateObjectSize$1(value, serializeFunctions, ignoreUndefined) + + 1); + } + case 'function': + // WTF for 0.4.X where typeof /someregexp/ === 'function' + if (value instanceof RegExp || isRegExp(value) || String.call(value) === '[object RegExp]') { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.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_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + buffer_1.byteLength(normalizedFunctionString(value), 'utf8') + + 1 + + calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined)); + } + else if (serializeFunctions) { + return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + buffer_1.byteLength(normalizedFunctionString(value), 'utf8') + + 1); + } + } + } + return 0; + } + + var FIRST_BIT = 0x80; + var FIRST_TWO_BITS = 0xc0; + var FIRST_THREE_BITS = 0xe0; + var FIRST_FOUR_BITS = 0xf0; + var FIRST_FIVE_BITS = 0xf8; + var TWO_BIT_CHAR = 0xc0; + var THREE_BIT_CHAR = 0xe0; + var FOUR_BIT_CHAR = 0xf0; + var CONTINUING_CHAR = 0x80; + /** + * Determines if the passed in bytes are valid utf8 + * @param bytes - An array of 8-bit bytes. Must be indexable and have length property + * @param start - The index to start validating + * @param end - The index to end validating + */ + function validateUtf8(bytes, start, end) { + var continuation = 0; + for (var i = start; i < end; i += 1) { + var byte = bytes[i]; + if (continuation) { + if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) { + return false; + } + continuation -= 1; + } + else if (byte & FIRST_BIT) { + if ((byte & FIRST_THREE_BITS) === TWO_BIT_CHAR) { + continuation = 1; + } + else if ((byte & FIRST_FOUR_BITS) === THREE_BIT_CHAR) { + continuation = 2; + } + else if ((byte & FIRST_FIVE_BITS) === FOUR_BIT_CHAR) { + continuation = 3; + } + else { + return false; + } + } + } + return !continuation; + } + + // Internal long versions + var JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX); + var JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN); + var functionCache = {}; + function deserialize$1(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); + if (size < 5) { + throw new BSONError("bson size must be >= 5, is ".concat(size)); + } + if (options.allowObjectSmallerThanBufferSize && buffer.length < size) { + throw new BSONError("buffer length ".concat(buffer.length, " must be >= bson size ").concat(size)); + } + if (!options.allowObjectSmallerThanBufferSize && buffer.length !== size) { + throw new BSONError("buffer length ".concat(buffer.length, " must === bson size ").concat(size)); + } + if (size + index > buffer.byteLength) { + throw new BSONError("(bson size ".concat(size, " + options.index ").concat(index, " must be <= buffer length ").concat(buffer.byteLength, ")")); + } + // Illegal end value + if (buffer[index + size - 1] !== 0) { + throw new BSONError("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 allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/; + function deserializeObject(buffer, index, options, isArray) { + if (isArray === void 0) { isArray = false; } + var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; + var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions']; + 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']; + // Ensures default validation option if none given + var validation = options.validation == null ? { utf8: true } : options.validation; + // Shows if global utf-8 validation is enabled or disabled + var globalUTFValidation = true; + // Reflects utf-8 validation setting regardless of global or specific key validation + var validationSetting; + // Set of keys either to enable or disable validation on + var utf8KeysSet = new Set(); + // Check for boolean uniformity and empty validation option + var utf8ValidatedKeys = validation.utf8; + if (typeof utf8ValidatedKeys === 'boolean') { + validationSetting = utf8ValidatedKeys; + } + else { + globalUTFValidation = false; + var utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function (key) { + return utf8ValidatedKeys[key]; + }); + if (utf8ValidationValues.length === 0) { + throw new BSONError('UTF-8 validation setting cannot be empty'); + } + if (typeof utf8ValidationValues[0] !== 'boolean') { + throw new BSONError('Invalid UTF-8 validation option, must specify boolean values'); + } + validationSetting = utf8ValidationValues[0]; + // Ensures boolean uniformity in utf-8 validation (all true or all false) + if (!utf8ValidationValues.every(function (item) { return item === validationSetting; })) { + throw new BSONError('Invalid UTF-8 validation option - keys must be all true or all false'); + } + } + // Add keys to set that will either be validated or not based on validationSetting + if (!globalUTFValidation) { + for (var _i = 0, _a = Object.keys(utf8ValidatedKeys); _i < _a.length; _i++) { + var key = _a[_i]; + utf8KeysSet.add(key); + } + } + // Set the start index + var startIndex = index; + // Validate that we have at least 4 bytes of buffer + if (buffer.length < 5) + throw new BSONError('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 BSONError('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; + var isPossibleDBRef = isArray ? false : null; + // While we have more left data left keep parsing + var dataview = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength); + 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.byteLength) + throw new BSONError('Bad BSON Document: illegal CString'); + // Represents the key + var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i); + // shouldValidateKey is true if the key should be validated, false otherwise + var shouldValidateKey = true; + if (globalUTFValidation || utf8KeysSet.has(name)) { + shouldValidateKey = validationSetting; + } + else { + shouldValidateKey = !validationSetting; + } + if (isPossibleDBRef !== false && name[0] === '$') { + isPossibleDBRef = allowedDBRefKeys.test(name); + } + var value = void 0; + index = i + 1; + if (elementType === 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 BSONError('bad string length in bson'); + } + value = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + index = index + stringSize; + } + else if (elementType === BSON_DATA_OID) { + var oid = buffer_1.alloc(12); + buffer.copy(oid, 0, index, index + 12); + value = new ObjectId(oid); + index = index + 12; + } + else if (elementType === BSON_DATA_INT && promoteValues === false) { + value = new Int32(buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24)); + } + else if (elementType === BSON_DATA_INT) { + value = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + } + else if (elementType === BSON_DATA_NUMBER && promoteValues === false) { + value = new Double(dataview.getFloat64(index, true)); + index = index + 8; + } + else if (elementType === BSON_DATA_NUMBER) { + value = dataview.getFloat64(index, true); + index = index + 8; + } + else if (elementType === 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); + value = new Date(new Long(lowBits, highBits).toNumber()); + } + else if (elementType === BSON_DATA_BOOLEAN) { + if (buffer[index] !== 0 && buffer[index] !== 1) + throw new BSONError('illegal boolean type value'); + value = buffer[index++] === 1; + } + else if (elementType === 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 BSONError('bad embedded document length in bson'); + // We have a raw value + if (raw) { + value = buffer.slice(index, index + objectSize); + } + else { + var objectOptions = options; + if (!globalUTFValidation) { + objectOptions = _assign(_assign({}, options), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, objectOptions, false); + } + index = index + objectSize; + } + else if (elementType === BSON_DATA_ARRAY) { + var _index = index; + var 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; + } + if (!globalUTFValidation) { + arrayOptions = _assign(_assign({}, arrayOptions), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, arrayOptions, true); + index = index + objectSize; + if (buffer[index - 1] !== 0) + throw new BSONError('invalid array terminator byte'); + if (index !== stopIndex) + throw new BSONError('corrupted array bson'); + } + else if (elementType === BSON_DATA_UNDEFINED) { + value = undefined; + } + else if (elementType === BSON_DATA_NULL) { + value = null; + } + else if (elementType === BSON_DATA_LONG) { + // Unpack the low and high bits + 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); + var long = new Long(lowBits, highBits); + // Promote the long if possible + if (promoteLongs && promoteValues === true) { + value = + long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) + ? long.toNumber() + : long; + } + else { + value = long; + } + } + else if (elementType === BSON_DATA_DECIMAL128) { + // Buffer to contain the decimal bytes + var bytes = buffer_1.alloc(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 + if ('toObject' in decimal128 && typeof decimal128.toObject === 'function') { + value = decimal128.toObject(); + } + else { + value = decimal128; + } + } + else if (elementType === 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 BSONError('Negative binary type element size found'); + // Is the length longer than the document + if (binarySize > buffer.byteLength) + throw new BSONError('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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + if (promoteBuffers && promoteValues) { + value = buffer.slice(index, index + binarySize); + } + else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) { + value = value.toUUID(); + } + } + } + else { + var _buffer = buffer_1.alloc(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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + // Copy the data + for (i = 0; i < binarySize; i++) { + _buffer[i] = buffer[index + i]; + } + if (promoteBuffers && promoteValues) { + value = _buffer; + } + else if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) { + value = new Binary(buffer.slice(index, index + binarySize), subType).toUUID(); + } + else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + } + } + // Update the index + index = index + binarySize; + } + else if (elementType === 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 BSONError('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 BSONError('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; + } + } + value = new RegExp(source, optionsArray.join('')); + } + else if (elementType === 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + // Set the object + value = new BSONRegExp(source, regExpOptions); + } + else if (elementType === BSON_DATA_SYMBOL) { + 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 BSONError('bad string length in bson'); + } + var symbol = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + value = promoteValues ? symbol : new BSONSymbol(symbol); + index = index + stringSize; + } + else if (elementType === BSON_DATA_TIMESTAMP) { + 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); + value = new Timestamp(lowBits, highBits); + } + else if (elementType === BSON_DATA_MIN_KEY) { + value = new MinKey(); + } + else if (elementType === BSON_DATA_MAX_KEY) { + value = new MaxKey(); + } + else if (elementType === BSON_DATA_CODE) { + 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 BSONError('bad string length in bson'); + } + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + } + else { + value = new Code(functionString); + } + // Update parse index position + index = index + stringSize; + } + else if (elementType === 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 BSONError('code_w_scope total size shorter minimum expected length'); + } + // Get the code string size + var 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 BSONError('bad string length in bson'); + } + // Javascript function + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // Update parse index position + index = index + stringSize; + // Parse the element + var _index = index; + // Decode the size of the object document + var 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 too short + if (totalSize < 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too short, truncating scope'); + } + // Check if totalSize field is too long + if (totalSize > 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + value.scope = scopeObject; + } + else { + value = new Code(functionString, scopeObject); + } + } + else if (elementType === BSON_DATA_DBPOINTER) { + // Get the code string size + var 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 BSONError('bad string length in bson'); + // Namespace + if (validation != null && validation.utf8) { + if (!validateUtf8(buffer, index, index + stringSize - 1)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + } + var namespace = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + // Read the oid + var oidBuffer = buffer_1.alloc(12); + buffer.copy(oidBuffer, 0, index, index + 12); + var oid = new ObjectId(oidBuffer); + // Update the index + index = index + 12; + // Upgrade to DBRef type + value = new DBRef(namespace, oid); + } + else { + throw new BSONError("Detected unknown BSON type ".concat(elementType.toString(16), " for fieldname \"").concat(name, "\"")); + } + if (name === '__proto__') { + Object.defineProperty(object, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + object[name] = value; + } + } + // Check if the deserialization was against a valid array/object + if (size !== index - startIndex) { + if (isArray) + throw new BSONError('corrupt array bson'); + throw new BSONError('corrupt object bson'); + } + // if we did not find "$ref", "$id", "$db", or found an extraneous $key, don't make a DBRef + if (!isPossibleDBRef) + return object; + if (isDBRefLike(object)) { + var copy = Object.assign({}, object); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(object.$ref, object.$id, object.$db, copy); + } + return object; + } + /** + * Ensure eval is isolated, store the result in functionCache. + * + * @internal + */ + function isolateEval(functionString, functionCache, object) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + if (!functionCache) + return new Function(functionString); + // Check for cache hit, eval if missing and return cached function + if (functionCache[functionString] == null) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + functionCache[functionString] = new Function(functionString); + } + // Set the object + return functionCache[functionString].bind(object); + } + function getValidatedString(buffer, start, end, shouldValidateUtf8) { + var value = buffer.toString('utf8', start, end); + // if utf8 validation is on, do the check + if (shouldValidateUtf8) { + for (var i = 0; i < value.length; i++) { + if (value.charCodeAt(i) === 0xfffd) { + if (!validateUtf8(buffer, start, end)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + break; + } + } + } + return value; + } + + var regexp = /\x00/; // eslint-disable-line no-control-regex + var ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']); + /* + * isArray indicates if we are writing to a BSON array (type 0x04) + * which forces the "key" which really an array index as a string to be written as ascii + * This will catch any errors in index as a string generation + */ + function serializeString(buffer, key, value, index, isArray) { + // Encode String type + buffer[index++] = BSON_DATA_STRING; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes + 1; + buffer[index - 1] = 0; + // Write the string + var size = buffer.write(value, index + 4, undefined, 'utf8'); + // Write the size of the string to buffer + buffer[index + 3] = ((size + 1) >> 24) & 0xff; + buffer[index + 2] = ((size + 1) >> 16) & 0xff; + buffer[index + 1] = ((size + 1) >> 8) & 0xff; + buffer[index] = (size + 1) & 0xff; + // Update index + index = index + 4 + size; + // Write zero + buffer[index++] = 0; + return index; + } + var SPACE_FOR_FLOAT64 = new Uint8Array(8); + var DV_FOR_FLOAT64 = new DataView(SPACE_FOR_FLOAT64.buffer, SPACE_FOR_FLOAT64.byteOffset, SPACE_FOR_FLOAT64.byteLength); + function serializeNumber(buffer, key, value, index, isArray) { + // We have an integer value + // TODO(NODE-2529): Add support for big int + if (Number.isInteger(value) && + value >= BSON_INT32_MIN$1 && + value <= BSON_INT32_MAX$1) { + // If the value fits in 32 bits encode as int32 + // Set int type 32 bits or less + buffer[index++] = BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + } + else { + // Encode as double + buffer[index++] = BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + } + return index; + } + function serializeNull(buffer, key, _, index, isArray) { + // Set long type + buffer[index++] = BSON_DATA_NULL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; + } + function serializeBoolean(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BOOLEAN; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Encode the boolean value + buffer[index++] = value ? 1 : 0; + return index; + } + function serializeDate(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_DATE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var dateInMilis = Long.fromNumber(value.getTime()); + var lowBits = dateInMilis.getLowBits(); + var highBits = dateInMilis.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; + } + function serializeRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + if (value.source && value.source.match(regexp) != null) { + throw Error('value ' + value.source + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.source, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the parameters + if (value.ignoreCase) + buffer[index++] = 0x69; // i + if (value.global) + buffer[index++] = 0x73; // s + if (value.multiline) + buffer[index++] = 0x6d; // m + // Add ending zero + buffer[index++] = 0x00; + return index; + } + function serializeBSONRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Check the pattern for 0 bytes + if (value.pattern.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('pattern ' + value.pattern + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.pattern, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the options + index = index + buffer.write(value.options.split('').sort().join(''), index, undefined, 'utf8'); + // Add ending zero + buffer[index++] = 0x00; + return index; + } + function serializeMinMax(buffer, key, value, index, isArray) { + // Write the type of either min or max key + if (value === null) { + buffer[index++] = BSON_DATA_NULL; + } + else if (value._bsontype === 'MinKey') { + buffer[index++] = BSON_DATA_MIN_KEY; + } + else { + buffer[index++] = BSON_DATA_MAX_KEY; + } + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; + } + function serializeObjectId(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_OID; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the objectId into the shared buffer + if (typeof value.id === 'string') { + buffer.write(value.id, index, undefined, 'binary'); + } + else if (isUint8Array(value.id)) { + // Use the standard JS methods here because buffer.copy() is buggy with the + // browser polyfill + buffer.set(value.id.subarray(0, 12), index); + } + else { + throw new BSONTypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId'); + } + // Adjust index + return index + 12; + } + function serializeBuffer(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Get size of the buffer (current write point) + var size = value.length; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the default subtype + buffer[index++] = BSON_BINARY_SUBTYPE_DEFAULT; + // Copy the content form the binary field to the buffer + buffer.set(ensureBuffer(value), index); + // Adjust the index + index = index + size; + return index; + } + function serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (path === void 0) { path = []; } + for (var i = 0; i < path.length; i++) { + if (path[i] === value) + throw new BSONError('cyclic dependency detected'); + } + // Push value to stack + path.push(value); + // Write the type + buffer[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var endIndex = serializeInto(buffer, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path); + // Pop stack + path.pop(); + return endIndex; + } + function serializeDecimal128(buffer, key, value, index, isArray) { + buffer[index++] = BSON_DATA_DECIMAL128; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the data from the value + // Prefer the standard JS methods because their typechecking is not buggy, + // unlike the `buffer` polyfill's. + buffer.set(value.bytes.subarray(0, 16), index); + return index + 16; + } + function serializeLong(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = + value._bsontype === 'Long' ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var lowBits = value.getLowBits(); + var highBits = value.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; + } + function serializeInt32(buffer, key, value, index, isArray) { + value = value.valueOf(); + // Set int type 32 bits or less + buffer[index++] = BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + return index; + } + function serializeDouble(buffer, key, value, index, isArray) { + // Encode as double + buffer[index++] = BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value.value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + return index; + } + function serializeFunction(buffer, key, value, index, _checkKeys, _depth, isArray) { + buffer[index++] = BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = normalizedFunctionString(value); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + return index; + } + function serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (value.scope && typeof value.scope === 'object') { + // Write the type + buffer[index++] = BSON_DATA_CODE_W_SCOPE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Starting index + var startIndex = index; + // Serialize the function + // Get the function string + var functionString = typeof value.code === 'string' ? value.code : value.code.toString(); + // Index adjustment + index = index + 4; + // Write string into buffer + var codeSize = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = codeSize & 0xff; + buffer[index + 1] = (codeSize >> 8) & 0xff; + buffer[index + 2] = (codeSize >> 16) & 0xff; + buffer[index + 3] = (codeSize >> 24) & 0xff; + // Write end 0 + buffer[index + 4 + codeSize - 1] = 0; + // Write the + index = index + codeSize + 4; + // + // Serialize the scope value + var endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined); + index = endIndex - 1; + // Writ the total + var totalSize = endIndex - startIndex; + // Write the total size of the object + buffer[startIndex++] = totalSize & 0xff; + buffer[startIndex++] = (totalSize >> 8) & 0xff; + buffer[startIndex++] = (totalSize >> 16) & 0xff; + buffer[startIndex++] = (totalSize >> 24) & 0xff; + // Write trailing zero + buffer[index++] = 0; + } + else { + buffer[index++] = BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = value.code.toString(); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + } + return index; + } + function serializeBinary(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Extract the buffer + var data = value.value(true); + // Calculate size + var size = value.position; + // Add the deprecated 02 type 4 bytes of size to total + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) + size = size + 4; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the subtype to the buffer + buffer[index++] = value.sub_type; + // If we have binary type 2 the 4 first bytes are the size + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + size = size - 4; + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + } + // Write the data to the object + buffer.set(data, index); + // Adjust the index + index = index + value.position; + return index; + } + function serializeSymbol(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_SYMBOL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the string + var size = buffer.write(value.value, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0x00; + return index; + } + function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, isArray) { + // Write the type + buffer[index++] = BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var startIndex = index; + var output = { + $ref: value.collection || value.namespace, + $id: value.oid + }; + if (value.db != null) { + output.$db = value.db; + } + output = Object.assign(output, value.fields); + var endIndex = serializeInto(buffer, output, false, index, depth + 1, serializeFunctions); + // Calculate object size + var size = endIndex - startIndex; + // Write the size + buffer[startIndex++] = size & 0xff; + buffer[startIndex++] = (size >> 8) & 0xff; + buffer[startIndex++] = (size >> 16) & 0xff; + buffer[startIndex++] = (size >> 24) & 0xff; + // Set index + return endIndex; + } + function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (startingIndex === void 0) { startingIndex = 0; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (path === void 0) { path = []; } + startingIndex = startingIndex || 0; + path = path || []; + // Push the object to the path + path.push(object); + // Start place to serialize into + var index = startingIndex + 4; + // Special case isArray + if (Array.isArray(object)) { + // Get object keys + for (var i = 0; i < object.length; i++) { + var key = "".concat(i); + var value = object[i]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + if (typeof value === 'string') { + index = serializeString(buffer, key, value, index, true); + } + else if (typeof value === 'number') { + index = serializeNumber(buffer, key, value, index, true); + } + else if (typeof value === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (typeof value === 'boolean') { + index = serializeBoolean(buffer, key, value, index, true); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index, true); + } + else if (value === undefined) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index, true); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index, true); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index, true); + } + else if (typeof value === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true, path); + } + else if (typeof value === 'object' && + isBSONType(value) && + value._bsontype === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index, true); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, true); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, true); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index, true); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else if (object instanceof exports.Map || isMap(object)) { + var iterator = object.entries(); + var done = false; + while (!done) { + // Unpack the next entry + var entry = iterator.next(); + done = !!entry.done; + // Are we done, then skip and terminate + if (done) + continue; + // Get the entry values + var key = entry.value[0]; + var value = entry.value[1]; + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint' || isBigInt64Array(value) || isBigUInt64Array(value)) { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === null || (value === undefined && ignoreUndefined === false)) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else { + if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + // Provided a custom serialization method + object = object.toBSON(); + if (object != null && typeof object !== 'object') { + throw new BSONTypeError('toBSON function did not return an object'); + } + } + // Iterate over all the keys + for (var key in object) { + var value = object[key]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === undefined) { + if (ignoreUndefined === false) + index = serializeNull(buffer, key, value, index); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + // Remove the path + path.pop(); + // Final padding byte for object + buffer[index++] = 0x00; + // Final size + var size = index - startingIndex; + // Write the size of the object + buffer[startingIndex++] = size & 0xff; + buffer[startingIndex++] = (size >> 8) & 0xff; + buffer[startingIndex++] = (size >> 16) & 0xff; + buffer[startingIndex++] = (size >> 24) & 0xff; + return index; + } + + /** @internal */ + // Default Max Size + var MAXSIZE = 1024 * 1024 * 17; + // Current Internal Temporary Serialization Buffer + var buffer = buffer_1.alloc(MAXSIZE); + /** + * Sets the size of the internal serialization buffer. + * + * @param size - The desired size for the internal serialization buffer + * @public + */ + function setInternalBufferSize(size) { + // Resize the internal serialization buffer if needed + if (buffer.length < size) { + buffer = buffer_1.alloc(size); + } + } + /** + * Serialize a Javascript object. + * + * @param object - the Javascript object to serialize. + * @returns Buffer object containing the serialized object. + * @public + */ + function serialize(object, options) { + if (options === void 0) { 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 = buffer_1.alloc(minInternalBufferSize); + } + // Attempt to serialize + var serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []); + // Create the final buffer + var finishedBuffer = buffer_1.alloc(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 - the Javascript object to serialize. + * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object. + * @returns the index pointing to the last written byte in the buffer. + * @public + */ + function serializeWithBufferAndIndex(object, finalBuffer, options) { + if (options === void 0) { 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 = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined); + buffer.copy(finalBuffer, startIndex, 0, serializationIndex); + // Return the index + return startIndex + serializationIndex - 1; + } + /** + * Deserialize data as BSON. + * + * @param buffer - the buffer containing the serialized set of BSON documents. + * @returns returns the deserialized Javascript Object. + * @public + */ + function deserialize(buffer, options) { + if (options === void 0) { options = {}; } + return deserialize$1(buffer instanceof buffer_1 ? buffer : ensureBuffer(buffer), options); + } + /** + * Calculate the bson size for a passed in Javascript object. + * + * @param object - the Javascript object to calculate the BSON byte size for + * @returns size of BSON object in bytes + * @public + */ + function calculateObjectSize(object, options) { + if (options === void 0) { options = {}; } + options = options || {}; + var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + return calculateObjectSize$1(object, serializeFunctions, ignoreUndefined); + } + /** + * Deserialize stream data as BSON documents. + * + * @param data - the buffer containing the serialized set of BSON documents. + * @param startIndex - the start index in the data Buffer where the deserialization is to start. + * @param numberOfDocuments - number of documents to deserialize. + * @param documents - an array where to store the deserialized documents. + * @param docStartIndex - the index in the documents array from where to start inserting documents. + * @param options - additional options used for the deserialization. + * @returns next index in the buffer after deserialization **x** numbers of documents. + * @public + */ + function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) { + var internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options); + var bufferData = ensureBuffer(data); + var index = startIndex; + // Loop over all documents + for (var i = 0; i < numberOfDocuments; i++) { + // Find size of the document + var size = bufferData[index] | + (bufferData[index + 1] << 8) | + (bufferData[index + 2] << 16) | + (bufferData[index + 3] << 24); + // Update options with index + internalOptions.index = index; + // Parse the document at this point + documents[docStartIndex + i] = deserialize$1(bufferData, internalOptions); + // Adjust index by the document size + index = index + size; + } + // Return object containing end index of parsing and list of documents + return index; + } + /** + * BSON default export + * @deprecated Please use named exports + * @privateRemarks + * We want to someday deprecate the default export, + * so none of the new TS types are being exported on the default + * @public + */ + var BSON = { + Binary: Binary, + Code: Code, + DBRef: DBRef, + Decimal128: Decimal128, + Double: Double, + Int32: Int32, + Long: Long, + UUID: UUID, + Map: exports.Map, + MaxKey: MaxKey, + MinKey: MinKey, + ObjectId: ObjectId, + ObjectID: ObjectId, + BSONRegExp: BSONRegExp, + BSONSymbol: BSONSymbol, + Timestamp: Timestamp, + EJSON: exports.EJSON, + setInternalBufferSize: setInternalBufferSize, + serialize: serialize, + serializeWithBufferAndIndex: serializeWithBufferAndIndex, + deserialize: deserialize, + calculateObjectSize: calculateObjectSize, + deserializeStream: deserializeStream, + BSONError: BSONError, + BSONTypeError: BSONTypeError + }; + + exports.BSONError = BSONError; + exports.BSONRegExp = BSONRegExp; + exports.BSONSymbol = BSONSymbol; + exports.BSONTypeError = BSONTypeError; + exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = BSON_BINARY_SUBTYPE_BYTE_ARRAY; + exports.BSON_BINARY_SUBTYPE_COLUMN = BSON_BINARY_SUBTYPE_COLUMN; + exports.BSON_BINARY_SUBTYPE_DEFAULT = BSON_BINARY_SUBTYPE_DEFAULT; + exports.BSON_BINARY_SUBTYPE_ENCRYPTED = BSON_BINARY_SUBTYPE_ENCRYPTED; + exports.BSON_BINARY_SUBTYPE_FUNCTION = BSON_BINARY_SUBTYPE_FUNCTION; + exports.BSON_BINARY_SUBTYPE_MD5 = BSON_BINARY_SUBTYPE_MD5; + exports.BSON_BINARY_SUBTYPE_USER_DEFINED = BSON_BINARY_SUBTYPE_USER_DEFINED; + exports.BSON_BINARY_SUBTYPE_UUID = BSON_BINARY_SUBTYPE_UUID; + exports.BSON_BINARY_SUBTYPE_UUID_NEW = BSON_BINARY_SUBTYPE_UUID_NEW; + exports.BSON_DATA_ARRAY = BSON_DATA_ARRAY; + exports.BSON_DATA_BINARY = BSON_DATA_BINARY; + exports.BSON_DATA_BOOLEAN = BSON_DATA_BOOLEAN; + exports.BSON_DATA_CODE = BSON_DATA_CODE; + exports.BSON_DATA_CODE_W_SCOPE = BSON_DATA_CODE_W_SCOPE; + exports.BSON_DATA_DATE = BSON_DATA_DATE; + exports.BSON_DATA_DBPOINTER = BSON_DATA_DBPOINTER; + exports.BSON_DATA_DECIMAL128 = BSON_DATA_DECIMAL128; + exports.BSON_DATA_INT = BSON_DATA_INT; + exports.BSON_DATA_LONG = BSON_DATA_LONG; + exports.BSON_DATA_MAX_KEY = BSON_DATA_MAX_KEY; + exports.BSON_DATA_MIN_KEY = BSON_DATA_MIN_KEY; + exports.BSON_DATA_NULL = BSON_DATA_NULL; + exports.BSON_DATA_NUMBER = BSON_DATA_NUMBER; + exports.BSON_DATA_OBJECT = BSON_DATA_OBJECT; + exports.BSON_DATA_OID = BSON_DATA_OID; + exports.BSON_DATA_REGEXP = BSON_DATA_REGEXP; + exports.BSON_DATA_STRING = BSON_DATA_STRING; + exports.BSON_DATA_SYMBOL = BSON_DATA_SYMBOL; + exports.BSON_DATA_TIMESTAMP = BSON_DATA_TIMESTAMP; + exports.BSON_DATA_UNDEFINED = BSON_DATA_UNDEFINED; + exports.BSON_INT32_MAX = BSON_INT32_MAX$1; + exports.BSON_INT32_MIN = BSON_INT32_MIN$1; + exports.BSON_INT64_MAX = BSON_INT64_MAX$1; + exports.BSON_INT64_MIN = BSON_INT64_MIN$1; + exports.Binary = Binary; + exports.Code = Code; + exports.DBRef = DBRef; + exports.Decimal128 = Decimal128; + exports.Double = Double; + exports.Int32 = Int32; + exports.Long = Long; + exports.LongWithoutOverridesClass = LongWithoutOverridesClass; + exports.MaxKey = MaxKey; + exports.MinKey = MinKey; + exports.ObjectID = ObjectId; + exports.ObjectId = ObjectId; + exports.Timestamp = Timestamp; + exports.UUID = UUID; + exports.calculateObjectSize = calculateObjectSize; + exports.default = BSON; + exports.deserialize = deserialize; + exports.deserializeStream = deserializeStream; + exports.serialize = serialize; + exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex; + exports.setInternalBufferSize = setInternalBufferSize; + + Object.defineProperty(exports, '__esModule', { value: true }); + + return exports; + +}({})); +//# sourceMappingURL=bson.bundle.js.map diff --git a/node_modules/bson/dist/bson.bundle.js.map b/node_modules/bson/dist/bson.bundle.js.map new file mode 100644 index 0000000..ba233e1 --- /dev/null +++ b/node_modules/bson/dist/bson.bundle.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bson.bundle.js","sources":["../node_modules/base64-js/index.js","../node_modules/ieee754/index.js","../node_modules/buffer/index.js","../node_modules/tslib/tslib.es6.js","../src/error.ts","../src/utils/global.ts","../src/parser/utils.ts","../src/ensure_buffer.ts","../src/uuid_utils.ts","../src/constants.ts","../src/binary.ts","../src/code.ts","../src/db_ref.ts","../src/long.ts","../src/decimal128.ts","../src/double.ts","../src/int_32.ts","../src/max_key.ts","../src/min_key.ts","../src/objectid.ts","../src/regexp.ts","../src/symbol.ts","../src/timestamp.ts","../src/extended_json.ts","../src/map.ts","../src/parser/calculate_size.ts","../src/validate_utf8.ts","../src/parser/deserializer.ts","../src/parser/serializer.ts","../src/bson.ts"],"sourcesContent":["'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar customInspectSymbol =\n (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nvar K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n var arr = new Uint8Array(1)\n var proto = { foo: function () { return 42 } }\n Object.setPrototypeOf(proto, Uint8Array.prototype)\n Object.setPrototypeOf(arr, proto)\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n var buf = new Uint8Array(length)\n Object.setPrototypeOf(buf, Buffer.prototype)\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayView(value)\n }\n\n if (value == null) {\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof SharedArrayBuffer !== 'undefined' &&\n (isInstance(value, SharedArrayBuffer) ||\n (value && isInstance(value.buffer, SharedArrayBuffer)))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n var valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n var b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(\n value[Symbol.toPrimitive]('string'), encodingOrOffset, length\n )\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)\nObject.setPrototypeOf(Buffer, Uint8Array)\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n var length = byteLength(string, encoding) | 0\n var buf = createBuffer(length)\n\n var actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n var buf = createBuffer(length)\n for (var i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayView (arrayView) {\n if (isInstance(arrayView, Uint8Array)) {\n var copy = new Uint8Array(arrayView)\n return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)\n }\n return fromArrayLike(arrayView)\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n var buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, Buffer.prototype)\n\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n var buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n Buffer.from(buf).copy(buffer, pos)\n } else {\n Uint8Array.prototype.set.call(\n buffer,\n buf,\n pos\n )\n }\n } else if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n } else {\n buf.copy(buffer, pos)\n }\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n var len = string.length\n var mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return ''\n}\nif (customInspectSymbol) {\n Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n var strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n case 'latin1':\n case 'binary':\n return asciiWrite(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF)\n ? 4\n : (firstByte > 0xDF)\n ? 3\n : (firstByte > 0xBF)\n ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += hexSliceLookupTable[buf[i]]\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for (var i = 0; i < bytes.length - 1; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, Buffer.prototype)\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUintLE =\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUintBE =\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUint8 =\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUint16LE =\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUint16BE =\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUint32LE =\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUint32BE =\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUintLE =\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUintBE =\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUint8 =\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUint16LE =\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUint16BE =\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUint32LE =\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUint32BE =\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n var limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n var limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n } else if (typeof val === 'boolean') {\n val = Number(val)\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n var len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nvar hexSliceLookupTable = (function () {\n var alphabet = '0123456789abcdef'\n var table = new Array(256)\n for (var i = 0; i < 16; ++i) {\n var i16 = i * 16\n for (var j = 0; j < 16; ++j) {\n table[i16 + j] = alphabet[i] + alphabet[j]\n }\n }\n return table\n})()\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["byteLength","toByteArray","fromByteArray","lookup","revLookup","Arr","Uint8Array","Array","code","i","len","length","charCodeAt","getLens","b64","Error","validLen","indexOf","placeHoldersLen","lens","_byteLength","tmp","arr","curByte","tripletToBase64","num","encodeChunk","uint8","start","end","output","push","join","extraBytes","parts","maxChunkLength","len2","buffer","offset","isLE","mLen","nBytes","e","m","eLen","eMax","eBias","nBits","d","s","NaN","Infinity","Math","pow","value","c","rt","abs","isNaN","floor","log","LN2","customInspectSymbol","Symbol","exports","Buffer","SlowBuffer","K_MAX_LENGTH","TYPED_ARRAY_SUPPORT","typedArraySupport","console","error","proto","foo","Object","setPrototypeOf","prototype","defineProperty","enumerable","get","isBuffer","undefined","byteOffset","createBuffer","RangeError","buf","arg","encodingOrOffset","TypeError","allocUnsafe","from","poolSize","fromString","ArrayBuffer","isView","fromArrayView","isInstance","fromArrayBuffer","SharedArrayBuffer","valueOf","b","fromObject","toPrimitive","assertSize","size","alloc","fill","encoding","checked","allocUnsafeSlow","string","isEncoding","actual","write","slice","fromArrayLike","array","arrayView","copy","obj","numberIsNaN","type","isArray","data","toString","_isBuffer","compare","a","x","y","min","String","toLowerCase","concat","list","pos","set","call","mustMatch","arguments","loweredCase","utf8ToBytes","base64ToBytes","slowToString","hexSlice","utf8Slice","asciiSlice","latin1Slice","base64Slice","utf16leSlice","swap","n","swap16","swap32","swap64","apply","toLocaleString","equals","inspect","str","max","INSPECT_MAX_BYTES","replace","trim","target","thisStart","thisEnd","thisCopy","targetCopy","bidirectionalIndexOf","val","dir","arrayIndexOf","lastIndexOf","indexSize","arrLength","valLength","read","readUInt16BE","foundIndex","found","j","includes","hexWrite","Number","remaining","strLen","parsed","parseInt","substr","utf8Write","blitBuffer","asciiWrite","asciiToBytes","base64Write","ucs2Write","utf16leToBytes","isFinite","toJSON","_arr","base64","res","firstByte","codePoint","bytesPerSequence","secondByte","thirdByte","fourthByte","tempCodePoint","decodeCodePointsArray","MAX_ARGUMENTS_LENGTH","codePoints","fromCharCode","ret","out","hexSliceLookupTable","bytes","newBuf","subarray","checkOffset","ext","readUintLE","readUIntLE","noAssert","mul","readUintBE","readUIntBE","readUint8","readUInt8","readUint16LE","readUInt16LE","readUint16BE","readUint32LE","readUInt32LE","readUint32BE","readUInt32BE","readIntLE","readIntBE","readInt8","readInt16LE","readInt16BE","readInt32LE","readInt32BE","readFloatLE","ieee754","readFloatBE","readDoubleLE","readDoubleBE","checkInt","writeUintLE","writeUIntLE","maxBytes","writeUintBE","writeUIntBE","writeUint8","writeUInt8","writeUint16LE","writeUInt16LE","writeUint16BE","writeUInt16BE","writeUint32LE","writeUInt32LE","writeUint32BE","writeUInt32BE","writeIntLE","limit","sub","writeIntBE","writeInt8","writeInt16LE","writeInt16BE","writeInt32LE","writeInt32BE","checkIEEE754","writeFloat","littleEndian","writeFloatLE","writeFloatBE","writeDouble","writeDoubleLE","writeDoubleBE","targetStart","copyWithin","INVALID_BASE64_RE","base64clean","split","units","leadSurrogate","byteArray","hi","lo","src","dst","constructor","name","alphabet","table","i16","extendStatics","__proto__","p","hasOwnProperty","__extends","__","create","__assign","assign","t","BSON_INT32_MAX","BSON_INT32_MIN","BSON_INT64_MAX","BSON_INT64_MIN","EJSON","bsonMap","calculateObjectSize","constants.JS_INT_MIN","constants.JS_INT_MAX","constants.BSON_INT32_MIN","constants.BSON_INT32_MAX","deserialize","constants.BSON_DATA_STRING","constants.BSON_DATA_OID","constants.BSON_DATA_INT","constants.BSON_DATA_NUMBER","constants.BSON_DATA_DATE","constants.BSON_DATA_BOOLEAN","constants.BSON_DATA_OBJECT","constants.BSON_DATA_ARRAY","constants.BSON_DATA_UNDEFINED","constants.BSON_DATA_NULL","constants.BSON_DATA_LONG","constants.BSON_DATA_DECIMAL128","constants.BSON_DATA_BINARY","constants.BSON_BINARY_SUBTYPE_UUID_NEW","constants.BSON_DATA_REGEXP","constants.BSON_DATA_SYMBOL","constants.BSON_DATA_TIMESTAMP","constants.BSON_DATA_MIN_KEY","constants.BSON_DATA_MAX_KEY","constants.BSON_DATA_CODE","constants.BSON_DATA_CODE_W_SCOPE","constants.BSON_DATA_DBPOINTER","constants.BSON_BINARY_SUBTYPE_DEFAULT","Map","internalSerialize","internalDeserialize","internalCalculateObjectSize"],"mappings":";;;;;;;CAEA,gBAAkB,GAAGA,UAArB;CACA,iBAAmB,GAAGC,WAAtB;CACA,mBAAqB,GAAGC,aAAxB;CAEA,IAAIC,MAAM,GAAG,EAAb;CACA,IAAIC,SAAS,GAAG,EAAhB;CACA,IAAIC,GAAG,GAAG,OAAOC,UAAP,KAAsB,WAAtB,GAAoCA,UAApC,GAAiDC,KAA3D;CAEA,IAAIC,IAAI,GAAG,kEAAX;;CACA,KAAK,IAAIC,CA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,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;;SAEhC,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC;;SAE9B,SAAS,CAAC,aAAa,GAAG,CAAC,CAAC,GAAGD,aAAmB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;;SAEhF,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;MACtB;;KAGD,OAAO,KAAK,CAAC;CACf,CAAC;CAED;;;;;;;;KAQM,IAAI,GAAG;KACX,MAAM,QAAA;KACN,IAAI,MAAA;KACJ,KAAK,OAAA;KACL,UAAU,YAAA;KACV,MAAM,QAAA;KACN,KAAK,OAAA;KACL,IAAI,MAAA;KACJ,IAAI,MAAA;KACJ,GAAG,aAAA;KACH,MAAM,QAAA;KACN,MAAM,QAAA;KACN,QAAQ,UAAA;KACR,QAAQ,EAAE,QAAQ;KAClB,UAAU,YAAA;KACV,UAAU,YAAA;KACV,SAAS,WAAA;KACT,KAAK,eAAA;KACL,qBAAqB,uBAAA;KACrB,SAAS,WAAA;KACT,2BAA2B,6BAAA;KAC3B,WAAW,aAAA;KACX,mBAAmB,qBAAA;KACnB,iBAAiB,mBAAA;KACjB,SAAS,WAAA;KACT,aAAa,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/bson/dist/bson.esm.js b/node_modules/bson/dist/bson.esm.js new file mode 100644 index 0000000..c68c5bf --- /dev/null +++ b/node_modules/bson/dist/bson.esm.js @@ -0,0 +1,5436 @@ +import { Buffer } from 'buffer'; + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ + +/* global Reflect, Promise */ +var _extendStatics = function extendStatics(d, b) { + _extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) { + if (b.hasOwnProperty(p)) d[p] = b[p]; + } + }; + + return _extendStatics(d, b); +}; + +function __extends(d, b) { + _extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var _assign = function __assign() { + _assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) { + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + } + + return t; + }; + + return _assign.apply(this, arguments); +}; + +/** @public */ +var BSONError = /** @class */ (function (_super) { + __extends(BSONError, _super); + function BSONError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONError.prototype); + return _this; + } + Object.defineProperty(BSONError.prototype, "name", { + get: function () { + return 'BSONError'; + }, + enumerable: false, + configurable: true + }); + return BSONError; +}(Error)); +/** @public */ +var BSONTypeError = /** @class */ (function (_super) { + __extends(BSONTypeError, _super); + function BSONTypeError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONTypeError.prototype); + return _this; + } + Object.defineProperty(BSONTypeError.prototype, "name", { + get: function () { + return 'BSONTypeError'; + }, + enumerable: false, + configurable: true + }); + return BSONTypeError; +}(TypeError)); + +function checkForMath(potentialGlobal) { + // eslint-disable-next-line eqeqeq + return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal; +} +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +function getGlobal() { + return (checkForMath(typeof globalThis === 'object' && globalThis) || + checkForMath(typeof window === 'object' && window) || + checkForMath(typeof self === 'object' && self) || + checkForMath(typeof global === 'object' && global) || + // eslint-disable-next-line @typescript-eslint/no-implied-eval + Function('return this')()); +} + +/** + * Normalizes our expected stringified form of a function across versions of node + * @param fn - The function to stringify + */ +function normalizedFunctionString(fn) { + return fn.toString().replace('function(', 'function ('); +} +function isReactNative() { + var g = getGlobal(); + return typeof g.navigator === 'object' && g.navigator.product === 'ReactNative'; +} +var insecureRandomBytes = function insecureRandomBytes(size) { + var insecureWarning = isReactNative() + ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.' + : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.'; + console.warn(insecureWarning); + var result = Buffer.alloc(size); + for (var i = 0; i < size; ++i) + result[i] = Math.floor(Math.random() * 256); + return result; +}; +var detectRandomBytes = function () { + { + var requiredRandomBytes = void 0; + try { + requiredRandomBytes = require('crypto').randomBytes; + } + catch (e) { + // keep the fallback + } + // NOTE: in transpiled cases the above require might return null/undefined + return requiredRandomBytes || insecureRandomBytes; + } +}; +var randomBytes = detectRandomBytes(); +function isAnyArrayBuffer(value) { + return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value)); +} +function isUint8Array(value) { + return Object.prototype.toString.call(value) === '[object Uint8Array]'; +} +function isBigInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigInt64Array]'; +} +function isBigUInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigUint64Array]'; +} +function isRegExp(d) { + return Object.prototype.toString.call(d) === '[object RegExp]'; +} +function isMap(d) { + return Object.prototype.toString.call(d) === '[object Map]'; +} +// To ensure that 0.4 of node works correctly +function isDate(d) { + return isObjectLike(d) && Object.prototype.toString.call(d) === '[object Date]'; +} +/** + * @internal + * this is to solve the `'someKey' in x` problem where x is unknown. + * https://github.com/typescript-eslint/typescript-eslint/issues/1071#issuecomment-541955753 + */ +function isObjectLike(candidate) { + return typeof candidate === 'object' && candidate !== null; +} +function deprecate(fn, message) { + var warned = false; + function deprecated() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!warned) { + console.warn(message); + warned = true; + } + return fn.apply(this, args); + } + return deprecated; +} + +/** + * Makes sure that, if a Uint8Array is passed in, it is wrapped in a Buffer. + * + * @param potentialBuffer - The potential buffer + * @returns Buffer the input if potentialBuffer is a buffer, or a buffer that + * wraps a passed in Uint8Array + * @throws BSONTypeError If anything other than a Buffer or Uint8Array is passed in + */ +function ensureBuffer(potentialBuffer) { + if (ArrayBuffer.isView(potentialBuffer)) { + return Buffer.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength); + } + if (isAnyArrayBuffer(potentialBuffer)) { + return Buffer.from(potentialBuffer); + } + throw new BSONTypeError('Must use either Buffer or TypedArray'); +} + +// Validation regex for v4 uuid (validates with or without dashes) +var VALIDATION_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i; +var uuidValidateString = function (str) { + return typeof str === 'string' && VALIDATION_REGEX.test(str); +}; +var uuidHexStringToBuffer = function (hexString) { + if (!uuidValidateString(hexString)) { + throw new BSONTypeError('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".'); + } + var sanitizedHexString = hexString.replace(/-/g, ''); + return Buffer.from(sanitizedHexString, 'hex'); +}; +var bufferToUuidHexString = function (buffer, includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + return includeDashes + ? buffer.toString('hex', 0, 4) + + '-' + + buffer.toString('hex', 4, 6) + + '-' + + buffer.toString('hex', 6, 8) + + '-' + + buffer.toString('hex', 8, 10) + + '-' + + buffer.toString('hex', 10, 16) + : buffer.toString('hex'); +}; + +/** @internal */ +var BSON_INT32_MAX$1 = 0x7fffffff; +/** @internal */ +var BSON_INT32_MIN$1 = -0x80000000; +/** @internal */ +var BSON_INT64_MAX$1 = Math.pow(2, 63) - 1; +/** @internal */ +var BSON_INT64_MIN$1 = -Math.pow(2, 63); +/** + * Any integer up to 2^53 can be precisely represented by a double. + * @internal + */ +var JS_INT_MAX = Math.pow(2, 53); +/** + * Any integer down to -2^53 can be precisely represented by a double. + * @internal + */ +var JS_INT_MIN = -Math.pow(2, 53); +/** Number BSON Type @internal */ +var BSON_DATA_NUMBER = 1; +/** String BSON Type @internal */ +var BSON_DATA_STRING = 2; +/** Object BSON Type @internal */ +var BSON_DATA_OBJECT = 3; +/** Array BSON Type @internal */ +var BSON_DATA_ARRAY = 4; +/** Binary BSON Type @internal */ +var BSON_DATA_BINARY = 5; +/** Binary BSON Type @internal */ +var BSON_DATA_UNDEFINED = 6; +/** ObjectId BSON Type @internal */ +var BSON_DATA_OID = 7; +/** Boolean BSON Type @internal */ +var BSON_DATA_BOOLEAN = 8; +/** Date BSON Type @internal */ +var BSON_DATA_DATE = 9; +/** null BSON Type @internal */ +var BSON_DATA_NULL = 10; +/** RegExp BSON Type @internal */ +var BSON_DATA_REGEXP = 11; +/** Code BSON Type @internal */ +var BSON_DATA_DBPOINTER = 12; +/** Code BSON Type @internal */ +var BSON_DATA_CODE = 13; +/** Symbol BSON Type @internal */ +var BSON_DATA_SYMBOL = 14; +/** Code with Scope BSON Type @internal */ +var BSON_DATA_CODE_W_SCOPE = 15; +/** 32 bit Integer BSON Type @internal */ +var BSON_DATA_INT = 16; +/** Timestamp BSON Type @internal */ +var BSON_DATA_TIMESTAMP = 17; +/** Long BSON Type @internal */ +var BSON_DATA_LONG = 18; +/** Decimal128 BSON Type @internal */ +var BSON_DATA_DECIMAL128 = 19; +/** MinKey BSON Type @internal */ +var BSON_DATA_MIN_KEY = 0xff; +/** MaxKey BSON Type @internal */ +var BSON_DATA_MAX_KEY = 0x7f; +/** Binary Default Type @internal */ +var BSON_BINARY_SUBTYPE_DEFAULT = 0; +/** Binary Function Type @internal */ +var BSON_BINARY_SUBTYPE_FUNCTION = 1; +/** Binary Byte Array Type @internal */ +var BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; +/** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */ +var BSON_BINARY_SUBTYPE_UUID = 3; +/** Binary UUID Type @internal */ +var BSON_BINARY_SUBTYPE_UUID_NEW = 4; +/** Binary MD5 Type @internal */ +var BSON_BINARY_SUBTYPE_MD5 = 5; +/** Encrypted BSON type @internal */ +var BSON_BINARY_SUBTYPE_ENCRYPTED = 6; +/** Column BSON type @internal */ +var BSON_BINARY_SUBTYPE_COLUMN = 7; +/** Binary User Defined Type @internal */ +var BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + +/** + * A class representation of the BSON Binary type. + * @public + * @category BSONType + */ +var Binary = /** @class */ (function () { + /** + * Create a new Binary instance. + * + * This constructor can accept a string as its first argument. In this case, + * this string will be encoded using ISO-8859-1, **not** using UTF-8. + * This is almost certainly not what you want. Use `new Binary(Buffer.from(string))` + * instead to convert the string to a Buffer using UTF-8 first. + * + * @param buffer - a buffer object containing the binary data. + * @param subType - the option binary type. + */ + function Binary(buffer, subType) { + if (!(this instanceof Binary)) + return new Binary(buffer, subType); + if (!(buffer == null) && + !(typeof buffer === 'string') && + !ArrayBuffer.isView(buffer) && + !(buffer instanceof ArrayBuffer) && + !Array.isArray(buffer)) { + throw new BSONTypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array'); + } + this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT; + if (buffer == null) { + // create an empty binary buffer + this.buffer = Buffer.alloc(Binary.BUFFER_SIZE); + this.position = 0; + } + else { + if (typeof buffer === 'string') { + // string + this.buffer = Buffer.from(buffer, 'binary'); + } + else if (Array.isArray(buffer)) { + // number[] + this.buffer = Buffer.from(buffer); + } + else { + // Buffer | TypedArray | ArrayBuffer + this.buffer = ensureBuffer(buffer); + } + this.position = this.buffer.byteLength; + } + } + /** + * Updates this binary with byte_value. + * + * @param byteValue - a single byte we wish to write. + */ + Binary.prototype.put = function (byteValue) { + // If it's a string and a has more than one character throw an error + if (typeof byteValue === 'string' && byteValue.length !== 1) { + throw new BSONTypeError('only accepts single character String'); + } + else if (typeof byteValue !== 'number' && byteValue.length !== 1) + throw new BSONTypeError('only accepts single character Uint8Array or Array'); + // Decode the byte value once + var decodedByte; + if (typeof byteValue === 'string') { + decodedByte = byteValue.charCodeAt(0); + } + else if (typeof byteValue === 'number') { + decodedByte = byteValue; + } + else { + decodedByte = byteValue[0]; + } + if (decodedByte < 0 || decodedByte > 255) { + throw new BSONTypeError('only accepts number in a valid unsigned byte range 0-255'); + } + if (this.buffer.length > this.position) { + this.buffer[this.position++] = decodedByte; + } + else { + var buffer = Buffer.alloc(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++] = decodedByte; + } + }; + /** + * Writes a buffer or string to the binary. + * + * @param sequence - a string or buffer to be written to the Binary BSON object. + * @param offset - specify the binary of where to write the content. + */ + Binary.prototype.write = function (sequence, offset) { + offset = typeof offset === 'number' ? offset : this.position; + // If the buffer is to small let's extend the buffer + if (this.buffer.length < offset + sequence.length) { + var buffer = Buffer.alloc(this.buffer.length + sequence.length); + this.buffer.copy(buffer, 0, 0, this.buffer.length); + // Assign the new buffer + this.buffer = buffer; + } + if (ArrayBuffer.isView(sequence)) { + this.buffer.set(ensureBuffer(sequence), offset); + this.position = + offset + sequence.byteLength > this.position ? offset + sequence.length : this.position; + } + else if (typeof sequence === 'string') { + this.buffer.write(sequence, offset, sequence.length, 'binary'); + this.position = + offset + sequence.length > this.position ? offset + sequence.length : this.position; + } + }; + /** + * Reads **length** bytes starting at **position**. + * + * @param position - read from the given position in the Binary. + * @param length - the number of bytes to read. + */ + Binary.prototype.read = function (position, length) { + length = length && length > 0 ? length : this.position; + // Let's return the data based on the type we have + return this.buffer.slice(position, position + length); + }; + /** + * Returns the value of this binary as a string. + * @param asRaw - Will skip converting to a string + * @remarks + * This is handy when calling this function conditionally for some key value pairs and not others + */ + Binary.prototype.value = function (asRaw) { + asRaw = !!asRaw; + // Optimize to serialize for the situation where the data == size of buffer + if (asRaw && this.buffer.length === this.position) { + return this.buffer; + } + // If it's a node.js buffer object + if (asRaw) { + return this.buffer.slice(0, this.position); + } + return this.buffer.toString('binary', 0, this.position); + }; + /** the length of the binary sequence */ + Binary.prototype.length = function () { + return this.position; + }; + Binary.prototype.toJSON = function () { + return this.buffer.toString('base64'); + }; + Binary.prototype.toString = function (format) { + return this.buffer.toString(format); + }; + /** @internal */ + Binary.prototype.toExtendedJSON = function (options) { + options = options || {}; + var base64String = this.buffer.toString('base64'); + var subType = Number(this.sub_type).toString(16); + if (options.legacy) { + return { + $binary: base64String, + $type: subType.length === 1 ? '0' + subType : subType + }; + } + return { + $binary: { + base64: base64String, + subType: subType.length === 1 ? '0' + subType : subType + } + }; + }; + Binary.prototype.toUUID = function () { + if (this.sub_type === Binary.SUBTYPE_UUID) { + return new UUID(this.buffer.slice(0, this.position)); + } + throw new BSONError("Binary sub_type \"".concat(this.sub_type, "\" is not supported for converting to UUID. Only \"").concat(Binary.SUBTYPE_UUID, "\" is currently supported.")); + }; + /** @internal */ + Binary.fromExtendedJSON = function (doc, options) { + options = options || {}; + var data; + var type; + if ('$binary' in doc) { + if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) { + type = doc.$type ? parseInt(doc.$type, 16) : 0; + data = Buffer.from(doc.$binary, 'base64'); + } + else { + if (typeof doc.$binary !== 'string') { + type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0; + data = Buffer.from(doc.$binary.base64, 'base64'); + } + } + } + else if ('$uuid' in doc) { + type = 4; + data = uuidHexStringToBuffer(doc.$uuid); + } + if (!data) { + throw new BSONTypeError("Unexpected Binary Extended JSON format ".concat(JSON.stringify(doc))); + } + return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type); + }; + /** @internal */ + Binary.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Binary.prototype.inspect = function () { + var asBuffer = this.value(true); + return "new Binary(Buffer.from(\"".concat(asBuffer.toString('hex'), "\", \"hex\"), ").concat(this.sub_type, ")"); + }; + /** + * Binary default subtype + * @internal + */ + Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** Initial buffer default size */ + Binary.BUFFER_SIZE = 256; + /** Default BSON type */ + Binary.SUBTYPE_DEFAULT = 0; + /** Function BSON type */ + Binary.SUBTYPE_FUNCTION = 1; + /** Byte Array BSON type */ + Binary.SUBTYPE_BYTE_ARRAY = 2; + /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */ + Binary.SUBTYPE_UUID_OLD = 3; + /** UUID BSON type */ + Binary.SUBTYPE_UUID = 4; + /** MD5 BSON type */ + Binary.SUBTYPE_MD5 = 5; + /** Encrypted BSON type */ + Binary.SUBTYPE_ENCRYPTED = 6; + /** Column BSON type */ + Binary.SUBTYPE_COLUMN = 7; + /** User BSON type */ + Binary.SUBTYPE_USER_DEFINED = 128; + return Binary; +}()); +Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' }); +var UUID_BYTE_LENGTH = 16; +/** + * A class representation of the BSON UUID type. + * @public + */ +var UUID = /** @class */ (function (_super) { + __extends(UUID, _super); + /** + * Create an UUID type + * + * @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer. + */ + function UUID(input) { + var _this = this; + var bytes; + var hexStr; + if (input == null) { + bytes = UUID.generate(); + } + else if (input instanceof UUID) { + bytes = Buffer.from(input.buffer); + hexStr = input.__id; + } + else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) { + bytes = ensureBuffer(input); + } + else if (typeof input === 'string') { + bytes = uuidHexStringToBuffer(input); + } + else { + throw new BSONTypeError('Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'); + } + _this = _super.call(this, bytes, BSON_BINARY_SUBTYPE_UUID_NEW) || this; + _this.__id = hexStr; + return _this; + } + Object.defineProperty(UUID.prototype, "id", { + /** + * The UUID bytes + * @readonly + */ + get: function () { + return this.buffer; + }, + set: function (value) { + this.buffer = value; + if (UUID.cacheHexString) { + this.__id = bufferToUuidHexString(value); + } + }, + enumerable: false, + configurable: true + }); + /** + * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated) + * @param includeDashes - should the string exclude dash-separators. + * */ + UUID.prototype.toHexString = function (includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + if (UUID.cacheHexString && this.__id) { + return this.__id; + } + var uuidHexString = bufferToUuidHexString(this.id, includeDashes); + if (UUID.cacheHexString) { + this.__id = uuidHexString; + } + return uuidHexString; + }; + /** + * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified. + */ + UUID.prototype.toString = function (encoding) { + return encoding ? this.id.toString(encoding) : this.toHexString(); + }; + /** + * Converts the id into its JSON string representation. + * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + */ + UUID.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this UUID with `otherID`. + * + * @param otherId - UUID instance to compare against. + */ + UUID.prototype.equals = function (otherId) { + if (!otherId) { + return false; + } + if (otherId instanceof UUID) { + return otherId.id.equals(this.id); + } + try { + return new UUID(otherId).id.equals(this.id); + } + catch (_a) { + return false; + } + }; + /** + * Creates a Binary instance from the current UUID. + */ + UUID.prototype.toBinary = function () { + return new Binary(this.id, Binary.SUBTYPE_UUID); + }; + /** + * Generates a populated buffer containing a v4 uuid + */ + UUID.generate = function () { + var bytes = randomBytes(UUID_BYTE_LENGTH); + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + // Kindly borrowed from https://github.com/uuidjs/uuid/blob/master/src/v4.js + bytes[6] = (bytes[6] & 0x0f) | 0x40; + bytes[8] = (bytes[8] & 0x3f) | 0x80; + return Buffer.from(bytes); + }; + /** + * Checks if a value is a valid bson UUID + * @param input - UUID, string or Buffer to validate. + */ + UUID.isValid = function (input) { + if (!input) { + return false; + } + if (input instanceof UUID) { + return true; + } + if (typeof input === 'string') { + return uuidValidateString(input); + } + if (isUint8Array(input)) { + // check for length & uuid version (https://tools.ietf.org/html/rfc4122#section-4.1.3) + if (input.length !== UUID_BYTE_LENGTH) { + return false; + } + return (input[6] & 0xf0) === 0x40 && (input[8] & 0x80) === 0x80; + } + return false; + }; + /** + * Creates an UUID from a hex string representation of an UUID. + * @param hexString - 32 or 36 character hex string (dashes excluded/included). + */ + UUID.createFromHexString = function (hexString) { + var buffer = uuidHexStringToBuffer(hexString); + return new UUID(buffer); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 36 character hex string representation. + * @internal + */ + UUID.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + UUID.prototype.inspect = function () { + return "new UUID(\"".concat(this.toHexString(), "\")"); + }; + return UUID; +}(Binary)); + +/** + * A class representation of the BSON Code type. + * @public + * @category BSONType + */ +var Code = /** @class */ (function () { + /** + * @param code - a string or function. + * @param scope - an optional scope for the function. + */ + function Code(code, scope) { + if (!(this instanceof Code)) + return new Code(code, scope); + this.code = code; + this.scope = scope; + } + Code.prototype.toJSON = function () { + return { code: this.code, scope: this.scope }; + }; + /** @internal */ + Code.prototype.toExtendedJSON = function () { + if (this.scope) { + return { $code: this.code, $scope: this.scope }; + } + return { $code: this.code }; + }; + /** @internal */ + Code.fromExtendedJSON = function (doc) { + return new Code(doc.$code, doc.$scope); + }; + /** @internal */ + Code.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Code.prototype.inspect = function () { + var codeJson = this.toJSON(); + return "new Code(\"".concat(String(codeJson.code), "\"").concat(codeJson.scope ? ", ".concat(JSON.stringify(codeJson.scope)) : '', ")"); + }; + return Code; +}()); +Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' }); + +/** @internal */ +function isDBRefLike(value) { + return (isObjectLike(value) && + value.$id != null && + typeof value.$ref === 'string' && + (value.$db == null || typeof value.$db === 'string')); +} +/** + * A class representation of the BSON DBRef type. + * @public + * @category BSONType + */ +var DBRef = /** @class */ (function () { + /** + * @param collection - the collection name. + * @param oid - the reference ObjectId. + * @param db - optional db name, if omitted the reference is local to the current db. + */ + function DBRef(collection, oid, db, fields) { + if (!(this instanceof DBRef)) + return new DBRef(collection, oid, db, fields); + // check if namespace has been provided + var parts = collection.split('.'); + if (parts.length === 2) { + db = parts.shift(); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + collection = parts.shift(); + } + this.collection = collection; + this.oid = oid; + this.db = db; + this.fields = fields || {}; + } + Object.defineProperty(DBRef.prototype, "namespace", { + // Property provided for compatibility with the 1.x parser + // the 1.x parser used a "namespace" property, while 4.x uses "collection" + /** @internal */ + get: function () { + return this.collection; + }, + set: function (value) { + this.collection = value; + }, + enumerable: false, + configurable: true + }); + DBRef.prototype.toJSON = function () { + var o = Object.assign({ + $ref: this.collection, + $id: this.oid + }, this.fields); + if (this.db != null) + o.$db = this.db; + return o; + }; + /** @internal */ + DBRef.prototype.toExtendedJSON = function (options) { + options = options || {}; + var o = { + $ref: this.collection, + $id: this.oid + }; + if (options.legacy) { + return o; + } + if (this.db) + o.$db = this.db; + o = Object.assign(o, this.fields); + return o; + }; + /** @internal */ + DBRef.fromExtendedJSON = function (doc) { + var copy = Object.assign({}, doc); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(doc.$ref, doc.$id, doc.$db, copy); + }; + /** @internal */ + DBRef.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + DBRef.prototype.inspect = function () { + // NOTE: if OID is an ObjectId class it will just print the oid string. + var oid = this.oid === undefined || this.oid.toString === undefined ? this.oid : this.oid.toString(); + return "new DBRef(\"".concat(this.namespace, "\", new ObjectId(\"").concat(String(oid), "\")").concat(this.db ? ", \"".concat(this.db, "\"") : '', ")"); + }; + return DBRef; +}()); +Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' }); + +/** + * wasm optimizations, to do native i64 multiplication and divide + */ +var wasm = undefined; +try { + wasm = new WebAssembly.Instance(new WebAssembly.Module( + // prettier-ignore + new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports; +} +catch (_a) { + // no wasm support +} +var TWO_PWR_16_DBL = 1 << 16; +var TWO_PWR_24_DBL = 1 << 24; +var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL; +var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL; +var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2; +/** A cache of the Long representations of small integer values. */ +var INT_CACHE = {}; +/** A cache of the Long representations of small unsigned integer values. */ +var UINT_CACHE = {}; +/** + * A class representing a 64-bit integer + * @public + * @category BSONType + * @remarks + * 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. + * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class. + */ +var Long = /** @class */ (function () { + /** + * 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. + * + * Acceptable signatures are: + * - Long(low, high, unsigned?) + * - Long(bigint, unsigned?) + * - Long(string, unsigned?) + * + * @param low - The low (signed) 32 bits of the long + * @param high - The high (signed) 32 bits of the long + * @param unsigned - Whether unsigned or not, defaults to signed + */ + function Long(low, high, unsigned) { + if (low === void 0) { low = 0; } + if (!(this instanceof Long)) + return new Long(low, high, unsigned); + if (typeof low === 'bigint') { + Object.assign(this, Long.fromBigInt(low, !!high)); + } + else if (typeof low === 'string') { + Object.assign(this, Long.fromString(low, !!high)); + } + else { + this.low = low | 0; + this.high = high | 0; + this.unsigned = !!unsigned; + } + Object.defineProperty(this, '__isLong__', { + value: true, + configurable: false, + writable: false, + enumerable: false + }); + } + /** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. + * Each is assumed to use 32 bits. + * @param lowBits - The low 32 bits + * @param highBits - The high 32 bits + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBits = function (lowBits, highBits, unsigned) { + return new Long(lowBits, highBits, unsigned); + }; + /** + * Returns a Long representing the given 32 bit integer value. + * @param value - The 32 bit integer in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromInt = function (value, unsigned) { + var obj, cachedObj, cache; + if (unsigned) { + value >>>= 0; + if ((cache = 0 <= value && value < 256)) { + cachedObj = UINT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true); + if (cache) + UINT_CACHE[value] = obj; + return obj; + } + else { + value |= 0; + if ((cache = -128 <= value && value < 128)) { + cachedObj = INT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, value < 0 ? -1 : 0, false); + if (cache) + INT_CACHE[value] = obj; + return obj; + } + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromNumber = function (value, unsigned) { + if (isNaN(value)) + return unsigned ? Long.UZERO : Long.ZERO; + if (unsigned) { + if (value < 0) + return Long.UZERO; + if (value >= TWO_PWR_64_DBL) + return Long.MAX_UNSIGNED_VALUE; + } + else { + if (value <= -TWO_PWR_63_DBL) + return Long.MIN_VALUE; + if (value + 1 >= TWO_PWR_63_DBL) + return Long.MAX_VALUE; + } + if (value < 0) + return Long.fromNumber(-value, unsigned).neg(); + return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned); + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBigInt = function (value, unsigned) { + return Long.fromString(value.toString(), unsigned); + }; + /** + * Returns a Long representation of the given string, written using the specified radix. + * @param str - The textual representation of the Long + * @param unsigned - Whether unsigned or not, defaults to signed + * @param radix - The radix in which the text is written (2-36), defaults to 10 + * @returns The corresponding Long value + */ + Long.fromString = function (str, unsigned, radix) { + if (str.length === 0) + throw Error('empty string'); + if (str === 'NaN' || str === 'Infinity' || str === '+Infinity' || str === '-Infinity') + return Long.ZERO; + if (typeof unsigned === 'number') { + // For goog.math.long compatibility + (radix = unsigned), (unsigned = false); + } + else { + unsigned = !!unsigned; + } + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + var p; + if ((p = str.indexOf('-')) > 0) + throw Error('interior hyphen'); + else if (p === 0) { + return Long.fromString(str.substring(1), unsigned, radix).neg(); + } + // 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), value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Long.fromNumber(Math.pow(radix, size)); + result = result.mul(power).add(Long.fromNumber(value)); + } + else { + result = result.mul(radixToPower); + result = result.add(Long.fromNumber(value)); + } + } + result.unsigned = unsigned; + return result; + }; + /** + * Creates a Long from its byte representation. + * @param bytes - Byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @param le - Whether little or big endian, defaults to big endian + * @returns The corresponding Long value + */ + Long.fromBytes = function (bytes, unsigned, le) { + return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned); + }; + /** + * Creates a Long from its little endian byte representation. + * @param bytes - Little endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesLE = function (bytes, unsigned) { + return new Long(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24), bytes[4] | (bytes[5] << 8) | (bytes[6] << 16) | (bytes[7] << 24), unsigned); + }; + /** + * Creates a Long from its big endian byte representation. + * @param bytes - Big endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesBE = function (bytes, unsigned) { + return new Long((bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7], (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3], unsigned); + }; + /** + * Tests if the specified object is a Long. + */ + Long.isLong = function (value) { + return isObjectLike(value) && value['__isLong__'] === true; + }; + /** + * Converts the specified value to a Long. + * @param unsigned - Whether unsigned or not, defaults to signed + */ + Long.fromValue = function (val, unsigned) { + if (typeof val === 'number') + return Long.fromNumber(val, unsigned); + if (typeof val === 'string') + return Long.fromString(val, unsigned); + // Throws for non-objects, converts non-instanceof Long: + return Long.fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned); + }; + /** Returns the sum of this and the specified Long. */ + Long.prototype.add = function (addend) { + if (!Long.isLong(addend)) + addend = Long.fromValue(addend); + // 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 = addend.high >>> 16; + var b32 = addend.high & 0xffff; + var b16 = addend.low >>> 16; + var b00 = addend.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, this.unsigned); + }; + /** + * Returns the sum of this and the specified Long. + * @returns Sum + */ + Long.prototype.and = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); + }; + /** + * Compares this Long's value with the specified's. + * @returns 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 (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.eq(other)) + return 0; + var thisNeg = this.isNegative(), otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) + return -1; + if (!thisNeg && otherNeg) + return 1; + // At this point the sign bits are the same + if (!this.unsigned) + return this.sub(other).isNegative() ? -1 : 1; + // Both are positive if at least one is unsigned + return other.high >>> 0 > this.high >>> 0 || + (other.high === this.high && other.low >>> 0 > this.low >>> 0) + ? -1 + : 1; + }; + /** This is an alias of {@link Long.compare} */ + Long.prototype.comp = function (other) { + return this.compare(other); + }; + /** + * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned. + * @returns Quotient + */ + Long.prototype.divide = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + if (divisor.isZero()) + throw Error('division by zero'); + // use wasm support if present + if (wasm) { + // guard against signed division overflow: the largest + // negative number / -1 would be 1 larger than the largest + // positive number, due to two's complement. + if (!this.unsigned && + this.high === -0x80000000 && + divisor.low === -1 && + divisor.high === -1) { + // be consistent with non-wasm code path + return this; + } + var low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (this.isZero()) + return this.unsigned ? Long.UZERO : Long.ZERO; + var approx, rem, res; + if (!this.unsigned) { + // This section is only relevant for signed longs and is derived from the + // closure library as a whole. + if (this.eq(Long.MIN_VALUE)) { + if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE)) + return Long.MIN_VALUE; + // recall that -MIN_VALUE == MIN_VALUE + else if (divisor.eq(Long.MIN_VALUE)) + return Long.ONE; + else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shr(1); + approx = halfThis.div(divisor).shl(1); + if (approx.eq(Long.ZERO)) { + return divisor.isNegative() ? Long.ONE : Long.NEG_ONE; + } + else { + rem = this.sub(divisor.mul(approx)); + res = approx.add(rem.div(divisor)); + return res; + } + } + } + else if (divisor.eq(Long.MIN_VALUE)) + return this.unsigned ? Long.UZERO : Long.ZERO; + if (this.isNegative()) { + if (divisor.isNegative()) + return this.neg().div(divisor.neg()); + return this.neg().div(divisor).neg(); + } + else if (divisor.isNegative()) + return this.div(divisor.neg()).neg(); + res = Long.ZERO; + } + else { + // The algorithm below has not been made for unsigned longs. It's therefore + // required to take special care of the MSB prior to running it. + if (!divisor.unsigned) + divisor = divisor.toUnsigned(); + if (divisor.gt(this)) + return Long.UZERO; + if (divisor.gt(this.shru(1))) + // 15 >>> 1 = 7 ; with divisor = 8 ; true + return Long.UONE; + res = Long.UZERO; + } + // 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. + // eslint-disable-next-line @typescript-eslint/no-this-alias + rem = this; + while (rem.gte(divisor)) { + // 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() / divisor.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.mul(divisor); + while (approxRem.isNegative() || approxRem.gt(rem)) { + approx -= delta; + approxRes = Long.fromNumber(approx, this.unsigned); + approxRem = approxRes.mul(divisor); + } + // 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.sub(approxRem); + } + return res; + }; + /**This is an alias of {@link Long.divide} */ + Long.prototype.div = function (divisor) { + return this.divide(divisor); + }; + /** + * Tests if this Long's value equals the specified's. + * @param other - Other value + */ + Long.prototype.equals = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1) + return false; + return this.high === other.high && this.low === other.low; + }; + /** This is an alias of {@link Long.equals} */ + Long.prototype.eq = function (other) { + return this.equals(other); + }; + /** Gets the high 32 bits as a signed integer. */ + Long.prototype.getHighBits = function () { + return this.high; + }; + /** Gets the high 32 bits as an unsigned integer. */ + Long.prototype.getHighBitsUnsigned = function () { + return this.high >>> 0; + }; + /** Gets the low 32 bits as a signed integer. */ + Long.prototype.getLowBits = function () { + return this.low; + }; + /** Gets the low 32 bits as an unsigned integer. */ + Long.prototype.getLowBitsUnsigned = function () { + return this.low >>> 0; + }; + /** Gets the number of bits needed to represent the absolute value of this Long. */ + Long.prototype.getNumBitsAbs = function () { + if (this.isNegative()) { + // Unsigned Longs are never negative + return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); + } + var val = this.high !== 0 ? this.high : this.low; + var bit; + for (bit = 31; bit > 0; bit--) + if ((val & (1 << bit)) !== 0) + break; + return this.high !== 0 ? bit + 33 : bit + 1; + }; + /** Tests if this Long's value is greater than the specified's. */ + Long.prototype.greaterThan = function (other) { + return this.comp(other) > 0; + }; + /** This is an alias of {@link Long.greaterThan} */ + Long.prototype.gt = function (other) { + return this.greaterThan(other); + }; + /** Tests if this Long's value is greater than or equal the specified's. */ + Long.prototype.greaterThanOrEqual = function (other) { + return this.comp(other) >= 0; + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.gte = function (other) { + return this.greaterThanOrEqual(other); + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.ge = function (other) { + return this.greaterThanOrEqual(other); + }; + /** Tests if this Long's value is even. */ + Long.prototype.isEven = function () { + return (this.low & 1) === 0; + }; + /** Tests if this Long's value is negative. */ + Long.prototype.isNegative = function () { + return !this.unsigned && this.high < 0; + }; + /** Tests if this Long's value is odd. */ + Long.prototype.isOdd = function () { + return (this.low & 1) === 1; + }; + /** Tests if this Long's value is positive. */ + Long.prototype.isPositive = function () { + return this.unsigned || this.high >= 0; + }; + /** Tests if this Long's value equals zero. */ + Long.prototype.isZero = function () { + return this.high === 0 && this.low === 0; + }; + /** Tests if this Long's value is less than the specified's. */ + Long.prototype.lessThan = function (other) { + return this.comp(other) < 0; + }; + /** This is an alias of {@link Long#lessThan}. */ + Long.prototype.lt = function (other) { + return this.lessThan(other); + }; + /** Tests if this Long's value is less than or equal the specified's. */ + Long.prototype.lessThanOrEqual = function (other) { + return this.comp(other) <= 0; + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.lte = function (other) { + return this.lessThanOrEqual(other); + }; + /** Returns this Long modulo the specified. */ + Long.prototype.modulo = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + // use wasm support if present + if (wasm) { + var low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + return this.sub(this.div(divisor).mul(divisor)); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.mod = function (divisor) { + return this.modulo(divisor); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.rem = function (divisor) { + return this.modulo(divisor); + }; + /** + * Returns the product of this and the specified Long. + * @param multiplier - Multiplier + * @returns Product + */ + Long.prototype.multiply = function (multiplier) { + if (this.isZero()) + return Long.ZERO; + if (!Long.isLong(multiplier)) + multiplier = Long.fromValue(multiplier); + // use wasm support if present + if (wasm) { + var low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (multiplier.isZero()) + return Long.ZERO; + if (this.eq(Long.MIN_VALUE)) + return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (multiplier.eq(Long.MIN_VALUE)) + return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (this.isNegative()) { + if (multiplier.isNegative()) + return this.neg().mul(multiplier.neg()); + else + return this.neg().mul(multiplier).neg(); + } + else if (multiplier.isNegative()) + return this.mul(multiplier.neg()).neg(); + // If both longs are small, use float multiplication + if (this.lt(Long.TWO_PWR_24) && multiplier.lt(Long.TWO_PWR_24)) + return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); + // 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 = multiplier.high >>> 16; + var b32 = multiplier.high & 0xffff; + var b16 = multiplier.low >>> 16; + var b00 = multiplier.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, this.unsigned); + }; + /** This is an alias of {@link Long.multiply} */ + Long.prototype.mul = function (multiplier) { + return this.multiply(multiplier); + }; + /** Returns the Negation of this Long's value. */ + Long.prototype.negate = function () { + if (!this.unsigned && this.eq(Long.MIN_VALUE)) + return Long.MIN_VALUE; + return this.not().add(Long.ONE); + }; + /** This is an alias of {@link Long.negate} */ + Long.prototype.neg = function () { + return this.negate(); + }; + /** Returns the bitwise NOT of this Long. */ + Long.prototype.not = function () { + return Long.fromBits(~this.low, ~this.high, this.unsigned); + }; + /** Tests if this Long's value differs from the specified's. */ + Long.prototype.notEquals = function (other) { + return !this.equals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.neq = function (other) { + return this.notEquals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.ne = function (other) { + return this.notEquals(other); + }; + /** + * Returns the bitwise OR of this Long and the specified. + */ + Long.prototype.or = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); + }; + /** + * Returns this Long with bits shifted to the left by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftLeft = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); + else + return Long.fromBits(0, this.low << (numBits - 32), this.unsigned); + }; + /** This is an alias of {@link Long.shiftLeft} */ + Long.prototype.shl = function (numBits) { + return this.shiftLeft(numBits); + }; + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRight = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); + else + return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); + }; + /** This is an alias of {@link Long.shiftRight} */ + Long.prototype.shr = function (numBits) { + return this.shiftRight(numBits); + }; + /** + * Returns this Long with bits logically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRightUnsigned = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + 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, this.unsigned); + } + else if (numBits === 32) + return Long.fromBits(high, 0, this.unsigned); + else + return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned); + } + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shr_u = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shru = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** + * Returns the difference of this and the specified Long. + * @param subtrahend - Subtrahend + * @returns Difference + */ + Long.prototype.subtract = function (subtrahend) { + if (!Long.isLong(subtrahend)) + subtrahend = Long.fromValue(subtrahend); + return this.add(subtrahend.neg()); + }; + /** This is an alias of {@link Long.subtract} */ + Long.prototype.sub = function (subtrahend) { + return this.subtract(subtrahend); + }; + /** Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. */ + Long.prototype.toInt = function () { + return this.unsigned ? this.low >>> 0 : this.low; + }; + /** Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). */ + Long.prototype.toNumber = function () { + if (this.unsigned) + return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0); + return this.high * TWO_PWR_32_DBL + (this.low >>> 0); + }; + /** Converts the Long to a BigInt (arbitrary precision). */ + Long.prototype.toBigInt = function () { + return BigInt(this.toString()); + }; + /** + * Converts this Long to its byte representation. + * @param le - Whether little or big endian, defaults to big endian + * @returns Byte representation + */ + Long.prototype.toBytes = function (le) { + return le ? this.toBytesLE() : this.toBytesBE(); + }; + /** + * Converts this Long to its little endian byte representation. + * @returns Little endian byte representation + */ + Long.prototype.toBytesLE = function () { + var hi = this.high, lo = this.low; + return [ + lo & 0xff, + (lo >>> 8) & 0xff, + (lo >>> 16) & 0xff, + lo >>> 24, + hi & 0xff, + (hi >>> 8) & 0xff, + (hi >>> 16) & 0xff, + hi >>> 24 + ]; + }; + /** + * Converts this Long to its big endian byte representation. + * @returns Big endian byte representation + */ + Long.prototype.toBytesBE = function () { + var hi = this.high, lo = this.low; + return [ + hi >>> 24, + (hi >>> 16) & 0xff, + (hi >>> 8) & 0xff, + hi & 0xff, + lo >>> 24, + (lo >>> 16) & 0xff, + (lo >>> 8) & 0xff, + lo & 0xff + ]; + }; + /** + * Converts this Long to signed. + */ + Long.prototype.toSigned = function () { + if (!this.unsigned) + return this; + return Long.fromBits(this.low, this.high, false); + }; + /** + * Converts the Long to a string written in the specified radix. + * @param radix - Radix (2-36), defaults to 10 + * @throws RangeError If `radix` is out of range + */ + Long.prototype.toString = function (radix) { + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + if (this.isZero()) + return '0'; + if (this.isNegative()) { + // Unsigned Longs are never negative + if (this.eq(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), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this); + return div.toString(radix) + rem1.toInt().toString(radix); + } + else + return '-' + this.neg().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), this.unsigned); + // eslint-disable-next-line @typescript-eslint/no-this-alias + var rem = this; + var result = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + var remDiv = rem.div(radixToPower); + var intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0; + var digits = intval.toString(radix); + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } + else { + while (digits.length < 6) + digits = '0' + digits; + result = '' + digits + result; + } + } + }; + /** Converts this Long to unsigned. */ + Long.prototype.toUnsigned = function () { + if (this.unsigned) + return this; + return Long.fromBits(this.low, this.high, true); + }; + /** Returns the bitwise XOR of this Long and the given one. */ + Long.prototype.xor = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); + }; + /** This is an alias of {@link Long.isZero} */ + Long.prototype.eqz = function () { + return this.isZero(); + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.le = function (other) { + return this.lessThanOrEqual(other); + }; + /* + **************************************************************** + * BSON SPECIFIC ADDITIONS * + **************************************************************** + */ + Long.prototype.toExtendedJSON = function (options) { + if (options && options.relaxed) + return this.toNumber(); + return { $numberLong: this.toString() }; + }; + Long.fromExtendedJSON = function (doc, options) { + var result = Long.fromString(doc.$numberLong); + return options && options.relaxed ? result.toNumber() : result; + }; + /** @internal */ + Long.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Long.prototype.inspect = function () { + return "new Long(\"".concat(this.toString(), "\"").concat(this.unsigned ? ', true' : '', ")"); + }; + Long.TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL); + /** Maximum unsigned value. */ + Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xffffffff | 0, 0xffffffff | 0, true); + /** Signed zero */ + Long.ZERO = Long.fromInt(0); + /** Unsigned zero. */ + Long.UZERO = Long.fromInt(0, true); + /** Signed one. */ + Long.ONE = Long.fromInt(1); + /** Unsigned one. */ + Long.UONE = Long.fromInt(1, true); + /** Signed negative one. */ + Long.NEG_ONE = Long.fromInt(-1); + /** Maximum signed value. */ + Long.MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0, false); + /** Minimum signed value. */ + Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false); + return Long; +}()); +Object.defineProperty(Long.prototype, '__isLong__', { value: true }); +Object.defineProperty(Long.prototype, '_bsontype', { value: '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+)?$/; +// 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; +// Detect if the value is a digit +function isDigit(value) { + return !isNaN(parseInt(value, 10)); +} +// Divide two uint128 values +function divideu128(value) { + var DIVISOR = Long.fromNumber(1000 * 1000 * 1000); + var _rem = Long.fromNumber(0); + if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) { + return { quotient: value, rem: _rem }; + } + for (var 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 +function multiply64x2(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 }; +} +function lessThan(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; +} +function invalidErr(string, message) { + throw new BSONTypeError("\"".concat(string, "\" is not a valid Decimal128 string - ").concat(message)); +} +/** + * A class representation of the BSON Decimal128 type. + * @public + * @category BSONType + */ +var Decimal128 = /** @class */ (function () { + /** + * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order, + * or a string representation as returned by .toString() + */ + function Decimal128(bytes) { + if (!(this instanceof Decimal128)) + return new Decimal128(bytes); + if (typeof bytes === 'string') { + this.bytes = Decimal128.fromString(bytes).bytes; + } + else if (isUint8Array(bytes)) { + if (bytes.byteLength !== 16) { + throw new BSONTypeError('Decimal128 must take a Buffer of 16 bytes'); + } + this.bytes = bytes; + } + else { + throw new BSONTypeError('Decimal128 must take a Buffer or string'); + } + } + /** + * Create a Decimal128 instance from a string representation + * + * @param representation - a numeric string representation. + */ + Decimal128.fromString = function (representation) { + // 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 = new Long(0, 0); + // The low 17 digits of the significand + var significandLow = new Long(0, 0); + // The biased exponent + var biasedExponent = 0; + // Read index + var index = 0; + // Naively prevent against REDOS attacks. + // TODO: implementing a custom parsing for this, or refactoring the regex would yield + // further gains. + if (representation.length >= 7000) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + // Results + var stringMatch = representation.match(PARSE_STRING_REGEXP); + var infMatch = representation.match(PARSE_INF_REGEXP); + var nanMatch = representation.match(PARSE_NAN_REGEXP); + // Validate the string + if ((!stringMatch && !infMatch && !nanMatch) || representation.length === 0) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + if (stringMatch) { + // full_match = stringMatch[0] + // sign = stringMatch[1] + var unsignedNumber = stringMatch[2]; + // stringMatch[3] is undefined if a whole number (ex "1", 12") + // but defined if a number w/ decimal in it (ex "1.0, 12.2") + var e = stringMatch[4]; + var expSign = stringMatch[5]; + var expNumber = stringMatch[6]; + // they provided e, but didn't give an exponent number. for ex "1e" + if (e && expNumber === undefined) + invalidErr(representation, 'missing exponent power'); + // they provided e, but didn't give a number before it. for ex "e1" + if (e && unsignedNumber === undefined) + invalidErr(representation, 'missing exponent base'); + if (e === undefined && (expSign || expNumber)) { + invalidErr(representation, 'missing e before exponent'); + } + } + // Get the negative or positive sign + if (representation[index] === '+' || representation[index] === '-') { + isNegative = representation[index++] === '-'; + } + // Check if user passed Infinity or NaN + if (!isDigit(representation[index]) && representation[index] !== '.') { + if (representation[index] === 'i' || representation[index] === 'I') { + return new Decimal128(Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + else if (representation[index] === 'N') { + return new Decimal128(Buffer.from(NAN_BUFFER)); + } + } + // Read all the digits + while (isDigit(representation[index]) || representation[index] === '.') { + if (representation[index] === '.') { + if (sawRadix) + invalidErr(representation, 'contains multiple periods'); + sawRadix = true; + index = index + 1; + continue; + } + if (nDigitsStored < 34) { + if (representation[index] !== '0' || foundNonZero) { + if (!foundNonZero) { + firstNonZero = nDigitsRead; + } + foundNonZero = true; + // Only store 34 digits + digits[digitsInsert++] = parseInt(representation[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 BSONTypeError('' + representation + ' not a valid Decimal128 string'); + // Read exponent if exists + if (representation[index] === 'e' || representation[index] === 'E') { + // Read exponent digits + var match = representation.substr(++index).match(EXPONENT_REGEX); + // No digits read + if (!match || !match[2]) + return new Decimal128(Buffer.from(NAN_BUFFER)); + // Get exponent + exponent = parseInt(match[0], 10); + // Adjust the index + index = index + match[0].length; + } + // Return not a number + if (representation[index]) + return new Decimal128(Buffer.from(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 (significantDigits !== 1) { + while (digits[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; + } + invalidErr(representation, 'overflow'); + } + exponent = exponent - 1; + } + while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { + // Shift last digit. can only do this if < significant digits than # stored. + if (lastDigit === 0 && significantDigits < nDigitsStored) { + 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 + var digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } + invalidErr(representation, 'overflow'); + } + } + // Round + // We've normalized the exponent, but might still need to round. + if (lastDigit - firstDigit + 1 < significantDigits) { + 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) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + // if negative, we need to increment again to account for - sign at start. + if (isNegative) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + var roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10); + var roundBit = 0; + if (roundDigit >= 5) { + roundBit = 1; + if (roundDigit === 5) { + roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0; + for (i = firstNonZero + lastDigit + 2; i < endOfString; i++) { + if (parseInt(representation[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(Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + } + } + } + } + // 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) { + var 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 { + var 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(1))) { + // 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 = Buffer.alloc(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); + }; + /** Create a string representation of the raw Decimal128 value */ + Decimal128.prototype.toString = function () { + // Note: bits in this routine are referred to starting at 0, + // from the sign bit, towards the coefficient. + // 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; + // true if the number is zero + var is_zero = false; + // the most significant significand bits (50-46) + var significand_msb; + // temporary storage for significand decoding + var significand128 = { parts: [0, 0, 0, 0] }; + // indexing variables + var j, k; + // Output string + var string = []; + // Unpack index + index = 0; + // Buffer reference + var buffer = this.bytes; + // Unpack the low 64bits into a long + // bits 96 - 127 + var low = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 64 - 95 + var midl = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // Unpack the high 64bits into a long + // bits 32 - 63 + var midh = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 0 - 31 + var 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 + // bits 1 - 5 + var 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; + } + // unbiased exponent + var 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; + // Perform 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; + while (!significand[index]) { + significand_digits = significand_digits - 1; + index = index + 1; + } + } + // the exponent if scientific notation is used + var 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 + // if there are too many significant digits, we should just be treating numbers + // as + or - 0 and using the non-scientific exponent (this is for the "invalid + // representation should be treated as 0/-0" spec cases in decimal128-1.json) + if (significand_digits > 34) { + string.push("".concat(0)); + if (exponent > 0) + string.push("E+".concat(exponent)); + else if (exponent < 0) + string.push("E".concat(exponent)); + return string.join(''); + } + string.push("".concat(significand[index++])); + significand_digits = significand_digits - 1; + if (significand_digits) { + string.push('.'); + } + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + // Exponent + string.push('E'); + if (scientific_exponent > 0) { + string.push("+".concat(scientific_exponent)); + } + else { + string.push("".concat(scientific_exponent)); + } + } + else { + // Regular format with no decimal place + if (exponent >= 0) { + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + } + else { + var radix_position = significand_digits + exponent; + // non-zero digits before radix + if (radix_position > 0) { + for (var i = 0; i < radix_position; i++) { + string.push("".concat(significand[index++])); + } + } + else { + string.push('0'); + } + string.push('.'); + // add leading zeros after radix + while (radix_position++ < 0) { + string.push('0'); + } + for (var i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) { + string.push("".concat(significand[index++])); + } + } + } + return string.join(''); + }; + Decimal128.prototype.toJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.prototype.toExtendedJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.fromExtendedJSON = function (doc) { + return Decimal128.fromString(doc.$numberDecimal); + }; + /** @internal */ + Decimal128.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Decimal128.prototype.inspect = function () { + return "new Decimal128(\"".concat(this.toString(), "\")"); + }; + return Decimal128; +}()); +Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' }); + +/** + * A class representation of the BSON Double type. + * @public + * @category BSONType + */ +var Double = /** @class */ (function () { + /** + * Create a Double type + * + * @param value - the number we want to represent as a double. + */ + function Double(value) { + if (!(this instanceof Double)) + return new Double(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value; + } + /** + * Access the number value. + * + * @returns returns the wrapped double number. + */ + Double.prototype.valueOf = function () { + return this.value; + }; + Double.prototype.toJSON = function () { + return this.value; + }; + Double.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + /** @internal */ + Double.prototype.toExtendedJSON = function (options) { + if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) { + return this.value; + } + // NOTE: JavaScript has +0 and -0, apparently to model limit calculations. If a user + // explicitly provided `-0` then we need to ensure the sign makes it into the output + if (Object.is(Math.sign(this.value), -0)) { + return { $numberDouble: "-".concat(this.value.toFixed(1)) }; + } + var $numberDouble; + if (Number.isInteger(this.value)) { + $numberDouble = this.value.toFixed(1); + if ($numberDouble.length >= 13) { + $numberDouble = this.value.toExponential(13).toUpperCase(); + } + } + else { + $numberDouble = this.value.toString(); + } + return { $numberDouble: $numberDouble }; + }; + /** @internal */ + Double.fromExtendedJSON = function (doc, options) { + var doubleValue = parseFloat(doc.$numberDouble); + return options && options.relaxed ? doubleValue : new Double(doubleValue); + }; + /** @internal */ + Double.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Double.prototype.inspect = function () { + var eJSON = this.toExtendedJSON(); + return "new Double(".concat(eJSON.$numberDouble, ")"); + }; + return Double; +}()); +Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' }); + +/** + * A class representation of a BSON Int32 type. + * @public + * @category BSONType + */ +var Int32 = /** @class */ (function () { + /** + * Create an Int32 type + * + * @param value - the number we want to represent as an int32. + */ + function Int32(value) { + if (!(this instanceof Int32)) + return new Int32(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value | 0; + } + /** + * Access the number value. + * + * @returns returns the wrapped int32 number. + */ + Int32.prototype.valueOf = function () { + return this.value; + }; + Int32.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + Int32.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + Int32.prototype.toExtendedJSON = function (options) { + if (options && (options.relaxed || options.legacy)) + return this.value; + return { $numberInt: this.value.toString() }; + }; + /** @internal */ + Int32.fromExtendedJSON = function (doc, options) { + return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new Int32(doc.$numberInt); + }; + /** @internal */ + Int32.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Int32.prototype.inspect = function () { + return "new Int32(".concat(this.valueOf(), ")"); + }; + return Int32; +}()); +Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' }); + +/** + * A class representation of the BSON MaxKey type. + * @public + * @category BSONType + */ +var MaxKey = /** @class */ (function () { + function MaxKey() { + if (!(this instanceof MaxKey)) + return new MaxKey(); + } + /** @internal */ + MaxKey.prototype.toExtendedJSON = function () { + return { $maxKey: 1 }; + }; + /** @internal */ + MaxKey.fromExtendedJSON = function () { + return new MaxKey(); + }; + /** @internal */ + MaxKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MaxKey.prototype.inspect = function () { + return 'new MaxKey()'; + }; + return MaxKey; +}()); +Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' }); + +/** + * A class representation of the BSON MinKey type. + * @public + * @category BSONType + */ +var MinKey = /** @class */ (function () { + function MinKey() { + if (!(this instanceof MinKey)) + return new MinKey(); + } + /** @internal */ + MinKey.prototype.toExtendedJSON = function () { + return { $minKey: 1 }; + }; + /** @internal */ + MinKey.fromExtendedJSON = function () { + return new MinKey(); + }; + /** @internal */ + MinKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MinKey.prototype.inspect = function () { + return 'new MinKey()'; + }; + return MinKey; +}()); +Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' }); + +// Regular expression that checks for hex value +var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$'); +// Unique sequence for the current process (initialized on first use) +var PROCESS_UNIQUE = null; +var kId = Symbol('id'); +/** + * A class representation of the BSON ObjectId type. + * @public + * @category BSONType + */ +var ObjectId = /** @class */ (function () { + /** + * Create an ObjectId type + * + * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number. + */ + function ObjectId(inputId) { + if (!(this instanceof ObjectId)) + return new ObjectId(inputId); + // workingId is set based on type of input and whether valid id exists for the input + var workingId; + if (typeof inputId === 'object' && inputId && 'id' in inputId) { + if (typeof inputId.id !== 'string' && !ArrayBuffer.isView(inputId.id)) { + throw new BSONTypeError('Argument passed in must have an id that is of type string or Buffer'); + } + if ('toHexString' in inputId && typeof inputId.toHexString === 'function') { + workingId = Buffer.from(inputId.toHexString(), 'hex'); + } + else { + workingId = inputId.id; + } + } + else { + workingId = inputId; + } + // the following cases use workingId to construct an ObjectId + if (workingId == null || typeof workingId === 'number') { + // The most common use case (blank id, new objectId instance) + // Generate a new id + this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined); + } + else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) { + // If intstanceof matches we can escape calling ensure buffer in Node.js environments + this[kId] = workingId instanceof Buffer ? workingId : ensureBuffer(workingId); + } + else if (typeof workingId === 'string') { + if (workingId.length === 12) { + var bytes = Buffer.from(workingId); + if (bytes.byteLength === 12) { + this[kId] = bytes; + } + else { + throw new BSONTypeError('Argument passed in must be a string of 12 bytes'); + } + } + else if (workingId.length === 24 && checkForHexRegExp.test(workingId)) { + this[kId] = Buffer.from(workingId, 'hex'); + } + else { + throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer'); + } + } + else { + throw new BSONTypeError('Argument passed in does not match the accepted types'); + } + // If we are caching the hex string + if (ObjectId.cacheHexString) { + this.__id = this.id.toString('hex'); + } + } + Object.defineProperty(ObjectId.prototype, "id", { + /** + * The ObjectId bytes + * @readonly + */ + get: function () { + return this[kId]; + }, + set: function (value) { + this[kId] = value; + if (ObjectId.cacheHexString) { + this.__id = value.toString('hex'); + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(ObjectId.prototype, "generationTime", { + /** + * The generation time of this ObjectId instance + * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch + */ + get: function () { + return this.id.readInt32BE(0); + }, + set: function (value) { + // Encode time into first 4 bytes + this.id.writeUInt32BE(value, 0); + }, + enumerable: false, + configurable: true + }); + /** Returns the ObjectId id as a 24 character hex string representation */ + ObjectId.prototype.toHexString = function () { + if (ObjectId.cacheHexString && this.__id) { + return this.__id; + } + var hexString = this.id.toString('hex'); + if (ObjectId.cacheHexString && !this.__id) { + this.__id = hexString; + } + return hexString; + }; + /** + * Update the ObjectId index + * @privateRemarks + * Used in generating new ObjectId's on the driver + * @internal + */ + ObjectId.getInc = function () { + return (ObjectId.index = (ObjectId.index + 1) % 0xffffff); + }; + /** + * Generate a 12 byte id buffer used in ObjectId's + * + * @param time - pass in a second based timestamp. + */ + ObjectId.generate = function (time) { + if ('number' !== typeof time) { + time = Math.floor(Date.now() / 1000); + } + var inc = ObjectId.getInc(); + var buffer = Buffer.alloc(12); + // 4-byte timestamp + buffer.writeUInt32BE(time, 0); + // set PROCESS_UNIQUE if yet not initialized + if (PROCESS_UNIQUE === null) { + PROCESS_UNIQUE = randomBytes(5); + } + // 5-byte process unique + buffer[4] = PROCESS_UNIQUE[0]; + buffer[5] = PROCESS_UNIQUE[1]; + buffer[6] = PROCESS_UNIQUE[2]; + buffer[7] = PROCESS_UNIQUE[3]; + buffer[8] = PROCESS_UNIQUE[4]; + // 3-byte counter + buffer[11] = inc & 0xff; + buffer[10] = (inc >> 8) & 0xff; + buffer[9] = (inc >> 16) & 0xff; + return buffer; + }; + /** + * Converts the id into a 24 character hex string for printing + * + * @param format - The Buffer toString format parameter. + */ + ObjectId.prototype.toString = function (format) { + // Is the id a buffer then use the buffer toString method to return the format + if (format) + return this.id.toString(format); + return this.toHexString(); + }; + /** Converts to its JSON the 24 character hex string representation. */ + ObjectId.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this ObjectId with `otherID`. + * + * @param otherId - ObjectId instance to compare against. + */ + ObjectId.prototype.equals = function (otherId) { + if (otherId === undefined || otherId === null) { + return false; + } + if (otherId instanceof ObjectId) { + return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]); + } + if (typeof otherId === 'string' && + ObjectId.isValid(otherId) && + otherId.length === 12 && + isUint8Array(this.id)) { + return otherId === Buffer.prototype.toString.call(this.id, 'latin1'); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 24) { + return otherId.toLowerCase() === this.toHexString(); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 12) { + return Buffer.from(otherId).equals(this.id); + } + if (typeof otherId === 'object' && + 'toHexString' in otherId && + typeof otherId.toHexString === 'function') { + var otherIdString = otherId.toHexString(); + var thisIdString = this.toHexString().toLowerCase(); + return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString; + } + return false; + }; + /** Returns the generation date (accurate up to the second) that this ID was generated. */ + ObjectId.prototype.getTimestamp = function () { + var timestamp = new Date(); + var time = this.id.readUInt32BE(0); + timestamp.setTime(Math.floor(time) * 1000); + return timestamp; + }; + /** @internal */ + ObjectId.createPk = function () { + 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. + * + * @param time - an integer number representing a number of seconds. + */ + ObjectId.createFromTime = function (time) { + var buffer = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Encode time into first 4 bytes + buffer.writeUInt32BE(time, 0); + // Return the new objectId + return new ObjectId(buffer); + }; + /** + * Creates an ObjectId from a hex string representation of an ObjectId. + * + * @param hexString - create a ObjectId from a passed in 24 character hexstring. + */ + ObjectId.createFromHexString = function (hexString) { + // Throw an error if it's not a valid setup + if (typeof hexString === 'undefined' || (hexString != null && hexString.length !== 24)) { + throw new BSONTypeError('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'); + } + return new ObjectId(Buffer.from(hexString, 'hex')); + }; + /** + * Checks if a value is a valid bson ObjectId + * + * @param id - ObjectId instance to validate. + */ + ObjectId.isValid = function (id) { + if (id == null) + return false; + try { + new ObjectId(id); + return true; + } + catch (_a) { + return false; + } + }; + /** @internal */ + ObjectId.prototype.toExtendedJSON = function () { + if (this.toHexString) + return { $oid: this.toHexString() }; + return { $oid: this.toString('hex') }; + }; + /** @internal */ + ObjectId.fromExtendedJSON = function (doc) { + return new ObjectId(doc.$oid); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 24 character hex string representation. + * @internal + */ + ObjectId.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + ObjectId.prototype.inspect = function () { + return "new ObjectId(\"".concat(this.toHexString(), "\")"); + }; + /** @internal */ + ObjectId.index = Math.floor(Math.random() * 0xffffff); + return ObjectId; +}()); +// Deprecated methods +Object.defineProperty(ObjectId.prototype, 'generate', { + value: deprecate(function (time) { return ObjectId.generate(time); }, 'Please use the static `ObjectId.generate(time)` instead') +}); +Object.defineProperty(ObjectId.prototype, 'getInc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') +}); +Object.defineProperty(ObjectId.prototype, 'get_inc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') +}); +Object.defineProperty(ObjectId, 'get_inc', { + value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') +}); +Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' }); + +function alphabetize(str) { + return str.split('').sort().join(''); +} +/** + * A class representation of the BSON RegExp type. + * @public + * @category BSONType + */ +var BSONRegExp = /** @class */ (function () { + /** + * @param pattern - The regular expression pattern to match + * @param options - The regular expression options + */ + function BSONRegExp(pattern, options) { + if (!(this instanceof BSONRegExp)) + return new BSONRegExp(pattern, options); + this.pattern = pattern; + this.options = alphabetize(options !== null && options !== void 0 ? options : ''); + if (this.pattern.indexOf('\x00') !== -1) { + throw new BSONError("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern))); + } + if (this.options.indexOf('\x00') !== -1) { + throw new BSONError("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.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 BSONError("The regular expression option [".concat(this.options[i], "] is not supported")); + } + } + } + BSONRegExp.parseOptions = function (options) { + return options ? options.split('').sort().join('') : ''; + }; + /** @internal */ + BSONRegExp.prototype.toExtendedJSON = function (options) { + options = options || {}; + if (options.legacy) { + return { $regex: this.pattern, $options: this.options }; + } + return { $regularExpression: { pattern: this.pattern, options: this.options } }; + }; + /** @internal */ + BSONRegExp.fromExtendedJSON = function (doc) { + if ('$regex' in doc) { + if (typeof doc.$regex !== 'string') { + // This is for $regex query operators that have extended json values. + if (doc.$regex._bsontype === 'BSONRegExp') { + return doc; + } + } + else { + return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options)); + } + } + if ('$regularExpression' in doc) { + return new BSONRegExp(doc.$regularExpression.pattern, BSONRegExp.parseOptions(doc.$regularExpression.options)); + } + throw new BSONTypeError("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(doc))); + }; + return BSONRegExp; +}()); +Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' }); + +/** + * A class representation of the BSON Symbol type. + * @public + * @category BSONType + */ +var BSONSymbol = /** @class */ (function () { + /** + * @param value - the string representing the symbol. + */ + function BSONSymbol(value) { + if (!(this instanceof BSONSymbol)) + return new BSONSymbol(value); + this.value = value; + } + /** Access the wrapped string value. */ + BSONSymbol.prototype.valueOf = function () { + return this.value; + }; + BSONSymbol.prototype.toString = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.inspect = function () { + return "new BSONSymbol(\"".concat(this.value, "\")"); + }; + BSONSymbol.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.toExtendedJSON = function () { + return { $symbol: this.value }; + }; + /** @internal */ + BSONSymbol.fromExtendedJSON = function (doc) { + return new BSONSymbol(doc.$symbol); + }; + /** @internal */ + BSONSymbol.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + return BSONSymbol; +}()); +Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' }); + +/** @public */ +var LongWithoutOverridesClass = Long; +/** + * @public + * @category BSONType + * */ +var Timestamp = /** @class */ (function (_super) { + __extends(Timestamp, _super); + function Timestamp(low, high) { + var _this = this; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + if (!(_this instanceof Timestamp)) + return new Timestamp(low, high); + if (Long.isLong(low)) { + _this = _super.call(this, low.low, low.high, true) || this; + } + else if (isObjectLike(low) && typeof low.t !== 'undefined' && typeof low.i !== 'undefined') { + _this = _super.call(this, low.i, low.t, true) || this; + } + else { + _this = _super.call(this, low, high, true) || this; + } + Object.defineProperty(_this, '_bsontype', { + value: 'Timestamp', + writable: false, + configurable: false, + enumerable: false + }); + return _this; + } + Timestamp.prototype.toJSON = function () { + return { + $timestamp: this.toString() + }; + }; + /** Returns a Timestamp represented by the given (32-bit) integer value. */ + Timestamp.fromInt = function (value) { + return new Timestamp(Long.fromInt(value, true)); + }; + /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */ + Timestamp.fromNumber = function (value) { + return new Timestamp(Long.fromNumber(value, true)); + }; + /** + * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits. + * + * @param lowBits - the low 32-bits. + * @param highBits - the high 32-bits. + */ + Timestamp.fromBits = function (lowBits, highBits) { + return new Timestamp(lowBits, highBits); + }; + /** + * Returns a Timestamp from the given string, optionally using the given radix. + * + * @param str - the textual representation of the Timestamp. + * @param optRadix - the radix in which the text is written. + */ + Timestamp.fromString = function (str, optRadix) { + return new Timestamp(Long.fromString(str, true, optRadix)); + }; + /** @internal */ + Timestamp.prototype.toExtendedJSON = function () { + return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } }; + }; + /** @internal */ + Timestamp.fromExtendedJSON = function (doc) { + return new Timestamp(doc.$timestamp); + }; + /** @internal */ + Timestamp.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Timestamp.prototype.inspect = function () { + return "new Timestamp({ t: ".concat(this.getHighBits(), ", i: ").concat(this.getLowBits(), " })"); + }; + Timestamp.MAX_VALUE = Long.MAX_UNSIGNED_VALUE; + return Timestamp; +}(LongWithoutOverridesClass)); + +function isBSONType(value) { + return (isObjectLike(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string'); +} +// INT32 boundaries +var BSON_INT32_MAX = 0x7fffffff; +var BSON_INT32_MIN = -0x80000000; +// INT64 boundaries +// const BSON_INT64_MAX = 0x7fffffffffffffff; // TODO(NODE-4377): This number cannot be precisely represented in JS +var BSON_INT64_MAX = 0x8000000000000000; +var BSON_INT64_MIN = -0x8000000000000000; +// all the types where we don't need to do any special processing and can just pass the EJSON +//straight to type.fromExtendedJSON +var keysToCodecs = { + $oid: ObjectId, + $binary: Binary, + $uuid: Binary, + $symbol: BSONSymbol, + $numberInt: Int32, + $numberDecimal: Decimal128, + $numberDouble: Double, + $numberLong: Long, + $minKey: MinKey, + $maxKey: MaxKey, + $regex: BSONRegExp, + $regularExpression: BSONRegExp, + $timestamp: Timestamp +}; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function deserializeValue(value, options) { + if (options === void 0) { options = {}; } + if (typeof value === 'number') { + if (options.relaxed || options.legacy) { + return value; + } + // if it's an integer, should interpret as smallest BSON integer + // that can represent it exactly. (if out of range, interpret as double.) + if (Math.floor(value) === value) { + if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) + return new Int32(value); + if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) + return Long.fromNumber(value); + } + // If the number is a non-integer or out of integer range, should interpret as BSON Double. + return new Double(value); + } + // from here on out we're looking for bson types, so bail if its not an object + if (value == null || typeof value !== 'object') + return value; + // upgrade deprecated undefined to null + if (value.$undefined) + return null; + var keys = Object.keys(value).filter(function (k) { return k.startsWith('$') && value[k] != null; }); + for (var i = 0; i < keys.length; i++) { + var c = keysToCodecs[keys[i]]; + if (c) + return c.fromExtendedJSON(value, options); + } + if (value.$date != null) { + var d = value.$date; + var date = new Date(); + if (options.legacy) { + if (typeof d === 'number') + date.setTime(d); + else if (typeof d === 'string') + date.setTime(Date.parse(d)); + } + else { + if (typeof d === 'string') + date.setTime(Date.parse(d)); + else if (Long.isLong(d)) + date.setTime(d.toNumber()); + else if (typeof d === 'number' && options.relaxed) + date.setTime(d); + } + return date; + } + if (value.$code != null) { + var copy = Object.assign({}, value); + if (value.$scope) { + copy.$scope = deserializeValue(value.$scope); + } + return Code.fromExtendedJSON(value); + } + if (isDBRefLike(value) || value.$dbPointer) { + var v = value.$ref ? value : value.$dbPointer; + // we run into this in a "degenerate EJSON" case (with $id and $ref order flipped) + // because of the order JSON.parse goes through the document + if (v instanceof DBRef) + return v; + var dollarKeys = Object.keys(v).filter(function (k) { return k.startsWith('$'); }); + var valid_1 = true; + dollarKeys.forEach(function (k) { + if (['$ref', '$id', '$db'].indexOf(k) === -1) + valid_1 = false; + }); + // only make DBRef if $ keys are all valid + if (valid_1) + return DBRef.fromExtendedJSON(v); + } + return value; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeArray(array, options) { + return array.map(function (v, index) { + options.seenObjects.push({ propertyName: "index ".concat(index), obj: null }); + try { + return serializeValue(v, options); + } + finally { + options.seenObjects.pop(); + } + }); +} +function getISOString(date) { + var isoStr = date.toISOString(); + // we should only show milliseconds in timestamp if they're non-zero + return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + 'Z'; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeValue(value, options) { + if ((typeof value === 'object' || typeof value === 'function') && value !== null) { + var index = options.seenObjects.findIndex(function (entry) { return entry.obj === value; }); + if (index !== -1) { + var props = options.seenObjects.map(function (entry) { return entry.propertyName; }); + var leadingPart = props + .slice(0, index) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var alreadySeen = props[index]; + var circularPart = ' -> ' + + props + .slice(index + 1, props.length - 1) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var current = props[props.length - 1]; + var leadingSpace = ' '.repeat(leadingPart.length + alreadySeen.length / 2); + var dashes = '-'.repeat(circularPart.length + (alreadySeen.length + current.length) / 2 - 1); + throw new BSONTypeError('Converting circular structure to EJSON:\n' + + " ".concat(leadingPart).concat(alreadySeen).concat(circularPart).concat(current, "\n") + + " ".concat(leadingSpace, "\\").concat(dashes, "/")); + } + options.seenObjects[options.seenObjects.length - 1].obj = value; + } + if (Array.isArray(value)) + return serializeArray(value, options); + if (value === undefined) + return null; + if (value instanceof Date || isDate(value)) { + var dateNum = value.getTime(), + // is it in year range 1970-9999? + inRange = dateNum > -1 && dateNum < 253402318800000; + if (options.legacy) { + return options.relaxed && inRange + ? { $date: value.getTime() } + : { $date: getISOString(value) }; + } + return options.relaxed && inRange + ? { $date: getISOString(value) } + : { $date: { $numberLong: value.getTime().toString() } }; + } + if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) { + // it's an integer + if (Math.floor(value) === value) { + var int32Range = value >= BSON_INT32_MIN && value <= BSON_INT32_MAX, int64Range = value >= BSON_INT64_MIN && value <= BSON_INT64_MAX; + // interpret as being of the smallest BSON integer type that can represent the number exactly + if (int32Range) + return { $numberInt: value.toString() }; + if (int64Range) + return { $numberLong: value.toString() }; + } + return { $numberDouble: value.toString() }; + } + if (value instanceof RegExp || isRegExp(value)) { + var flags = value.flags; + if (flags === undefined) { + var match = value.toString().match(/[gimuy]*$/); + if (match) { + flags = match[0]; + } + } + var rx = new BSONRegExp(value.source, flags); + return rx.toExtendedJSON(options); + } + if (value != null && typeof value === 'object') + return serializeDocument(value, options); + return value; +} +var BSON_TYPE_MAPPINGS = { + Binary: function (o) { return new Binary(o.value(), o.sub_type); }, + Code: function (o) { return new Code(o.code, o.scope); }, + DBRef: function (o) { return new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields); }, + Decimal128: function (o) { return new Decimal128(o.bytes); }, + Double: function (o) { return new Double(o.value); }, + Int32: function (o) { return new Int32(o.value); }, + Long: function (o) { + return Long.fromBits( + // underscore variants for 1.x backwards compatibility + o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_); + }, + MaxKey: function () { return new MaxKey(); }, + MinKey: function () { return new MinKey(); }, + ObjectID: function (o) { return new ObjectId(o); }, + ObjectId: function (o) { return new ObjectId(o); }, + BSONRegExp: function (o) { return new BSONRegExp(o.pattern, o.options); }, + Symbol: function (o) { return new BSONSymbol(o.value); }, + Timestamp: function (o) { return Timestamp.fromBits(o.low, o.high); } +}; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeDocument(doc, options) { + if (doc == null || typeof doc !== 'object') + throw new BSONError('not an object instance'); + var bsontype = doc._bsontype; + if (typeof bsontype === 'undefined') { + // It's a regular object. Recursively serialize its property values. + var _doc = {}; + for (var name in doc) { + options.seenObjects.push({ propertyName: name, obj: null }); + try { + var value = serializeValue(doc[name], options); + if (name === '__proto__') { + Object.defineProperty(_doc, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + _doc[name] = value; + } + } + finally { + options.seenObjects.pop(); + } + } + return _doc; + } + else if (isBSONType(doc)) { + // the "document" is really just a BSON type object + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var outDoc = doc; + if (typeof outDoc.toExtendedJSON !== 'function') { + // There's no EJSON serialization function on the object. It's probably an + // object created by a previous version of this library (or another library) + // that's duck-typing objects to look like they were generated by this library). + // Copy the object into this library's version of that type. + var mapper = BSON_TYPE_MAPPINGS[doc._bsontype]; + if (!mapper) { + throw new BSONTypeError('Unrecognized or invalid _bsontype: ' + doc._bsontype); + } + outDoc = mapper(outDoc); + } + // Two BSON types may have nested objects that may need to be serialized too + if (bsontype === 'Code' && outDoc.scope) { + outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options)); + } + else if (bsontype === 'DBRef' && outDoc.oid) { + outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options)); + } + return outDoc.toExtendedJSON(options); + } + else { + throw new BSONError('_bsontype must be a string, but was: ' + typeof bsontype); + } +} +/** + * EJSON parse / stringify API + * @public + */ +// the namespace here is used to emulate `export * as EJSON from '...'` +// which as of now (sept 2020) api-extractor does not support +// eslint-disable-next-line @typescript-eslint/no-namespace +var EJSON; +(function (EJSON) { + /** + * Parse an Extended JSON string, constructing the JavaScript value or object described by that + * string. + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const text = '{ "int32": { "$numberInt": "10" } }'; + * + * // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } } + * console.log(EJSON.parse(text, { relaxed: false })); + * + * // prints { int32: 10 } + * console.log(EJSON.parse(text)); + * ``` + */ + function parse(text, options) { + var finalOptions = Object.assign({}, { relaxed: true, legacy: false }, options); + // relaxed implies not strict + if (typeof finalOptions.relaxed === 'boolean') + finalOptions.strict = !finalOptions.relaxed; + if (typeof finalOptions.strict === 'boolean') + finalOptions.relaxed = !finalOptions.strict; + return JSON.parse(text, function (key, value) { + if (key.indexOf('\x00') !== -1) { + throw new BSONError("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(key))); + } + return deserializeValue(value, finalOptions); + }); + } + EJSON.parse = parse; + /** + * Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer + * function is specified or optionally including only the specified properties if a replacer array + * is specified. + * + * @param value - The value to convert to extended JSON + * @param replacer - A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string + * @param space - A String or Number object that's used to insert white space into the output JSON string for readability purposes. + * @param options - Optional settings + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const Int32 = require('mongodb').Int32; + * const doc = { int32: new Int32(10) }; + * + * // prints '{"int32":{"$numberInt":"10"}}' + * console.log(EJSON.stringify(doc, { relaxed: false })); + * + * // prints '{"int32":10}' + * console.log(EJSON.stringify(doc)); + * ``` + */ + function stringify(value, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + replacer, space, options) { + if (space != null && typeof space === 'object') { + options = space; + space = 0; + } + if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) { + options = replacer; + replacer = undefined; + space = 0; + } + var serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, { + seenObjects: [{ propertyName: '(root)', obj: null }] + }); + var doc = serializeValue(value, serializeOptions); + return JSON.stringify(doc, replacer, space); + } + EJSON.stringify = stringify; + /** + * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object. + * + * @param value - The object to serialize + * @param options - Optional settings passed to the `stringify` function + */ + function serialize(value, options) { + options = options || {}; + return JSON.parse(stringify(value, options)); + } + EJSON.serialize = serialize; + /** + * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types + * + * @param ejson - The Extended JSON object to deserialize + * @param options - Optional settings passed to the parse method + */ + function deserialize(ejson, options) { + options = options || {}; + return parse(JSON.stringify(ejson), options); + } + EJSON.deserialize = deserialize; +})(EJSON || (EJSON = {})); + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** @public */ +var bsonMap; +var bsonGlobal = getGlobal(); +if (bsonGlobal.Map) { + bsonMap = bsonGlobal.Map; +} +else { + // We will return a polyfill + bsonMap = /** @class */ (function () { + function Map(array) { + if (array === void 0) { 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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? [key, _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? _this._values[key].v : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + Object.defineProperty(Map.prototype, "size", { + get: function () { + return this._keys.length; + }, + enumerable: false, + configurable: true + }); + return Map; + }()); +} + +function calculateObjectSize$1(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 (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + object = object.toBSON(); + } + // Calculate size + for (var key in object) { + totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined); + } + } + return totalLength; +} +/** @internal */ +function calculateElement(name, +// eslint-disable-next-line @typescript-eslint/no-explicit-any +value, serializeFunctions, isArray, ignoreUndefined) { + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (isArray === void 0) { isArray = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = false; } + // If we have toBSON defined, override the current object + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + 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 >= JS_INT_MIN && + value <= JS_INT_MAX) { + if (value >= BSON_INT32_MIN$1 && value <= BSON_INT32_MAX$1) { + // 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['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1; + } + else if (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 (ArrayBuffer.isView(value) || + value instanceof ArrayBuffer || + isAnyArrayBuffer(value)) { + return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength); + } + else if (value['_bsontype'] === 'Long' || + value['_bsontype'] === 'Double' || + value['_bsontype'] === 'Timestamp') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + else if (value['_bsontype'] === 'Decimal128') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1); + } + else if (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$1(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['_bsontype'] === 'Binary') { + var binary = value; + // Check what kind of subtype we have + if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + (binary.position + 1 + 4 + 1 + 4)); + } + else { + return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (binary.position + 1 + 4 + 1)); + } + } + else if (value['_bsontype'] === 'Symbol') { + return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + Buffer.byteLength(value.value, 'utf8') + + 4 + + 1 + + 1); + } + else if (value['_bsontype'] === 'DBRef') { + // Set up correct object for serialization + var ordered_values = Object.assign({ + $ref: value.collection, + $id: value.oid + }, value.fields); + // Add db reference if it exists + if (value.db != null) { + ordered_values['$db'] = value.db; + } + return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + calculateObjectSize$1(ordered_values, serializeFunctions, ignoreUndefined)); + } + else if (value instanceof RegExp || isRegExp(value)) { + 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['_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$1(value, serializeFunctions, ignoreUndefined) + + 1); + } + case 'function': + // WTF for 0.4.X where typeof /someregexp/ === 'function' + if (value instanceof RegExp || isRegExp(value) || 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$1(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 FIRST_BIT = 0x80; +var FIRST_TWO_BITS = 0xc0; +var FIRST_THREE_BITS = 0xe0; +var FIRST_FOUR_BITS = 0xf0; +var FIRST_FIVE_BITS = 0xf8; +var TWO_BIT_CHAR = 0xc0; +var THREE_BIT_CHAR = 0xe0; +var FOUR_BIT_CHAR = 0xf0; +var CONTINUING_CHAR = 0x80; +/** + * Determines if the passed in bytes are valid utf8 + * @param bytes - An array of 8-bit bytes. Must be indexable and have length property + * @param start - The index to start validating + * @param end - The index to end validating + */ +function validateUtf8(bytes, start, end) { + var continuation = 0; + for (var i = start; i < end; i += 1) { + var byte = bytes[i]; + if (continuation) { + if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) { + return false; + } + continuation -= 1; + } + else if (byte & FIRST_BIT) { + if ((byte & FIRST_THREE_BITS) === TWO_BIT_CHAR) { + continuation = 1; + } + else if ((byte & FIRST_FOUR_BITS) === THREE_BIT_CHAR) { + continuation = 2; + } + else if ((byte & FIRST_FIVE_BITS) === FOUR_BIT_CHAR) { + continuation = 3; + } + else { + return false; + } + } + } + return !continuation; +} + +// Internal long versions +var JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX); +var JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN); +var functionCache = {}; +function deserialize$1(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); + if (size < 5) { + throw new BSONError("bson size must be >= 5, is ".concat(size)); + } + if (options.allowObjectSmallerThanBufferSize && buffer.length < size) { + throw new BSONError("buffer length ".concat(buffer.length, " must be >= bson size ").concat(size)); + } + if (!options.allowObjectSmallerThanBufferSize && buffer.length !== size) { + throw new BSONError("buffer length ".concat(buffer.length, " must === bson size ").concat(size)); + } + if (size + index > buffer.byteLength) { + throw new BSONError("(bson size ".concat(size, " + options.index ").concat(index, " must be <= buffer length ").concat(buffer.byteLength, ")")); + } + // Illegal end value + if (buffer[index + size - 1] !== 0) { + throw new BSONError("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 allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/; +function deserializeObject(buffer, index, options, isArray) { + if (isArray === void 0) { isArray = false; } + var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; + var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions']; + 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']; + // Ensures default validation option if none given + var validation = options.validation == null ? { utf8: true } : options.validation; + // Shows if global utf-8 validation is enabled or disabled + var globalUTFValidation = true; + // Reflects utf-8 validation setting regardless of global or specific key validation + var validationSetting; + // Set of keys either to enable or disable validation on + var utf8KeysSet = new Set(); + // Check for boolean uniformity and empty validation option + var utf8ValidatedKeys = validation.utf8; + if (typeof utf8ValidatedKeys === 'boolean') { + validationSetting = utf8ValidatedKeys; + } + else { + globalUTFValidation = false; + var utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function (key) { + return utf8ValidatedKeys[key]; + }); + if (utf8ValidationValues.length === 0) { + throw new BSONError('UTF-8 validation setting cannot be empty'); + } + if (typeof utf8ValidationValues[0] !== 'boolean') { + throw new BSONError('Invalid UTF-8 validation option, must specify boolean values'); + } + validationSetting = utf8ValidationValues[0]; + // Ensures boolean uniformity in utf-8 validation (all true or all false) + if (!utf8ValidationValues.every(function (item) { return item === validationSetting; })) { + throw new BSONError('Invalid UTF-8 validation option - keys must be all true or all false'); + } + } + // Add keys to set that will either be validated or not based on validationSetting + if (!globalUTFValidation) { + for (var _i = 0, _a = Object.keys(utf8ValidatedKeys); _i < _a.length; _i++) { + var key = _a[_i]; + utf8KeysSet.add(key); + } + } + // Set the start index + var startIndex = index; + // Validate that we have at least 4 bytes of buffer + if (buffer.length < 5) + throw new BSONError('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 BSONError('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; + var isPossibleDBRef = isArray ? false : null; + // While we have more left data left keep parsing + var dataview = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength); + 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.byteLength) + throw new BSONError('Bad BSON Document: illegal CString'); + // Represents the key + var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i); + // shouldValidateKey is true if the key should be validated, false otherwise + var shouldValidateKey = true; + if (globalUTFValidation || utf8KeysSet.has(name)) { + shouldValidateKey = validationSetting; + } + else { + shouldValidateKey = !validationSetting; + } + if (isPossibleDBRef !== false && name[0] === '$') { + isPossibleDBRef = allowedDBRefKeys.test(name); + } + var value = void 0; + index = i + 1; + if (elementType === 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 BSONError('bad string length in bson'); + } + value = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + index = index + stringSize; + } + else if (elementType === BSON_DATA_OID) { + var oid = Buffer.alloc(12); + buffer.copy(oid, 0, index, index + 12); + value = new ObjectId(oid); + index = index + 12; + } + else if (elementType === BSON_DATA_INT && promoteValues === false) { + value = new Int32(buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24)); + } + else if (elementType === BSON_DATA_INT) { + value = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + } + else if (elementType === BSON_DATA_NUMBER && promoteValues === false) { + value = new Double(dataview.getFloat64(index, true)); + index = index + 8; + } + else if (elementType === BSON_DATA_NUMBER) { + value = dataview.getFloat64(index, true); + index = index + 8; + } + else if (elementType === 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); + value = new Date(new Long(lowBits, highBits).toNumber()); + } + else if (elementType === BSON_DATA_BOOLEAN) { + if (buffer[index] !== 0 && buffer[index] !== 1) + throw new BSONError('illegal boolean type value'); + value = buffer[index++] === 1; + } + else if (elementType === 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 BSONError('bad embedded document length in bson'); + // We have a raw value + if (raw) { + value = buffer.slice(index, index + objectSize); + } + else { + var objectOptions = options; + if (!globalUTFValidation) { + objectOptions = _assign(_assign({}, options), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, objectOptions, false); + } + index = index + objectSize; + } + else if (elementType === BSON_DATA_ARRAY) { + var _index = index; + var 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; + } + if (!globalUTFValidation) { + arrayOptions = _assign(_assign({}, arrayOptions), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, arrayOptions, true); + index = index + objectSize; + if (buffer[index - 1] !== 0) + throw new BSONError('invalid array terminator byte'); + if (index !== stopIndex) + throw new BSONError('corrupted array bson'); + } + else if (elementType === BSON_DATA_UNDEFINED) { + value = undefined; + } + else if (elementType === BSON_DATA_NULL) { + value = null; + } + else if (elementType === BSON_DATA_LONG) { + // Unpack the low and high bits + 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); + var long = new Long(lowBits, highBits); + // Promote the long if possible + if (promoteLongs && promoteValues === true) { + value = + long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) + ? long.toNumber() + : long; + } + else { + value = long; + } + } + else if (elementType === BSON_DATA_DECIMAL128) { + // Buffer to contain the decimal bytes + var bytes = Buffer.alloc(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 + if ('toObject' in decimal128 && typeof decimal128.toObject === 'function') { + value = decimal128.toObject(); + } + else { + value = decimal128; + } + } + else if (elementType === 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 BSONError('Negative binary type element size found'); + // Is the length longer than the document + if (binarySize > buffer.byteLength) + throw new BSONError('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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + if (promoteBuffers && promoteValues) { + value = buffer.slice(index, index + binarySize); + } + else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) { + value = value.toUUID(); + } + } + } + else { + var _buffer = Buffer.alloc(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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + // Copy the data + for (i = 0; i < binarySize; i++) { + _buffer[i] = buffer[index + i]; + } + if (promoteBuffers && promoteValues) { + value = _buffer; + } + else if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) { + value = new Binary(buffer.slice(index, index + binarySize), subType).toUUID(); + } + else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + } + } + // Update the index + index = index + binarySize; + } + else if (elementType === 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 BSONError('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 BSONError('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; + } + } + value = new RegExp(source, optionsArray.join('')); + } + else if (elementType === 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + // Set the object + value = new BSONRegExp(source, regExpOptions); + } + else if (elementType === BSON_DATA_SYMBOL) { + 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 BSONError('bad string length in bson'); + } + var symbol = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + value = promoteValues ? symbol : new BSONSymbol(symbol); + index = index + stringSize; + } + else if (elementType === BSON_DATA_TIMESTAMP) { + 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); + value = new Timestamp(lowBits, highBits); + } + else if (elementType === BSON_DATA_MIN_KEY) { + value = new MinKey(); + } + else if (elementType === BSON_DATA_MAX_KEY) { + value = new MaxKey(); + } + else if (elementType === BSON_DATA_CODE) { + 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 BSONError('bad string length in bson'); + } + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + } + else { + value = new Code(functionString); + } + // Update parse index position + index = index + stringSize; + } + else if (elementType === 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 BSONError('code_w_scope total size shorter minimum expected length'); + } + // Get the code string size + var 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 BSONError('bad string length in bson'); + } + // Javascript function + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // Update parse index position + index = index + stringSize; + // Parse the element + var _index = index; + // Decode the size of the object document + var 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 too short + if (totalSize < 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too short, truncating scope'); + } + // Check if totalSize field is too long + if (totalSize > 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + value.scope = scopeObject; + } + else { + value = new Code(functionString, scopeObject); + } + } + else if (elementType === BSON_DATA_DBPOINTER) { + // Get the code string size + var 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 BSONError('bad string length in bson'); + // Namespace + if (validation != null && validation.utf8) { + if (!validateUtf8(buffer, index, index + stringSize - 1)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + } + var namespace = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + // Read the oid + var oidBuffer = Buffer.alloc(12); + buffer.copy(oidBuffer, 0, index, index + 12); + var oid = new ObjectId(oidBuffer); + // Update the index + index = index + 12; + // Upgrade to DBRef type + value = new DBRef(namespace, oid); + } + else { + throw new BSONError("Detected unknown BSON type ".concat(elementType.toString(16), " for fieldname \"").concat(name, "\"")); + } + if (name === '__proto__') { + Object.defineProperty(object, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + object[name] = value; + } + } + // Check if the deserialization was against a valid array/object + if (size !== index - startIndex) { + if (isArray) + throw new BSONError('corrupt array bson'); + throw new BSONError('corrupt object bson'); + } + // if we did not find "$ref", "$id", "$db", or found an extraneous $key, don't make a DBRef + if (!isPossibleDBRef) + return object; + if (isDBRefLike(object)) { + var copy = Object.assign({}, object); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(object.$ref, object.$id, object.$db, copy); + } + return object; +} +/** + * Ensure eval is isolated, store the result in functionCache. + * + * @internal + */ +function isolateEval(functionString, functionCache, object) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + if (!functionCache) + return new Function(functionString); + // Check for cache hit, eval if missing and return cached function + if (functionCache[functionString] == null) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + functionCache[functionString] = new Function(functionString); + } + // Set the object + return functionCache[functionString].bind(object); +} +function getValidatedString(buffer, start, end, shouldValidateUtf8) { + var value = buffer.toString('utf8', start, end); + // if utf8 validation is on, do the check + if (shouldValidateUtf8) { + for (var i = 0; i < value.length; i++) { + if (value.charCodeAt(i) === 0xfffd) { + if (!validateUtf8(buffer, start, end)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + break; + } + } + } + return value; +} + +var regexp = /\x00/; // eslint-disable-line no-control-regex +var ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']); +/* + * isArray indicates if we are writing to a BSON array (type 0x04) + * which forces the "key" which really an array index as a string to be written as ascii + * This will catch any errors in index as a string generation + */ +function serializeString(buffer, key, value, index, isArray) { + // Encode String type + buffer[index++] = BSON_DATA_STRING; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes + 1; + buffer[index - 1] = 0; + // Write the string + var size = buffer.write(value, index + 4, undefined, 'utf8'); + // Write the size of the string to buffer + buffer[index + 3] = ((size + 1) >> 24) & 0xff; + buffer[index + 2] = ((size + 1) >> 16) & 0xff; + buffer[index + 1] = ((size + 1) >> 8) & 0xff; + buffer[index] = (size + 1) & 0xff; + // Update index + index = index + 4 + size; + // Write zero + buffer[index++] = 0; + return index; +} +var SPACE_FOR_FLOAT64 = new Uint8Array(8); +var DV_FOR_FLOAT64 = new DataView(SPACE_FOR_FLOAT64.buffer, SPACE_FOR_FLOAT64.byteOffset, SPACE_FOR_FLOAT64.byteLength); +function serializeNumber(buffer, key, value, index, isArray) { + // We have an integer value + // TODO(NODE-2529): Add support for big int + if (Number.isInteger(value) && + value >= BSON_INT32_MIN$1 && + value <= BSON_INT32_MAX$1) { + // If the value fits in 32 bits encode as int32 + // Set int type 32 bits or less + buffer[index++] = BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + } + else { + // Encode as double + buffer[index++] = BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + } + return index; +} +function serializeNull(buffer, key, _, index, isArray) { + // Set long type + buffer[index++] = BSON_DATA_NULL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +} +function serializeBoolean(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BOOLEAN; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Encode the boolean value + buffer[index++] = value ? 1 : 0; + return index; +} +function serializeDate(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_DATE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var dateInMilis = Long.fromNumber(value.getTime()); + var lowBits = dateInMilis.getLowBits(); + var highBits = dateInMilis.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +} +function serializeRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + if (value.source && value.source.match(regexp) != null) { + throw Error('value ' + value.source + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.source, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the parameters + if (value.ignoreCase) + buffer[index++] = 0x69; // i + if (value.global) + buffer[index++] = 0x73; // s + if (value.multiline) + buffer[index++] = 0x6d; // m + // Add ending zero + buffer[index++] = 0x00; + return index; +} +function serializeBSONRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Check the pattern for 0 bytes + if (value.pattern.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('pattern ' + value.pattern + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.pattern, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the options + index = index + buffer.write(value.options.split('').sort().join(''), index, undefined, 'utf8'); + // Add ending zero + buffer[index++] = 0x00; + return index; +} +function serializeMinMax(buffer, key, value, index, isArray) { + // Write the type of either min or max key + if (value === null) { + buffer[index++] = BSON_DATA_NULL; + } + else if (value._bsontype === 'MinKey') { + buffer[index++] = BSON_DATA_MIN_KEY; + } + else { + buffer[index++] = BSON_DATA_MAX_KEY; + } + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +} +function serializeObjectId(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_OID; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the objectId into the shared buffer + if (typeof value.id === 'string') { + buffer.write(value.id, index, undefined, 'binary'); + } + else if (isUint8Array(value.id)) { + // Use the standard JS methods here because buffer.copy() is buggy with the + // browser polyfill + buffer.set(value.id.subarray(0, 12), index); + } + else { + throw new BSONTypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId'); + } + // Adjust index + return index + 12; +} +function serializeBuffer(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Get size of the buffer (current write point) + var size = value.length; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the default subtype + buffer[index++] = BSON_BINARY_SUBTYPE_DEFAULT; + // Copy the content form the binary field to the buffer + buffer.set(ensureBuffer(value), index); + // Adjust the index + index = index + size; + return index; +} +function serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (path === void 0) { path = []; } + for (var i = 0; i < path.length; i++) { + if (path[i] === value) + throw new BSONError('cyclic dependency detected'); + } + // Push value to stack + path.push(value); + // Write the type + buffer[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var endIndex = serializeInto(buffer, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path); + // Pop stack + path.pop(); + return endIndex; +} +function serializeDecimal128(buffer, key, value, index, isArray) { + buffer[index++] = BSON_DATA_DECIMAL128; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the data from the value + // Prefer the standard JS methods because their typechecking is not buggy, + // unlike the `buffer` polyfill's. + buffer.set(value.bytes.subarray(0, 16), index); + return index + 16; +} +function serializeLong(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = + value._bsontype === 'Long' ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var lowBits = value.getLowBits(); + var highBits = value.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +} +function serializeInt32(buffer, key, value, index, isArray) { + value = value.valueOf(); + // Set int type 32 bits or less + buffer[index++] = BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + return index; +} +function serializeDouble(buffer, key, value, index, isArray) { + // Encode as double + buffer[index++] = BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value.value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + return index; +} +function serializeFunction(buffer, key, value, index, _checkKeys, _depth, isArray) { + buffer[index++] = BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = normalizedFunctionString(value); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + return index; +} +function serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (value.scope && typeof value.scope === 'object') { + // Write the type + buffer[index++] = BSON_DATA_CODE_W_SCOPE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Starting index + var startIndex = index; + // Serialize the function + // Get the function string + var functionString = typeof value.code === 'string' ? value.code : value.code.toString(); + // Index adjustment + index = index + 4; + // Write string into buffer + var codeSize = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = codeSize & 0xff; + buffer[index + 1] = (codeSize >> 8) & 0xff; + buffer[index + 2] = (codeSize >> 16) & 0xff; + buffer[index + 3] = (codeSize >> 24) & 0xff; + // Write end 0 + buffer[index + 4 + codeSize - 1] = 0; + // Write the + index = index + codeSize + 4; + // + // Serialize the scope value + var endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined); + index = endIndex - 1; + // Writ the total + var totalSize = endIndex - startIndex; + // Write the total size of the object + buffer[startIndex++] = totalSize & 0xff; + buffer[startIndex++] = (totalSize >> 8) & 0xff; + buffer[startIndex++] = (totalSize >> 16) & 0xff; + buffer[startIndex++] = (totalSize >> 24) & 0xff; + // Write trailing zero + buffer[index++] = 0; + } + else { + buffer[index++] = BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = value.code.toString(); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + } + return index; +} +function serializeBinary(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Extract the buffer + var data = value.value(true); + // Calculate size + var size = value.position; + // Add the deprecated 02 type 4 bytes of size to total + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) + size = size + 4; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the subtype to the buffer + buffer[index++] = value.sub_type; + // If we have binary type 2 the 4 first bytes are the size + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + size = size - 4; + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + } + // Write the data to the object + buffer.set(data, index); + // Adjust the index + index = index + value.position; + return index; +} +function serializeSymbol(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON_DATA_SYMBOL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the string + var size = buffer.write(value.value, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0x00; + return index; +} +function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, isArray) { + // Write the type + buffer[index++] = BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var startIndex = index; + var output = { + $ref: value.collection || value.namespace, + $id: value.oid + }; + if (value.db != null) { + output.$db = value.db; + } + output = Object.assign(output, value.fields); + var endIndex = serializeInto(buffer, output, false, index, depth + 1, serializeFunctions); + // Calculate object size + var size = endIndex - startIndex; + // Write the size + buffer[startIndex++] = size & 0xff; + buffer[startIndex++] = (size >> 8) & 0xff; + buffer[startIndex++] = (size >> 16) & 0xff; + buffer[startIndex++] = (size >> 24) & 0xff; + // Set index + return endIndex; +} +function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (startingIndex === void 0) { startingIndex = 0; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (path === void 0) { path = []; } + startingIndex = startingIndex || 0; + path = path || []; + // Push the object to the path + path.push(object); + // Start place to serialize into + var index = startingIndex + 4; + // Special case isArray + if (Array.isArray(object)) { + // Get object keys + for (var i = 0; i < object.length; i++) { + var key = "".concat(i); + var value = object[i]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + if (typeof value === 'string') { + index = serializeString(buffer, key, value, index, true); + } + else if (typeof value === 'number') { + index = serializeNumber(buffer, key, value, index, true); + } + else if (typeof value === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (typeof value === 'boolean') { + index = serializeBoolean(buffer, key, value, index, true); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index, true); + } + else if (value === undefined) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index, true); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index, true); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index, true); + } + else if (typeof value === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true, path); + } + else if (typeof value === 'object' && + isBSONType(value) && + value._bsontype === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index, true); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, true); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, true); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index, true); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else if (object instanceof bsonMap || isMap(object)) { + var iterator = object.entries(); + var done = false; + while (!done) { + // Unpack the next entry + var entry = iterator.next(); + done = !!entry.done; + // Are we done, then skip and terminate + if (done) + continue; + // Get the entry values + var key = entry.value[0]; + var value = entry.value[1]; + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint' || isBigInt64Array(value) || isBigUInt64Array(value)) { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === null || (value === undefined && ignoreUndefined === false)) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else { + if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + // Provided a custom serialization method + object = object.toBSON(); + if (object != null && typeof object !== 'object') { + throw new BSONTypeError('toBSON function did not return an object'); + } + } + // Iterate over all the keys + for (var key in object) { + var value = object[key]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === undefined) { + if (ignoreUndefined === false) + index = serializeNull(buffer, key, value, index); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + // Remove the path + path.pop(); + // Final padding byte for object + buffer[index++] = 0x00; + // Final size + var size = index - startingIndex; + // Write the size of the object + buffer[startingIndex++] = size & 0xff; + buffer[startingIndex++] = (size >> 8) & 0xff; + buffer[startingIndex++] = (size >> 16) & 0xff; + buffer[startingIndex++] = (size >> 24) & 0xff; + return index; +} + +/** @internal */ +// Default Max Size +var MAXSIZE = 1024 * 1024 * 17; +// Current Internal Temporary Serialization Buffer +var buffer = Buffer.alloc(MAXSIZE); +/** + * Sets the size of the internal serialization buffer. + * + * @param size - The desired size for the internal serialization buffer + * @public + */ +function setInternalBufferSize(size) { + // Resize the internal serialization buffer if needed + if (buffer.length < size) { + buffer = Buffer.alloc(size); + } +} +/** + * Serialize a Javascript object. + * + * @param object - the Javascript object to serialize. + * @returns Buffer object containing the serialized object. + * @public + */ +function serialize(object, options) { + if (options === void 0) { 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 = Buffer.alloc(minInternalBufferSize); + } + // Attempt to serialize + var serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []); + // Create the final buffer + var finishedBuffer = Buffer.alloc(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 - the Javascript object to serialize. + * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object. + * @returns the index pointing to the last written byte in the buffer. + * @public + */ +function serializeWithBufferAndIndex(object, finalBuffer, options) { + if (options === void 0) { 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 = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined); + buffer.copy(finalBuffer, startIndex, 0, serializationIndex); + // Return the index + return startIndex + serializationIndex - 1; +} +/** + * Deserialize data as BSON. + * + * @param buffer - the buffer containing the serialized set of BSON documents. + * @returns returns the deserialized Javascript Object. + * @public + */ +function deserialize(buffer, options) { + if (options === void 0) { options = {}; } + return deserialize$1(buffer instanceof Buffer ? buffer : ensureBuffer(buffer), options); +} +/** + * Calculate the bson size for a passed in Javascript object. + * + * @param object - the Javascript object to calculate the BSON byte size for + * @returns size of BSON object in bytes + * @public + */ +function calculateObjectSize(object, options) { + if (options === void 0) { options = {}; } + options = options || {}; + var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + return calculateObjectSize$1(object, serializeFunctions, ignoreUndefined); +} +/** + * Deserialize stream data as BSON documents. + * + * @param data - the buffer containing the serialized set of BSON documents. + * @param startIndex - the start index in the data Buffer where the deserialization is to start. + * @param numberOfDocuments - number of documents to deserialize. + * @param documents - an array where to store the deserialized documents. + * @param docStartIndex - the index in the documents array from where to start inserting documents. + * @param options - additional options used for the deserialization. + * @returns next index in the buffer after deserialization **x** numbers of documents. + * @public + */ +function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) { + var internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options); + var bufferData = ensureBuffer(data); + var index = startIndex; + // Loop over all documents + for (var i = 0; i < numberOfDocuments; i++) { + // Find size of the document + var size = bufferData[index] | + (bufferData[index + 1] << 8) | + (bufferData[index + 2] << 16) | + (bufferData[index + 3] << 24); + // Update options with index + internalOptions.index = index; + // Parse the document at this point + documents[docStartIndex + i] = deserialize$1(bufferData, internalOptions); + // Adjust index by the document size + index = index + size; + } + // Return object containing end index of parsing and list of documents + return index; +} +/** + * BSON default export + * @deprecated Please use named exports + * @privateRemarks + * We want to someday deprecate the default export, + * so none of the new TS types are being exported on the default + * @public + */ +var BSON = { + Binary: Binary, + Code: Code, + DBRef: DBRef, + Decimal128: Decimal128, + Double: Double, + Int32: Int32, + Long: Long, + UUID: UUID, + Map: bsonMap, + MaxKey: MaxKey, + MinKey: MinKey, + ObjectId: ObjectId, + ObjectID: ObjectId, + BSONRegExp: BSONRegExp, + BSONSymbol: BSONSymbol, + Timestamp: Timestamp, + EJSON: EJSON, + setInternalBufferSize: setInternalBufferSize, + serialize: serialize, + serializeWithBufferAndIndex: serializeWithBufferAndIndex, + deserialize: deserialize, + calculateObjectSize: calculateObjectSize, + deserializeStream: deserializeStream, + BSONError: BSONError, + BSONTypeError: BSONTypeError +}; + +export default BSON; +export { BSONError, BSONRegExp, BSONSymbol, BSONTypeError, BSON_BINARY_SUBTYPE_BYTE_ARRAY, BSON_BINARY_SUBTYPE_COLUMN, BSON_BINARY_SUBTYPE_DEFAULT, BSON_BINARY_SUBTYPE_ENCRYPTED, BSON_BINARY_SUBTYPE_FUNCTION, BSON_BINARY_SUBTYPE_MD5, BSON_BINARY_SUBTYPE_USER_DEFINED, BSON_BINARY_SUBTYPE_UUID, BSON_BINARY_SUBTYPE_UUID_NEW, BSON_DATA_ARRAY, BSON_DATA_BINARY, BSON_DATA_BOOLEAN, BSON_DATA_CODE, BSON_DATA_CODE_W_SCOPE, BSON_DATA_DATE, BSON_DATA_DBPOINTER, BSON_DATA_DECIMAL128, BSON_DATA_INT, BSON_DATA_LONG, BSON_DATA_MAX_KEY, BSON_DATA_MIN_KEY, BSON_DATA_NULL, BSON_DATA_NUMBER, BSON_DATA_OBJECT, BSON_DATA_OID, BSON_DATA_REGEXP, BSON_DATA_STRING, BSON_DATA_SYMBOL, BSON_DATA_TIMESTAMP, BSON_DATA_UNDEFINED, BSON_INT32_MAX$1 as BSON_INT32_MAX, BSON_INT32_MIN$1 as BSON_INT32_MIN, BSON_INT64_MAX$1 as BSON_INT64_MAX, BSON_INT64_MIN$1 as BSON_INT64_MIN, Binary, Code, DBRef, Decimal128, Double, EJSON, Int32, Long, LongWithoutOverridesClass, bsonMap as Map, MaxKey, MinKey, ObjectId as ObjectID, ObjectId, Timestamp, UUID, calculateObjectSize, deserialize, deserializeStream, serialize, serializeWithBufferAndIndex, setInternalBufferSize }; +//# sourceMappingURL=bson.esm.js.map diff --git a/node_modules/bson/dist/bson.esm.js.map b/node_modules/bson/dist/bson.esm.js.map new file mode 100644 index 0000000..c1919da --- /dev/null +++ b/node_modules/bson/dist/bson.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bson.esm.js","sources":["../node_modules/tslib/tslib.es6.js","../src/error.ts","../src/utils/global.ts","../src/parser/utils.ts","../src/ensure_buffer.ts","../src/uuid_utils.ts","../src/constants.ts","../src/binary.ts","../src/code.ts","../src/db_ref.ts","../src/long.ts","../src/decimal128.ts","../src/double.ts","../src/int_32.ts","../src/max_key.ts","../src/min_key.ts","../src/objectid.ts","../src/regexp.ts","../src/symbol.ts","../src/timestamp.ts","../src/extended_json.ts","../src/map.ts","../src/parser/calculate_size.ts","../src/validate_utf8.ts","../src/parser/deserializer.ts","../src/parser/serializer.ts","../src/bson.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__extends","__","constructor","prototype","create","__assign","assign","t","s","i","n","arguments","length","call","apply","BSON_INT32_MAX","BSON_INT32_MIN","BSON_INT64_MAX","BSON_INT64_MIN","calculateObjectSize","constants.JS_INT_MIN","constants.JS_INT_MAX","constants.BSON_INT32_MIN","constants.BSON_INT32_MAX","deserialize","constants.BSON_DATA_STRING","constants.BSON_DATA_OID","constants.BSON_DATA_INT","constants.BSON_DATA_NUMBER","constants.BSON_DATA_DATE","constants.BSON_DATA_BOOLEAN","constants.BSON_DATA_OBJECT","constants.BSON_DATA_ARRAY","constants.BSON_DATA_UNDEFINED","constants.BSON_DATA_NULL","constants.BSON_DATA_LONG","constants.BSON_DATA_DECIMAL128","constants.BSON_DATA_BINARY","constants.BSON_BINARY_SUBTYPE_UUID_NEW","constants.BSON_DATA_REGEXP","constants.BSON_DATA_SYMBOL","constants.BSON_DATA_TIMESTAMP","constants.BSON_DATA_MIN_KEY","constants.BSON_DATA_MAX_KEY","constants.BSON_DATA_CODE","constants.BSON_DATA_CODE_W_SCOPE","constants.BSON_DATA_DBPOINTER","constants.BSON_BINARY_SUBTYPE_DEFAULT","Map","internalSerialize","internalDeserialize","internalCalculateObjectSize"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAEA,IAAIA,cAAa,GAAG,uBAASC,CAAT,EAAYC,CAAZ,EAAe;AAC/BF,EAAAA,cAAa,GAAGG,MAAM,CAACC,cAAP,IACX;AAAEC,IAAAA,SAAS,EAAE;AAAb,eAA6BC,KAA7B,IAAsC,UAAUL,CAAV,EAAaC,CAAb,EA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IAAI,GACR,UAAU,CAAC,KAAK,CAAC;aAChB,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;aAC3B,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;aAC5B,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;;QAEhC,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC;;QAE9B,SAAS,CAAC,aAAa,GAAG,CAAC,CAAC,GAAGD,aAAmB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;;QAEhF,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;KACtB;;IAGD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;IAQM,IAAI,GAAG;IACX,MAAM,QAAA;IACN,IAAI,MAAA;IACJ,KAAK,OAAA;IACL,UAAU,YAAA;IACV,MAAM,QAAA;IACN,KAAK,OAAA;IACL,IAAI,MAAA;IACJ,IAAI,MAAA;IACJ,GAAG,SAAA;IACH,MAAM,QAAA;IACN,MAAM,QAAA;IACN,QAAQ,UAAA;IACR,QAAQ,EAAE,QAAQ;IAClB,UAAU,YAAA;IACV,UAAU,YAAA;IACV,SAAS,WAAA;IACT,KAAK,OAAA;IACL,qBAAqB,uBAAA;IACrB,SAAS,WAAA;IACT,2BAA2B,6BAAA;IAC3B,WAAW,aAAA;IACX,mBAAmB,qBAAA;IACnB,iBAAiB,mBAAA;IACjB,SAAS,WAAA;IACT,aAAa,eAAA;;;;;;"} \ No newline at end of file diff --git a/node_modules/bson/etc/prepare.js b/node_modules/bson/etc/prepare.js new file mode 100755 index 0000000..91e6f3a --- /dev/null +++ b/node_modules/bson/etc/prepare.js @@ -0,0 +1,19 @@ +#! /usr/bin/env node +var cp = require('child_process'); +var fs = require('fs'); + +var nodeMajorVersion = +process.version.match(/^v(\d+)\.\d+/)[1]; + +if (fs.existsSync('src') && nodeMajorVersion >= 10) { + cp.spawnSync('npm', ['run', 'build'], { stdio: 'inherit', shell: true }); +} else { + if (!fs.existsSync('lib')) { + console.warn('BSON: No compiled javascript present, the library is not installed correctly.'); + if (nodeMajorVersion < 10) { + console.warn( + 'This library can only be compiled in nodejs version 10 or later, currently running: ' + + nodeMajorVersion + ); + } + } +} diff --git a/node_modules/bson/lib/binary.js b/node_modules/bson/lib/binary.js new file mode 100644 index 0000000..39e1342 --- /dev/null +++ b/node_modules/bson/lib/binary.js @@ -0,0 +1,426 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UUID = exports.Binary = void 0; +var buffer_1 = require("buffer"); +var ensure_buffer_1 = require("./ensure_buffer"); +var uuid_utils_1 = require("./uuid_utils"); +var utils_1 = require("./parser/utils"); +var error_1 = require("./error"); +var constants_1 = require("./constants"); +/** + * A class representation of the BSON Binary type. + * @public + * @category BSONType + */ +var Binary = /** @class */ (function () { + /** + * Create a new Binary instance. + * + * This constructor can accept a string as its first argument. In this case, + * this string will be encoded using ISO-8859-1, **not** using UTF-8. + * This is almost certainly not what you want. Use `new Binary(Buffer.from(string))` + * instead to convert the string to a Buffer using UTF-8 first. + * + * @param buffer - a buffer object containing the binary data. + * @param subType - the option binary type. + */ + function Binary(buffer, subType) { + if (!(this instanceof Binary)) + return new Binary(buffer, subType); + if (!(buffer == null) && + !(typeof buffer === 'string') && + !ArrayBuffer.isView(buffer) && + !(buffer instanceof ArrayBuffer) && + !Array.isArray(buffer)) { + throw new error_1.BSONTypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array'); + } + this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT; + if (buffer == null) { + // create an empty binary buffer + this.buffer = buffer_1.Buffer.alloc(Binary.BUFFER_SIZE); + this.position = 0; + } + else { + if (typeof buffer === 'string') { + // string + this.buffer = buffer_1.Buffer.from(buffer, 'binary'); + } + else if (Array.isArray(buffer)) { + // number[] + this.buffer = buffer_1.Buffer.from(buffer); + } + else { + // Buffer | TypedArray | ArrayBuffer + this.buffer = (0, ensure_buffer_1.ensureBuffer)(buffer); + } + this.position = this.buffer.byteLength; + } + } + /** + * Updates this binary with byte_value. + * + * @param byteValue - a single byte we wish to write. + */ + Binary.prototype.put = function (byteValue) { + // If it's a string and a has more than one character throw an error + if (typeof byteValue === 'string' && byteValue.length !== 1) { + throw new error_1.BSONTypeError('only accepts single character String'); + } + else if (typeof byteValue !== 'number' && byteValue.length !== 1) + throw new error_1.BSONTypeError('only accepts single character Uint8Array or Array'); + // Decode the byte value once + var decodedByte; + if (typeof byteValue === 'string') { + decodedByte = byteValue.charCodeAt(0); + } + else if (typeof byteValue === 'number') { + decodedByte = byteValue; + } + else { + decodedByte = byteValue[0]; + } + if (decodedByte < 0 || decodedByte > 255) { + throw new error_1.BSONTypeError('only accepts number in a valid unsigned byte range 0-255'); + } + if (this.buffer.length > this.position) { + this.buffer[this.position++] = decodedByte; + } + else { + var buffer = buffer_1.Buffer.alloc(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++] = decodedByte; + } + }; + /** + * Writes a buffer or string to the binary. + * + * @param sequence - a string or buffer to be written to the Binary BSON object. + * @param offset - specify the binary of where to write the content. + */ + Binary.prototype.write = function (sequence, offset) { + offset = typeof offset === 'number' ? offset : this.position; + // If the buffer is to small let's extend the buffer + if (this.buffer.length < offset + sequence.length) { + var buffer = buffer_1.Buffer.alloc(this.buffer.length + sequence.length); + this.buffer.copy(buffer, 0, 0, this.buffer.length); + // Assign the new buffer + this.buffer = buffer; + } + if (ArrayBuffer.isView(sequence)) { + this.buffer.set((0, ensure_buffer_1.ensureBuffer)(sequence), offset); + this.position = + offset + sequence.byteLength > this.position ? offset + sequence.length : this.position; + } + else if (typeof sequence === 'string') { + this.buffer.write(sequence, offset, sequence.length, 'binary'); + this.position = + offset + sequence.length > this.position ? offset + sequence.length : this.position; + } + }; + /** + * Reads **length** bytes starting at **position**. + * + * @param position - read from the given position in the Binary. + * @param length - the number of bytes to read. + */ + Binary.prototype.read = function (position, length) { + length = length && length > 0 ? length : this.position; + // Let's return the data based on the type we have + return this.buffer.slice(position, position + length); + }; + /** + * Returns the value of this binary as a string. + * @param asRaw - Will skip converting to a string + * @remarks + * This is handy when calling this function conditionally for some key value pairs and not others + */ + Binary.prototype.value = function (asRaw) { + asRaw = !!asRaw; + // Optimize to serialize for the situation where the data == size of buffer + if (asRaw && this.buffer.length === this.position) { + return this.buffer; + } + // If it's a node.js buffer object + if (asRaw) { + return this.buffer.slice(0, this.position); + } + return this.buffer.toString('binary', 0, this.position); + }; + /** the length of the binary sequence */ + Binary.prototype.length = function () { + return this.position; + }; + Binary.prototype.toJSON = function () { + return this.buffer.toString('base64'); + }; + Binary.prototype.toString = function (format) { + return this.buffer.toString(format); + }; + /** @internal */ + Binary.prototype.toExtendedJSON = function (options) { + options = options || {}; + var base64String = this.buffer.toString('base64'); + var subType = Number(this.sub_type).toString(16); + if (options.legacy) { + return { + $binary: base64String, + $type: subType.length === 1 ? '0' + subType : subType + }; + } + return { + $binary: { + base64: base64String, + subType: subType.length === 1 ? '0' + subType : subType + } + }; + }; + Binary.prototype.toUUID = function () { + if (this.sub_type === Binary.SUBTYPE_UUID) { + return new UUID(this.buffer.slice(0, this.position)); + } + throw new error_1.BSONError("Binary sub_type \"".concat(this.sub_type, "\" is not supported for converting to UUID. Only \"").concat(Binary.SUBTYPE_UUID, "\" is currently supported.")); + }; + /** @internal */ + Binary.fromExtendedJSON = function (doc, options) { + options = options || {}; + var data; + var type; + if ('$binary' in doc) { + if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) { + type = doc.$type ? parseInt(doc.$type, 16) : 0; + data = buffer_1.Buffer.from(doc.$binary, 'base64'); + } + else { + if (typeof doc.$binary !== 'string') { + type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0; + data = buffer_1.Buffer.from(doc.$binary.base64, 'base64'); + } + } + } + else if ('$uuid' in doc) { + type = 4; + data = (0, uuid_utils_1.uuidHexStringToBuffer)(doc.$uuid); + } + if (!data) { + throw new error_1.BSONTypeError("Unexpected Binary Extended JSON format ".concat(JSON.stringify(doc))); + } + return type === constants_1.BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type); + }; + /** @internal */ + Binary.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Binary.prototype.inspect = function () { + var asBuffer = this.value(true); + return "new Binary(Buffer.from(\"".concat(asBuffer.toString('hex'), "\", \"hex\"), ").concat(this.sub_type, ")"); + }; + /** + * Binary default subtype + * @internal + */ + Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** Initial buffer default size */ + Binary.BUFFER_SIZE = 256; + /** Default BSON type */ + Binary.SUBTYPE_DEFAULT = 0; + /** Function BSON type */ + Binary.SUBTYPE_FUNCTION = 1; + /** Byte Array BSON type */ + Binary.SUBTYPE_BYTE_ARRAY = 2; + /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */ + Binary.SUBTYPE_UUID_OLD = 3; + /** UUID BSON type */ + Binary.SUBTYPE_UUID = 4; + /** MD5 BSON type */ + Binary.SUBTYPE_MD5 = 5; + /** Encrypted BSON type */ + Binary.SUBTYPE_ENCRYPTED = 6; + /** Column BSON type */ + Binary.SUBTYPE_COLUMN = 7; + /** User BSON type */ + Binary.SUBTYPE_USER_DEFINED = 128; + return Binary; +}()); +exports.Binary = Binary; +Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' }); +var UUID_BYTE_LENGTH = 16; +/** + * A class representation of the BSON UUID type. + * @public + */ +var UUID = /** @class */ (function (_super) { + __extends(UUID, _super); + /** + * Create an UUID type + * + * @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer. + */ + function UUID(input) { + var _this = this; + var bytes; + var hexStr; + if (input == null) { + bytes = UUID.generate(); + } + else if (input instanceof UUID) { + bytes = buffer_1.Buffer.from(input.buffer); + hexStr = input.__id; + } + else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) { + bytes = (0, ensure_buffer_1.ensureBuffer)(input); + } + else if (typeof input === 'string') { + bytes = (0, uuid_utils_1.uuidHexStringToBuffer)(input); + } + else { + throw new error_1.BSONTypeError('Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'); + } + _this = _super.call(this, bytes, constants_1.BSON_BINARY_SUBTYPE_UUID_NEW) || this; + _this.__id = hexStr; + return _this; + } + Object.defineProperty(UUID.prototype, "id", { + /** + * The UUID bytes + * @readonly + */ + get: function () { + return this.buffer; + }, + set: function (value) { + this.buffer = value; + if (UUID.cacheHexString) { + this.__id = (0, uuid_utils_1.bufferToUuidHexString)(value); + } + }, + enumerable: false, + configurable: true + }); + /** + * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated) + * @param includeDashes - should the string exclude dash-separators. + * */ + UUID.prototype.toHexString = function (includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + if (UUID.cacheHexString && this.__id) { + return this.__id; + } + var uuidHexString = (0, uuid_utils_1.bufferToUuidHexString)(this.id, includeDashes); + if (UUID.cacheHexString) { + this.__id = uuidHexString; + } + return uuidHexString; + }; + /** + * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified. + */ + UUID.prototype.toString = function (encoding) { + return encoding ? this.id.toString(encoding) : this.toHexString(); + }; + /** + * Converts the id into its JSON string representation. + * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + */ + UUID.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this UUID with `otherID`. + * + * @param otherId - UUID instance to compare against. + */ + UUID.prototype.equals = function (otherId) { + if (!otherId) { + return false; + } + if (otherId instanceof UUID) { + return otherId.id.equals(this.id); + } + try { + return new UUID(otherId).id.equals(this.id); + } + catch (_a) { + return false; + } + }; + /** + * Creates a Binary instance from the current UUID. + */ + UUID.prototype.toBinary = function () { + return new Binary(this.id, Binary.SUBTYPE_UUID); + }; + /** + * Generates a populated buffer containing a v4 uuid + */ + UUID.generate = function () { + var bytes = (0, utils_1.randomBytes)(UUID_BYTE_LENGTH); + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + // Kindly borrowed from https://github.com/uuidjs/uuid/blob/master/src/v4.js + bytes[6] = (bytes[6] & 0x0f) | 0x40; + bytes[8] = (bytes[8] & 0x3f) | 0x80; + return buffer_1.Buffer.from(bytes); + }; + /** + * Checks if a value is a valid bson UUID + * @param input - UUID, string or Buffer to validate. + */ + UUID.isValid = function (input) { + if (!input) { + return false; + } + if (input instanceof UUID) { + return true; + } + if (typeof input === 'string') { + return (0, uuid_utils_1.uuidValidateString)(input); + } + if ((0, utils_1.isUint8Array)(input)) { + // check for length & uuid version (https://tools.ietf.org/html/rfc4122#section-4.1.3) + if (input.length !== UUID_BYTE_LENGTH) { + return false; + } + return (input[6] & 0xf0) === 0x40 && (input[8] & 0x80) === 0x80; + } + return false; + }; + /** + * Creates an UUID from a hex string representation of an UUID. + * @param hexString - 32 or 36 character hex string (dashes excluded/included). + */ + UUID.createFromHexString = function (hexString) { + var buffer = (0, uuid_utils_1.uuidHexStringToBuffer)(hexString); + return new UUID(buffer); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 36 character hex string representation. + * @internal + */ + UUID.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + UUID.prototype.inspect = function () { + return "new UUID(\"".concat(this.toHexString(), "\")"); + }; + return UUID; +}(Binary)); +exports.UUID = UUID; +//# sourceMappingURL=binary.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/binary.js.map b/node_modules/bson/lib/binary.js.map new file mode 100644 index 0000000..412903a --- /dev/null +++ b/node_modules/bson/lib/binary.js.map @@ -0,0 +1 @@ +{"version":3,"file":"binary.js","sourceRoot":"","sources":["../src/binary.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAChC,iDAA+C;AAC/C,2CAAgG;AAChG,wCAA2D;AAE3D,iCAAmD;AACnD,yCAA2D;AAmB3D;;;;GAIG;AACH;IAkCE;;;;;;;;;;OAUG;IACH,gBAAY,MAAgC,EAAE,OAAgB;QAC5D,IAAI,CAAC,CAAC,IAAI,YAAY,MAAM,CAAC;YAAE,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAElE,IACE,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC;YACjB,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC;YAC7B,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;YAC3B,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC;YAChC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACtB;YACA,MAAM,IAAI,qBAAa,CACrB,kFAAkF,CACnF,CAAC;SACH;QAED,IAAI,CAAC,QAAQ,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,MAAM,CAAC,2BAA2B,CAAC;QAE9D,IAAI,MAAM,IAAI,IAAI,EAAE;YAClB,gCAAgC;YAChC,IAAI,CAAC,MAAM,GAAG,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC/C,IAAI,CAAC,QAAQ,GAAG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M,GA8K/B;AA9KY,oBAAI"} \ No newline at end of file diff --git a/node_modules/bson/lib/bson.js b/node_modules/bson/lib/bson.js new file mode 100644 index 0000000..265d4a0 --- /dev/null +++ b/node_modules/bson/lib/bson.js @@ -0,0 +1,251 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BSONRegExp = exports.MaxKey = exports.MinKey = exports.Int32 = exports.Double = exports.Timestamp = exports.Long = exports.UUID = exports.ObjectId = exports.Binary = exports.DBRef = exports.BSONSymbol = exports.Map = exports.Code = exports.LongWithoutOverridesClass = exports.EJSON = exports.BSON_INT64_MIN = exports.BSON_INT64_MAX = exports.BSON_INT32_MIN = exports.BSON_INT32_MAX = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_STRING = exports.BSON_DATA_REGEXP = exports.BSON_DATA_OID = exports.BSON_DATA_OBJECT = exports.BSON_DATA_NUMBER = exports.BSON_DATA_NULL = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_LONG = exports.BSON_DATA_INT = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_DATE = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_CODE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_BINARY_SUBTYPE_COLUMN = exports.BSON_BINARY_SUBTYPE_ENCRYPTED = exports.BSON_BINARY_SUBTYPE_UUID_NEW = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = void 0; +exports.deserializeStream = exports.calculateObjectSize = exports.deserialize = exports.serializeWithBufferAndIndex = exports.serialize = exports.setInternalBufferSize = exports.BSONTypeError = exports.BSONError = exports.ObjectID = exports.Decimal128 = void 0; +var buffer_1 = require("buffer"); +var binary_1 = require("./binary"); +Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return binary_1.Binary; } }); +Object.defineProperty(exports, "UUID", { enumerable: true, get: function () { return binary_1.UUID; } }); +var code_1 = require("./code"); +Object.defineProperty(exports, "Code", { enumerable: true, get: function () { return code_1.Code; } }); +var db_ref_1 = require("./db_ref"); +Object.defineProperty(exports, "DBRef", { enumerable: true, get: function () { return db_ref_1.DBRef; } }); +var decimal128_1 = require("./decimal128"); +Object.defineProperty(exports, "Decimal128", { enumerable: true, get: function () { return decimal128_1.Decimal128; } }); +var double_1 = require("./double"); +Object.defineProperty(exports, "Double", { enumerable: true, get: function () { return double_1.Double; } }); +var ensure_buffer_1 = require("./ensure_buffer"); +var extended_json_1 = require("./extended_json"); +var int_32_1 = require("./int_32"); +Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { return int_32_1.Int32; } }); +var long_1 = require("./long"); +Object.defineProperty(exports, "Long", { enumerable: true, get: function () { return long_1.Long; } }); +var map_1 = require("./map"); +Object.defineProperty(exports, "Map", { enumerable: true, get: function () { return map_1.Map; } }); +var max_key_1 = require("./max_key"); +Object.defineProperty(exports, "MaxKey", { enumerable: true, get: function () { return max_key_1.MaxKey; } }); +var min_key_1 = require("./min_key"); +Object.defineProperty(exports, "MinKey", { enumerable: true, get: function () { return min_key_1.MinKey; } }); +var objectid_1 = require("./objectid"); +Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return objectid_1.ObjectId; } }); +Object.defineProperty(exports, "ObjectID", { enumerable: true, get: function () { return objectid_1.ObjectId; } }); +var error_1 = require("./error"); +var calculate_size_1 = require("./parser/calculate_size"); +// Parts of the parser +var deserializer_1 = require("./parser/deserializer"); +var serializer_1 = require("./parser/serializer"); +var regexp_1 = require("./regexp"); +Object.defineProperty(exports, "BSONRegExp", { enumerable: true, get: function () { return regexp_1.BSONRegExp; } }); +var symbol_1 = require("./symbol"); +Object.defineProperty(exports, "BSONSymbol", { enumerable: true, get: function () { return symbol_1.BSONSymbol; } }); +var timestamp_1 = require("./timestamp"); +Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return timestamp_1.Timestamp; } }); +var constants_1 = require("./constants"); +Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_BYTE_ARRAY", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_BYTE_ARRAY; } }); +Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_DEFAULT", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_DEFAULT; } }); +Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_FUNCTION", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_FUNCTION; } }); +Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_MD5", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_MD5; } }); +Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_USER_DEFINED", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_USER_DEFINED; } }); +Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_UUID; } }); +Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID_NEW", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_UUID_NEW; } }); +Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_ENCRYPTED", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_ENCRYPTED; } }); +Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_COLUMN", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_COLUMN; } }); +Object.defineProperty(exports, "BSON_DATA_ARRAY", { enumerable: true, get: function () { return constants_1.BSON_DATA_ARRAY; } }); +Object.defineProperty(exports, "BSON_DATA_BINARY", { enumerable: true, get: function () { return constants_1.BSON_DATA_BINARY; } }); +Object.defineProperty(exports, "BSON_DATA_BOOLEAN", { enumerable: true, get: function () { return constants_1.BSON_DATA_BOOLEAN; } }); +Object.defineProperty(exports, "BSON_DATA_CODE", { enumerable: true, get: function () { return constants_1.BSON_DATA_CODE; } }); +Object.defineProperty(exports, "BSON_DATA_CODE_W_SCOPE", { enumerable: true, get: function () { return constants_1.BSON_DATA_CODE_W_SCOPE; } }); +Object.defineProperty(exports, "BSON_DATA_DATE", { enumerable: true, get: function () { return constants_1.BSON_DATA_DATE; } }); +Object.defineProperty(exports, "BSON_DATA_DBPOINTER", { enumerable: true, get: function () { return constants_1.BSON_DATA_DBPOINTER; } }); +Object.defineProperty(exports, "BSON_DATA_DECIMAL128", { enumerable: true, get: function () { return constants_1.BSON_DATA_DECIMAL128; } }); +Object.defineProperty(exports, "BSON_DATA_INT", { enumerable: true, get: function () { return constants_1.BSON_DATA_INT; } }); +Object.defineProperty(exports, "BSON_DATA_LONG", { enumerable: true, get: function () { return constants_1.BSON_DATA_LONG; } }); +Object.defineProperty(exports, "BSON_DATA_MAX_KEY", { enumerable: true, get: function () { return constants_1.BSON_DATA_MAX_KEY; } }); +Object.defineProperty(exports, "BSON_DATA_MIN_KEY", { enumerable: true, get: function () { return constants_1.BSON_DATA_MIN_KEY; } }); +Object.defineProperty(exports, "BSON_DATA_NULL", { enumerable: true, get: function () { return constants_1.BSON_DATA_NULL; } }); +Object.defineProperty(exports, "BSON_DATA_NUMBER", { enumerable: true, get: function () { return constants_1.BSON_DATA_NUMBER; } }); +Object.defineProperty(exports, "BSON_DATA_OBJECT", { enumerable: true, get: function () { return constants_1.BSON_DATA_OBJECT; } }); +Object.defineProperty(exports, "BSON_DATA_OID", { enumerable: true, get: function () { return constants_1.BSON_DATA_OID; } }); +Object.defineProperty(exports, "BSON_DATA_REGEXP", { enumerable: true, get: function () { return constants_1.BSON_DATA_REGEXP; } }); +Object.defineProperty(exports, "BSON_DATA_STRING", { enumerable: true, get: function () { return constants_1.BSON_DATA_STRING; } }); +Object.defineProperty(exports, "BSON_DATA_SYMBOL", { enumerable: true, get: function () { return constants_1.BSON_DATA_SYMBOL; } }); +Object.defineProperty(exports, "BSON_DATA_TIMESTAMP", { enumerable: true, get: function () { return constants_1.BSON_DATA_TIMESTAMP; } }); +Object.defineProperty(exports, "BSON_DATA_UNDEFINED", { enumerable: true, get: function () { return constants_1.BSON_DATA_UNDEFINED; } }); +Object.defineProperty(exports, "BSON_INT32_MAX", { enumerable: true, get: function () { return constants_1.BSON_INT32_MAX; } }); +Object.defineProperty(exports, "BSON_INT32_MIN", { enumerable: true, get: function () { return constants_1.BSON_INT32_MIN; } }); +Object.defineProperty(exports, "BSON_INT64_MAX", { enumerable: true, get: function () { return constants_1.BSON_INT64_MAX; } }); +Object.defineProperty(exports, "BSON_INT64_MIN", { enumerable: true, get: function () { return constants_1.BSON_INT64_MIN; } }); +var extended_json_2 = require("./extended_json"); +Object.defineProperty(exports, "EJSON", { enumerable: true, get: function () { return extended_json_2.EJSON; } }); +var timestamp_2 = require("./timestamp"); +Object.defineProperty(exports, "LongWithoutOverridesClass", { enumerable: true, get: function () { return timestamp_2.LongWithoutOverridesClass; } }); +var error_2 = require("./error"); +Object.defineProperty(exports, "BSONError", { enumerable: true, get: function () { return error_2.BSONError; } }); +Object.defineProperty(exports, "BSONTypeError", { enumerable: true, get: function () { return error_2.BSONTypeError; } }); +/** @internal */ +// Default Max Size +var MAXSIZE = 1024 * 1024 * 17; +// Current Internal Temporary Serialization Buffer +var buffer = buffer_1.Buffer.alloc(MAXSIZE); +/** + * Sets the size of the internal serialization buffer. + * + * @param size - The desired size for the internal serialization buffer + * @public + */ +function setInternalBufferSize(size) { + // Resize the internal serialization buffer if needed + if (buffer.length < size) { + buffer = buffer_1.Buffer.alloc(size); + } +} +exports.setInternalBufferSize = setInternalBufferSize; +/** + * Serialize a Javascript object. + * + * @param object - the Javascript object to serialize. + * @returns Buffer object containing the serialized object. + * @public + */ +function serialize(object, options) { + if (options === void 0) { 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 = buffer_1.Buffer.alloc(minInternalBufferSize); + } + // Attempt to serialize + var serializationIndex = (0, serializer_1.serializeInto)(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []); + // Create the final buffer + var finishedBuffer = buffer_1.Buffer.alloc(serializationIndex); + // Copy into the finished buffer + buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length); + // Return the buffer + return finishedBuffer; +} +exports.serialize = serialize; +/** + * Serialize a Javascript object using a predefined Buffer and index into the buffer, + * useful when pre-allocating the space for serialization. + * + * @param object - the Javascript object to serialize. + * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object. + * @returns the index pointing to the last written byte in the buffer. + * @public + */ +function serializeWithBufferAndIndex(object, finalBuffer, options) { + if (options === void 0) { 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 = (0, serializer_1.serializeInto)(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined); + buffer.copy(finalBuffer, startIndex, 0, serializationIndex); + // Return the index + return startIndex + serializationIndex - 1; +} +exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex; +/** + * Deserialize data as BSON. + * + * @param buffer - the buffer containing the serialized set of BSON documents. + * @returns returns the deserialized Javascript Object. + * @public + */ +function deserialize(buffer, options) { + if (options === void 0) { options = {}; } + return (0, deserializer_1.deserialize)(buffer instanceof buffer_1.Buffer ? buffer : (0, ensure_buffer_1.ensureBuffer)(buffer), options); +} +exports.deserialize = deserialize; +/** + * Calculate the bson size for a passed in Javascript object. + * + * @param object - the Javascript object to calculate the BSON byte size for + * @returns size of BSON object in bytes + * @public + */ +function calculateObjectSize(object, options) { + if (options === void 0) { options = {}; } + options = options || {}; + var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + return (0, calculate_size_1.calculateObjectSize)(object, serializeFunctions, ignoreUndefined); +} +exports.calculateObjectSize = calculateObjectSize; +/** + * Deserialize stream data as BSON documents. + * + * @param data - the buffer containing the serialized set of BSON documents. + * @param startIndex - the start index in the data Buffer where the deserialization is to start. + * @param numberOfDocuments - number of documents to deserialize. + * @param documents - an array where to store the deserialized documents. + * @param docStartIndex - the index in the documents array from where to start inserting documents. + * @param options - additional options used for the deserialization. + * @returns next index in the buffer after deserialization **x** numbers of documents. + * @public + */ +function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) { + var internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options); + var bufferData = (0, ensure_buffer_1.ensureBuffer)(data); + var index = startIndex; + // Loop over all documents + for (var i = 0; i < numberOfDocuments; i++) { + // Find size of the document + var size = bufferData[index] | + (bufferData[index + 1] << 8) | + (bufferData[index + 2] << 16) | + (bufferData[index + 3] << 24); + // Update options with index + internalOptions.index = index; + // Parse the document at this point + documents[docStartIndex + i] = (0, deserializer_1.deserialize)(bufferData, internalOptions); + // Adjust index by the document size + index = index + size; + } + // Return object containing end index of parsing and list of documents + return index; +} +exports.deserializeStream = deserializeStream; +/** + * BSON default export + * @deprecated Please use named exports + * @privateRemarks + * We want to someday deprecate the default export, + * so none of the new TS types are being exported on the default + * @public + */ +var BSON = { + Binary: binary_1.Binary, + Code: code_1.Code, + DBRef: db_ref_1.DBRef, + Decimal128: decimal128_1.Decimal128, + Double: double_1.Double, + Int32: int_32_1.Int32, + Long: long_1.Long, + UUID: binary_1.UUID, + Map: map_1.Map, + MaxKey: max_key_1.MaxKey, + MinKey: min_key_1.MinKey, + ObjectId: objectid_1.ObjectId, + ObjectID: objectid_1.ObjectId, + BSONRegExp: regexp_1.BSONRegExp, + BSONSymbol: symbol_1.BSONSymbol, + Timestamp: timestamp_1.Timestamp, + EJSON: extended_json_1.EJSON, + setInternalBufferSize: setInternalBufferSize, + serialize: serialize, + serializeWithBufferAndIndex: serializeWithBufferAndIndex, + deserialize: deserialize, + calculateObjectSize: calculateObjectSize, + deserializeStream: deserializeStream, + BSONError: error_1.BSONError, + BSONTypeError: error_1.BSONTypeError +}; +exports.default = BSON; +//# sourceMappingURL=bson.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/bson.js.map b/node_modules/bson/lib/bson.js.map new file mode 100644 index 0000000..cc4b5c3 --- /dev/null +++ b/node_modules/bson/lib/bson.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bson.js","sourceRoot":"","sources":["../src/bson.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAChC,mCAAwC;AA+EtC,uFA/EO,eAAM,OA+EP;AAEN,qFAjFe,aAAI,OAiFf;AAhFN,+BAA8B;AA0E5B,qFA1EO,WAAI,OA0EP;AAzEN,mCAAiC;AA4E/B,sFA5EO,cAAK,OA4EP;AA3EP,2CAA0C;AAsFxC,2FAtFO,uBAAU,OAsFP;AArFZ,mCAAkC;AAgFhC,uFAhFO,eAAM,OAgFP;AA/ER,iDAA+C;AAC/C,iDAAwC;AACxC,mCAAiC;AA8E/B,sFA9EO,cAAK,OA8EP;AA7EP,+BAA8B;AA0E5B,qFA1EO,WAAI,OA0EP;AAzEN,6BAA4B;AAmE1B,oFAnEO,SAAG,OAmEP;AAlEL,qCAAmC;AA6EjC,uFA7EO,gBAAM,OA6E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AAW,aAAA;IACX,mBAAmB,qBAAA;IACnB,iBAAiB,mBAAA;IACjB,SAAS,mBAAA;IACT,aAAa,uBAAA;CACd,CAAC;AACF,kBAAe,IAAI,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/code.js b/node_modules/bson/lib/code.js new file mode 100644 index 0000000..5855393 --- /dev/null +++ b/node_modules/bson/lib/code.js @@ -0,0 +1,46 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Code = void 0; +/** + * A class representation of the BSON Code type. + * @public + * @category BSONType + */ +var Code = /** @class */ (function () { + /** + * @param code - a string or function. + * @param scope - an optional scope for the function. + */ + function Code(code, scope) { + if (!(this instanceof Code)) + return new Code(code, scope); + this.code = code; + this.scope = scope; + } + Code.prototype.toJSON = function () { + return { code: this.code, scope: this.scope }; + }; + /** @internal */ + Code.prototype.toExtendedJSON = function () { + if (this.scope) { + return { $code: this.code, $scope: this.scope }; + } + return { $code: this.code }; + }; + /** @internal */ + Code.fromExtendedJSON = function (doc) { + return new Code(doc.$code, doc.$scope); + }; + /** @internal */ + Code.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Code.prototype.inspect = function () { + var codeJson = this.toJSON(); + return "new Code(\"".concat(String(codeJson.code), "\"").concat(codeJson.scope ? ", ".concat(JSON.stringify(codeJson.scope)) : '', ")"); + }; + return Code; +}()); +exports.Code = Code; +Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' }); +//# sourceMappingURL=code.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/code.js.map b/node_modules/bson/lib/code.js.map new file mode 100644 index 0000000..2291a6b --- /dev/null +++ b/node_modules/bson/lib/code.js.map @@ -0,0 +1 @@ +{"version":3,"file":"code.js","sourceRoot":"","sources":["../src/code.ts"],"names":[],"mappings":";;;AAQA;;;;GAIG;AACH;IAKE;;;OAGG;IACH,cAAY,IAAuB,EAAE,KAAgB;QACnD,IAAI,CAAC,CAAC,IAAI,YAAY,IAAI,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AAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/constants.js b/node_modules/bson/lib/constants.js new file mode 100644 index 0000000..ff8b68d --- /dev/null +++ b/node_modules/bson/lib/constants.js @@ -0,0 +1,82 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_COLUMN = exports.BSON_BINARY_SUBTYPE_ENCRYPTED = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_UUID_NEW = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_LONG = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_INT = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_CODE = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_REGEXP = exports.BSON_DATA_NULL = exports.BSON_DATA_DATE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_OID = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_DATA_OBJECT = exports.BSON_DATA_STRING = exports.BSON_DATA_NUMBER = exports.JS_INT_MIN = exports.JS_INT_MAX = exports.BSON_INT64_MIN = exports.BSON_INT64_MAX = exports.BSON_INT32_MIN = exports.BSON_INT32_MAX = void 0; +/** @internal */ +exports.BSON_INT32_MAX = 0x7fffffff; +/** @internal */ +exports.BSON_INT32_MIN = -0x80000000; +/** @internal */ +exports.BSON_INT64_MAX = Math.pow(2, 63) - 1; +/** @internal */ +exports.BSON_INT64_MIN = -Math.pow(2, 63); +/** + * Any integer up to 2^53 can be precisely represented by a double. + * @internal + */ +exports.JS_INT_MAX = Math.pow(2, 53); +/** + * Any integer down to -2^53 can be precisely represented by a double. + * @internal + */ +exports.JS_INT_MIN = -Math.pow(2, 53); +/** Number BSON Type @internal */ +exports.BSON_DATA_NUMBER = 1; +/** String BSON Type @internal */ +exports.BSON_DATA_STRING = 2; +/** Object BSON Type @internal */ +exports.BSON_DATA_OBJECT = 3; +/** Array BSON Type @internal */ +exports.BSON_DATA_ARRAY = 4; +/** Binary BSON Type @internal */ +exports.BSON_DATA_BINARY = 5; +/** Binary BSON Type @internal */ +exports.BSON_DATA_UNDEFINED = 6; +/** ObjectId BSON Type @internal */ +exports.BSON_DATA_OID = 7; +/** Boolean BSON Type @internal */ +exports.BSON_DATA_BOOLEAN = 8; +/** Date BSON Type @internal */ +exports.BSON_DATA_DATE = 9; +/** null BSON Type @internal */ +exports.BSON_DATA_NULL = 10; +/** RegExp BSON Type @internal */ +exports.BSON_DATA_REGEXP = 11; +/** Code BSON Type @internal */ +exports.BSON_DATA_DBPOINTER = 12; +/** Code BSON Type @internal */ +exports.BSON_DATA_CODE = 13; +/** Symbol BSON Type @internal */ +exports.BSON_DATA_SYMBOL = 14; +/** Code with Scope BSON Type @internal */ +exports.BSON_DATA_CODE_W_SCOPE = 15; +/** 32 bit Integer BSON Type @internal */ +exports.BSON_DATA_INT = 16; +/** Timestamp BSON Type @internal */ +exports.BSON_DATA_TIMESTAMP = 17; +/** Long BSON Type @internal */ +exports.BSON_DATA_LONG = 18; +/** Decimal128 BSON Type @internal */ +exports.BSON_DATA_DECIMAL128 = 19; +/** MinKey BSON Type @internal */ +exports.BSON_DATA_MIN_KEY = 0xff; +/** MaxKey BSON Type @internal */ +exports.BSON_DATA_MAX_KEY = 0x7f; +/** Binary Default Type @internal */ +exports.BSON_BINARY_SUBTYPE_DEFAULT = 0; +/** Binary Function Type @internal */ +exports.BSON_BINARY_SUBTYPE_FUNCTION = 1; +/** Binary Byte Array Type @internal */ +exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; +/** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */ +exports.BSON_BINARY_SUBTYPE_UUID = 3; +/** Binary UUID Type @internal */ +exports.BSON_BINARY_SUBTYPE_UUID_NEW = 4; +/** Binary MD5 Type @internal */ +exports.BSON_BINARY_SUBTYPE_MD5 = 5; +/** Encrypted BSON type @internal */ +exports.BSON_BINARY_SUBTYPE_ENCRYPTED = 6; +/** Column BSON type @internal */ +exports.BSON_BINARY_SUBTYPE_COLUMN = 7; +/** Binary User Defined Type @internal */ +exports.BSON_BINARY_SUBTYPE_USER_DEFINED = 128; +//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/constants.js.map b/node_modules/bson/lib/constants.js.map new file mode 100644 index 0000000..3b9c0ca --- /dev/null +++ b/node_modules/bson/lib/constants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,gBAAgB;AACH,QAAA,cAAc,GAAG,UAAU,CAAC;AACzC,gBAAgB;AACH,QAAA,cAAc,GAAG,CAAC,UAAU,CAAC;AAC1C,gBAAgB;AACH,QAAA,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;AAClD,gBAAgB;AACH,QAAA,cAAc,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE/C;;;GAGG;AACU,QAAA,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE1C;;;GAGG;AACU,QAAA,UAAU,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE3C,iCAAiC;AACpB,QAAA,gBAAgB,GAAG,CAAC,CAAC;AAElC,iCAAiC;AACpB,QAAA,gBAAgB,GAAG,CAAC,CAAC;AAElC,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AiC;AACpB,QAAA,4BAA4B,GAAG,CAAC,CAAC;AAE9C,gCAAgC;AACnB,QAAA,uBAAuB,GAAG,CAAC,CAAC;AAEzC,oCAAoC;AACvB,QAAA,6BAA6B,GAAG,CAAC,CAAC;AAE/C,iCAAiC;AACpB,QAAA,0BAA0B,GAAG,CAAC,CAAC;AAE5C,yCAAyC;AAC5B,QAAA,gCAAgC,GAAG,GAAG,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/db_ref.js b/node_modules/bson/lib/db_ref.js new file mode 100644 index 0000000..d18bd96 --- /dev/null +++ b/node_modules/bson/lib/db_ref.js @@ -0,0 +1,97 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DBRef = exports.isDBRefLike = void 0; +var utils_1 = require("./parser/utils"); +/** @internal */ +function isDBRefLike(value) { + return ((0, utils_1.isObjectLike)(value) && + value.$id != null && + typeof value.$ref === 'string' && + (value.$db == null || typeof value.$db === 'string')); +} +exports.isDBRefLike = isDBRefLike; +/** + * A class representation of the BSON DBRef type. + * @public + * @category BSONType + */ +var DBRef = /** @class */ (function () { + /** + * @param collection - the collection name. + * @param oid - the reference ObjectId. + * @param db - optional db name, if omitted the reference is local to the current db. + */ + function DBRef(collection, oid, db, fields) { + if (!(this instanceof DBRef)) + return new DBRef(collection, oid, db, fields); + // check if namespace has been provided + var parts = collection.split('.'); + if (parts.length === 2) { + db = parts.shift(); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + collection = parts.shift(); + } + this.collection = collection; + this.oid = oid; + this.db = db; + this.fields = fields || {}; + } + Object.defineProperty(DBRef.prototype, "namespace", { + // Property provided for compatibility with the 1.x parser + // the 1.x parser used a "namespace" property, while 4.x uses "collection" + /** @internal */ + get: function () { + return this.collection; + }, + set: function (value) { + this.collection = value; + }, + enumerable: false, + configurable: true + }); + DBRef.prototype.toJSON = function () { + var o = Object.assign({ + $ref: this.collection, + $id: this.oid + }, this.fields); + if (this.db != null) + o.$db = this.db; + return o; + }; + /** @internal */ + DBRef.prototype.toExtendedJSON = function (options) { + options = options || {}; + var o = { + $ref: this.collection, + $id: this.oid + }; + if (options.legacy) { + return o; + } + if (this.db) + o.$db = this.db; + o = Object.assign(o, this.fields); + return o; + }; + /** @internal */ + DBRef.fromExtendedJSON = function (doc) { + var copy = Object.assign({}, doc); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(doc.$ref, doc.$id, doc.$db, copy); + }; + /** @internal */ + DBRef.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + DBRef.prototype.inspect = function () { + // NOTE: if OID is an ObjectId class it will just print the oid string. + var oid = this.oid === undefined || this.oid.toString === undefined ? this.oid : this.oid.toString(); + return "new DBRef(\"".concat(this.namespace, "\", new ObjectId(\"").concat(String(oid), "\")").concat(this.db ? ", \"".concat(this.db, "\"") : '', ")"); + }; + return DBRef; +}()); +exports.DBRef = DBRef; +Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' }); +//# sourceMappingURL=db_ref.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/db_ref.js.map b/node_modules/bson/lib/db_ref.js.map new file mode 100644 index 0000000..74e49aa --- /dev/null +++ b/node_modules/bson/lib/db_ref.js.map @@ -0,0 +1 @@ +{"version":3,"file":"db_ref.js","sourceRoot":"","sources":["../src/db_ref.ts"],"names":[],"mappings":";;;AAGA,wCAA8C;AAS9C,gBAAgB;AAChB,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,IAAA,oBAAY,EAAC,KAAK,CAAC;QACnB,KAAK,CAAC,GAAG,IAAI,IAAI;QACjB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,CACrD,CAAC;AACJ,CAAC;AAPD,kCAOC;AAED;;;;GAIG;AACH;IAQE;;;;OAIG;IACH,eAAY,UAAkB,EAAE,G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C,EAAE,MAC9B,CAAC;IACN,CAAC;IACH,YAAC;AAAD,CAAC,AA9FD,IA8FC;AA9FY,sBAAK;AAgGlB,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/decimal128.js b/node_modules/bson/lib/decimal128.js new file mode 100644 index 0000000..2fd7efa --- /dev/null +++ b/node_modules/bson/lib/decimal128.js @@ -0,0 +1,669 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Decimal128 = void 0; +var buffer_1 = require("buffer"); +var error_1 = require("./error"); +var long_1 = require("./long"); +var utils_1 = require("./parser/utils"); +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+)?$/; +// 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; +// Detect if the value is a digit +function isDigit(value) { + return !isNaN(parseInt(value, 10)); +} +// Divide two uint128 values +function divideu128(value) { + var DIVISOR = long_1.Long.fromNumber(1000 * 1000 * 1000); + var _rem = long_1.Long.fromNumber(0); + if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) { + return { quotient: value, rem: _rem }; + } + for (var 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_1.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 +function multiply64x2(left, right) { + if (!left && !right) { + return { high: long_1.Long.fromNumber(0), low: long_1.Long.fromNumber(0) }; + } + var leftHigh = left.shiftRightUnsigned(32); + var leftLow = new long_1.Long(left.getLowBits(), 0); + var rightHigh = right.shiftRightUnsigned(32); + var rightLow = new long_1.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_1.Long(productMid.getLowBits(), 0) + .add(productMid2) + .add(productLow.shiftRightUnsigned(32)); + productHigh = productHigh.add(productMid.shiftRightUnsigned(32)); + productLow = productMid.shiftLeft(32).add(new long_1.Long(productLow.getLowBits(), 0)); + // Return the 128 bit result + return { high: productHigh, low: productLow }; +} +function lessThan(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; +} +function invalidErr(string, message) { + throw new error_1.BSONTypeError("\"".concat(string, "\" is not a valid Decimal128 string - ").concat(message)); +} +/** + * A class representation of the BSON Decimal128 type. + * @public + * @category BSONType + */ +var Decimal128 = /** @class */ (function () { + /** + * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order, + * or a string representation as returned by .toString() + */ + function Decimal128(bytes) { + if (!(this instanceof Decimal128)) + return new Decimal128(bytes); + if (typeof bytes === 'string') { + this.bytes = Decimal128.fromString(bytes).bytes; + } + else if ((0, utils_1.isUint8Array)(bytes)) { + if (bytes.byteLength !== 16) { + throw new error_1.BSONTypeError('Decimal128 must take a Buffer of 16 bytes'); + } + this.bytes = bytes; + } + else { + throw new error_1.BSONTypeError('Decimal128 must take a Buffer or string'); + } + } + /** + * Create a Decimal128 instance from a string representation + * + * @param representation - a numeric string representation. + */ + Decimal128.fromString = function (representation) { + // 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 = new long_1.Long(0, 0); + // The low 17 digits of the significand + var significandLow = new long_1.Long(0, 0); + // The biased exponent + var biasedExponent = 0; + // Read index + var index = 0; + // Naively prevent against REDOS attacks. + // TODO: implementing a custom parsing for this, or refactoring the regex would yield + // further gains. + if (representation.length >= 7000) { + throw new error_1.BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + // Results + var stringMatch = representation.match(PARSE_STRING_REGEXP); + var infMatch = representation.match(PARSE_INF_REGEXP); + var nanMatch = representation.match(PARSE_NAN_REGEXP); + // Validate the string + if ((!stringMatch && !infMatch && !nanMatch) || representation.length === 0) { + throw new error_1.BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + if (stringMatch) { + // full_match = stringMatch[0] + // sign = stringMatch[1] + var unsignedNumber = stringMatch[2]; + // stringMatch[3] is undefined if a whole number (ex "1", 12") + // but defined if a number w/ decimal in it (ex "1.0, 12.2") + var e = stringMatch[4]; + var expSign = stringMatch[5]; + var expNumber = stringMatch[6]; + // they provided e, but didn't give an exponent number. for ex "1e" + if (e && expNumber === undefined) + invalidErr(representation, 'missing exponent power'); + // they provided e, but didn't give a number before it. for ex "e1" + if (e && unsignedNumber === undefined) + invalidErr(representation, 'missing exponent base'); + if (e === undefined && (expSign || expNumber)) { + invalidErr(representation, 'missing e before exponent'); + } + } + // Get the negative or positive sign + if (representation[index] === '+' || representation[index] === '-') { + isNegative = representation[index++] === '-'; + } + // Check if user passed Infinity or NaN + if (!isDigit(representation[index]) && representation[index] !== '.') { + if (representation[index] === 'i' || representation[index] === 'I') { + return new Decimal128(buffer_1.Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + else if (representation[index] === 'N') { + return new Decimal128(buffer_1.Buffer.from(NAN_BUFFER)); + } + } + // Read all the digits + while (isDigit(representation[index]) || representation[index] === '.') { + if (representation[index] === '.') { + if (sawRadix) + invalidErr(representation, 'contains multiple periods'); + sawRadix = true; + index = index + 1; + continue; + } + if (nDigitsStored < 34) { + if (representation[index] !== '0' || foundNonZero) { + if (!foundNonZero) { + firstNonZero = nDigitsRead; + } + foundNonZero = true; + // Only store 34 digits + digits[digitsInsert++] = parseInt(representation[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_1.BSONTypeError('' + representation + ' not a valid Decimal128 string'); + // Read exponent if exists + if (representation[index] === 'e' || representation[index] === 'E') { + // Read exponent digits + var match = representation.substr(++index).match(EXPONENT_REGEX); + // No digits read + if (!match || !match[2]) + return new Decimal128(buffer_1.Buffer.from(NAN_BUFFER)); + // Get exponent + exponent = parseInt(match[0], 10); + // Adjust the index + index = index + match[0].length; + } + // Return not a number + if (representation[index]) + return new Decimal128(buffer_1.Buffer.from(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 (significantDigits !== 1) { + while (digits[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; + } + invalidErr(representation, 'overflow'); + } + exponent = exponent - 1; + } + while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { + // Shift last digit. can only do this if < significant digits than # stored. + if (lastDigit === 0 && significantDigits < nDigitsStored) { + 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 + var digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } + invalidErr(representation, 'overflow'); + } + } + // Round + // We've normalized the exponent, but might still need to round. + if (lastDigit - firstDigit + 1 < significantDigits) { + 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) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + // if negative, we need to increment again to account for - sign at start. + if (isNegative) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + var roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10); + var roundBit = 0; + if (roundDigit >= 5) { + roundBit = 1; + if (roundDigit === 5) { + roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0; + for (i = firstNonZero + lastDigit + 2; i < endOfString; i++) { + if (parseInt(representation[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(buffer_1.Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + } + } + } + } + // Encode significand + // The high 17 digits of the significand + significandHigh = long_1.Long.fromNumber(0); + // The low 17 digits of the significand + significandLow = long_1.Long.fromNumber(0); + // read a zero + if (significantDigits === 0) { + significandHigh = long_1.Long.fromNumber(0); + significandLow = long_1.Long.fromNumber(0); + } + else if (lastDigit - firstDigit < 17) { + var dIdx = firstDigit; + significandLow = long_1.Long.fromNumber(digits[dIdx++]); + significandHigh = new long_1.Long(0, 0); + for (; dIdx <= lastDigit; dIdx++) { + significandLow = significandLow.multiply(long_1.Long.fromNumber(10)); + significandLow = significandLow.add(long_1.Long.fromNumber(digits[dIdx])); + } + } + else { + var dIdx = firstDigit; + significandHigh = long_1.Long.fromNumber(digits[dIdx++]); + for (; dIdx <= lastDigit - 17; dIdx++) { + significandHigh = significandHigh.multiply(long_1.Long.fromNumber(10)); + significandHigh = significandHigh.add(long_1.Long.fromNumber(digits[dIdx])); + } + significandLow = long_1.Long.fromNumber(digits[dIdx++]); + for (; dIdx <= lastDigit; dIdx++) { + significandLow = significandLow.multiply(long_1.Long.fromNumber(10)); + significandLow = significandLow.add(long_1.Long.fromNumber(digits[dIdx])); + } + } + var significand = multiply64x2(significandHigh, long_1.Long.fromString('100000000000000000')); + significand.low = significand.low.add(significandLow); + if (lessThan(significand.low, significandLow)) { + significand.high = significand.high.add(long_1.Long.fromNumber(1)); + } + // Biased exponent + biasedExponent = exponent + EXPONENT_BIAS; + var dec = { low: long_1.Long.fromNumber(0), high: long_1.Long.fromNumber(0) }; + // Encode combination, exponent, and significand. + if (significand.high.shiftRightUnsigned(49).and(long_1.Long.fromNumber(1)).equals(long_1.Long.fromNumber(1))) { + // Encode '11' into bits 1 to 3 + dec.high = dec.high.or(long_1.Long.fromNumber(0x3).shiftLeft(61)); + dec.high = dec.high.or(long_1.Long.fromNumber(biasedExponent).and(long_1.Long.fromNumber(0x3fff).shiftLeft(47))); + dec.high = dec.high.or(significand.high.and(long_1.Long.fromNumber(0x7fffffffffff))); + } + else { + dec.high = dec.high.or(long_1.Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49)); + dec.high = dec.high.or(significand.high.and(long_1.Long.fromNumber(0x1ffffffffffff))); + } + dec.low = significand.low; + // Encode sign + if (isNegative) { + dec.high = dec.high.or(long_1.Long.fromString('9223372036854775808')); + } + // Encode into a buffer + var buffer = buffer_1.Buffer.alloc(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); + }; + /** Create a string representation of the raw Decimal128 value */ + Decimal128.prototype.toString = function () { + // Note: bits in this routine are referred to starting at 0, + // from the sign bit, towards the coefficient. + // 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; + // true if the number is zero + var is_zero = false; + // the most significant significand bits (50-46) + var significand_msb; + // temporary storage for significand decoding + var significand128 = { parts: [0, 0, 0, 0] }; + // indexing variables + var j, k; + // Output string + var string = []; + // Unpack index + index = 0; + // Buffer reference + var buffer = this.bytes; + // Unpack the low 64bits into a long + // bits 96 - 127 + var low = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 64 - 95 + var midl = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // Unpack the high 64bits into a long + // bits 32 - 63 + var midh = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 0 - 31 + var 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_1.Long(low, midl), + high: new long_1.Long(midh, high) + }; + if (dec.high.lessThan(long_1.Long.ZERO)) { + string.push('-'); + } + // Decode combination field and exponent + // bits 1 - 5 + var 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; + } + // unbiased exponent + var 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; + // Perform 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; + while (!significand[index]) { + significand_digits = significand_digits - 1; + index = index + 1; + } + } + // the exponent if scientific notation is used + var 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 + // if there are too many significant digits, we should just be treating numbers + // as + or - 0 and using the non-scientific exponent (this is for the "invalid + // representation should be treated as 0/-0" spec cases in decimal128-1.json) + if (significand_digits > 34) { + string.push("".concat(0)); + if (exponent > 0) + string.push("E+".concat(exponent)); + else if (exponent < 0) + string.push("E".concat(exponent)); + return string.join(''); + } + string.push("".concat(significand[index++])); + significand_digits = significand_digits - 1; + if (significand_digits) { + string.push('.'); + } + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + // Exponent + string.push('E'); + if (scientific_exponent > 0) { + string.push("+".concat(scientific_exponent)); + } + else { + string.push("".concat(scientific_exponent)); + } + } + else { + // Regular format with no decimal place + if (exponent >= 0) { + for (var i = 0; i < significand_digits; i++) { + string.push("".concat(significand[index++])); + } + } + else { + var radix_position = significand_digits + exponent; + // non-zero digits before radix + if (radix_position > 0) { + for (var i = 0; i < radix_position; i++) { + string.push("".concat(significand[index++])); + } + } + else { + string.push('0'); + } + string.push('.'); + // add leading zeros after radix + while (radix_position++ < 0) { + string.push('0'); + } + for (var i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) { + string.push("".concat(significand[index++])); + } + } + } + return string.join(''); + }; + Decimal128.prototype.toJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.prototype.toExtendedJSON = function () { + return { $numberDecimal: this.toString() }; + }; + /** @internal */ + Decimal128.fromExtendedJSON = function (doc) { + return Decimal128.fromString(doc.$numberDecimal); + }; + /** @internal */ + Decimal128.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Decimal128.prototype.inspect = function () { + return "new Decimal128(\"".concat(this.toString(), "\")"); + }; + return Decimal128; +}()); +exports.Decimal128 = Decimal128; +Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' }); +//# sourceMappingURL=decimal128.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/decimal128.js.map b/node_modules/bson/lib/decimal128.js.map new file mode 100644 index 0000000..31f0ee8 --- /dev/null +++ b/node_modules/bson/lib/decimal128.js.map @@ -0,0 +1 @@ +{"version":3,"file":"decimal128.js","sourceRoot":"","sources":["../src/decimal128.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,iCAAwC;AACxC,+BAA8B;AAC9B,wCAA8C;AAE9C,IAAM,mBAAmB,GAAG,+CAA+C,CAAC;AAC5E,IAAM,gBAAgB,GAAG,0BAA0B,CAAC;AACpD,IAAM,gBAAgB,GAAG,eAAe,CAAC;AAEzC,IAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,IAAM,YAAY,GAAG,CAAC,IAAI,CAAC;AAC3B,IAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,IAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,yDAAyD;AACzD,IAAM,UAAU,GAAG;IACjB,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CAC/F,CAAC,OAAO,EAAE,CAAC;AACZ,2DAA2D;AAC3D,IAAM,mBAAmB,GAAG;IAC1B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CAC/F,CAAC,OAAO,EAAE,CAAC;AACZ,IAAM,mBAAmB,GAAG;IAC1B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI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/double.js new file mode 100644 index 0000000..39c488f --- /dev/null +++ b/node_modules/bson/lib/double.js @@ -0,0 +1,76 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Double = void 0; +/** + * A class representation of the BSON Double type. + * @public + * @category BSONType + */ +var Double = /** @class */ (function () { + /** + * Create a Double type + * + * @param value - the number we want to represent as a double. + */ + function Double(value) { + if (!(this instanceof Double)) + return new Double(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value; + } + /** + * Access the number value. + * + * @returns returns the wrapped double number. + */ + Double.prototype.valueOf = function () { + return this.value; + }; + Double.prototype.toJSON = function () { + return this.value; + }; + Double.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + /** @internal */ + Double.prototype.toExtendedJSON = function (options) { + if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) { + return this.value; + } + // NOTE: JavaScript has +0 and -0, apparently to model limit calculations. If a user + // explicitly provided `-0` then we need to ensure the sign makes it into the output + if (Object.is(Math.sign(this.value), -0)) { + return { $numberDouble: "-".concat(this.value.toFixed(1)) }; + } + var $numberDouble; + if (Number.isInteger(this.value)) { + $numberDouble = this.value.toFixed(1); + if ($numberDouble.length >= 13) { + $numberDouble = this.value.toExponential(13).toUpperCase(); + } + } + else { + $numberDouble = this.value.toString(); + } + return { $numberDouble: $numberDouble }; + }; + /** @internal */ + Double.fromExtendedJSON = function (doc, options) { + var doubleValue = parseFloat(doc.$numberDouble); + return options && options.relaxed ? doubleValue : new Double(doubleValue); + }; + /** @internal */ + Double.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Double.prototype.inspect = function () { + var eJSON = this.toExtendedJSON(); + return "new Double(".concat(eJSON.$numberDouble, ")"); + }; + return Double; +}()); +exports.Double = Double; +Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' }); +//# sourceMappingURL=double.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/double.js.map b/node_modules/bson/lib/double.js.map new file mode 100644 index 0000000..31201e1 --- /dev/null +++ b/node_modules/bson/lib/double.js.map @@ -0,0 +1 @@ +{"version":3,"file":"double.js","sourceRoot":"","sources":["../src/double.ts"],"names":[],"mappings":";;;AAOA;;;;GAIG;AACH;IAIE;;;;OAIG;IACH,gBAAY,KAAa;QACvB,IAAI,CAAC,CAAC,IAAI,YAAY,MAAM,CAAC;YAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;QAExD,IAAK,KAAiB,YAAY,MAAM,EAAE;YACxC,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;SACzB;QAED,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,wBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,uBAAM,GAAN;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,yBAAQ,GAAR,UAAS,KAAc;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,gBAAgB;IAChB,+BAAc,GAAd,UAAe,OAAsB;QACnC,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YAC5E,OAAO,IAAI,CAAC,KAAK,CAAC;SACnB;QAED,oFAAoF;QACpF,oFAAoF;QACpF,IAAI,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;YACxC,OAAO,EAAE,aAAa,EAAE,WAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC;SACvD;QAED,IAAI,aAAqB,CAAC;QAC1B,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAChC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACtC,IAAI,aAAa,CAAC,MAAM,IAAI,EAAE,EAAE;gBAC9B,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;aAC5D;SACF;aAAM;YACL,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;SACvC;QAED,OAAO,EAAE,aAAa,eAAA,EAAE,CAAC;IAC3B,CAAC;IAED,gBAAgB;IACT,uBAAgB,GAAvB,UAAwB,GAAmB,EAAE,OAAsB;QACjE,IAAM,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAClD,OAAO,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;IAC5E,CAAC;IAED,gBAAgB;IAChB,iBAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,GAA1C;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,wBAAO,GAAP;QACE,IAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAoB,CAAC;QACtD,OAAO,qBAAc,KAAK,CAAC,aAAa,MAAG,CAAC;IAC9C,CAAC;IACH,aAAC;AAAD,CAAC,AA5ED,IA4EC;AA5EY,wBAAM;AA8EnB,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/ensure_buffer.js b/node_modules/bson/lib/ensure_buffer.js new file mode 100644 index 0000000..d8298ea --- /dev/null +++ b/node_modules/bson/lib/ensure_buffer.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ensureBuffer = void 0; +var buffer_1 = require("buffer"); +var error_1 = require("./error"); +var utils_1 = require("./parser/utils"); +/** + * Makes sure that, if a Uint8Array is passed in, it is wrapped in a Buffer. + * + * @param potentialBuffer - The potential buffer + * @returns Buffer the input if potentialBuffer is a buffer, or a buffer that + * wraps a passed in Uint8Array + * @throws BSONTypeError If anything other than a Buffer or Uint8Array is passed in + */ +function ensureBuffer(potentialBuffer) { + if (ArrayBuffer.isView(potentialBuffer)) { + return buffer_1.Buffer.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength); + } + if ((0, utils_1.isAnyArrayBuffer)(potentialBuffer)) { + return buffer_1.Buffer.from(potentialBuffer); + } + throw new error_1.BSONTypeError('Must use either Buffer or TypedArray'); +} +exports.ensureBuffer = ensureBuffer; +//# sourceMappingURL=ensure_buffer.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/ensure_buffer.js.map b/node_modules/bson/lib/ensure_buffer.js.map new file mode 100644 index 0000000..f39d86a --- /dev/null +++ b/node_modules/bson/lib/ensure_buffer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ensure_buffer.js","sourceRoot":"","sources":["../src/ensure_buffer.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,iCAAwC;AACxC,wCAAkD;AAElD;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,eAAuD;IAClF,IAAI,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE;QACvC,OAAO,eAAM,CAAC,IAAI,CAChB,eAAe,CAAC,MAAM,EACtB,eAAe,CAAC,UAAU,EAC1B,eAAe,CAAC,UAAU,CAC3B,CAAC;KACH;IAED,IAAI,IAAA,wBAAgB,EAAC,eAAe,CAAC,EAAE;QACrC,OAAO,eAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;KACrC;IAED,MAAM,IAAI,qBAAa,CAAC,sCAAsC,CAAC,CAAC;AAClE,CAAC;AAdD,oCAcC"} \ No newline at end of file diff --git a/node_modules/bson/lib/error.js b/node_modules/bson/lib/error.js new file mode 100644 index 0000000..035ce86 --- /dev/null +++ b/node_modules/bson/lib/error.js @@ -0,0 +1,55 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BSONTypeError = exports.BSONError = void 0; +/** @public */ +var BSONError = /** @class */ (function (_super) { + __extends(BSONError, _super); + function BSONError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONError.prototype); + return _this; + } + Object.defineProperty(BSONError.prototype, "name", { + get: function () { + return 'BSONError'; + }, + enumerable: false, + configurable: true + }); + return BSONError; +}(Error)); +exports.BSONError = BSONError; +/** @public */ +var BSONTypeError = /** @class */ (function (_super) { + __extends(BSONTypeError, _super); + function BSONTypeError(message) { + var _this = _super.call(this, message) || this; + Object.setPrototypeOf(_this, BSONTypeError.prototype); + return _this; + } + Object.defineProperty(BSONTypeError.prototype, "name", { + get: function () { + return 'BSONTypeError'; + }, + enumerable: false, + configurable: true + }); + return BSONTypeError; +}(TypeError)); +exports.BSONTypeError = BSONTypeError; +//# sourceMappingURL=error.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/error.js.map b/node_modules/bson/lib/error.js.map new file mode 100644 index 0000000..2acd4ef --- /dev/null +++ b/node_modules/bson/lib/error.js.map @@ -0,0 +1 @@ +{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd;IAA+B,6BAAK;IAClC,mBAAY,OAAe;QAA3B,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;;IACnD,CAAC;IAED,sBAAI,2BAAI;aAAR;YACE,OAAO,WAAW,CAAC;QACrB,CAAC;;;OAAA;IACH,gBAAC;AAAD,CAAC,AATD,CAA+B,KAAK,GASnC;AATY,8BAAS;AAWtB,cAAc;AACd;IAAmC,iCAAS;IAC1C,uBAAY,OAAe;QAA3B,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;;IACvD,CAAC;IAED,sBAAI,+BAAI;aAAR;YACE,OAAO,eAAe,CAAC;QACzB,CAAC;;;OAAA;IACH,oBAAC;AAAD,CAAC,AATD,CAAmC,SAAS,GAS3C;AATY,sCAAa"} \ No newline at end of file diff --git a/node_modules/bson/lib/extended_json.js b/node_modules/bson/lib/extended_json.js new file mode 100644 index 0000000..980e4db --- /dev/null +++ b/node_modules/bson/lib/extended_json.js @@ -0,0 +1,390 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EJSON = exports.isBSONType = void 0; +var binary_1 = require("./binary"); +var code_1 = require("./code"); +var db_ref_1 = require("./db_ref"); +var decimal128_1 = require("./decimal128"); +var double_1 = require("./double"); +var error_1 = require("./error"); +var int_32_1 = require("./int_32"); +var long_1 = require("./long"); +var max_key_1 = require("./max_key"); +var min_key_1 = require("./min_key"); +var objectid_1 = require("./objectid"); +var utils_1 = require("./parser/utils"); +var regexp_1 = require("./regexp"); +var symbol_1 = require("./symbol"); +var timestamp_1 = require("./timestamp"); +function isBSONType(value) { + return ((0, utils_1.isObjectLike)(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string'); +} +exports.isBSONType = isBSONType; +// INT32 boundaries +var BSON_INT32_MAX = 0x7fffffff; +var BSON_INT32_MIN = -0x80000000; +// INT64 boundaries +// const BSON_INT64_MAX = 0x7fffffffffffffff; // TODO(NODE-4377): This number cannot be precisely represented in JS +var BSON_INT64_MAX = 0x8000000000000000; +var BSON_INT64_MIN = -0x8000000000000000; +// all the types where we don't need to do any special processing and can just pass the EJSON +//straight to type.fromExtendedJSON +var keysToCodecs = { + $oid: objectid_1.ObjectId, + $binary: binary_1.Binary, + $uuid: binary_1.Binary, + $symbol: symbol_1.BSONSymbol, + $numberInt: int_32_1.Int32, + $numberDecimal: decimal128_1.Decimal128, + $numberDouble: double_1.Double, + $numberLong: long_1.Long, + $minKey: min_key_1.MinKey, + $maxKey: max_key_1.MaxKey, + $regex: regexp_1.BSONRegExp, + $regularExpression: regexp_1.BSONRegExp, + $timestamp: timestamp_1.Timestamp +}; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function deserializeValue(value, options) { + if (options === void 0) { options = {}; } + if (typeof value === 'number') { + if (options.relaxed || options.legacy) { + return value; + } + // if it's an integer, should interpret as smallest BSON integer + // that can represent it exactly. (if out of range, interpret as double.) + if (Math.floor(value) === value) { + if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) + return new int_32_1.Int32(value); + if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) + return long_1.Long.fromNumber(value); + } + // If the number is a non-integer or out of integer range, should interpret as BSON Double. + return new double_1.Double(value); + } + // from here on out we're looking for bson types, so bail if its not an object + if (value == null || typeof value !== 'object') + return value; + // upgrade deprecated undefined to null + if (value.$undefined) + return null; + var keys = Object.keys(value).filter(function (k) { return k.startsWith('$') && value[k] != null; }); + for (var i = 0; i < keys.length; i++) { + var c = keysToCodecs[keys[i]]; + if (c) + return c.fromExtendedJSON(value, options); + } + if (value.$date != null) { + var d = value.$date; + var date = new Date(); + if (options.legacy) { + if (typeof d === 'number') + date.setTime(d); + else if (typeof d === 'string') + date.setTime(Date.parse(d)); + } + else { + if (typeof d === 'string') + date.setTime(Date.parse(d)); + else if (long_1.Long.isLong(d)) + date.setTime(d.toNumber()); + else if (typeof d === 'number' && options.relaxed) + date.setTime(d); + } + return date; + } + if (value.$code != null) { + var copy = Object.assign({}, value); + if (value.$scope) { + copy.$scope = deserializeValue(value.$scope); + } + return code_1.Code.fromExtendedJSON(value); + } + if ((0, db_ref_1.isDBRefLike)(value) || value.$dbPointer) { + var v = value.$ref ? value : value.$dbPointer; + // we run into this in a "degenerate EJSON" case (with $id and $ref order flipped) + // because of the order JSON.parse goes through the document + if (v instanceof db_ref_1.DBRef) + return v; + var dollarKeys = Object.keys(v).filter(function (k) { return k.startsWith('$'); }); + var valid_1 = true; + dollarKeys.forEach(function (k) { + if (['$ref', '$id', '$db'].indexOf(k) === -1) + valid_1 = false; + }); + // only make DBRef if $ keys are all valid + if (valid_1) + return db_ref_1.DBRef.fromExtendedJSON(v); + } + return value; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeArray(array, options) { + return array.map(function (v, index) { + options.seenObjects.push({ propertyName: "index ".concat(index), obj: null }); + try { + return serializeValue(v, options); + } + finally { + options.seenObjects.pop(); + } + }); +} +function getISOString(date) { + var isoStr = date.toISOString(); + // we should only show milliseconds in timestamp if they're non-zero + return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + 'Z'; +} +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeValue(value, options) { + if ((typeof value === 'object' || typeof value === 'function') && value !== null) { + var index = options.seenObjects.findIndex(function (entry) { return entry.obj === value; }); + if (index !== -1) { + var props = options.seenObjects.map(function (entry) { return entry.propertyName; }); + var leadingPart = props + .slice(0, index) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var alreadySeen = props[index]; + var circularPart = ' -> ' + + props + .slice(index + 1, props.length - 1) + .map(function (prop) { return "".concat(prop, " -> "); }) + .join(''); + var current = props[props.length - 1]; + var leadingSpace = ' '.repeat(leadingPart.length + alreadySeen.length / 2); + var dashes = '-'.repeat(circularPart.length + (alreadySeen.length + current.length) / 2 - 1); + throw new error_1.BSONTypeError('Converting circular structure to EJSON:\n' + + " ".concat(leadingPart).concat(alreadySeen).concat(circularPart).concat(current, "\n") + + " ".concat(leadingSpace, "\\").concat(dashes, "/")); + } + options.seenObjects[options.seenObjects.length - 1].obj = value; + } + if (Array.isArray(value)) + return serializeArray(value, options); + if (value === undefined) + return null; + if (value instanceof Date || (0, utils_1.isDate)(value)) { + var dateNum = value.getTime(), + // is it in year range 1970-9999? + inRange = dateNum > -1 && dateNum < 253402318800000; + if (options.legacy) { + return options.relaxed && inRange + ? { $date: value.getTime() } + : { $date: getISOString(value) }; + } + return options.relaxed && inRange + ? { $date: getISOString(value) } + : { $date: { $numberLong: value.getTime().toString() } }; + } + if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) { + // it's an integer + if (Math.floor(value) === value) { + var int32Range = value >= BSON_INT32_MIN && value <= BSON_INT32_MAX, int64Range = value >= BSON_INT64_MIN && value <= BSON_INT64_MAX; + // interpret as being of the smallest BSON integer type that can represent the number exactly + if (int32Range) + return { $numberInt: value.toString() }; + if (int64Range) + return { $numberLong: value.toString() }; + } + return { $numberDouble: value.toString() }; + } + if (value instanceof RegExp || (0, utils_1.isRegExp)(value)) { + var flags = value.flags; + if (flags === undefined) { + var match = value.toString().match(/[gimuy]*$/); + if (match) { + flags = match[0]; + } + } + var rx = new regexp_1.BSONRegExp(value.source, flags); + return rx.toExtendedJSON(options); + } + if (value != null && typeof value === 'object') + return serializeDocument(value, options); + return value; +} +var BSON_TYPE_MAPPINGS = { + Binary: function (o) { return new binary_1.Binary(o.value(), o.sub_type); }, + Code: function (o) { return new code_1.Code(o.code, o.scope); }, + DBRef: function (o) { return new db_ref_1.DBRef(o.collection || o.namespace, o.oid, o.db, o.fields); }, + Decimal128: function (o) { return new decimal128_1.Decimal128(o.bytes); }, + Double: function (o) { return new double_1.Double(o.value); }, + Int32: function (o) { return new int_32_1.Int32(o.value); }, + Long: function (o) { + return long_1.Long.fromBits( + // underscore variants for 1.x backwards compatibility + o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_); + }, + MaxKey: function () { return new max_key_1.MaxKey(); }, + MinKey: function () { return new min_key_1.MinKey(); }, + ObjectID: function (o) { return new objectid_1.ObjectId(o); }, + ObjectId: function (o) { return new objectid_1.ObjectId(o); }, + BSONRegExp: function (o) { return new regexp_1.BSONRegExp(o.pattern, o.options); }, + Symbol: function (o) { return new symbol_1.BSONSymbol(o.value); }, + Timestamp: function (o) { return timestamp_1.Timestamp.fromBits(o.low, o.high); } +}; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeDocument(doc, options) { + if (doc == null || typeof doc !== 'object') + throw new error_1.BSONError('not an object instance'); + var bsontype = doc._bsontype; + if (typeof bsontype === 'undefined') { + // It's a regular object. Recursively serialize its property values. + var _doc = {}; + for (var name in doc) { + options.seenObjects.push({ propertyName: name, obj: null }); + try { + var value = serializeValue(doc[name], options); + if (name === '__proto__') { + Object.defineProperty(_doc, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + _doc[name] = value; + } + } + finally { + options.seenObjects.pop(); + } + } + return _doc; + } + else if (isBSONType(doc)) { + // the "document" is really just a BSON type object + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var outDoc = doc; + if (typeof outDoc.toExtendedJSON !== 'function') { + // There's no EJSON serialization function on the object. It's probably an + // object created by a previous version of this library (or another library) + // that's duck-typing objects to look like they were generated by this library). + // Copy the object into this library's version of that type. + var mapper = BSON_TYPE_MAPPINGS[doc._bsontype]; + if (!mapper) { + throw new error_1.BSONTypeError('Unrecognized or invalid _bsontype: ' + doc._bsontype); + } + outDoc = mapper(outDoc); + } + // Two BSON types may have nested objects that may need to be serialized too + if (bsontype === 'Code' && outDoc.scope) { + outDoc = new code_1.Code(outDoc.code, serializeValue(outDoc.scope, options)); + } + else if (bsontype === 'DBRef' && outDoc.oid) { + outDoc = new db_ref_1.DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options)); + } + return outDoc.toExtendedJSON(options); + } + else { + throw new error_1.BSONError('_bsontype must be a string, but was: ' + typeof bsontype); + } +} +/** + * EJSON parse / stringify API + * @public + */ +// the namespace here is used to emulate `export * as EJSON from '...'` +// which as of now (sept 2020) api-extractor does not support +// eslint-disable-next-line @typescript-eslint/no-namespace +var EJSON; +(function (EJSON) { + /** + * Parse an Extended JSON string, constructing the JavaScript value or object described by that + * string. + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const text = '{ "int32": { "$numberInt": "10" } }'; + * + * // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } } + * console.log(EJSON.parse(text, { relaxed: false })); + * + * // prints { int32: 10 } + * console.log(EJSON.parse(text)); + * ``` + */ + function parse(text, options) { + var finalOptions = Object.assign({}, { relaxed: true, legacy: false }, options); + // relaxed implies not strict + if (typeof finalOptions.relaxed === 'boolean') + finalOptions.strict = !finalOptions.relaxed; + if (typeof finalOptions.strict === 'boolean') + finalOptions.relaxed = !finalOptions.strict; + return JSON.parse(text, function (key, value) { + if (key.indexOf('\x00') !== -1) { + throw new error_1.BSONError("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(key))); + } + return deserializeValue(value, finalOptions); + }); + } + EJSON.parse = parse; + /** + * Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer + * function is specified or optionally including only the specified properties if a replacer array + * is specified. + * + * @param value - The value to convert to extended JSON + * @param replacer - A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string + * @param space - A String or Number object that's used to insert white space into the output JSON string for readability purposes. + * @param options - Optional settings + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const Int32 = require('mongodb').Int32; + * const doc = { int32: new Int32(10) }; + * + * // prints '{"int32":{"$numberInt":"10"}}' + * console.log(EJSON.stringify(doc, { relaxed: false })); + * + * // prints '{"int32":10}' + * console.log(EJSON.stringify(doc)); + * ``` + */ + function stringify(value, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + replacer, space, options) { + if (space != null && typeof space === 'object') { + options = space; + space = 0; + } + if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) { + options = replacer; + replacer = undefined; + space = 0; + } + var serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, { + seenObjects: [{ propertyName: '(root)', obj: null }] + }); + var doc = serializeValue(value, serializeOptions); + return JSON.stringify(doc, replacer, space); + } + EJSON.stringify = stringify; + /** + * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object. + * + * @param value - The object to serialize + * @param options - Optional settings passed to the `stringify` function + */ + function serialize(value, options) { + options = options || {}; + return JSON.parse(stringify(value, options)); + } + EJSON.serialize = serialize; + /** + * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types + * + * @param ejson - The Extended JSON object to deserialize + * @param options - Optional settings passed to the parse method + */ + function deserialize(ejson, options) { + options = options || {}; + return parse(JSON.stringify(ejson), options); + } + EJSON.deserialize = deserialize; +})(EJSON = exports.EJSON || (exports.EJSON = {})); +//# sourceMappingURL=extended_json.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/extended_json.js.map b/node_modules/bson/lib/extended_json.js.map new file mode 100644 index 0000000..d123c0e --- /dev/null +++ b/node_modules/bson/lib/extended_json.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extended_json.js","sourceRoot":"","sources":["../src/extended_json.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAElC,+BAA8B;AAC9B,mCAA8C;AAC9C,2CAA0C;AAC1C,mCAAkC;AAClC,iCAAmD;AACnD,mCAAiC;AACjC,+BAA8B;AAC9B,qCAAmC;AACnC,qCAAmC;AACnC,uCAAsC;AACtC,wCAAgE;AAChE,mCAAsC;AACtC,mCAAsC;AACtC,yCAAwC;AAqBxC,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,CAC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ACD,IAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE;YAChF,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;SACrD,CAAC,CAAC;QAEH,IAAM,GAAG,GAAG,cAAc,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,QAA4C,EAAE,KAAK,CAAC,CAAC;IAClF,CAAC;IAtBe,eAAS,YAsBxB,CAAA;IAED;;;;;OAKG;IACH,SAAgB,SAAS,CAAC,KAAwB,EAAE,OAAuB;QACzE,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,CAAC;IAHe,eAAS,YAGxB,CAAA;IAED;;;;;OAKG;IACH,SAAgB,WAAW,CAAC,KAAe,EAAE,OAAuB;QAClE,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAHe,iBAAW,cAG1B,CAAA;AACH,CAAC,EArHgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAqHrB"} \ No newline at end of file diff --git a/node_modules/bson/lib/int_32.js b/node_modules/bson/lib/int_32.js new file mode 100644 index 0000000..e862255 --- /dev/null +++ b/node_modules/bson/lib/int_32.js @@ -0,0 +1,58 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Int32 = void 0; +/** + * A class representation of a BSON Int32 type. + * @public + * @category BSONType + */ +var Int32 = /** @class */ (function () { + /** + * Create an Int32 type + * + * @param value - the number we want to represent as an int32. + */ + function Int32(value) { + if (!(this instanceof Int32)) + return new Int32(value); + if (value instanceof Number) { + value = value.valueOf(); + } + this.value = +value | 0; + } + /** + * Access the number value. + * + * @returns returns the wrapped int32 number. + */ + Int32.prototype.valueOf = function () { + return this.value; + }; + Int32.prototype.toString = function (radix) { + return this.value.toString(radix); + }; + Int32.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + Int32.prototype.toExtendedJSON = function (options) { + if (options && (options.relaxed || options.legacy)) + return this.value; + return { $numberInt: this.value.toString() }; + }; + /** @internal */ + Int32.fromExtendedJSON = function (doc, options) { + return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new Int32(doc.$numberInt); + }; + /** @internal */ + Int32.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Int32.prototype.inspect = function () { + return "new Int32(".concat(this.valueOf(), ")"); + }; + return Int32; +}()); +exports.Int32 = Int32; +Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' }); +//# sourceMappingURL=int_32.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/int_32.js.map b/node_modules/bson/lib/int_32.js.map new file mode 100644 index 0000000..f55ab85 --- /dev/null +++ b/node_modules/bson/lib/int_32.js.map @@ -0,0 +1 @@ +{"version":3,"file":"int_32.js","sourceRoot":"","sources":["../src/int_32.ts"],"names":[],"mappings":";;;AAOA;;;;GAIG;AACH;IAIE;;;;OAIG;IACH,eAAY,KAAsB;QAChC,IAAI,CAAC,CAAC,IAAI,YAAY,KAAK,CAAC;YAAE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;QAEtD,IAAK,KAAiB,YAAY,MAAM,EAAE;YACxC,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;SACzB;QAED,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,uBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,wBAAQ,GAAR,UAAS,KAAc;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,sBAAM,GAAN;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,gBAAgB;IAChB,8BAAc,GAAd,UAAe,OAAsB;QACnC,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC;QACtE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED,gBAAgB;IACT,sBAAgB,GAAvB,UAAwB,GAAkB,EAAE,OAAsB;QAChE,OAAO,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/F,CAAC;IAED,gBAAgB;IAChB,gBAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,GAA1C;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,uBAAO,GAAP;QACE,OAAO,oBAAa,IAAI,CAAC,OAAO,EAAE,MAAG,CAAC;IACxC,CAAC;IACH,YAAC;AAAD,CAAC,AAvDD,IAuDC;AAvDY,sBAAK;AAyDlB,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/long.js b/node_modules/bson/lib/long.js new file mode 100644 index 0000000..ec7aaec --- /dev/null +++ b/node_modules/bson/lib/long.js @@ -0,0 +1,900 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Long = void 0; +var utils_1 = require("./parser/utils"); +/** + * wasm optimizations, to do native i64 multiplication and divide + */ +var wasm = undefined; +try { + wasm = new WebAssembly.Instance(new WebAssembly.Module( + // prettier-ignore + new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports; +} +catch (_a) { + // no wasm support +} +var TWO_PWR_16_DBL = 1 << 16; +var TWO_PWR_24_DBL = 1 << 24; +var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL; +var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL; +var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2; +/** A cache of the Long representations of small integer values. */ +var INT_CACHE = {}; +/** A cache of the Long representations of small unsigned integer values. */ +var UINT_CACHE = {}; +/** + * A class representing a 64-bit integer + * @public + * @category BSONType + * @remarks + * 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. + * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class. + */ +var Long = /** @class */ (function () { + /** + * 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. + * + * Acceptable signatures are: + * - Long(low, high, unsigned?) + * - Long(bigint, unsigned?) + * - Long(string, unsigned?) + * + * @param low - The low (signed) 32 bits of the long + * @param high - The high (signed) 32 bits of the long + * @param unsigned - Whether unsigned or not, defaults to signed + */ + function Long(low, high, unsigned) { + if (low === void 0) { low = 0; } + if (!(this instanceof Long)) + return new Long(low, high, unsigned); + if (typeof low === 'bigint') { + Object.assign(this, Long.fromBigInt(low, !!high)); + } + else if (typeof low === 'string') { + Object.assign(this, Long.fromString(low, !!high)); + } + else { + this.low = low | 0; + this.high = high | 0; + this.unsigned = !!unsigned; + } + Object.defineProperty(this, '__isLong__', { + value: true, + configurable: false, + writable: false, + enumerable: false + }); + } + /** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. + * Each is assumed to use 32 bits. + * @param lowBits - The low 32 bits + * @param highBits - The high 32 bits + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBits = function (lowBits, highBits, unsigned) { + return new Long(lowBits, highBits, unsigned); + }; + /** + * Returns a Long representing the given 32 bit integer value. + * @param value - The 32 bit integer in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromInt = function (value, unsigned) { + var obj, cachedObj, cache; + if (unsigned) { + value >>>= 0; + if ((cache = 0 <= value && value < 256)) { + cachedObj = UINT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true); + if (cache) + UINT_CACHE[value] = obj; + return obj; + } + else { + value |= 0; + if ((cache = -128 <= value && value < 128)) { + cachedObj = INT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, value < 0 ? -1 : 0, false); + if (cache) + INT_CACHE[value] = obj; + return obj; + } + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromNumber = function (value, unsigned) { + if (isNaN(value)) + return unsigned ? Long.UZERO : Long.ZERO; + if (unsigned) { + if (value < 0) + return Long.UZERO; + if (value >= TWO_PWR_64_DBL) + return Long.MAX_UNSIGNED_VALUE; + } + else { + if (value <= -TWO_PWR_63_DBL) + return Long.MIN_VALUE; + if (value + 1 >= TWO_PWR_63_DBL) + return Long.MAX_VALUE; + } + if (value < 0) + return Long.fromNumber(-value, unsigned).neg(); + return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned); + }; + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBigInt = function (value, unsigned) { + return Long.fromString(value.toString(), unsigned); + }; + /** + * Returns a Long representation of the given string, written using the specified radix. + * @param str - The textual representation of the Long + * @param unsigned - Whether unsigned or not, defaults to signed + * @param radix - The radix in which the text is written (2-36), defaults to 10 + * @returns The corresponding Long value + */ + Long.fromString = function (str, unsigned, radix) { + if (str.length === 0) + throw Error('empty string'); + if (str === 'NaN' || str === 'Infinity' || str === '+Infinity' || str === '-Infinity') + return Long.ZERO; + if (typeof unsigned === 'number') { + // For goog.math.long compatibility + (radix = unsigned), (unsigned = false); + } + else { + unsigned = !!unsigned; + } + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + var p; + if ((p = str.indexOf('-')) > 0) + throw Error('interior hyphen'); + else if (p === 0) { + return Long.fromString(str.substring(1), unsigned, radix).neg(); + } + // 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), value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Long.fromNumber(Math.pow(radix, size)); + result = result.mul(power).add(Long.fromNumber(value)); + } + else { + result = result.mul(radixToPower); + result = result.add(Long.fromNumber(value)); + } + } + result.unsigned = unsigned; + return result; + }; + /** + * Creates a Long from its byte representation. + * @param bytes - Byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @param le - Whether little or big endian, defaults to big endian + * @returns The corresponding Long value + */ + Long.fromBytes = function (bytes, unsigned, le) { + return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned); + }; + /** + * Creates a Long from its little endian byte representation. + * @param bytes - Little endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesLE = function (bytes, unsigned) { + return new Long(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24), bytes[4] | (bytes[5] << 8) | (bytes[6] << 16) | (bytes[7] << 24), unsigned); + }; + /** + * Creates a Long from its big endian byte representation. + * @param bytes - Big endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + Long.fromBytesBE = function (bytes, unsigned) { + return new Long((bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7], (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3], unsigned); + }; + /** + * Tests if the specified object is a Long. + */ + Long.isLong = function (value) { + return (0, utils_1.isObjectLike)(value) && value['__isLong__'] === true; + }; + /** + * Converts the specified value to a Long. + * @param unsigned - Whether unsigned or not, defaults to signed + */ + Long.fromValue = function (val, unsigned) { + if (typeof val === 'number') + return Long.fromNumber(val, unsigned); + if (typeof val === 'string') + return Long.fromString(val, unsigned); + // Throws for non-objects, converts non-instanceof Long: + return Long.fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned); + }; + /** Returns the sum of this and the specified Long. */ + Long.prototype.add = function (addend) { + if (!Long.isLong(addend)) + addend = Long.fromValue(addend); + // 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 = addend.high >>> 16; + var b32 = addend.high & 0xffff; + var b16 = addend.low >>> 16; + var b00 = addend.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, this.unsigned); + }; + /** + * Returns the sum of this and the specified Long. + * @returns Sum + */ + Long.prototype.and = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); + }; + /** + * Compares this Long's value with the specified's. + * @returns 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 (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.eq(other)) + return 0; + var thisNeg = this.isNegative(), otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) + return -1; + if (!thisNeg && otherNeg) + return 1; + // At this point the sign bits are the same + if (!this.unsigned) + return this.sub(other).isNegative() ? -1 : 1; + // Both are positive if at least one is unsigned + return other.high >>> 0 > this.high >>> 0 || + (other.high === this.high && other.low >>> 0 > this.low >>> 0) + ? -1 + : 1; + }; + /** This is an alias of {@link Long.compare} */ + Long.prototype.comp = function (other) { + return this.compare(other); + }; + /** + * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned. + * @returns Quotient + */ + Long.prototype.divide = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + if (divisor.isZero()) + throw Error('division by zero'); + // use wasm support if present + if (wasm) { + // guard against signed division overflow: the largest + // negative number / -1 would be 1 larger than the largest + // positive number, due to two's complement. + if (!this.unsigned && + this.high === -0x80000000 && + divisor.low === -1 && + divisor.high === -1) { + // be consistent with non-wasm code path + return this; + } + var low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (this.isZero()) + return this.unsigned ? Long.UZERO : Long.ZERO; + var approx, rem, res; + if (!this.unsigned) { + // This section is only relevant for signed longs and is derived from the + // closure library as a whole. + if (this.eq(Long.MIN_VALUE)) { + if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE)) + return Long.MIN_VALUE; + // recall that -MIN_VALUE == MIN_VALUE + else if (divisor.eq(Long.MIN_VALUE)) + return Long.ONE; + else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shr(1); + approx = halfThis.div(divisor).shl(1); + if (approx.eq(Long.ZERO)) { + return divisor.isNegative() ? Long.ONE : Long.NEG_ONE; + } + else { + rem = this.sub(divisor.mul(approx)); + res = approx.add(rem.div(divisor)); + return res; + } + } + } + else if (divisor.eq(Long.MIN_VALUE)) + return this.unsigned ? Long.UZERO : Long.ZERO; + if (this.isNegative()) { + if (divisor.isNegative()) + return this.neg().div(divisor.neg()); + return this.neg().div(divisor).neg(); + } + else if (divisor.isNegative()) + return this.div(divisor.neg()).neg(); + res = Long.ZERO; + } + else { + // The algorithm below has not been made for unsigned longs. It's therefore + // required to take special care of the MSB prior to running it. + if (!divisor.unsigned) + divisor = divisor.toUnsigned(); + if (divisor.gt(this)) + return Long.UZERO; + if (divisor.gt(this.shru(1))) + // 15 >>> 1 = 7 ; with divisor = 8 ; true + return Long.UONE; + res = Long.UZERO; + } + // 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. + // eslint-disable-next-line @typescript-eslint/no-this-alias + rem = this; + while (rem.gte(divisor)) { + // 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() / divisor.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.mul(divisor); + while (approxRem.isNegative() || approxRem.gt(rem)) { + approx -= delta; + approxRes = Long.fromNumber(approx, this.unsigned); + approxRem = approxRes.mul(divisor); + } + // 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.sub(approxRem); + } + return res; + }; + /**This is an alias of {@link Long.divide} */ + Long.prototype.div = function (divisor) { + return this.divide(divisor); + }; + /** + * Tests if this Long's value equals the specified's. + * @param other - Other value + */ + Long.prototype.equals = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1) + return false; + return this.high === other.high && this.low === other.low; + }; + /** This is an alias of {@link Long.equals} */ + Long.prototype.eq = function (other) { + return this.equals(other); + }; + /** Gets the high 32 bits as a signed integer. */ + Long.prototype.getHighBits = function () { + return this.high; + }; + /** Gets the high 32 bits as an unsigned integer. */ + Long.prototype.getHighBitsUnsigned = function () { + return this.high >>> 0; + }; + /** Gets the low 32 bits as a signed integer. */ + Long.prototype.getLowBits = function () { + return this.low; + }; + /** Gets the low 32 bits as an unsigned integer. */ + Long.prototype.getLowBitsUnsigned = function () { + return this.low >>> 0; + }; + /** Gets the number of bits needed to represent the absolute value of this Long. */ + Long.prototype.getNumBitsAbs = function () { + if (this.isNegative()) { + // Unsigned Longs are never negative + return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); + } + var val = this.high !== 0 ? this.high : this.low; + var bit; + for (bit = 31; bit > 0; bit--) + if ((val & (1 << bit)) !== 0) + break; + return this.high !== 0 ? bit + 33 : bit + 1; + }; + /** Tests if this Long's value is greater than the specified's. */ + Long.prototype.greaterThan = function (other) { + return this.comp(other) > 0; + }; + /** This is an alias of {@link Long.greaterThan} */ + Long.prototype.gt = function (other) { + return this.greaterThan(other); + }; + /** Tests if this Long's value is greater than or equal the specified's. */ + Long.prototype.greaterThanOrEqual = function (other) { + return this.comp(other) >= 0; + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.gte = function (other) { + return this.greaterThanOrEqual(other); + }; + /** This is an alias of {@link Long.greaterThanOrEqual} */ + Long.prototype.ge = function (other) { + return this.greaterThanOrEqual(other); + }; + /** Tests if this Long's value is even. */ + Long.prototype.isEven = function () { + return (this.low & 1) === 0; + }; + /** Tests if this Long's value is negative. */ + Long.prototype.isNegative = function () { + return !this.unsigned && this.high < 0; + }; + /** Tests if this Long's value is odd. */ + Long.prototype.isOdd = function () { + return (this.low & 1) === 1; + }; + /** Tests if this Long's value is positive. */ + Long.prototype.isPositive = function () { + return this.unsigned || this.high >= 0; + }; + /** Tests if this Long's value equals zero. */ + Long.prototype.isZero = function () { + return this.high === 0 && this.low === 0; + }; + /** Tests if this Long's value is less than the specified's. */ + Long.prototype.lessThan = function (other) { + return this.comp(other) < 0; + }; + /** This is an alias of {@link Long#lessThan}. */ + Long.prototype.lt = function (other) { + return this.lessThan(other); + }; + /** Tests if this Long's value is less than or equal the specified's. */ + Long.prototype.lessThanOrEqual = function (other) { + return this.comp(other) <= 0; + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.lte = function (other) { + return this.lessThanOrEqual(other); + }; + /** Returns this Long modulo the specified. */ + Long.prototype.modulo = function (divisor) { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + // use wasm support if present + if (wasm) { + var low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + return this.sub(this.div(divisor).mul(divisor)); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.mod = function (divisor) { + return this.modulo(divisor); + }; + /** This is an alias of {@link Long.modulo} */ + Long.prototype.rem = function (divisor) { + return this.modulo(divisor); + }; + /** + * Returns the product of this and the specified Long. + * @param multiplier - Multiplier + * @returns Product + */ + Long.prototype.multiply = function (multiplier) { + if (this.isZero()) + return Long.ZERO; + if (!Long.isLong(multiplier)) + multiplier = Long.fromValue(multiplier); + // use wasm support if present + if (wasm) { + var low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + if (multiplier.isZero()) + return Long.ZERO; + if (this.eq(Long.MIN_VALUE)) + return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (multiplier.eq(Long.MIN_VALUE)) + return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (this.isNegative()) { + if (multiplier.isNegative()) + return this.neg().mul(multiplier.neg()); + else + return this.neg().mul(multiplier).neg(); + } + else if (multiplier.isNegative()) + return this.mul(multiplier.neg()).neg(); + // If both longs are small, use float multiplication + if (this.lt(Long.TWO_PWR_24) && multiplier.lt(Long.TWO_PWR_24)) + return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); + // 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 = multiplier.high >>> 16; + var b32 = multiplier.high & 0xffff; + var b16 = multiplier.low >>> 16; + var b00 = multiplier.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, this.unsigned); + }; + /** This is an alias of {@link Long.multiply} */ + Long.prototype.mul = function (multiplier) { + return this.multiply(multiplier); + }; + /** Returns the Negation of this Long's value. */ + Long.prototype.negate = function () { + if (!this.unsigned && this.eq(Long.MIN_VALUE)) + return Long.MIN_VALUE; + return this.not().add(Long.ONE); + }; + /** This is an alias of {@link Long.negate} */ + Long.prototype.neg = function () { + return this.negate(); + }; + /** Returns the bitwise NOT of this Long. */ + Long.prototype.not = function () { + return Long.fromBits(~this.low, ~this.high, this.unsigned); + }; + /** Tests if this Long's value differs from the specified's. */ + Long.prototype.notEquals = function (other) { + return !this.equals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.neq = function (other) { + return this.notEquals(other); + }; + /** This is an alias of {@link Long.notEquals} */ + Long.prototype.ne = function (other) { + return this.notEquals(other); + }; + /** + * Returns the bitwise OR of this Long and the specified. + */ + Long.prototype.or = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); + }; + /** + * Returns this Long with bits shifted to the left by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftLeft = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); + else + return Long.fromBits(0, this.low << (numBits - 32), this.unsigned); + }; + /** This is an alias of {@link Long.shiftLeft} */ + Long.prototype.shl = function (numBits) { + return this.shiftLeft(numBits); + }; + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRight = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); + else + return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); + }; + /** This is an alias of {@link Long.shiftRight} */ + Long.prototype.shr = function (numBits) { + return this.shiftRight(numBits); + }; + /** + * Returns this Long with bits logically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + Long.prototype.shiftRightUnsigned = function (numBits) { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + 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, this.unsigned); + } + else if (numBits === 32) + return Long.fromBits(high, 0, this.unsigned); + else + return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned); + } + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shr_u = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** This is an alias of {@link Long.shiftRightUnsigned} */ + Long.prototype.shru = function (numBits) { + return this.shiftRightUnsigned(numBits); + }; + /** + * Returns the difference of this and the specified Long. + * @param subtrahend - Subtrahend + * @returns Difference + */ + Long.prototype.subtract = function (subtrahend) { + if (!Long.isLong(subtrahend)) + subtrahend = Long.fromValue(subtrahend); + return this.add(subtrahend.neg()); + }; + /** This is an alias of {@link Long.subtract} */ + Long.prototype.sub = function (subtrahend) { + return this.subtract(subtrahend); + }; + /** Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. */ + Long.prototype.toInt = function () { + return this.unsigned ? this.low >>> 0 : this.low; + }; + /** Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). */ + Long.prototype.toNumber = function () { + if (this.unsigned) + return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0); + return this.high * TWO_PWR_32_DBL + (this.low >>> 0); + }; + /** Converts the Long to a BigInt (arbitrary precision). */ + Long.prototype.toBigInt = function () { + return BigInt(this.toString()); + }; + /** + * Converts this Long to its byte representation. + * @param le - Whether little or big endian, defaults to big endian + * @returns Byte representation + */ + Long.prototype.toBytes = function (le) { + return le ? this.toBytesLE() : this.toBytesBE(); + }; + /** + * Converts this Long to its little endian byte representation. + * @returns Little endian byte representation + */ + Long.prototype.toBytesLE = function () { + var hi = this.high, lo = this.low; + return [ + lo & 0xff, + (lo >>> 8) & 0xff, + (lo >>> 16) & 0xff, + lo >>> 24, + hi & 0xff, + (hi >>> 8) & 0xff, + (hi >>> 16) & 0xff, + hi >>> 24 + ]; + }; + /** + * Converts this Long to its big endian byte representation. + * @returns Big endian byte representation + */ + Long.prototype.toBytesBE = function () { + var hi = this.high, lo = this.low; + return [ + hi >>> 24, + (hi >>> 16) & 0xff, + (hi >>> 8) & 0xff, + hi & 0xff, + lo >>> 24, + (lo >>> 16) & 0xff, + (lo >>> 8) & 0xff, + lo & 0xff + ]; + }; + /** + * Converts this Long to signed. + */ + Long.prototype.toSigned = function () { + if (!this.unsigned) + return this; + return Long.fromBits(this.low, this.high, false); + }; + /** + * Converts the Long to a string written in the specified radix. + * @param radix - Radix (2-36), defaults to 10 + * @throws RangeError If `radix` is out of range + */ + Long.prototype.toString = function (radix) { + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + if (this.isZero()) + return '0'; + if (this.isNegative()) { + // Unsigned Longs are never negative + if (this.eq(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), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this); + return div.toString(radix) + rem1.toInt().toString(radix); + } + else + return '-' + this.neg().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), this.unsigned); + // eslint-disable-next-line @typescript-eslint/no-this-alias + var rem = this; + var result = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + var remDiv = rem.div(radixToPower); + var intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0; + var digits = intval.toString(radix); + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } + else { + while (digits.length < 6) + digits = '0' + digits; + result = '' + digits + result; + } + } + }; + /** Converts this Long to unsigned. */ + Long.prototype.toUnsigned = function () { + if (this.unsigned) + return this; + return Long.fromBits(this.low, this.high, true); + }; + /** Returns the bitwise XOR of this Long and the given one. */ + Long.prototype.xor = function (other) { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); + }; + /** This is an alias of {@link Long.isZero} */ + Long.prototype.eqz = function () { + return this.isZero(); + }; + /** This is an alias of {@link Long.lessThanOrEqual} */ + Long.prototype.le = function (other) { + return this.lessThanOrEqual(other); + }; + /* + **************************************************************** + * BSON SPECIFIC ADDITIONS * + **************************************************************** + */ + Long.prototype.toExtendedJSON = function (options) { + if (options && options.relaxed) + return this.toNumber(); + return { $numberLong: this.toString() }; + }; + Long.fromExtendedJSON = function (doc, options) { + var result = Long.fromString(doc.$numberLong); + return options && options.relaxed ? result.toNumber() : result; + }; + /** @internal */ + Long.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Long.prototype.inspect = function () { + return "new Long(\"".concat(this.toString(), "\"").concat(this.unsigned ? ', true' : '', ")"); + }; + Long.TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL); + /** Maximum unsigned value. */ + Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xffffffff | 0, 0xffffffff | 0, true); + /** Signed zero */ + Long.ZERO = Long.fromInt(0); + /** Unsigned zero. */ + Long.UZERO = Long.fromInt(0, true); + /** Signed one. */ + Long.ONE = Long.fromInt(1); + /** Unsigned one. */ + Long.UONE = Long.fromInt(1, true); + /** Signed negative one. */ + Long.NEG_ONE = Long.fromInt(-1); + /** Maximum signed value. */ + Long.MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0, false); + /** Minimum signed value. */ + Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false); + return Long; +}()); +exports.Long = Long; +Object.defineProperty(Long.prototype, '__isLong__', { value: true }); +Object.defineProperty(Long.prototype, '_bsontype', { value: 'Long' }); +//# sourceMappingURL=long.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/long.js.map b/node_modules/bson/lib/long.js.map new file mode 100644 index 0000000..c191742 --- /dev/null +++ b/node_modules/bson/lib/long.js.map @@ -0,0 +1 @@ +{"version":3,"file":"long.js","sourceRoot":"","sources":["../src/long.ts"],"names":[],"mappings":";;;AACA,wCAA8C;AA2C9C;;GAEG;AACH,IAAI,IAAI,GAAgC,SAAS,CAAC;AAMlD,I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,QAAQ,CAAC,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACxE,4BAA4B;IACrB,cAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IA+1B7D,WAAC;CAAA,AAv6BD,IAu6BC;AAv6BY,oBAAI;AAy6BjB,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACrE,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/map.js b/node_modules/bson/lib/map.js new file mode 100644 index 0000000..32334f5 --- /dev/null +++ b/node_modules/bson/lib/map.js @@ -0,0 +1,123 @@ +"use strict"; +/* eslint-disable @typescript-eslint/no-explicit-any */ +// We have an ES6 Map available, return the native instance +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Map = void 0; +var global_1 = require("./utils/global"); +/** @public */ +var bsonMap; +exports.Map = bsonMap; +var bsonGlobal = (0, global_1.getGlobal)(); +if (bsonGlobal.Map) { + exports.Map = bsonMap = bsonGlobal.Map; +} +else { + // We will return a polyfill + exports.Map = bsonMap = /** @class */ (function () { + function Map(array) { + if (array === void 0) { 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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? [key, _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._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 _this = this; + var index = 0; + return { + next: function () { + var key = _this._keys[index++]; + return { + value: key !== undefined ? _this._values[key].v : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + Object.defineProperty(Map.prototype, "size", { + get: function () { + return this._keys.length; + }, + enumerable: false, + configurable: true + }); + return Map; + }()); +} +//# sourceMappingURL=map.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/map.js.map b/node_modules/bson/lib/map.js.map new file mode 100644 index 0000000..944dcf6 --- /dev/null +++ b/node_modules/bson/lib/map.js.map @@ -0,0 +1 @@ +{"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,2DAA2D;;;AAE3D,yCAA2C;AAE3C,cAAc;AACd,IAAI,OAAuB,CAAC;AAgHR,sBAAG;AA9GvB,IAAM,UAAU,GAAG,IAAA,kBAAS,GAA4B,CAAC;AACzD,IAAI,UAAU,CAAC,GAAG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CAAC,CAAC,SAAS;wBAC1D,IAAI,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;qBACvC,CAAC;gBACJ,CAAC;aACF,CAAC;QACJ,CAAC;QACD,sBAAI,qBAAI;iBAAR;gBACE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YAC3B,CAAC;;;WAAA;QACH,UAAC;IAAD,CAAC,AAtGS,GAsGoB,CAAC;CAChC"} \ No newline at end of file diff --git a/node_modules/bson/lib/max_key.js b/node_modules/bson/lib/max_key.js new file mode 100644 index 0000000..f9fd376 --- /dev/null +++ b/node_modules/bson/lib/max_key.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MaxKey = void 0; +/** + * A class representation of the BSON MaxKey type. + * @public + * @category BSONType + */ +var MaxKey = /** @class */ (function () { + function MaxKey() { + if (!(this instanceof MaxKey)) + return new MaxKey(); + } + /** @internal */ + MaxKey.prototype.toExtendedJSON = function () { + return { $maxKey: 1 }; + }; + /** @internal */ + MaxKey.fromExtendedJSON = function () { + return new MaxKey(); + }; + /** @internal */ + MaxKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MaxKey.prototype.inspect = function () { + return 'new MaxKey()'; + }; + return MaxKey; +}()); +exports.MaxKey = MaxKey; +Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' }); +//# sourceMappingURL=max_key.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/max_key.js.map b/node_modules/bson/lib/max_key.js.map new file mode 100644 index 0000000..f85a590 --- /dev/null +++ b/node_modules/bson/lib/max_key.js.map @@ -0,0 +1 @@ +{"version":3,"file":"max_key.js","sourceRoot":"","sources":["../src/max_key.ts"],"names":[],"mappings":";;;AAKA;;;;GAIG;AACH;IAGE;QACE,IAAI,CAAC,CAAC,IAAI,YAAY,MAAM,CAAC;YAAE,OAAO,IAAI,MAAM,EAAE,CAAC;IACrD,CAAC;IAED,gBAAgB;IAChB,+BAAc,GAAd;QACE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,uBAAgB,GAAvB;QACE,OAAO,IAAI,MAAM,EAAE,CAAC;IACtB,CAAC;IAED,gBAAgB;IAChB,iBAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,GAA1C;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,wBAAO,GAAP;QACE,OAAO,cAAc,CAAC;IACxB,CAAC;IACH,aAAC;AAAD,CAAC,AAzBD,IAyBC;AAzBY,wBAAM;AA2BnB,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/min_key.js b/node_modules/bson/lib/min_key.js new file mode 100644 index 0000000..c67b3df --- /dev/null +++ b/node_modules/bson/lib/min_key.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MinKey = void 0; +/** + * A class representation of the BSON MinKey type. + * @public + * @category BSONType + */ +var MinKey = /** @class */ (function () { + function MinKey() { + if (!(this instanceof MinKey)) + return new MinKey(); + } + /** @internal */ + MinKey.prototype.toExtendedJSON = function () { + return { $minKey: 1 }; + }; + /** @internal */ + MinKey.fromExtendedJSON = function () { + return new MinKey(); + }; + /** @internal */ + MinKey.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + MinKey.prototype.inspect = function () { + return 'new MinKey()'; + }; + return MinKey; +}()); +exports.MinKey = MinKey; +Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' }); +//# sourceMappingURL=min_key.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/min_key.js.map b/node_modules/bson/lib/min_key.js.map new file mode 100644 index 0000000..2d642d1 --- /dev/null +++ b/node_modules/bson/lib/min_key.js.map @@ -0,0 +1 @@ +{"version":3,"file":"min_key.js","sourceRoot":"","sources":["../src/min_key.ts"],"names":[],"mappings":";;;AAKA;;;;GAIG;AACH;IAGE;QACE,IAAI,CAAC,CAAC,IAAI,YAAY,MAAM,CAAC;YAAE,OAAO,IAAI,MAAM,EAAE,CAAC;IACrD,CAAC;IAED,gBAAgB;IAChB,+BAAc,GAAd;QACE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,uBAAgB,GAAvB;QACE,OAAO,IAAI,MAAM,EAAE,CAAC;IACtB,CAAC;IAED,gBAAgB;IAChB,iBAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,GAA1C;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,wBAAO,GAAP;QACE,OAAO,cAAc,CAAC;IACxB,CAAC;IACH,aAAC;AAAD,CAAC,AAzBD,IAyBC;AAzBY,wBAAM;AA2BnB,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/objectid.js b/node_modules/bson/lib/objectid.js new file mode 100644 index 0000000..287de6e --- /dev/null +++ b/node_modules/bson/lib/objectid.js @@ -0,0 +1,299 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ObjectId = void 0; +var buffer_1 = require("buffer"); +var ensure_buffer_1 = require("./ensure_buffer"); +var error_1 = require("./error"); +var utils_1 = require("./parser/utils"); +// Regular expression that checks for hex value +var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$'); +// Unique sequence for the current process (initialized on first use) +var PROCESS_UNIQUE = null; +var kId = Symbol('id'); +/** + * A class representation of the BSON ObjectId type. + * @public + * @category BSONType + */ +var ObjectId = /** @class */ (function () { + /** + * Create an ObjectId type + * + * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number. + */ + function ObjectId(inputId) { + if (!(this instanceof ObjectId)) + return new ObjectId(inputId); + // workingId is set based on type of input and whether valid id exists for the input + var workingId; + if (typeof inputId === 'object' && inputId && 'id' in inputId) { + if (typeof inputId.id !== 'string' && !ArrayBuffer.isView(inputId.id)) { + throw new error_1.BSONTypeError('Argument passed in must have an id that is of type string or Buffer'); + } + if ('toHexString' in inputId && typeof inputId.toHexString === 'function') { + workingId = buffer_1.Buffer.from(inputId.toHexString(), 'hex'); + } + else { + workingId = inputId.id; + } + } + else { + workingId = inputId; + } + // the following cases use workingId to construct an ObjectId + if (workingId == null || typeof workingId === 'number') { + // The most common use case (blank id, new objectId instance) + // Generate a new id + this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined); + } + else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) { + // If intstanceof matches we can escape calling ensure buffer in Node.js environments + this[kId] = workingId instanceof buffer_1.Buffer ? workingId : (0, ensure_buffer_1.ensureBuffer)(workingId); + } + else if (typeof workingId === 'string') { + if (workingId.length === 12) { + var bytes = buffer_1.Buffer.from(workingId); + if (bytes.byteLength === 12) { + this[kId] = bytes; + } + else { + throw new error_1.BSONTypeError('Argument passed in must be a string of 12 bytes'); + } + } + else if (workingId.length === 24 && checkForHexRegExp.test(workingId)) { + this[kId] = buffer_1.Buffer.from(workingId, 'hex'); + } + else { + throw new error_1.BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer'); + } + } + else { + throw new error_1.BSONTypeError('Argument passed in does not match the accepted types'); + } + // If we are caching the hex string + if (ObjectId.cacheHexString) { + this.__id = this.id.toString('hex'); + } + } + Object.defineProperty(ObjectId.prototype, "id", { + /** + * The ObjectId bytes + * @readonly + */ + get: function () { + return this[kId]; + }, + set: function (value) { + this[kId] = value; + if (ObjectId.cacheHexString) { + this.__id = value.toString('hex'); + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(ObjectId.prototype, "generationTime", { + /** + * The generation time of this ObjectId instance + * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch + */ + get: function () { + return this.id.readInt32BE(0); + }, + set: function (value) { + // Encode time into first 4 bytes + this.id.writeUInt32BE(value, 0); + }, + enumerable: false, + configurable: true + }); + /** Returns the ObjectId id as a 24 character hex string representation */ + ObjectId.prototype.toHexString = function () { + if (ObjectId.cacheHexString && this.__id) { + return this.__id; + } + var hexString = this.id.toString('hex'); + if (ObjectId.cacheHexString && !this.__id) { + this.__id = hexString; + } + return hexString; + }; + /** + * Update the ObjectId index + * @privateRemarks + * Used in generating new ObjectId's on the driver + * @internal + */ + ObjectId.getInc = function () { + return (ObjectId.index = (ObjectId.index + 1) % 0xffffff); + }; + /** + * Generate a 12 byte id buffer used in ObjectId's + * + * @param time - pass in a second based timestamp. + */ + ObjectId.generate = function (time) { + if ('number' !== typeof time) { + time = Math.floor(Date.now() / 1000); + } + var inc = ObjectId.getInc(); + var buffer = buffer_1.Buffer.alloc(12); + // 4-byte timestamp + buffer.writeUInt32BE(time, 0); + // set PROCESS_UNIQUE if yet not initialized + if (PROCESS_UNIQUE === null) { + PROCESS_UNIQUE = (0, utils_1.randomBytes)(5); + } + // 5-byte process unique + buffer[4] = PROCESS_UNIQUE[0]; + buffer[5] = PROCESS_UNIQUE[1]; + buffer[6] = PROCESS_UNIQUE[2]; + buffer[7] = PROCESS_UNIQUE[3]; + buffer[8] = PROCESS_UNIQUE[4]; + // 3-byte counter + buffer[11] = inc & 0xff; + buffer[10] = (inc >> 8) & 0xff; + buffer[9] = (inc >> 16) & 0xff; + return buffer; + }; + /** + * Converts the id into a 24 character hex string for printing + * + * @param format - The Buffer toString format parameter. + */ + ObjectId.prototype.toString = function (format) { + // Is the id a buffer then use the buffer toString method to return the format + if (format) + return this.id.toString(format); + return this.toHexString(); + }; + /** Converts to its JSON the 24 character hex string representation. */ + ObjectId.prototype.toJSON = function () { + return this.toHexString(); + }; + /** + * Compares the equality of this ObjectId with `otherID`. + * + * @param otherId - ObjectId instance to compare against. + */ + ObjectId.prototype.equals = function (otherId) { + if (otherId === undefined || otherId === null) { + return false; + } + if (otherId instanceof ObjectId) { + return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]); + } + if (typeof otherId === 'string' && + ObjectId.isValid(otherId) && + otherId.length === 12 && + (0, utils_1.isUint8Array)(this.id)) { + return otherId === buffer_1.Buffer.prototype.toString.call(this.id, 'latin1'); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 24) { + return otherId.toLowerCase() === this.toHexString(); + } + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 12) { + return buffer_1.Buffer.from(otherId).equals(this.id); + } + if (typeof otherId === 'object' && + 'toHexString' in otherId && + typeof otherId.toHexString === 'function') { + var otherIdString = otherId.toHexString(); + var thisIdString = this.toHexString().toLowerCase(); + return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString; + } + return false; + }; + /** Returns the generation date (accurate up to the second) that this ID was generated. */ + ObjectId.prototype.getTimestamp = function () { + var timestamp = new Date(); + var time = this.id.readUInt32BE(0); + timestamp.setTime(Math.floor(time) * 1000); + return timestamp; + }; + /** @internal */ + ObjectId.createPk = function () { + 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. + * + * @param time - an integer number representing a number of seconds. + */ + ObjectId.createFromTime = function (time) { + var buffer = buffer_1.Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Encode time into first 4 bytes + buffer.writeUInt32BE(time, 0); + // Return the new objectId + return new ObjectId(buffer); + }; + /** + * Creates an ObjectId from a hex string representation of an ObjectId. + * + * @param hexString - create a ObjectId from a passed in 24 character hexstring. + */ + ObjectId.createFromHexString = function (hexString) { + // Throw an error if it's not a valid setup + if (typeof hexString === 'undefined' || (hexString != null && hexString.length !== 24)) { + throw new error_1.BSONTypeError('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'); + } + return new ObjectId(buffer_1.Buffer.from(hexString, 'hex')); + }; + /** + * Checks if a value is a valid bson ObjectId + * + * @param id - ObjectId instance to validate. + */ + ObjectId.isValid = function (id) { + if (id == null) + return false; + try { + new ObjectId(id); + return true; + } + catch (_a) { + return false; + } + }; + /** @internal */ + ObjectId.prototype.toExtendedJSON = function () { + if (this.toHexString) + return { $oid: this.toHexString() }; + return { $oid: this.toString('hex') }; + }; + /** @internal */ + ObjectId.fromExtendedJSON = function (doc) { + return new ObjectId(doc.$oid); + }; + /** + * Converts to a string representation of this Id. + * + * @returns return the 24 character hex string representation. + * @internal + */ + ObjectId.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + ObjectId.prototype.inspect = function () { + return "new ObjectId(\"".concat(this.toHexString(), "\")"); + }; + /** @internal */ + ObjectId.index = Math.floor(Math.random() * 0xffffff); + return ObjectId; +}()); +exports.ObjectId = ObjectId; +// Deprecated methods +Object.defineProperty(ObjectId.prototype, 'generate', { + value: (0, utils_1.deprecate)(function (time) { return ObjectId.generate(time); }, 'Please use the static `ObjectId.generate(time)` instead') +}); +Object.defineProperty(ObjectId.prototype, 'getInc', { + value: (0, utils_1.deprecate)(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') +}); +Object.defineProperty(ObjectId.prototype, 'get_inc', { + value: (0, utils_1.deprecate)(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') +}); +Object.defineProperty(ObjectId, 'get_inc', { + value: (0, utils_1.deprecate)(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead') +}); +Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' }); +//# sourceMappingURL=objectid.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/objectid.js.map b/node_modules/bson/lib/objectid.js.map new file mode 100644 index 0000000..3238ada --- /dev/null +++ b/node_modules/bson/lib/objectid.js.map @@ -0,0 +1 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,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE;IAClD,KAAK,EAAE,IAAA,iBAAS,EAAC,cAAM,OAAA,QAAQ,CAAC,MAAM,EAAE,EAAjB,CAAiB,EAAE,mDAAmD,CAAC;CAC/F,CAAC,CAAC;AAEH,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE;IACnD,KAAK,EAAE,IAAA,iBAAS,EAAC,cAAM,OAAA,QAAQ,CAAC,MAAM,EAAE,EAAjB,CAAiB,EAAE,mDAAmD,CAAC;CAC/F,CAAC,CAAC;AAEH,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE;IACzC,KAAK,EAAE,IAAA,iBAAS,EAAC,cAAM,OAAA,QAAQ,CAAC,MAAM,EAAE,EAAjB,CAAiB,EAAE,mDAAmD,CAAC;CAC/F,CAAC,CAAC;AAEH,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/parser/calculate_size.js b/node_modules/bson/lib/parser/calculate_size.js new file mode 100644 index 0000000..3d11612 --- /dev/null +++ b/node_modules/bson/lib/parser/calculate_size.js @@ -0,0 +1,194 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.calculateObjectSize = void 0; +var buffer_1 = require("buffer"); +var binary_1 = require("../binary"); +var constants = require("../constants"); +var utils_1 = require("./utils"); +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 (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + object = object.toBSON(); + } + // Calculate size + for (var key in object) { + totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined); + } + } + return totalLength; +} +exports.calculateObjectSize = calculateObjectSize; +/** @internal */ +function calculateElement(name, +// eslint-disable-next-line @typescript-eslint/no-explicit-any +value, serializeFunctions, isArray, ignoreUndefined) { + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (isArray === void 0) { isArray = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = false; } + // If we have toBSON defined, override the current object + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + switch (typeof value) { + case 'string': + return 1 + buffer_1.Buffer.byteLength(name, 'utf8') + 1 + 4 + buffer_1.Buffer.byteLength(value, 'utf8') + 1; + case 'number': + if (Math.floor(value) === value && + value >= constants.JS_INT_MIN && + value <= constants.JS_INT_MAX) { + if (value >= constants.BSON_INT32_MIN && value <= constants.BSON_INT32_MAX) { + // 32 bit + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (4 + 1); + } + else { + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + } + else { + // 64 bit + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + case 'undefined': + if (isArray || !ignoreUndefined) + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + 1; + return 0; + case 'boolean': + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 1); + case 'object': + if (value == null || value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + 1; + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1); + } + else if (value instanceof Date || (0, utils_1.isDate)(value)) { + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + else if (ArrayBuffer.isView(value) || + value instanceof ArrayBuffer || + (0, utils_1.isAnyArrayBuffer)(value)) { + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength); + } + else if (value['_bsontype'] === 'Long' || + value['_bsontype'] === 'Double' || + value['_bsontype'] === 'Timestamp') { + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + else if (value['_bsontype'] === 'Decimal128') { + return (name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1); + } + else if (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_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + buffer_1.Buffer.byteLength(value.code.toString(), 'utf8') + + 1 + + calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined)); + } + else { + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + buffer_1.Buffer.byteLength(value.code.toString(), 'utf8') + + 1); + } + } + else if (value['_bsontype'] === 'Binary') { + var binary = value; + // Check what kind of subtype we have + if (binary.sub_type === binary_1.Binary.SUBTYPE_BYTE_ARRAY) { + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + (binary.position + 1 + 4 + 1 + 4)); + } + else { + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + (binary.position + 1 + 4 + 1)); + } + } + else if (value['_bsontype'] === 'Symbol') { + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + buffer_1.Buffer.byteLength(value.value, 'utf8') + + 4 + + 1 + + 1); + } + else if (value['_bsontype'] === 'DBRef') { + // Set up correct object for serialization + var ordered_values = Object.assign({ + $ref: value.collection, + $id: value.oid + }, value.fields); + // Add db reference if it exists + if (value.db != null) { + ordered_values['$db'] = value.db; + } + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + calculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined)); + } + else if (value instanceof RegExp || (0, utils_1.isRegExp)(value)) { + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.Buffer.byteLength(value.source, 'utf8') + + 1 + + (value.global ? 1 : 0) + + (value.ignoreCase ? 1 : 0) + + (value.multiline ? 1 : 0) + + 1); + } + else if (value['_bsontype'] === 'BSONRegExp') { + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_1.Buffer.byteLength(value.pattern, 'utf8') + + 1 + + buffer_1.Buffer.byteLength(value.options, 'utf8') + + 1); + } + else { + return ((name != null ? buffer_1.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 || (0, utils_1.isRegExp)(value) || String.call(value) === '[object RegExp]') { + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + buffer_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_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + buffer_1.Buffer.byteLength((0, utils_1.normalizedFunctionString)(value), 'utf8') + + 1 + + calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined)); + } + else if (serializeFunctions) { + return ((name != null ? buffer_1.Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + buffer_1.Buffer.byteLength((0, utils_1.normalizedFunctionString)(value), 'utf8') + + 1); + } + } + } + return 0; +} +//# sourceMappingURL=calculate_size.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/parser/calculate_size.js.map b/node_modules/bson/lib/parser/calculate_size.js.map new file mode 100644 index 0000000..f24906c --- /dev/null +++ b/node_modules/bson/lib/parser/calculate_size.js.map @@ -0,0 +1 @@ +{"version":3,"file":"calculate_size.js","sourceRoot":"","sources":["../../src/parser/calculate_size.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,oCAAmC;AAEnC,wCAA0C;AAC1C,iCAAuF;AAEvF,SAAgB,mBAAmB,CACjC,MAAgB,EAChB,kBAA4B,EAC5B,eAAyB;IAEzB,IAAI,WAAW,GAAG,CAAC,GAAG,CAAC,CAAC;IAExB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,WAAW,IAAI,gBAAgB,CAC7B,CAAC,CAAC,QAAQ,EAAE,EACZ,MAAM,CAAC,CAAC,CAAC,EACT,kBAAkB,EAClB,IAAI,EACJ,eAAe,CAChB,CAAC;SACH;KACF;SAAM;QACL,yDAAyD;QAEzD,IAAI,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAA,KAAK,UAAU,EAAE;YACxC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;SAC1B;QAED,iBAAiB;QACjB,KAAK,IAAM,GAAG,IAAI,MAAM,EAAE;YACxB,WAAW,IAAI,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;SAC/F;KACF;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AA/BD,kDA+BC;AAED,gBAAgB;AAChB,SAAS,gBAAgB,CACvB,IAAY;AACZ,8DAA8D;AAC9D,KAAU,EACV,kBAA0B,EAC1B,OAAe,EACf,eAAuB;IAFvB,mCAAA,EAAA,0BAA0B;I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,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBACxD,CAAC;wBACD,CAAC;wBACD,eAAM,CAAC,UAAU,CAAC,IAAA,gCAAwB,EAAC,KAAK,CAAC,EAAE,MAAM,CAAC;wBAC1D,CAAC,CACF,CAAC;iBACH;aACF;KACJ;IAED,OAAO,CAAC,CAAC;AACX,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/parser/deserializer.js b/node_modules/bson/lib/parser/deserializer.js new file mode 100644 index 0000000..57f14a1 --- /dev/null +++ b/node_modules/bson/lib/parser/deserializer.js @@ -0,0 +1,665 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.deserialize = void 0; +var buffer_1 = require("buffer"); +var binary_1 = require("../binary"); +var code_1 = require("../code"); +var constants = require("../constants"); +var db_ref_1 = require("../db_ref"); +var decimal128_1 = require("../decimal128"); +var double_1 = require("../double"); +var error_1 = require("../error"); +var int_32_1 = require("../int_32"); +var long_1 = require("../long"); +var max_key_1 = require("../max_key"); +var min_key_1 = require("../min_key"); +var objectid_1 = require("../objectid"); +var regexp_1 = require("../regexp"); +var symbol_1 = require("../symbol"); +var timestamp_1 = require("../timestamp"); +var validate_utf8_1 = require("../validate_utf8"); +// Internal long versions +var JS_INT_MAX_LONG = long_1.Long.fromNumber(constants.JS_INT_MAX); +var JS_INT_MIN_LONG = long_1.Long.fromNumber(constants.JS_INT_MIN); +var functionCache = {}; +function deserialize(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); + if (size < 5) { + throw new error_1.BSONError("bson size must be >= 5, is ".concat(size)); + } + if (options.allowObjectSmallerThanBufferSize && buffer.length < size) { + throw new error_1.BSONError("buffer length ".concat(buffer.length, " must be >= bson size ").concat(size)); + } + if (!options.allowObjectSmallerThanBufferSize && buffer.length !== size) { + throw new error_1.BSONError("buffer length ".concat(buffer.length, " must === bson size ").concat(size)); + } + if (size + index > buffer.byteLength) { + throw new error_1.BSONError("(bson size ".concat(size, " + options.index ").concat(index, " must be <= buffer length ").concat(buffer.byteLength, ")")); + } + // Illegal end value + if (buffer[index + size - 1] !== 0) { + throw new error_1.BSONError("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00"); + } + // Start deserializtion + return deserializeObject(buffer, index, options, isArray); +} +exports.deserialize = deserialize; +var allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/; +function deserializeObject(buffer, index, options, isArray) { + if (isArray === void 0) { isArray = false; } + var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; + var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions']; + 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']; + // Ensures default validation option if none given + var validation = options.validation == null ? { utf8: true } : options.validation; + // Shows if global utf-8 validation is enabled or disabled + var globalUTFValidation = true; + // Reflects utf-8 validation setting regardless of global or specific key validation + var validationSetting; + // Set of keys either to enable or disable validation on + var utf8KeysSet = new Set(); + // Check for boolean uniformity and empty validation option + var utf8ValidatedKeys = validation.utf8; + if (typeof utf8ValidatedKeys === 'boolean') { + validationSetting = utf8ValidatedKeys; + } + else { + globalUTFValidation = false; + var utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function (key) { + return utf8ValidatedKeys[key]; + }); + if (utf8ValidationValues.length === 0) { + throw new error_1.BSONError('UTF-8 validation setting cannot be empty'); + } + if (typeof utf8ValidationValues[0] !== 'boolean') { + throw new error_1.BSONError('Invalid UTF-8 validation option, must specify boolean values'); + } + validationSetting = utf8ValidationValues[0]; + // Ensures boolean uniformity in utf-8 validation (all true or all false) + if (!utf8ValidationValues.every(function (item) { return item === validationSetting; })) { + throw new error_1.BSONError('Invalid UTF-8 validation option - keys must be all true or all false'); + } + } + // Add keys to set that will either be validated or not based on validationSetting + if (!globalUTFValidation) { + for (var _i = 0, _a = Object.keys(utf8ValidatedKeys); _i < _a.length; _i++) { + var key = _a[_i]; + utf8KeysSet.add(key); + } + } + // Set the start index + var startIndex = index; + // Validate that we have at least 4 bytes of buffer + if (buffer.length < 5) + throw new error_1.BSONError('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_1.BSONError('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; + var isPossibleDBRef = isArray ? false : null; + // While we have more left data left keep parsing + var dataview = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength); + 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.byteLength) + throw new error_1.BSONError('Bad BSON Document: illegal CString'); + // Represents the key + var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i); + // shouldValidateKey is true if the key should be validated, false otherwise + var shouldValidateKey = true; + if (globalUTFValidation || utf8KeysSet.has(name)) { + shouldValidateKey = validationSetting; + } + else { + shouldValidateKey = !validationSetting; + } + if (isPossibleDBRef !== false && name[0] === '$') { + isPossibleDBRef = allowedDBRefKeys.test(name); + } + var value = void 0; + index = i + 1; + if (elementType === constants.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_1.BSONError('bad string length in bson'); + } + value = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + index = index + stringSize; + } + else if (elementType === constants.BSON_DATA_OID) { + var oid = buffer_1.Buffer.alloc(12); + buffer.copy(oid, 0, index, index + 12); + value = new objectid_1.ObjectId(oid); + index = index + 12; + } + else if (elementType === constants.BSON_DATA_INT && promoteValues === false) { + value = new int_32_1.Int32(buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24)); + } + else if (elementType === constants.BSON_DATA_INT) { + value = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + } + else if (elementType === constants.BSON_DATA_NUMBER && promoteValues === false) { + value = new double_1.Double(dataview.getFloat64(index, true)); + index = index + 8; + } + else if (elementType === constants.BSON_DATA_NUMBER) { + value = dataview.getFloat64(index, true); + index = index + 8; + } + else if (elementType === constants.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); + value = new Date(new long_1.Long(lowBits, highBits).toNumber()); + } + else if (elementType === constants.BSON_DATA_BOOLEAN) { + if (buffer[index] !== 0 && buffer[index] !== 1) + throw new error_1.BSONError('illegal boolean type value'); + value = buffer[index++] === 1; + } + else if (elementType === constants.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_1.BSONError('bad embedded document length in bson'); + // We have a raw value + if (raw) { + value = buffer.slice(index, index + objectSize); + } + else { + var objectOptions = options; + if (!globalUTFValidation) { + objectOptions = __assign(__assign({}, options), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, objectOptions, false); + } + index = index + objectSize; + } + else if (elementType === constants.BSON_DATA_ARRAY) { + var _index = index; + var 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; + } + if (!globalUTFValidation) { + arrayOptions = __assign(__assign({}, arrayOptions), { validation: { utf8: shouldValidateKey } }); + } + value = deserializeObject(buffer, _index, arrayOptions, true); + index = index + objectSize; + if (buffer[index - 1] !== 0) + throw new error_1.BSONError('invalid array terminator byte'); + if (index !== stopIndex) + throw new error_1.BSONError('corrupted array bson'); + } + else if (elementType === constants.BSON_DATA_UNDEFINED) { + value = undefined; + } + else if (elementType === constants.BSON_DATA_NULL) { + value = null; + } + else if (elementType === constants.BSON_DATA_LONG) { + // Unpack the low and high bits + 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); + var long = new long_1.Long(lowBits, highBits); + // Promote the long if possible + if (promoteLongs && promoteValues === true) { + value = + long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) + ? long.toNumber() + : long; + } + else { + value = long; + } + } + else if (elementType === constants.BSON_DATA_DECIMAL128) { + // Buffer to contain the decimal bytes + var bytes = buffer_1.Buffer.alloc(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_1.Decimal128(bytes); + // If we have an alternative mapper use that + if ('toObject' in decimal128 && typeof decimal128.toObject === 'function') { + value = decimal128.toObject(); + } + else { + value = decimal128; + } + } + else if (elementType === constants.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_1.BSONError('Negative binary type element size found'); + // Is the length longer than the document + if (binarySize > buffer.byteLength) + throw new error_1.BSONError('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_1.Binary.SUBTYPE_BYTE_ARRAY) { + binarySize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + if (binarySize < 0) + throw new error_1.BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new error_1.BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new error_1.BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + if (promoteBuffers && promoteValues) { + value = buffer.slice(index, index + binarySize); + } + else { + value = new binary_1.Binary(buffer.slice(index, index + binarySize), subType); + if (subType === constants.BSON_BINARY_SUBTYPE_UUID_NEW) { + value = value.toUUID(); + } + } + } + else { + var _buffer = buffer_1.Buffer.alloc(binarySize); + // If we have subtype 2 skip the 4 bytes for the size + if (subType === binary_1.Binary.SUBTYPE_BYTE_ARRAY) { + binarySize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + if (binarySize < 0) + throw new error_1.BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new error_1.BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new error_1.BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + // Copy the data + for (i = 0; i < binarySize; i++) { + _buffer[i] = buffer[index + i]; + } + if (promoteBuffers && promoteValues) { + value = _buffer; + } + else if (subType === constants.BSON_BINARY_SUBTYPE_UUID_NEW) { + value = new binary_1.Binary(buffer.slice(index, index + binarySize), subType).toUUID(); + } + else { + value = new binary_1.Binary(buffer.slice(index, index + binarySize), subType); + } + } + // Update the index + index = index + binarySize; + } + else if (elementType === constants.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_1.BSONError('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_1.BSONError('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; + } + } + value = new RegExp(source, optionsArray.join('')); + } + else if (elementType === constants.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_1.BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var 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_1.BSONError('Bad BSON Document: illegal CString'); + // Return the C string + var regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + // Set the object + value = new regexp_1.BSONRegExp(source, regExpOptions); + } + else if (elementType === constants.BSON_DATA_SYMBOL) { + 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_1.BSONError('bad string length in bson'); + } + var symbol = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + value = promoteValues ? symbol : new symbol_1.BSONSymbol(symbol); + index = index + stringSize; + } + else if (elementType === constants.BSON_DATA_TIMESTAMP) { + 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); + value = new timestamp_1.Timestamp(lowBits, highBits); + } + else if (elementType === constants.BSON_DATA_MIN_KEY) { + value = new min_key_1.MinKey(); + } + else if (elementType === constants.BSON_DATA_MAX_KEY) { + value = new max_key_1.MaxKey(); + } + else if (elementType === constants.BSON_DATA_CODE) { + 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_1.BSONError('bad string length in bson'); + } + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + } + else { + value = new code_1.Code(functionString); + } + // Update parse index position + index = index + stringSize; + } + else if (elementType === constants.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_1.BSONError('code_w_scope total size shorter minimum expected length'); + } + // Get the code string size + var 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_1.BSONError('bad string length in bson'); + } + // Javascript function + var functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + // Update parse index position + index = index + stringSize; + // Parse the element + var _index = index; + // Decode the size of the object document + var 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 too short + if (totalSize < 4 + 4 + objectSize + stringSize) { + throw new error_1.BSONError('code_w_scope total size is too short, truncating scope'); + } + // Check if totalSize field is too long + if (totalSize > 4 + 4 + objectSize + stringSize) { + throw new error_1.BSONError('code_w_scope total size is too 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } + else { + value = isolateEval(functionString); + } + value.scope = scopeObject; + } + else { + value = new code_1.Code(functionString, scopeObject); + } + } + else if (elementType === constants.BSON_DATA_DBPOINTER) { + // Get the code string size + var 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_1.BSONError('bad string length in bson'); + // Namespace + if (validation != null && validation.utf8) { + if (!(0, validate_utf8_1.validateUtf8)(buffer, index, index + stringSize - 1)) { + throw new error_1.BSONError('Invalid UTF-8 string in BSON document'); + } + } + var namespace = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + // Read the oid + var oidBuffer = buffer_1.Buffer.alloc(12); + buffer.copy(oidBuffer, 0, index, index + 12); + var oid = new objectid_1.ObjectId(oidBuffer); + // Update the index + index = index + 12; + // Upgrade to DBRef type + value = new db_ref_1.DBRef(namespace, oid); + } + else { + throw new error_1.BSONError("Detected unknown BSON type ".concat(elementType.toString(16), " for fieldname \"").concat(name, "\"")); + } + if (name === '__proto__') { + Object.defineProperty(object, name, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + else { + object[name] = value; + } + } + // Check if the deserialization was against a valid array/object + if (size !== index - startIndex) { + if (isArray) + throw new error_1.BSONError('corrupt array bson'); + throw new error_1.BSONError('corrupt object bson'); + } + // if we did not find "$ref", "$id", "$db", or found an extraneous $key, don't make a DBRef + if (!isPossibleDBRef) + return object; + if ((0, db_ref_1.isDBRefLike)(object)) { + var copy = Object.assign({}, object); + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new db_ref_1.DBRef(object.$ref, object.$id, object.$db, copy); + } + return object; +} +/** + * Ensure eval is isolated, store the result in functionCache. + * + * @internal + */ +function isolateEval(functionString, functionCache, object) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + if (!functionCache) + return new Function(functionString); + // Check for cache hit, eval if missing and return cached function + if (functionCache[functionString] == null) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + functionCache[functionString] = new Function(functionString); + } + // Set the object + return functionCache[functionString].bind(object); +} +function getValidatedString(buffer, start, end, shouldValidateUtf8) { + var value = buffer.toString('utf8', start, end); + // if utf8 validation is on, do the check + if (shouldValidateUtf8) { + for (var i = 0; i < value.length; i++) { + if (value.charCodeAt(i) === 0xfffd) { + if (!(0, validate_utf8_1.validateUtf8)(buffer, start, end)) { + throw new error_1.BSONError('Invalid UTF-8 string in BSON document'); + } + break; + } + } + } + return value; +} +//# sourceMappingURL=deserializer.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/parser/deserializer.js.map b/node_modules/bson/lib/parser/deserializer.js.map new file mode 100644 index 0000000..fc65ae3 --- /dev/null +++ b/node_modules/bson/lib/parser/deserializer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"deserializer.js","sourceRoot":"","sources":["../../src/parser/deserializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iCAAgC;AAChC,oCAAmC;AAEnC,gCAA+B;AAC/B,wCAA0C;AAC1C,oCAA0D;AAC1D,4CAA2C;AAC3C,oCAAmC;AACnC,kCAAqC;AACrC,oCAAkC;AAClC,gCAA+B;AAC/B,sCAAoC;AACpC,sCAAoC;AACpC,wCAAuC;AACvC,oCAAuC;AACvC,oCAAuC;AACvC,0CAAyC;AACzC,kDAAgD;AAgDhD,yBAAyB;AACzB,IAAM,eAAe,GAAG,WAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAC9D,IAAM,eAAe,GAAG,WAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAE9D,IAAM,aAAa,GAAiC,EAAE,CAAC;AAEvD,SAAgB,WAAW,CACzB,MAAc,EACd,OAA2B,EAC3B,OAAiB;IAEjB,OAAO,GAAG,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IACzC,IAAM,KAAK,GAAG,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,yBAAyB;IACzB,IAAM,IAAI,GACR,MAAM,CAAC,KAAK,CAAC;QACb,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,IA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E;YACrC,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE;gBAClC,IAAI,CAAC,IAAA,4BAAY,EAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE;oBACrC,MAAM,IAAI,iBAAS,CAAC,uCAAuC,CAAC,CAAC;iBAC9D;gBACD,MAAM;aACP;SACF;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/parser/serializer.js b/node_modules/bson/lib/parser/serializer.js new file mode 100644 index 0000000..d99ca96 --- /dev/null +++ b/node_modules/bson/lib/parser/serializer.js @@ -0,0 +1,867 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.serializeInto = void 0; +var binary_1 = require("../binary"); +var constants = require("../constants"); +var ensure_buffer_1 = require("../ensure_buffer"); +var error_1 = require("../error"); +var extended_json_1 = require("../extended_json"); +var long_1 = require("../long"); +var map_1 = require("../map"); +var utils_1 = require("./utils"); +var regexp = /\x00/; // eslint-disable-line no-control-regex +var ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']); +/* + * isArray indicates if we are writing to a BSON array (type 0x04) + * which forces the "key" which really an array index as a string to be written as ascii + * This will catch any errors in index as a string generation + */ +function serializeString(buffer, key, value, index, isArray) { + // Encode String type + buffer[index++] = constants.BSON_DATA_STRING; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes + 1; + buffer[index - 1] = 0; + // Write the string + var size = buffer.write(value, index + 4, undefined, 'utf8'); + // Write the size of the string to buffer + buffer[index + 3] = ((size + 1) >> 24) & 0xff; + buffer[index + 2] = ((size + 1) >> 16) & 0xff; + buffer[index + 1] = ((size + 1) >> 8) & 0xff; + buffer[index] = (size + 1) & 0xff; + // Update index + index = index + 4 + size; + // Write zero + buffer[index++] = 0; + return index; +} +var SPACE_FOR_FLOAT64 = new Uint8Array(8); +var DV_FOR_FLOAT64 = new DataView(SPACE_FOR_FLOAT64.buffer, SPACE_FOR_FLOAT64.byteOffset, SPACE_FOR_FLOAT64.byteLength); +function serializeNumber(buffer, key, value, index, isArray) { + // We have an integer value + // TODO(NODE-2529): Add support for big int + if (Number.isInteger(value) && + value >= constants.BSON_INT32_MIN && + value <= constants.BSON_INT32_MAX) { + // If the value fits in 32 bits encode as int32 + // Set int type 32 bits or less + buffer[index++] = constants.BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + } + else { + // Encode as double + buffer[index++] = constants.BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + } + return index; +} +function serializeNull(buffer, key, _, index, isArray) { + // Set long type + buffer[index++] = constants.BSON_DATA_NULL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +} +function serializeBoolean(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = constants.BSON_DATA_BOOLEAN; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Encode the boolean value + buffer[index++] = value ? 1 : 0; + return index; +} +function serializeDate(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = constants.BSON_DATA_DATE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var dateInMilis = long_1.Long.fromNumber(value.getTime()); + var lowBits = dateInMilis.getLowBits(); + var highBits = dateInMilis.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +} +function serializeRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = constants.BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + if (value.source && value.source.match(regexp) != null) { + throw Error('value ' + value.source + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.source, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the parameters + if (value.ignoreCase) + buffer[index++] = 0x69; // i + if (value.global) + buffer[index++] = 0x73; // s + if (value.multiline) + buffer[index++] = 0x6d; // m + // Add ending zero + buffer[index++] = 0x00; + return index; +} +function serializeBSONRegExp(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = constants.BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Check the pattern for 0 bytes + if (value.pattern.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('pattern ' + value.pattern + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.pattern, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the options + index = index + buffer.write(value.options.split('').sort().join(''), index, undefined, 'utf8'); + // Add ending zero + buffer[index++] = 0x00; + return index; +} +function serializeMinMax(buffer, key, value, index, isArray) { + // Write the type of either min or max key + if (value === null) { + buffer[index++] = constants.BSON_DATA_NULL; + } + else if (value._bsontype === 'MinKey') { + buffer[index++] = constants.BSON_DATA_MIN_KEY; + } + else { + buffer[index++] = constants.BSON_DATA_MAX_KEY; + } + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +} +function serializeObjectId(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = constants.BSON_DATA_OID; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the objectId into the shared buffer + if (typeof value.id === 'string') { + buffer.write(value.id, index, undefined, 'binary'); + } + else if ((0, utils_1.isUint8Array)(value.id)) { + // Use the standard JS methods here because buffer.copy() is buggy with the + // browser polyfill + buffer.set(value.id.subarray(0, 12), index); + } + else { + throw new error_1.BSONTypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId'); + } + // Adjust index + return index + 12; +} +function serializeBuffer(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = constants.BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Get size of the buffer (current write point) + var size = value.length; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the default subtype + buffer[index++] = constants.BSON_BINARY_SUBTYPE_DEFAULT; + // Copy the content form the binary field to the buffer + buffer.set((0, ensure_buffer_1.ensureBuffer)(value), index); + // Adjust the index + index = index + size; + return index; +} +function serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (path === void 0) { path = []; } + for (var i = 0; i < path.length; i++) { + if (path[i] === value) + throw new error_1.BSONError('cyclic dependency detected'); + } + // Push value to stack + path.push(value); + // Write the type + buffer[index++] = Array.isArray(value) ? constants.BSON_DATA_ARRAY : constants.BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var endIndex = serializeInto(buffer, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path); + // Pop stack + path.pop(); + return endIndex; +} +function serializeDecimal128(buffer, key, value, index, isArray) { + buffer[index++] = constants.BSON_DATA_DECIMAL128; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the data from the value + // Prefer the standard JS methods because their typechecking is not buggy, + // unlike the `buffer` polyfill's. + buffer.set(value.bytes.subarray(0, 16), index); + return index + 16; +} +function serializeLong(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = + value._bsontype === 'Long' ? constants.BSON_DATA_LONG : constants.BSON_DATA_TIMESTAMP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var lowBits = value.getLowBits(); + var highBits = value.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +} +function serializeInt32(buffer, key, value, index, isArray) { + value = value.valueOf(); + // Set int type 32 bits or less + buffer[index++] = constants.BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + return index; +} +function serializeDouble(buffer, key, value, index, isArray) { + // Encode as double + buffer[index++] = constants.BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value.value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + return index; +} +function serializeFunction(buffer, key, value, index, _checkKeys, _depth, isArray) { + if (_checkKeys === void 0) { _checkKeys = false; } + if (_depth === void 0) { _depth = 0; } + buffer[index++] = constants.BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = (0, utils_1.normalizedFunctionString)(value); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + return index; +} +function serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray) { + if (checkKeys === void 0) { checkKeys = false; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (isArray === void 0) { isArray = false; } + if (value.scope && typeof value.scope === 'object') { + // Write the type + buffer[index++] = constants.BSON_DATA_CODE_W_SCOPE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Starting index + var startIndex = index; + // Serialize the function + // Get the function string + var functionString = typeof value.code === 'string' ? value.code : value.code.toString(); + // Index adjustment + index = index + 4; + // Write string into buffer + var codeSize = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = codeSize & 0xff; + buffer[index + 1] = (codeSize >> 8) & 0xff; + buffer[index + 2] = (codeSize >> 16) & 0xff; + buffer[index + 3] = (codeSize >> 24) & 0xff; + // Write end 0 + buffer[index + 4 + codeSize - 1] = 0; + // Write the + index = index + codeSize + 4; + // + // Serialize the scope value + var endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined); + index = endIndex - 1; + // Writ the total + var totalSize = endIndex - startIndex; + // Write the total size of the object + buffer[startIndex++] = totalSize & 0xff; + buffer[startIndex++] = (totalSize >> 8) & 0xff; + buffer[startIndex++] = (totalSize >> 16) & 0xff; + buffer[startIndex++] = (totalSize >> 24) & 0xff; + // Write trailing zero + buffer[index++] = 0; + } + else { + buffer[index++] = constants.BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = value.code.toString(); + // Write the string + var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + } + return index; +} +function serializeBinary(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = constants.BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Extract the buffer + var data = value.value(true); + // Calculate size + var size = value.position; + // Add the deprecated 02 type 4 bytes of size to total + if (value.sub_type === binary_1.Binary.SUBTYPE_BYTE_ARRAY) + size = size + 4; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the subtype to the buffer + buffer[index++] = value.sub_type; + // If we have binary type 2 the 4 first bytes are the size + if (value.sub_type === binary_1.Binary.SUBTYPE_BYTE_ARRAY) { + size = size - 4; + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + } + // Write the data to the object + buffer.set(data, index); + // Adjust the index + index = index + value.position; + return index; +} +function serializeSymbol(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = constants.BSON_DATA_SYMBOL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the string + var size = buffer.write(value.value, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0x00; + return index; +} +function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, isArray) { + // Write the type + buffer[index++] = constants.BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var startIndex = index; + var output = { + $ref: value.collection || value.namespace, + $id: value.oid + }; + if (value.db != null) { + output.$db = value.db; + } + output = Object.assign(output, value.fields); + var endIndex = serializeInto(buffer, output, false, index, depth + 1, serializeFunctions); + // Calculate object size + var size = endIndex - startIndex; + // Write the size + buffer[startIndex++] = size & 0xff; + buffer[startIndex++] = (size >> 8) & 0xff; + buffer[startIndex++] = (size >> 16) & 0xff; + buffer[startIndex++] = (size >> 24) & 0xff; + // Set index + return endIndex; +} +function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) { + if (checkKeys === void 0) { checkKeys = false; } + if (startingIndex === void 0) { startingIndex = 0; } + if (depth === void 0) { depth = 0; } + if (serializeFunctions === void 0) { serializeFunctions = false; } + if (ignoreUndefined === void 0) { ignoreUndefined = true; } + if (path === void 0) { path = []; } + startingIndex = startingIndex || 0; + path = path || []; + // Push the object to the path + path.push(object); + // Start place to serialize into + var index = startingIndex + 4; + // Special case isArray + if (Array.isArray(object)) { + // Get object keys + for (var i = 0; i < object.length; i++) { + var key = "".concat(i); + var value = object[i]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + if (typeof value === 'string') { + index = serializeString(buffer, key, value, index, true); + } + else if (typeof value === 'number') { + index = serializeNumber(buffer, key, value, index, true); + } + else if (typeof value === 'bigint') { + throw new error_1.BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (typeof value === 'boolean') { + index = serializeBoolean(buffer, key, value, index, true); + } + else if (value instanceof Date || (0, utils_1.isDate)(value)) { + index = serializeDate(buffer, key, value, index, true); + } + else if (value === undefined) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index, true); + } + else if ((0, utils_1.isUint8Array)(value)) { + index = serializeBuffer(buffer, key, value, index, true); + } + else if (value instanceof RegExp || (0, utils_1.isRegExp)(value)) { + index = serializeRegExp(buffer, key, value, index, true); + } + else if (typeof value === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true, path); + } + else if (typeof value === 'object' && + (0, extended_json_1.isBSONType)(value) && + value._bsontype === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index, true); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, true); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, true); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index, true); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index, true); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new error_1.BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else if (object instanceof map_1.Map || (0, utils_1.isMap)(object)) { + var iterator = object.entries(); + var done = false; + while (!done) { + // Unpack the next entry + var entry = iterator.next(); + done = !!entry.done; + // Are we done, then skip and terminate + if (done) + continue; + // Get the entry values + var key = entry.value[0]; + var value = entry.value[1]; + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint' || (0, utils_1.isBigInt64Array)(value) || (0, utils_1.isBigUInt64Array)(value)) { + throw new error_1.BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || (0, utils_1.isDate)(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === null || (value === undefined && ignoreUndefined === false)) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if ((0, utils_1.isUint8Array)(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || (0, utils_1.isRegExp)(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new error_1.BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + else { + if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') { + // Provided a custom serialization method + object = object.toBSON(); + if (object != null && typeof object !== 'object') { + throw new error_1.BSONTypeError('toBSON function did not return an object'); + } + } + // Iterate over all the keys + for (var key in object) { + var value = object[key]; + // Is there an override value + if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') { + value = value.toBSON(); + } + // Check the type of the value + var type = typeof value; + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } + else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } + else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } + else if (type === 'bigint') { + throw new error_1.BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } + else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } + else if (value instanceof Date || (0, utils_1.isDate)(value)) { + index = serializeDate(buffer, key, value, index); + } + else if (value === undefined) { + if (ignoreUndefined === false) + index = serializeNull(buffer, key, value, index); + } + else if (value === null) { + index = serializeNull(buffer, key, value, index); + } + else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } + else if ((0, utils_1.isUint8Array)(value)) { + index = serializeBuffer(buffer, key, value, index); + } + else if (value instanceof RegExp || (0, utils_1.isRegExp)(value)) { + index = serializeRegExp(buffer, key, value, index); + } + else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } + else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } + else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } + else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } + else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } + else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } + else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + else if (typeof value['_bsontype'] !== 'undefined') { + throw new error_1.BSONTypeError("Unrecognized or invalid _bsontype: ".concat(String(value['_bsontype']))); + } + } + } + // Remove the path + path.pop(); + // Final padding byte for object + buffer[index++] = 0x00; + // Final size + var size = index - startingIndex; + // Write the size of the object + buffer[startingIndex++] = size & 0xff; + buffer[startingIndex++] = (size >> 8) & 0xff; + buffer[startingIndex++] = (size >> 16) & 0xff; + buffer[startingIndex++] = (size >> 24) & 0xff; + return index; +} +exports.serializeInto = serializeInto; +//# sourceMappingURL=serializer.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/parser/serializer.js.map b/node_modules/bson/lib/parser/serializer.js.map new file mode 100644 index 0000000..3261fd4 --- /dev/null +++ b/node_modules/bson/lib/parser/serializer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/parser/serializer.ts"],"names":[],"mappings":";;;AACA,oCAAmC;AAGnC,wCAA0C;AAI1C,kDAAgD;AAChD,kCAAoD;AACpD,kDAA8C;AAE9C,gCAA+B;AAC/B,8BAA6B;AAI7B,iCAQiB;AAgBjB,IAAM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..94e8b5f --- /dev/null +++ b/node_modules/bson/lib/parser/utils.js @@ -0,0 +1,115 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.deprecate = exports.isObjectLike = exports.isDate = exports.haveBuffer = exports.isMap = exports.isRegExp = exports.isBigUInt64Array = exports.isBigInt64Array = exports.isUint8Array = exports.isAnyArrayBuffer = exports.randomBytes = exports.normalizedFunctionString = void 0; +var buffer_1 = require("buffer"); +var global_1 = require("../utils/global"); +/** + * Normalizes our expected stringified form of a function across versions of node + * @param fn - The function to stringify + */ +function normalizedFunctionString(fn) { + return fn.toString().replace('function(', 'function ('); +} +exports.normalizedFunctionString = normalizedFunctionString; +function isReactNative() { + var g = (0, global_1.getGlobal)(); + return typeof g.navigator === 'object' && g.navigator.product === 'ReactNative'; +} +var insecureRandomBytes = function insecureRandomBytes(size) { + var insecureWarning = isReactNative() + ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.' + : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.'; + console.warn(insecureWarning); + var result = buffer_1.Buffer.alloc(size); + for (var i = 0; i < size; ++i) + result[i] = Math.floor(Math.random() * 256); + return result; +}; +var detectRandomBytes = function () { + if (process.browser) { + if (typeof window !== 'undefined') { + // browser crypto implementation(s) + var target_1 = window.crypto || window.msCrypto; // allow for IE11 + if (target_1 && target_1.getRandomValues) { + return function (size) { return target_1.getRandomValues(buffer_1.Buffer.alloc(size)); }; + } + } + if (typeof global !== 'undefined' && global.crypto && global.crypto.getRandomValues) { + // allow for RN packages such as https://www.npmjs.com/package/react-native-get-random-values to populate global + return function (size) { return global.crypto.getRandomValues(buffer_1.Buffer.alloc(size)); }; + } + return insecureRandomBytes; + } + else { + var requiredRandomBytes = void 0; + try { + requiredRandomBytes = require('crypto').randomBytes; + } + catch (e) { + // keep the fallback + } + // NOTE: in transpiled cases the above require might return null/undefined + return requiredRandomBytes || insecureRandomBytes; + } +}; +exports.randomBytes = detectRandomBytes(); +function isAnyArrayBuffer(value) { + return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value)); +} +exports.isAnyArrayBuffer = isAnyArrayBuffer; +function isUint8Array(value) { + return Object.prototype.toString.call(value) === '[object Uint8Array]'; +} +exports.isUint8Array = isUint8Array; +function isBigInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigInt64Array]'; +} +exports.isBigInt64Array = isBigInt64Array; +function isBigUInt64Array(value) { + return Object.prototype.toString.call(value) === '[object BigUint64Array]'; +} +exports.isBigUInt64Array = isBigUInt64Array; +function isRegExp(d) { + return Object.prototype.toString.call(d) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; +function isMap(d) { + return Object.prototype.toString.call(d) === '[object Map]'; +} +exports.isMap = isMap; +/** Call to check if your environment has `Buffer` */ +function haveBuffer() { + return typeof global !== 'undefined' && typeof global.Buffer !== 'undefined'; +} +exports.haveBuffer = haveBuffer; +// To ensure that 0.4 of node works correctly +function isDate(d) { + return isObjectLike(d) && Object.prototype.toString.call(d) === '[object Date]'; +} +exports.isDate = isDate; +/** + * @internal + * this is to solve the `'someKey' in x` problem where x is unknown. + * https://github.com/typescript-eslint/typescript-eslint/issues/1071#issuecomment-541955753 + */ +function isObjectLike(candidate) { + return typeof candidate === 'object' && candidate !== null; +} +exports.isObjectLike = isObjectLike; +function deprecate(fn, message) { + var warned = false; + function deprecated() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!warned) { + console.warn(message); + warned = true; + } + return fn.apply(this, args); + } + return deprecated; +} +exports.deprecate = deprecate; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/parser/utils.js.map b/node_modules/bson/lib/parser/utils.js.map new file mode 100644 index 0000000..6eba4a9 --- /dev/null +++ b/node_modules/bson/lib/parser/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/parser/utils.ts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"} \ No newline at end of file diff --git a/node_modules/bson/lib/regexp.js b/node_modules/bson/lib/regexp.js new file mode 100644 index 0000000..bc1f230 --- /dev/null +++ b/node_modules/bson/lib/regexp.js @@ -0,0 +1,74 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BSONRegExp = void 0; +var error_1 = require("./error"); +function alphabetize(str) { + return str.split('').sort().join(''); +} +/** + * A class representation of the BSON RegExp type. + * @public + * @category BSONType + */ +var BSONRegExp = /** @class */ (function () { + /** + * @param pattern - The regular expression pattern to match + * @param options - The regular expression options + */ + function BSONRegExp(pattern, options) { + if (!(this instanceof BSONRegExp)) + return new BSONRegExp(pattern, options); + this.pattern = pattern; + this.options = alphabetize(options !== null && options !== void 0 ? options : ''); + if (this.pattern.indexOf('\x00') !== -1) { + throw new error_1.BSONError("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern))); + } + if (this.options.indexOf('\x00') !== -1) { + throw new error_1.BSONError("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.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_1.BSONError("The regular expression option [".concat(this.options[i], "] is not supported")); + } + } + } + BSONRegExp.parseOptions = function (options) { + return options ? options.split('').sort().join('') : ''; + }; + /** @internal */ + BSONRegExp.prototype.toExtendedJSON = function (options) { + options = options || {}; + if (options.legacy) { + return { $regex: this.pattern, $options: this.options }; + } + return { $regularExpression: { pattern: this.pattern, options: this.options } }; + }; + /** @internal */ + BSONRegExp.fromExtendedJSON = function (doc) { + if ('$regex' in doc) { + if (typeof doc.$regex !== 'string') { + // This is for $regex query operators that have extended json values. + if (doc.$regex._bsontype === 'BSONRegExp') { + return doc; + } + } + else { + return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options)); + } + } + if ('$regularExpression' in doc) { + return new BSONRegExp(doc.$regularExpression.pattern, BSONRegExp.parseOptions(doc.$regularExpression.options)); + } + throw new error_1.BSONTypeError("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(doc))); + }; + return BSONRegExp; +}()); +exports.BSONRegExp = BSONRegExp; +Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' }); +//# sourceMappingURL=regexp.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/regexp.js.map b/node_modules/bson/lib/regexp.js.map new file mode 100644 index 0000000..1343817 --- /dev/null +++ b/node_modules/bson/lib/regexp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../src/regexp.ts"],"names":[],"mappings":";;;AAAA,iCAAmD;AAGnD,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvC,CAAC;AAgBD;;;;GAIG;AACH;IAKE;;;OAGG;IACH,oBAAY,OAAe,EAAE,OAAgB;QAC3C,IAAI,CAAC,CAAC,IAAI,YAAY,UAAU,CAAC;YAAE,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAE3E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC,CAAC;QAE1C,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;YACvC,MAAM,IAAI,iBAAS,CACjB,gEAAyD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAE,CACxF,CAAC;SACH;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;YACvC,MAAM,IAAI,iBA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AC;IAClF,CAAC;IAED,gBAAgB;IACT,2BAAgB,GAAvB,UAAwB,GAAkD;QACxE,IAAI,QAAQ,IAAI,GAAG,EAAE;YACnB,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAE;gBAClC,qEAAqE;gBACrE,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,YAAY,EAAE;oBACzC,OAAO,GAA4B,CAAC;iBACrC;aACF;iBAAM;gBACL,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC1E;SACF;QACD,IAAI,oBAAoB,IAAI,GAAG,EAAE;YAC/B,OAAO,IAAI,UAAU,CACnB,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAC9B,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,kBAAkB,CAAC,OAAO,CAAC,CACxD,CAAC;SACH;QACD,MAAM,IAAI,qBAAa,CAAC,mDAA4C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC;IAC7F,CAAC;IACH,iBAAC;AAAD,CAAC,AA5ED,IA4EC;AA5EY,gCAAU;AA8EvB,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/symbol.js b/node_modules/bson/lib/symbol.js new file mode 100644 index 0000000..cad9317 --- /dev/null +++ b/node_modules/bson/lib/symbol.js @@ -0,0 +1,48 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BSONSymbol = void 0; +/** + * A class representation of the BSON Symbol type. + * @public + * @category BSONType + */ +var BSONSymbol = /** @class */ (function () { + /** + * @param value - the string representing the symbol. + */ + function BSONSymbol(value) { + if (!(this instanceof BSONSymbol)) + return new BSONSymbol(value); + this.value = value; + } + /** Access the wrapped string value. */ + BSONSymbol.prototype.valueOf = function () { + return this.value; + }; + BSONSymbol.prototype.toString = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.inspect = function () { + return "new BSONSymbol(\"".concat(this.value, "\")"); + }; + BSONSymbol.prototype.toJSON = function () { + return this.value; + }; + /** @internal */ + BSONSymbol.prototype.toExtendedJSON = function () { + return { $symbol: this.value }; + }; + /** @internal */ + BSONSymbol.fromExtendedJSON = function (doc) { + return new BSONSymbol(doc.$symbol); + }; + /** @internal */ + BSONSymbol.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + return BSONSymbol; +}()); +exports.BSONSymbol = BSONSymbol; +Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' }); +//# sourceMappingURL=symbol.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/symbol.js.map b/node_modules/bson/lib/symbol.js.map new file mode 100644 index 0000000..3662444 --- /dev/null +++ b/node_modules/bson/lib/symbol.js.map @@ -0,0 +1 @@ +{"version":3,"file":"symbol.js","sourceRoot":"","sources":["../src/symbol.ts"],"names":[],"mappings":";;;AAKA;;;;GAIG;AACH;IAIE;;OAEG;IACH,oBAAY,KAAa;QACvB,IAAI,CAAC,CAAC,IAAI,YAAY,UAAU,CAAC;YAAE,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;QAEhE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,uCAAuC;IACvC,4BAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,6BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,gBAAgB;IAChB,4BAAO,GAAP;QACE,OAAO,2BAAmB,IAAI,CAAC,KAAK,QAAI,CAAC;IAC3C,CAAC;IAED,2BAAM,GAAN;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,gBAAgB;IAChB,mCAAc,GAAd;QACE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,gBAAgB;IACT,2BAAgB,GAAvB,UAAwB,GAAuB;QAC7C,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,gBAAgB;IAChB,qBAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,GAA1C;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IACH,iBAAC;AAAD,CAAC,AA7CD,IA6CC;AA7CY,gCAAU;AA+CvB,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/bson/lib/timestamp.js b/node_modules/bson/lib/timestamp.js new file mode 100644 index 0000000..a3a8417 --- /dev/null +++ b/node_modules/bson/lib/timestamp.js @@ -0,0 +1,102 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Timestamp = exports.LongWithoutOverridesClass = void 0; +var long_1 = require("./long"); +var utils_1 = require("./parser/utils"); +/** @public */ +exports.LongWithoutOverridesClass = long_1.Long; +/** + * @public + * @category BSONType + * */ +var Timestamp = /** @class */ (function (_super) { + __extends(Timestamp, _super); + function Timestamp(low, high) { + var _this = this; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + if (!(_this instanceof Timestamp)) + return new Timestamp(low, high); + if (long_1.Long.isLong(low)) { + _this = _super.call(this, low.low, low.high, true) || this; + } + else if ((0, utils_1.isObjectLike)(low) && typeof low.t !== 'undefined' && typeof low.i !== 'undefined') { + _this = _super.call(this, low.i, low.t, true) || this; + } + else { + _this = _super.call(this, low, high, true) || this; + } + Object.defineProperty(_this, '_bsontype', { + value: 'Timestamp', + writable: false, + configurable: false, + enumerable: false + }); + return _this; + } + Timestamp.prototype.toJSON = function () { + return { + $timestamp: this.toString() + }; + }; + /** Returns a Timestamp represented by the given (32-bit) integer value. */ + Timestamp.fromInt = function (value) { + return new Timestamp(long_1.Long.fromInt(value, true)); + }; + /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */ + Timestamp.fromNumber = function (value) { + return new Timestamp(long_1.Long.fromNumber(value, true)); + }; + /** + * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits. + * + * @param lowBits - the low 32-bits. + * @param highBits - the high 32-bits. + */ + Timestamp.fromBits = function (lowBits, highBits) { + return new Timestamp(lowBits, highBits); + }; + /** + * Returns a Timestamp from the given string, optionally using the given radix. + * + * @param str - the textual representation of the Timestamp. + * @param optRadix - the radix in which the text is written. + */ + Timestamp.fromString = function (str, optRadix) { + return new Timestamp(long_1.Long.fromString(str, true, optRadix)); + }; + /** @internal */ + Timestamp.prototype.toExtendedJSON = function () { + return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } }; + }; + /** @internal */ + Timestamp.fromExtendedJSON = function (doc) { + return new Timestamp(doc.$timestamp); + }; + /** @internal */ + Timestamp.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () { + return this.inspect(); + }; + Timestamp.prototype.inspect = function () { + return "new Timestamp({ t: ".concat(this.getHighBits(), ", i: ").concat(this.getLowBits(), " })"); + }; + Timestamp.MAX_VALUE = long_1.Long.MAX_UNSIGNED_VALUE; + return Timestamp; +}(exports.LongWithoutOverridesClass)); +exports.Timestamp = Timestamp; +//# sourceMappingURL=timestamp.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/timestamp.js.map b/node_modules/bson/lib/timestamp.js.map new file mode 100644 index 0000000..e1a8bef --- /dev/null +++ b/node_modules/bson/lib/timestamp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../src/timestamp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,wCAA8C;AAQ9C,cAAc;AACD,QAAA,yBAAyB,GACpC,WAAuC,CAAC;AAU1C;;;KAGK;AACL;IAA+B,6BAAyB;IAmBtD,mBAAY,GAA6C,EAAE,IAAa;QAAxE,iBAkBC;QAjBC,6DAA6D;QAC7D,mBAAmB;QACnB,IAAI,CAAC,CAAC,KAAI,YAAY,SAAS,CAAC;YAAE,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAElE,IAAI,WAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACpB,QAAA,kBAAM,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAC;SAChC;aAAM,IAAI,IAAA,oBAAY,EAAC,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,KAAK,WAAW,IAAI,OAAO,GAAG,CAAC,CAAC,KAAK,WAAW,EAAE;YAC5F,QAAA,kBAAM,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAC;SAC3B;aAAM;YACL,QAAA,kBAAM,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,SAAC;SACxB;QACD,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,WAAW,EAAE;YACvC,KAAK,EAAE,WAAW;YAClB,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;;IACL,CAAC;IAED,0BAAM,GAAN;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K,CAAC;IAChF,CAAC;IAzFe,mBAAS,GAAG,WAAI,CAAC,kBAAkB,CAAC;IA0FtD,gBAAC;CAAA,AA7FD,CAA+B,iCAAyB,GA6FvD;AA7FY,8BAAS"} \ No newline at end of file diff --git a/node_modules/bson/lib/utils/global.js b/node_modules/bson/lib/utils/global.js new file mode 100644 index 0000000..f4bf444 --- /dev/null +++ b/node_modules/bson/lib/utils/global.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getGlobal = void 0; +function checkForMath(potentialGlobal) { + // eslint-disable-next-line eqeqeq + return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal; +} +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +function getGlobal() { + return (checkForMath(typeof globalThis === 'object' && globalThis) || + checkForMath(typeof window === 'object' && window) || + checkForMath(typeof self === 'object' && self) || + checkForMath(typeof global === 'object' && global) || + // eslint-disable-next-line @typescript-eslint/no-implied-eval + Function('return this')()); +} +exports.getGlobal = getGlobal; +//# sourceMappingURL=global.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/utils/global.js.map b/node_modules/bson/lib/utils/global.js.map new file mode 100644 index 0000000..9d4ad79 --- /dev/null +++ b/node_modules/bson/lib/utils/global.js.map @@ -0,0 +1 @@ +{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/utils/global.ts"],"names":[],"mappings":";;;AAMA,SAAS,YAAY,CAAC,eAAoB;IACxC,kCAAkC;IAClC,OAAO,eAAe,IAAI,eAAe,CAAC,IAAI,IAAI,IAAI,IAAI,eAAe,CAAC;AAC5E,CAAC;AAED,uEAAuE;AACvE,SAAgB,SAAS;IACvB,OAAO,CACL,YAAY,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC;QAC1D,YAAY,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC;QAClD,YAAY,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC;QAC9C,YAAY,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC;QAClD,8DAA8D;QAC9D,QAAQ,CAAC,aAAa,CAAC,EAAE,CAC1B,CAAC;AACJ,CAAC;AATD,8BASC"} \ No newline at end of file diff --git a/node_modules/bson/lib/uuid_utils.js b/node_modules/bson/lib/uuid_utils.js new file mode 100644 index 0000000..bb1f8b7 --- /dev/null +++ b/node_modules/bson/lib/uuid_utils.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bufferToUuidHexString = exports.uuidHexStringToBuffer = exports.uuidValidateString = void 0; +var buffer_1 = require("buffer"); +var error_1 = require("./error"); +// Validation regex for v4 uuid (validates with or without dashes) +var VALIDATION_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i; +var uuidValidateString = function (str) { + return typeof str === 'string' && VALIDATION_REGEX.test(str); +}; +exports.uuidValidateString = uuidValidateString; +var uuidHexStringToBuffer = function (hexString) { + if (!(0, exports.uuidValidateString)(hexString)) { + throw new error_1.BSONTypeError('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".'); + } + var sanitizedHexString = hexString.replace(/-/g, ''); + return buffer_1.Buffer.from(sanitizedHexString, 'hex'); +}; +exports.uuidHexStringToBuffer = uuidHexStringToBuffer; +var bufferToUuidHexString = function (buffer, includeDashes) { + if (includeDashes === void 0) { includeDashes = true; } + return includeDashes + ? buffer.toString('hex', 0, 4) + + '-' + + buffer.toString('hex', 4, 6) + + '-' + + buffer.toString('hex', 6, 8) + + '-' + + buffer.toString('hex', 8, 10) + + '-' + + buffer.toString('hex', 10, 16) + : buffer.toString('hex'); +}; +exports.bufferToUuidHexString = bufferToUuidHexString; +//# sourceMappingURL=uuid_utils.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/uuid_utils.js.map b/node_modules/bson/lib/uuid_utils.js.map new file mode 100644 index 0000000..f388ec3 --- /dev/null +++ b/node_modules/bson/lib/uuid_utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"uuid_utils.js","sourceRoot":"","sources":["../src/uuid_utils.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,iCAAwC;AAExC,kEAAkE;AAClE,IAAM,gBAAgB,GACpB,uHAAuH,CAAC;AAEnH,IAAM,kBAAkB,GAAG,UAAC,GAAW;IAC5C,OAAA,OAAO,GAAG,KAAK,QAAQ,IAAI,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC;AAArD,CAAqD,CAAC;AAD3C,QAAA,kBAAkB,sBACyB;AAEjD,IAAM,qBAAqB,GAAG,UAAC,SAAiB;IACrD,IAAI,CAAC,IAAA,0BAAkB,EAAC,SAAS,CAAC,EAAE;QAClC,MAAM,IAAI,qBAAa,CACrB,uLAAuL,CACxL,CAAC;KACH;IAED,IAAM,kBAAkB,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACvD,OAAO,eAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC,CAAC;AATW,QAAA,qBAAqB,yBAShC;AAEK,IAAM,qBAAqB,GAAG,UAAC,MAAc,EAAE,aAAoB;IAApB,8BAAA,EAAA,oBAAoB;IACxE,OAAA,aAAa;QACX,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YAC5B,GAAG;YACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YAC5B,GAAG;YACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YAC5B,GAAG;YACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7B,GAAG;YACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAV1B,CAU0B,CAAC;AAXhB,QAAA,qBAAqB,yBAWL"} \ No newline at end of file diff --git a/node_modules/bson/lib/validate_utf8.js b/node_modules/bson/lib/validate_utf8.js new file mode 100644 index 0000000..ec78016 --- /dev/null +++ b/node_modules/bson/lib/validate_utf8.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validateUtf8 = void 0; +var FIRST_BIT = 0x80; +var FIRST_TWO_BITS = 0xc0; +var FIRST_THREE_BITS = 0xe0; +var FIRST_FOUR_BITS = 0xf0; +var FIRST_FIVE_BITS = 0xf8; +var TWO_BIT_CHAR = 0xc0; +var THREE_BIT_CHAR = 0xe0; +var FOUR_BIT_CHAR = 0xf0; +var CONTINUING_CHAR = 0x80; +/** + * Determines if the passed in bytes are valid utf8 + * @param bytes - An array of 8-bit bytes. Must be indexable and have length property + * @param start - The index to start validating + * @param end - The index to end validating + */ +function validateUtf8(bytes, start, end) { + var continuation = 0; + for (var i = start; i < end; i += 1) { + var byte = bytes[i]; + if (continuation) { + if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) { + return false; + } + continuation -= 1; + } + else if (byte & FIRST_BIT) { + if ((byte & FIRST_THREE_BITS) === TWO_BIT_CHAR) { + continuation = 1; + } + else if ((byte & FIRST_FOUR_BITS) === THREE_BIT_CHAR) { + continuation = 2; + } + else if ((byte & FIRST_FIVE_BITS) === FOUR_BIT_CHAR) { + continuation = 3; + } + else { + return false; + } + } + } + return !continuation; +} +exports.validateUtf8 = validateUtf8; +//# sourceMappingURL=validate_utf8.js.map \ No newline at end of file diff --git a/node_modules/bson/lib/validate_utf8.js.map b/node_modules/bson/lib/validate_utf8.js.map new file mode 100644 index 0000000..f1e975b --- /dev/null +++ b/node_modules/bson/lib/validate_utf8.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validate_utf8.js","sourceRoot":"","sources":["../src/validate_utf8.ts"],"names":[],"mappings":";;;AAAA,IAAM,SAAS,GAAG,IAAI,CAAC;AACvB,IAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,IAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,IAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,IAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,IAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,IAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,IAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,IAAM,eAAe,GAAG,IAAI,CAAC;AAE7B;;;;;GAKG;AACH,SAAgB,YAAY,CAC1B,KAAkC,EAClC,KAAa,EACb,GAAW;IAEX,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE;QACnC,IAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEtB,IAAI,YAAY,EAAE;YAChB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,eAAe,EAAE;gBAC/C,OAAO,KAAK,CAAC;aACd;YACD,YAAY,IAAI,CAAC,CAAC;SACnB;aAAM,IAAI,IAAI,GAAG,SAAS,EAAE;YAC3B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,KAAK,YAAY,EAAE;gBAC9C,YAAY,GAAG,CAAC,CAAC;aAClB;iBAAM,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,KAAK,cAAc,EAAE;gBACtD,YAAY,GAAG,CAAC,CAAC;aAClB;iBAAM,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,KAAK,aAAa,EAAE;gBACrD,YAAY,GAAG,CAAC,CAAC;aAClB;iBAAM;gBACL,OAAO,KAAK,CAAC;aACd;SACF;KACF;IAED,OAAO,CAAC,YAAY,CAAC;AACvB,CAAC;AA7BD,oCA6BC"} \ No newline at end of file diff --git a/node_modules/bson/package.json b/node_modules/bson/package.json new file mode 100644 index 0000000..983159d --- /dev/null +++ b/node_modules/bson/package.json @@ -0,0 +1,116 @@ +{ + "name": "bson", + "description": "A bson parser for node.js and the browser", + "keywords": [ + "mongodb", + "bson", + "parser" + ], + "files": [ + "lib", + "src", + "dist", + "bson.d.ts", + "etc/prepare.js", + "bower.json" + ], + "types": "bson.d.ts", + "version": "4.7.0", + "author": { + "name": "The MongoDB NodeJS Team", + "email": "dbx-node@mongodb.com" + }, + "license": "Apache-2.0", + "contributors": [], + "repository": "mongodb/js-bson", + "bugs": { + "url": "https://jira.mongodb.org/projects/NODE/issues/" + }, + "devDependencies": { + "@babel/plugin-external-helpers": "^7.10.4", + "@babel/preset-env": "^7.11.0", + "@istanbuljs/nyc-config-typescript": "^1.0.1", + "@microsoft/api-extractor": "^7.28.0", + "@rollup/plugin-babel": "^5.2.0", + "@rollup/plugin-commonjs": "^15.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^9.0.0", + "@rollup/plugin-replace": "^4.0.0", + "@rollup/plugin-typescript": "^6.0.0", + "@types/node": "^18.0.0", + "@typescript-eslint/eslint-plugin": "^5.30.0", + "@typescript-eslint/parser": "^5.30.0", + "array-includes": "^3.1.3", + "array.prototype.flatmap": "^1.3.0", + "benchmark": "^2.1.4", + "chai": "^4.2.0", + "eslint": "^8.18.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.1.0", + "eslint-plugin-tsdoc": "^0.2.16", + "karma": "^6.3.4", + "karma-chai": "^0.1.0", + "karma-chrome-launcher": "^3.1.0", + "karma-mocha": "^2.0.1", + "karma-mocha-reporter": "^2.2.5", + "karma-rollup-preprocessor": "^7.0.5", + "mocha": "5.2.0", + "node-fetch": "^2.6.1", + "nyc": "^15.1.0", + "object.entries": "^1.1.5", + "prettier": "^2.7.1", + "rimraf": "^3.0.2", + "rollup": "^2.26.5", + "rollup-plugin-commonjs": "^10.1.0", + "rollup-plugin-node-globals": "^1.4.0", + "rollup-plugin-node-polyfills": "^0.2.1", + "rollup-plugin-polyfill-node": "^0.7.0", + "standard-version": "^9.5.0", + "ts-node": "^9.0.0", + "tsd": "^0.21.0", + "typescript": "^4.7.4", + "typescript-cached-transpile": "0.0.6", + "uuid": "^8.3.2" + }, + "tsd": { + "directory": "test/types", + "compilerOptions": { + "strict": true, + "target": "esnext", + "module": "commonjs", + "moduleResolution": "node" + } + }, + "config": { + "native": false + }, + "main": "lib/bson.js", + "module": "dist/bson.esm.js", + "browser": { + "./lib/bson.js": "./dist/bson.browser.umd.js", + "./dist/bson.esm.js": "./dist/bson.browser.esm.js" + }, + "engines": { + "node": ">=6.9.0" + }, + "scripts": { + "docs": "typedoc", + "test": "npm run build && npm run test-node && npm run test-browser", + "test-node": "mocha test/node test/*_tests.js", + "test-tsd": "npm run build:dts && tsd", + "test-browser": "node --max-old-space-size=4096 ./node_modules/.bin/karma start karma.conf.js", + "build:ts": "tsc", + "build:dts": "npm run build:ts && api-extractor run --typescript-compiler-folder node_modules/typescript --local && rimraf 'lib/**/*.d.ts*'", + "build:bundle": "rollup -c rollup.config.js", + "build": "npm run build:dts && npm run build:bundle", + "lint": "eslint -v && eslint --ext '.js,.ts' --max-warnings=0 src test && tsc -v && tsc --noEmit && npm run test-tsd", + "format": "eslint --ext '.js,.ts' src test --fix", + "coverage": "nyc npm run test-node", + "coverage:html": "npm run coverage && open ./coverage/index.html", + "prepare": "node etc/prepare.js", + "release": "standard-version -i HISTORY.md" + }, + "dependencies": { + "buffer": "^5.6.0" + } +} diff --git a/node_modules/bson/src/binary.ts b/node_modules/bson/src/binary.ts new file mode 100644 index 0000000..d86275c --- /dev/null +++ b/node_modules/bson/src/binary.ts @@ -0,0 +1,481 @@ +import { Buffer } from 'buffer'; +import { ensureBuffer } from './ensure_buffer'; +import { bufferToUuidHexString, uuidHexStringToBuffer, uuidValidateString } from './uuid_utils'; +import { isUint8Array, randomBytes } from './parser/utils'; +import type { EJSONOptions } from './extended_json'; +import { BSONError, BSONTypeError } from './error'; +import { BSON_BINARY_SUBTYPE_UUID_NEW } from './constants'; + +/** @public */ +export type BinarySequence = Uint8Array | Buffer | number[]; + +/** @public */ +export interface BinaryExtendedLegacy { + $type: string; + $binary: string; +} + +/** @public */ +export interface BinaryExtended { + $binary: { + subType: string; + base64: string; + }; +} + +/** + * A class representation of the BSON Binary type. + * @public + * @category BSONType + */ +export class Binary { + _bsontype!: 'Binary'; + + /** + * Binary default subtype + * @internal + */ + private static readonly BSON_BINARY_SUBTYPE_DEFAULT = 0; + + /** Initial buffer default size */ + static readonly BUFFER_SIZE = 256; + /** Default BSON type */ + static readonly SUBTYPE_DEFAULT = 0; + /** Function BSON type */ + static readonly SUBTYPE_FUNCTION = 1; + /** Byte Array BSON type */ + static readonly SUBTYPE_BYTE_ARRAY = 2; + /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */ + static readonly SUBTYPE_UUID_OLD = 3; + /** UUID BSON type */ + static readonly SUBTYPE_UUID = 4; + /** MD5 BSON type */ + static readonly SUBTYPE_MD5 = 5; + /** Encrypted BSON type */ + static readonly SUBTYPE_ENCRYPTED = 6; + /** Column BSON type */ + static readonly SUBTYPE_COLUMN = 7; + /** User BSON type */ + static readonly SUBTYPE_USER_DEFINED = 128; + + buffer!: Buffer; + sub_type!: number; + position!: number; + + /** + * Create a new Binary instance. + * + * This constructor can accept a string as its first argument. In this case, + * this string will be encoded using ISO-8859-1, **not** using UTF-8. + * This is almost certainly not what you want. Use `new Binary(Buffer.from(string))` + * instead to convert the string to a Buffer using UTF-8 first. + * + * @param buffer - a buffer object containing the binary data. + * @param subType - the option binary type. + */ + constructor(buffer?: string | BinarySequence, subType?: number) { + if (!(this instanceof Binary)) return new Binary(buffer, subType); + + if ( + !(buffer == null) && + !(typeof buffer === 'string') && + !ArrayBuffer.isView(buffer) && + !(buffer instanceof ArrayBuffer) && + !Array.isArray(buffer) + ) { + throw new BSONTypeError( + 'Binary can only be constructed from string, Buffer, TypedArray, or Array' + ); + } + + this.sub_type = subType ?? Binary.BSON_BINARY_SUBTYPE_DEFAULT; + + if (buffer == null) { + // create an empty binary buffer + this.buffer = Buffer.alloc(Binary.BUFFER_SIZE); + this.position = 0; + } else { + if (typeof buffer === 'string') { + // string + this.buffer = Buffer.from(buffer, 'binary'); + } else if (Array.isArray(buffer)) { + // number[] + this.buffer = Buffer.from(buffer); + } else { + // Buffer | TypedArray | ArrayBuffer + this.buffer = ensureBuffer(buffer); + } + + this.position = this.buffer.byteLength; + } + } + + /** + * Updates this binary with byte_value. + * + * @param byteValue - a single byte we wish to write. + */ + put(byteValue: string | number | Uint8Array | Buffer | number[]): void { + // If it's a string and a has more than one character throw an error + if (typeof byteValue === 'string' && byteValue.length !== 1) { + throw new BSONTypeError('only accepts single character String'); + } else if (typeof byteValue !== 'number' && byteValue.length !== 1) + throw new BSONTypeError('only accepts single character Uint8Array or Array'); + + // Decode the byte value once + let decodedByte: number; + if (typeof byteValue === 'string') { + decodedByte = byteValue.charCodeAt(0); + } else if (typeof byteValue === 'number') { + decodedByte = byteValue; + } else { + decodedByte = byteValue[0]; + } + + if (decodedByte < 0 || decodedByte > 255) { + throw new BSONTypeError('only accepts number in a valid unsigned byte range 0-255'); + } + + if (this.buffer.length > this.position) { + this.buffer[this.position++] = decodedByte; + } else { + const buffer = Buffer.alloc(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++] = decodedByte; + } + } + + /** + * Writes a buffer or string to the binary. + * + * @param sequence - a string or buffer to be written to the Binary BSON object. + * @param offset - specify the binary of where to write the content. + */ + write(sequence: string | BinarySequence, offset: number): void { + offset = typeof offset === 'number' ? offset : this.position; + + // If the buffer is to small let's extend the buffer + if (this.buffer.length < offset + sequence.length) { + const buffer = Buffer.alloc(this.buffer.length + sequence.length); + this.buffer.copy(buffer, 0, 0, this.buffer.length); + + // Assign the new buffer + this.buffer = buffer; + } + + if (ArrayBuffer.isView(sequence)) { + this.buffer.set(ensureBuffer(sequence), offset); + this.position = + offset + sequence.byteLength > this.position ? offset + sequence.length : this.position; + } else if (typeof sequence === 'string') { + this.buffer.write(sequence, offset, sequence.length, 'binary'); + this.position = + offset + sequence.length > this.position ? offset + sequence.length : this.position; + } + } + + /** + * Reads **length** bytes starting at **position**. + * + * @param position - read from the given position in the Binary. + * @param length - the number of bytes to read. + */ + read(position: number, length: number): BinarySequence { + length = length && length > 0 ? length : this.position; + + // Let's return the data based on the type we have + return this.buffer.slice(position, position + length); + } + + /** + * Returns the value of this binary as a string. + * @param asRaw - Will skip converting to a string + * @remarks + * This is handy when calling this function conditionally for some key value pairs and not others + */ + value(asRaw?: boolean): string | BinarySequence { + asRaw = !!asRaw; + + // Optimize to serialize for the situation where the data == size of buffer + if (asRaw && this.buffer.length === this.position) { + return this.buffer; + } + + // If it's a node.js buffer object + if (asRaw) { + return this.buffer.slice(0, this.position); + } + return this.buffer.toString('binary', 0, this.position); + } + + /** the length of the binary sequence */ + length(): number { + return this.position; + } + + toJSON(): string { + return this.buffer.toString('base64'); + } + + toString(format?: string): string { + return this.buffer.toString(format); + } + + /** @internal */ + toExtendedJSON(options?: EJSONOptions): BinaryExtendedLegacy | BinaryExtended { + options = options || {}; + const base64String = this.buffer.toString('base64'); + + const subType = Number(this.sub_type).toString(16); + if (options.legacy) { + return { + $binary: base64String, + $type: subType.length === 1 ? '0' + subType : subType + }; + } + return { + $binary: { + base64: base64String, + subType: subType.length === 1 ? '0' + subType : subType + } + }; + } + + toUUID(): UUID { + if (this.sub_type === Binary.SUBTYPE_UUID) { + return new UUID(this.buffer.slice(0, this.position)); + } + + throw new BSONError( + `Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${Binary.SUBTYPE_UUID}" is currently supported.` + ); + } + + /** @internal */ + static fromExtendedJSON( + doc: BinaryExtendedLegacy | BinaryExtended | UUIDExtended, + options?: EJSONOptions + ): Binary { + options = options || {}; + let data: Buffer | undefined; + let type; + if ('$binary' in doc) { + if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) { + type = doc.$type ? parseInt(doc.$type, 16) : 0; + data = Buffer.from(doc.$binary, 'base64'); + } else { + if (typeof doc.$binary !== 'string') { + type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0; + data = Buffer.from(doc.$binary.base64, 'base64'); + } + } + } else if ('$uuid' in doc) { + type = 4; + data = uuidHexStringToBuffer(doc.$uuid); + } + if (!data) { + throw new BSONTypeError(`Unexpected Binary Extended JSON format ${JSON.stringify(doc)}`); + } + return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + const asBuffer = this.value(true); + return `new Binary(Buffer.from("${asBuffer.toString('hex')}", "hex"), ${this.sub_type})`; + } +} + +Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' }); + +/** @public */ +export type UUIDExtended = { + $uuid: string; +}; +const UUID_BYTE_LENGTH = 16; + +/** + * A class representation of the BSON UUID type. + * @public + */ +export class UUID extends Binary { + static cacheHexString: boolean; + + /** UUID hexString cache @internal */ + private __id?: string; + + /** + * Create an UUID type + * + * @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer. + */ + constructor(input?: string | Buffer | UUID) { + let bytes; + let hexStr; + if (input == null) { + bytes = UUID.generate(); + } else if (input instanceof UUID) { + bytes = Buffer.from(input.buffer); + hexStr = input.__id; + } else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) { + bytes = ensureBuffer(input); + } else if (typeof input === 'string') { + bytes = uuidHexStringToBuffer(input); + } else { + throw new BSONTypeError( + 'Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).' + ); + } + super(bytes, BSON_BINARY_SUBTYPE_UUID_NEW); + this.__id = hexStr; + } + + /** + * The UUID bytes + * @readonly + */ + get id(): Buffer { + return this.buffer; + } + + set id(value: Buffer) { + this.buffer = value; + + if (UUID.cacheHexString) { + this.__id = bufferToUuidHexString(value); + } + } + + /** + * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated) + * @param includeDashes - should the string exclude dash-separators. + * */ + toHexString(includeDashes = true): string { + if (UUID.cacheHexString && this.__id) { + return this.__id; + } + + const uuidHexString = bufferToUuidHexString(this.id, includeDashes); + + if (UUID.cacheHexString) { + this.__id = uuidHexString; + } + + return uuidHexString; + } + + /** + * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified. + */ + toString(encoding?: string): string { + return encoding ? this.id.toString(encoding) : this.toHexString(); + } + + /** + * Converts the id into its JSON string representation. + * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + */ + toJSON(): string { + return this.toHexString(); + } + + /** + * Compares the equality of this UUID with `otherID`. + * + * @param otherId - UUID instance to compare against. + */ + equals(otherId: string | Buffer | UUID): boolean { + if (!otherId) { + return false; + } + + if (otherId instanceof UUID) { + return otherId.id.equals(this.id); + } + + try { + return new UUID(otherId).id.equals(this.id); + } catch { + return false; + } + } + + /** + * Creates a Binary instance from the current UUID. + */ + toBinary(): Binary { + return new Binary(this.id, Binary.SUBTYPE_UUID); + } + + /** + * Generates a populated buffer containing a v4 uuid + */ + static generate(): Buffer { + const bytes = randomBytes(UUID_BYTE_LENGTH); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + // Kindly borrowed from https://github.com/uuidjs/uuid/blob/master/src/v4.js + bytes[6] = (bytes[6] & 0x0f) | 0x40; + bytes[8] = (bytes[8] & 0x3f) | 0x80; + + return Buffer.from(bytes); + } + + /** + * Checks if a value is a valid bson UUID + * @param input - UUID, string or Buffer to validate. + */ + static isValid(input: string | Buffer | UUID): boolean { + if (!input) { + return false; + } + + if (input instanceof UUID) { + return true; + } + + if (typeof input === 'string') { + return uuidValidateString(input); + } + + if (isUint8Array(input)) { + // check for length & uuid version (https://tools.ietf.org/html/rfc4122#section-4.1.3) + if (input.length !== UUID_BYTE_LENGTH) { + return false; + } + + return (input[6] & 0xf0) === 0x40 && (input[8] & 0x80) === 0x80; + } + + return false; + } + + /** + * Creates an UUID from a hex string representation of an UUID. + * @param hexString - 32 or 36 character hex string (dashes excluded/included). + */ + static createFromHexString(hexString: string): UUID { + const buffer = uuidHexStringToBuffer(hexString); + return new UUID(buffer); + } + + /** + * Converts to a string representation of this Id. + * + * @returns return the 36 character hex string representation. + * @internal + */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + return `new UUID("${this.toHexString()}")`; + } +} diff --git a/node_modules/bson/src/bson.ts b/node_modules/bson/src/bson.ts new file mode 100644 index 0000000..d32cfe8 --- /dev/null +++ b/node_modules/bson/src/bson.ts @@ -0,0 +1,330 @@ +import { Buffer } from 'buffer'; +import { Binary, UUID } from './binary'; +import { Code } from './code'; +import { DBRef } from './db_ref'; +import { Decimal128 } from './decimal128'; +import { Double } from './double'; +import { ensureBuffer } from './ensure_buffer'; +import { EJSON } from './extended_json'; +import { Int32 } from './int_32'; +import { Long } from './long'; +import { Map } from './map'; +import { MaxKey } from './max_key'; +import { MinKey } from './min_key'; +import { ObjectId } from './objectid'; +import { BSONError, BSONTypeError } from './error'; +import { calculateObjectSize as internalCalculateObjectSize } from './parser/calculate_size'; +// Parts of the parser +import { deserialize as internalDeserialize, DeserializeOptions } from './parser/deserializer'; +import { serializeInto as internalSerialize, SerializeOptions } from './parser/serializer'; +import { BSONRegExp } from './regexp'; +import { BSONSymbol } from './symbol'; +import { Timestamp } from './timestamp'; +export type { UUIDExtended, BinaryExtended, BinaryExtendedLegacy, BinarySequence } from './binary'; +export type { CodeExtended } from './code'; +export { + BSON_BINARY_SUBTYPE_BYTE_ARRAY, + BSON_BINARY_SUBTYPE_DEFAULT, + BSON_BINARY_SUBTYPE_FUNCTION, + BSON_BINARY_SUBTYPE_MD5, + BSON_BINARY_SUBTYPE_USER_DEFINED, + BSON_BINARY_SUBTYPE_UUID, + BSON_BINARY_SUBTYPE_UUID_NEW, + BSON_BINARY_SUBTYPE_ENCRYPTED, + BSON_BINARY_SUBTYPE_COLUMN, + BSON_DATA_ARRAY, + BSON_DATA_BINARY, + BSON_DATA_BOOLEAN, + BSON_DATA_CODE, + BSON_DATA_CODE_W_SCOPE, + BSON_DATA_DATE, + BSON_DATA_DBPOINTER, + BSON_DATA_DECIMAL128, + BSON_DATA_INT, + BSON_DATA_LONG, + BSON_DATA_MAX_KEY, + BSON_DATA_MIN_KEY, + BSON_DATA_NULL, + BSON_DATA_NUMBER, + BSON_DATA_OBJECT, + BSON_DATA_OID, + BSON_DATA_REGEXP, + BSON_DATA_STRING, + BSON_DATA_SYMBOL, + BSON_DATA_TIMESTAMP, + BSON_DATA_UNDEFINED, + BSON_INT32_MAX, + BSON_INT32_MIN, + BSON_INT64_MAX, + BSON_INT64_MIN +} from './constants'; +export type { DBRefLike } from './db_ref'; +export type { Decimal128Extended } from './decimal128'; +export type { DoubleExtended } from './double'; +export type { EJSONOptions } from './extended_json'; +export { EJSON } from './extended_json'; +export type { Int32Extended } from './int_32'; +export type { LongExtended } from './long'; +export type { MaxKeyExtended } from './max_key'; +export type { MinKeyExtended } from './min_key'; +export type { ObjectIdExtended, ObjectIdLike } from './objectid'; +export type { BSONRegExpExtended, BSONRegExpExtendedLegacy } from './regexp'; +export type { BSONSymbolExtended } from './symbol'; +export type { LongWithoutOverrides, TimestampExtended, TimestampOverrides } from './timestamp'; +export { LongWithoutOverridesClass } from './timestamp'; +export type { SerializeOptions, DeserializeOptions }; +export { + Code, + Map, + BSONSymbol, + DBRef, + Binary, + ObjectId, + UUID, + Long, + Timestamp, + Double, + Int32, + MinKey, + MaxKey, + BSONRegExp, + Decimal128, + // In 4.0.0 and 4.0.1, this property name was changed to ObjectId to match the class name. + // This caused interoperability problems with previous versions of the library, so in + // later builds we changed it back to ObjectID (capital D) to match legacy implementations. + ObjectId as ObjectID +}; +export { BSONError, BSONTypeError } from './error'; + +/** @public */ +export interface Document { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; +} + +/** @internal */ +// Default Max Size +const MAXSIZE = 1024 * 1024 * 17; + +// Current Internal Temporary Serialization Buffer +let buffer = Buffer.alloc(MAXSIZE); + +/** + * Sets the size of the internal serialization buffer. + * + * @param size - The desired size for the internal serialization buffer + * @public + */ +export function setInternalBufferSize(size: number): void { + // Resize the internal serialization buffer if needed + if (buffer.length < size) { + buffer = Buffer.alloc(size); + } +} + +/** + * Serialize a Javascript object. + * + * @param object - the Javascript object to serialize. + * @returns Buffer object containing the serialized object. + * @public + */ +export function serialize(object: Document, options: SerializeOptions = {}): Buffer { + // Unpack the options + const checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false; + const serializeFunctions = + typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + const ignoreUndefined = + typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + const minInternalBufferSize = + typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE; + + // Resize the internal serialization buffer if needed + if (buffer.length < minInternalBufferSize) { + buffer = Buffer.alloc(minInternalBufferSize); + } + + // Attempt to serialize + const serializationIndex = internalSerialize( + buffer, + object, + checkKeys, + 0, + 0, + serializeFunctions, + ignoreUndefined, + [] + ); + + // Create the final buffer + const finishedBuffer = Buffer.alloc(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 - the Javascript object to serialize. + * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object. + * @returns the index pointing to the last written byte in the buffer. + * @public + */ +export function serializeWithBufferAndIndex( + object: Document, + finalBuffer: Buffer, + options: SerializeOptions = {} +): number { + // Unpack the options + const checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false; + const serializeFunctions = + typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + const ignoreUndefined = + typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + const startIndex = typeof options.index === 'number' ? options.index : 0; + + // Attempt to serialize + const serializationIndex = internalSerialize( + buffer, + object, + checkKeys, + 0, + 0, + serializeFunctions, + ignoreUndefined + ); + buffer.copy(finalBuffer, startIndex, 0, serializationIndex); + + // Return the index + return startIndex + serializationIndex - 1; +} + +/** + * Deserialize data as BSON. + * + * @param buffer - the buffer containing the serialized set of BSON documents. + * @returns returns the deserialized Javascript Object. + * @public + */ +export function deserialize( + buffer: Buffer | ArrayBufferView | ArrayBuffer, + options: DeserializeOptions = {} +): Document { + return internalDeserialize(buffer instanceof Buffer ? buffer : ensureBuffer(buffer), options); +} + +/** @public */ +export type CalculateObjectSizeOptions = Pick< + SerializeOptions, + 'serializeFunctions' | 'ignoreUndefined' +>; + +/** + * Calculate the bson size for a passed in Javascript object. + * + * @param object - the Javascript object to calculate the BSON byte size for + * @returns size of BSON object in bytes + * @public + */ +export function calculateObjectSize( + object: Document, + options: CalculateObjectSizeOptions = {} +): number { + options = options || {}; + + const serializeFunctions = + typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + const ignoreUndefined = + typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + + return internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined); +} + +/** + * Deserialize stream data as BSON documents. + * + * @param data - the buffer containing the serialized set of BSON documents. + * @param startIndex - the start index in the data Buffer where the deserialization is to start. + * @param numberOfDocuments - number of documents to deserialize. + * @param documents - an array where to store the deserialized documents. + * @param docStartIndex - the index in the documents array from where to start inserting documents. + * @param options - additional options used for the deserialization. + * @returns next index in the buffer after deserialization **x** numbers of documents. + * @public + */ +export function deserializeStream( + data: Buffer | ArrayBufferView | ArrayBuffer, + startIndex: number, + numberOfDocuments: number, + documents: Document[], + docStartIndex: number, + options: DeserializeOptions +): number { + const internalOptions = Object.assign( + { allowObjectSmallerThanBufferSize: true, index: 0 }, + options + ); + const bufferData = ensureBuffer(data); + + let index = startIndex; + // Loop over all documents + for (let i = 0; i < numberOfDocuments; i++) { + // Find size of the document + const size = + bufferData[index] | + (bufferData[index + 1] << 8) | + (bufferData[index + 2] << 16) | + (bufferData[index + 3] << 24); + // Update options with index + internalOptions.index = index; + // Parse the document at this point + documents[docStartIndex + i] = internalDeserialize(bufferData, internalOptions); + // Adjust index by the document size + index = index + size; + } + + // Return object containing end index of parsing and list of documents + return index; +} + +/** + * BSON default export + * @deprecated Please use named exports + * @privateRemarks + * We want to someday deprecate the default export, + * so none of the new TS types are being exported on the default + * @public + */ +const BSON = { + Binary, + Code, + DBRef, + Decimal128, + Double, + Int32, + Long, + UUID, + Map, + MaxKey, + MinKey, + ObjectId, + ObjectID: ObjectId, + BSONRegExp, + BSONSymbol, + Timestamp, + EJSON, + setInternalBufferSize, + serialize, + serializeWithBufferAndIndex, + deserialize, + calculateObjectSize, + deserializeStream, + BSONError, + BSONTypeError +}; +export default BSON; diff --git a/node_modules/bson/src/code.ts b/node_modules/bson/src/code.ts new file mode 100644 index 0000000..86a4fb1 --- /dev/null +++ b/node_modules/bson/src/code.ts @@ -0,0 +1,61 @@ +import type { Document } from './bson'; + +/** @public */ +export interface CodeExtended { + $code: string | Function; + $scope?: Document; +} + +/** + * A class representation of the BSON Code type. + * @public + * @category BSONType + */ +export class Code { + _bsontype!: 'Code'; + + code!: string | Function; + scope?: Document; + /** + * @param code - a string or function. + * @param scope - an optional scope for the function. + */ + constructor(code: string | Function, scope?: Document) { + if (!(this instanceof Code)) return new Code(code, scope); + + this.code = code; + this.scope = scope; + } + + toJSON(): { code: string | Function; scope?: Document } { + return { code: this.code, scope: this.scope }; + } + + /** @internal */ + toExtendedJSON(): CodeExtended { + if (this.scope) { + return { $code: this.code, $scope: this.scope }; + } + + return { $code: this.code }; + } + + /** @internal */ + static fromExtendedJSON(doc: CodeExtended): Code { + return new Code(doc.$code, doc.$scope); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + const codeJson = this.toJSON(); + return `new Code("${String(codeJson.code)}"${ + codeJson.scope ? `, ${JSON.stringify(codeJson.scope)}` : '' + })`; + } +} + +Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' }); diff --git a/node_modules/bson/src/constants.ts b/node_modules/bson/src/constants.ts new file mode 100644 index 0000000..6af63e6 --- /dev/null +++ b/node_modules/bson/src/constants.ts @@ -0,0 +1,110 @@ +/** @internal */ +export const BSON_INT32_MAX = 0x7fffffff; +/** @internal */ +export const BSON_INT32_MIN = -0x80000000; +/** @internal */ +export const BSON_INT64_MAX = Math.pow(2, 63) - 1; +/** @internal */ +export const BSON_INT64_MIN = -Math.pow(2, 63); + +/** + * Any integer up to 2^53 can be precisely represented by a double. + * @internal + */ +export const JS_INT_MAX = Math.pow(2, 53); + +/** + * Any integer down to -2^53 can be precisely represented by a double. + * @internal + */ +export const JS_INT_MIN = -Math.pow(2, 53); + +/** Number BSON Type @internal */ +export const BSON_DATA_NUMBER = 1; + +/** String BSON Type @internal */ +export const BSON_DATA_STRING = 2; + +/** Object BSON Type @internal */ +export const BSON_DATA_OBJECT = 3; + +/** Array BSON Type @internal */ +export const BSON_DATA_ARRAY = 4; + +/** Binary BSON Type @internal */ +export const BSON_DATA_BINARY = 5; + +/** Binary BSON Type @internal */ +export const BSON_DATA_UNDEFINED = 6; + +/** ObjectId BSON Type @internal */ +export const BSON_DATA_OID = 7; + +/** Boolean BSON Type @internal */ +export const BSON_DATA_BOOLEAN = 8; + +/** Date BSON Type @internal */ +export const BSON_DATA_DATE = 9; + +/** null BSON Type @internal */ +export const BSON_DATA_NULL = 10; + +/** RegExp BSON Type @internal */ +export const BSON_DATA_REGEXP = 11; + +/** Code BSON Type @internal */ +export const BSON_DATA_DBPOINTER = 12; + +/** Code BSON Type @internal */ +export const BSON_DATA_CODE = 13; + +/** Symbol BSON Type @internal */ +export const BSON_DATA_SYMBOL = 14; + +/** Code with Scope BSON Type @internal */ +export const BSON_DATA_CODE_W_SCOPE = 15; + +/** 32 bit Integer BSON Type @internal */ +export const BSON_DATA_INT = 16; + +/** Timestamp BSON Type @internal */ +export const BSON_DATA_TIMESTAMP = 17; + +/** Long BSON Type @internal */ +export const BSON_DATA_LONG = 18; + +/** Decimal128 BSON Type @internal */ +export const BSON_DATA_DECIMAL128 = 19; + +/** MinKey BSON Type @internal */ +export const BSON_DATA_MIN_KEY = 0xff; + +/** MaxKey BSON Type @internal */ +export const BSON_DATA_MAX_KEY = 0x7f; + +/** Binary Default Type @internal */ +export const BSON_BINARY_SUBTYPE_DEFAULT = 0; + +/** Binary Function Type @internal */ +export const BSON_BINARY_SUBTYPE_FUNCTION = 1; + +/** Binary Byte Array Type @internal */ +export const BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; + +/** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */ +export const BSON_BINARY_SUBTYPE_UUID = 3; + +/** Binary UUID Type @internal */ +export const BSON_BINARY_SUBTYPE_UUID_NEW = 4; + +/** Binary MD5 Type @internal */ +export const BSON_BINARY_SUBTYPE_MD5 = 5; + +/** Encrypted BSON type @internal */ +export const BSON_BINARY_SUBTYPE_ENCRYPTED = 6; + +/** Column BSON type @internal */ +export const BSON_BINARY_SUBTYPE_COLUMN = 7; + +/** Binary User Defined Type @internal */ +export const BSON_BINARY_SUBTYPE_USER_DEFINED = 128; diff --git a/node_modules/bson/src/db_ref.ts b/node_modules/bson/src/db_ref.ts new file mode 100644 index 0000000..750c5be --- /dev/null +++ b/node_modules/bson/src/db_ref.ts @@ -0,0 +1,124 @@ +import type { Document } from './bson'; +import type { EJSONOptions } from './extended_json'; +import type { ObjectId } from './objectid'; +import { isObjectLike } from './parser/utils'; + +/** @public */ +export interface DBRefLike { + $ref: string; + $id: ObjectId; + $db?: string; +} + +/** @internal */ +export function isDBRefLike(value: unknown): value is DBRefLike { + return ( + isObjectLike(value) && + value.$id != null && + typeof value.$ref === 'string' && + (value.$db == null || typeof value.$db === 'string') + ); +} + +/** + * A class representation of the BSON DBRef type. + * @public + * @category BSONType + */ +export class DBRef { + _bsontype!: 'DBRef'; + + collection!: string; + oid!: ObjectId; + db?: string; + fields!: Document; + + /** + * @param collection - the collection name. + * @param oid - the reference ObjectId. + * @param db - optional db name, if omitted the reference is local to the current db. + */ + constructor(collection: string, oid: ObjectId, db?: string, fields?: Document) { + if (!(this instanceof DBRef)) return new DBRef(collection, oid, db, fields); + + // check if namespace has been provided + const parts = collection.split('.'); + if (parts.length === 2) { + db = parts.shift(); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + collection = parts.shift()!; + } + + this.collection = collection; + this.oid = oid; + this.db = db; + this.fields = fields || {}; + } + + // Property provided for compatibility with the 1.x parser + // the 1.x parser used a "namespace" property, while 4.x uses "collection" + + /** @internal */ + get namespace(): string { + return this.collection; + } + + set namespace(value: string) { + this.collection = value; + } + + toJSON(): DBRefLike & Document { + const o = Object.assign( + { + $ref: this.collection, + $id: this.oid + }, + this.fields + ); + + if (this.db != null) o.$db = this.db; + return o; + } + + /** @internal */ + toExtendedJSON(options?: EJSONOptions): DBRefLike { + options = options || {}; + let o: DBRefLike = { + $ref: this.collection, + $id: this.oid + }; + + if (options.legacy) { + return o; + } + + if (this.db) o.$db = this.db; + o = Object.assign(o, this.fields); + return o; + } + + /** @internal */ + static fromExtendedJSON(doc: DBRefLike): DBRef { + const copy = Object.assign({}, doc) as Partial; + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(doc.$ref, doc.$id, doc.$db, copy); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + // NOTE: if OID is an ObjectId class it will just print the oid string. + const oid = + this.oid === undefined || this.oid.toString === undefined ? this.oid : this.oid.toString(); + return `new DBRef("${this.namespace}", new ObjectId("${String(oid)}")${ + this.db ? `, "${this.db}"` : '' + })`; + } +} + +Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' }); diff --git a/node_modules/bson/src/decimal128.ts b/node_modules/bson/src/decimal128.ts new file mode 100644 index 0000000..8759986 --- /dev/null +++ b/node_modules/bson/src/decimal128.ts @@ -0,0 +1,773 @@ +import { Buffer } from 'buffer'; +import { BSONTypeError } from './error'; +import { Long } from './long'; +import { isUint8Array } from './parser/utils'; + +const PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/; +const PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i; +const PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i; + +const EXPONENT_MAX = 6111; +const EXPONENT_MIN = -6176; +const EXPONENT_BIAS = 6176; +const MAX_DIGITS = 34; + +// Nan value bits as 32 bit values (due to lack of longs) +const 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) +const INF_NEGATIVE_BUFFER = [ + 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +].reverse(); +const INF_POSITIVE_BUFFER = [ + 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +].reverse(); + +const EXPONENT_REGEX = /^([-+])?(\d+)?$/; + +// Extract least significant 5 bits +const COMBINATION_MASK = 0x1f; +// Extract least significant 14 bits +const EXPONENT_MASK = 0x3fff; +// Value of combination field for Inf +const COMBINATION_INFINITY = 30; +// Value of combination field for NaN +const COMBINATION_NAN = 31; + +// Detect if the value is a digit +function isDigit(value: string): boolean { + return !isNaN(parseInt(value, 10)); +} + +// Divide two uint128 values +function divideu128(value: { parts: [number, number, number, number] }) { + const DIVISOR = Long.fromNumber(1000 * 1000 * 1000); + let _rem = Long.fromNumber(0); + + if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) { + return { quotient: value, rem: _rem }; + } + + for (let 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 +function multiply64x2(left: Long, right: Long): { high: Long; low: Long } { + if (!left && !right) { + return { high: Long.fromNumber(0), low: Long.fromNumber(0) }; + } + + const leftHigh = left.shiftRightUnsigned(32); + const leftLow = new Long(left.getLowBits(), 0); + const rightHigh = right.shiftRightUnsigned(32); + const rightLow = new Long(right.getLowBits(), 0); + + let productHigh = leftHigh.multiply(rightHigh); + let productMid = leftHigh.multiply(rightLow); + const productMid2 = leftLow.multiply(rightHigh); + let 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 }; +} + +function lessThan(left: Long, right: Long): boolean { + // Make values unsigned + const uhleft = left.high >>> 0; + const uhright = right.high >>> 0; + + // Compare high bits first + if (uhleft < uhright) { + return true; + } else if (uhleft === uhright) { + const ulleft = left.low >>> 0; + const ulright = right.low >>> 0; + if (ulleft < ulright) return true; + } + + return false; +} + +function invalidErr(string: string, message: string) { + throw new BSONTypeError(`"${string}" is not a valid Decimal128 string - ${message}`); +} + +/** @public */ +export interface Decimal128Extended { + $numberDecimal: string; +} + +/** + * A class representation of the BSON Decimal128 type. + * @public + * @category BSONType + */ +export class Decimal128 { + _bsontype!: 'Decimal128'; + + readonly bytes!: Buffer; + + /** + * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order, + * or a string representation as returned by .toString() + */ + constructor(bytes: Buffer | string) { + if (!(this instanceof Decimal128)) return new Decimal128(bytes); + + if (typeof bytes === 'string') { + this.bytes = Decimal128.fromString(bytes).bytes; + } else if (isUint8Array(bytes)) { + if (bytes.byteLength !== 16) { + throw new BSONTypeError('Decimal128 must take a Buffer of 16 bytes'); + } + this.bytes = bytes; + } else { + throw new BSONTypeError('Decimal128 must take a Buffer or string'); + } + } + + /** + * Create a Decimal128 instance from a string representation + * + * @param representation - a numeric string representation. + */ + static fromString(representation: string): Decimal128 { + // Parse state tracking + let isNegative = false; + let sawRadix = false; + let foundNonZero = false; + + // Total number of significant digits (no leading or trailing zero) + let significantDigits = 0; + // Total number of significand digits read + let nDigitsRead = 0; + // Total number of digits (no leading zeros) + let nDigits = 0; + // The number of the digits after radix + let radixPosition = 0; + // The index of the first non-zero in *str* + let firstNonZero = 0; + + // Digits Array + const digits = [0]; + // The number of digits in digits + let nDigitsStored = 0; + // Insertion pointer for digits + let digitsInsert = 0; + // The index of the first non-zero digit + let firstDigit = 0; + // The index of the last digit + let lastDigit = 0; + + // Exponent + let exponent = 0; + // loop index over array + let i = 0; + // The high 17 digits of the significand + let significandHigh = new Long(0, 0); + // The low 17 digits of the significand + let significandLow = new Long(0, 0); + // The biased exponent + let biasedExponent = 0; + + // Read index + let index = 0; + + // Naively prevent against REDOS attacks. + // TODO: implementing a custom parsing for this, or refactoring the regex would yield + // further gains. + if (representation.length >= 7000) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + + // Results + const stringMatch = representation.match(PARSE_STRING_REGEXP); + const infMatch = representation.match(PARSE_INF_REGEXP); + const nanMatch = representation.match(PARSE_NAN_REGEXP); + + // Validate the string + if ((!stringMatch && !infMatch && !nanMatch) || representation.length === 0) { + throw new BSONTypeError('' + representation + ' not a valid Decimal128 string'); + } + + if (stringMatch) { + // full_match = stringMatch[0] + // sign = stringMatch[1] + + const unsignedNumber = stringMatch[2]; + // stringMatch[3] is undefined if a whole number (ex "1", 12") + // but defined if a number w/ decimal in it (ex "1.0, 12.2") + + const e = stringMatch[4]; + const expSign = stringMatch[5]; + const expNumber = stringMatch[6]; + + // they provided e, but didn't give an exponent number. for ex "1e" + if (e && expNumber === undefined) invalidErr(representation, 'missing exponent power'); + + // they provided e, but didn't give a number before it. for ex "e1" + if (e && unsignedNumber === undefined) invalidErr(representation, 'missing exponent base'); + + if (e === undefined && (expSign || expNumber)) { + invalidErr(representation, 'missing e before exponent'); + } + } + + // Get the negative or positive sign + if (representation[index] === '+' || representation[index] === '-') { + isNegative = representation[index++] === '-'; + } + + // Check if user passed Infinity or NaN + if (!isDigit(representation[index]) && representation[index] !== '.') { + if (representation[index] === 'i' || representation[index] === 'I') { + return new Decimal128(Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } else if (representation[index] === 'N') { + return new Decimal128(Buffer.from(NAN_BUFFER)); + } + } + + // Read all the digits + while (isDigit(representation[index]) || representation[index] === '.') { + if (representation[index] === '.') { + if (sawRadix) invalidErr(representation, 'contains multiple periods'); + + sawRadix = true; + index = index + 1; + continue; + } + + if (nDigitsStored < 34) { + if (representation[index] !== '0' || foundNonZero) { + if (!foundNonZero) { + firstNonZero = nDigitsRead; + } + + foundNonZero = true; + + // Only store 34 digits + digits[digitsInsert++] = parseInt(representation[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 BSONTypeError('' + representation + ' not a valid Decimal128 string'); + + // Read exponent if exists + if (representation[index] === 'e' || representation[index] === 'E') { + // Read exponent digits + const match = representation.substr(++index).match(EXPONENT_REGEX); + + // No digits read + if (!match || !match[2]) return new Decimal128(Buffer.from(NAN_BUFFER)); + + // Get exponent + exponent = parseInt(match[0], 10); + + // Adjust the index + index = index + match[0].length; + } + + // Return not a number + if (representation[index]) return new Decimal128(Buffer.from(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 (significantDigits !== 1) { + while (digits[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 + const digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } + + invalidErr(representation, 'overflow'); + } + exponent = exponent - 1; + } + + while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { + // Shift last digit. can only do this if < significant digits than # stored. + if (lastDigit === 0 && significantDigits < nDigitsStored) { + 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 + const digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } + invalidErr(representation, 'overflow'); + } + } + + // Round + // We've normalized the exponent, but might still need to round. + if (lastDigit - firstDigit + 1 < significantDigits) { + let 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) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + // if negative, we need to increment again to account for - sign at start. + if (isNegative) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + + const roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10); + let roundBit = 0; + + if (roundDigit >= 5) { + roundBit = 1; + if (roundDigit === 5) { + roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0; + for (i = firstNonZero + lastDigit + 2; i < endOfString; i++) { + if (parseInt(representation[i], 10)) { + roundBit = 1; + break; + } + } + } + } + + if (roundBit) { + let 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( + Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER) + ); + } + } + } + } + } + } + + // 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) { + let 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 { + let 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])); + } + } + + const 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; + const 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(1)) + ) { + // 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 + const buffer = Buffer.alloc(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); + } + + /** Create a string representation of the raw Decimal128 value */ + toString(): string { + // Note: bits in this routine are referred to starting at 0, + // from the sign bit, towards the coefficient. + + // decoded biased exponent (14 bits) + let biased_exponent; + // the number of significand digits + let significand_digits = 0; + // the base-10 digits in the significand + const significand = new Array(36); + for (let i = 0; i < significand.length; i++) significand[i] = 0; + // read pointer into significand + let index = 0; + + // true if the number is zero + let is_zero = false; + + // the most significant significand bits (50-46) + let significand_msb; + // temporary storage for significand decoding + let significand128: { parts: [number, number, number, number] } = { parts: [0, 0, 0, 0] }; + // indexing variables + let j, k; + + // Output string + const string: string[] = []; + + // Unpack index + index = 0; + + // Buffer reference + const buffer = this.bytes; + + // Unpack the low 64bits into a long + // bits 96 - 127 + const low = + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 64 - 95 + const midl = + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + + // Unpack the high 64bits into a long + // bits 32 - 63 + const midh = + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + // bits 0 - 31 + const high = + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + + // Unpack index + index = 0; + + // Create the state of the decimal + const dec = { + low: new Long(low, midl), + high: new Long(midh, high) + }; + + if (dec.high.lessThan(Long.ZERO)) { + string.push('-'); + } + + // Decode combination field and exponent + // bits 1 - 5 + const 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; + } + + // unbiased exponent + const 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--) { + let least_digits = 0; + // Perform the divide + const 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; + while (!significand[index]) { + significand_digits = significand_digits - 1; + index = index + 1; + } + } + + // the exponent if scientific notation is used + const 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 + + // if there are too many significant digits, we should just be treating numbers + // as + or - 0 and using the non-scientific exponent (this is for the "invalid + // representation should be treated as 0/-0" spec cases in decimal128-1.json) + if (significand_digits > 34) { + string.push(`${0}`); + if (exponent > 0) string.push(`E+${exponent}`); + else if (exponent < 0) string.push(`E${exponent}`); + return string.join(''); + } + + string.push(`${significand[index++]}`); + significand_digits = significand_digits - 1; + + if (significand_digits) { + string.push('.'); + } + + for (let 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 (let i = 0; i < significand_digits; i++) { + string.push(`${significand[index++]}`); + } + } else { + let radix_position = significand_digits + exponent; + + // non-zero digits before radix + if (radix_position > 0) { + for (let 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 (let i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) { + string.push(`${significand[index++]}`); + } + } + } + + return string.join(''); + } + + toJSON(): Decimal128Extended { + return { $numberDecimal: this.toString() }; + } + + /** @internal */ + toExtendedJSON(): Decimal128Extended { + return { $numberDecimal: this.toString() }; + } + + /** @internal */ + static fromExtendedJSON(doc: Decimal128Extended): Decimal128 { + return Decimal128.fromString(doc.$numberDecimal); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + return `new Decimal128("${this.toString()}")`; + } +} + +Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' }); diff --git a/node_modules/bson/src/double.ts b/node_modules/bson/src/double.ts new file mode 100644 index 0000000..51bbf22 --- /dev/null +++ b/node_modules/bson/src/double.ts @@ -0,0 +1,91 @@ +import type { EJSONOptions } from './extended_json'; + +/** @public */ +export interface DoubleExtended { + $numberDouble: string; +} + +/** + * A class representation of the BSON Double type. + * @public + * @category BSONType + */ +export class Double { + _bsontype!: 'Double'; + + value!: number; + /** + * Create a Double type + * + * @param value - the number we want to represent as a double. + */ + constructor(value: number) { + if (!(this instanceof Double)) return new Double(value); + + if ((value as unknown) instanceof Number) { + value = value.valueOf(); + } + + this.value = +value; + } + + /** + * Access the number value. + * + * @returns returns the wrapped double number. + */ + valueOf(): number { + return this.value; + } + + toJSON(): number { + return this.value; + } + + toString(radix?: number): string { + return this.value.toString(radix); + } + + /** @internal */ + toExtendedJSON(options?: EJSONOptions): number | DoubleExtended { + if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) { + return this.value; + } + + // NOTE: JavaScript has +0 and -0, apparently to model limit calculations. If a user + // explicitly provided `-0` then we need to ensure the sign makes it into the output + if (Object.is(Math.sign(this.value), -0)) { + return { $numberDouble: `-${this.value.toFixed(1)}` }; + } + + let $numberDouble: string; + if (Number.isInteger(this.value)) { + $numberDouble = this.value.toFixed(1); + if ($numberDouble.length >= 13) { + $numberDouble = this.value.toExponential(13).toUpperCase(); + } + } else { + $numberDouble = this.value.toString(); + } + + return { $numberDouble }; + } + + /** @internal */ + static fromExtendedJSON(doc: DoubleExtended, options?: EJSONOptions): number | Double { + const doubleValue = parseFloat(doc.$numberDouble); + return options && options.relaxed ? doubleValue : new Double(doubleValue); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + const eJSON = this.toExtendedJSON() as DoubleExtended; + return `new Double(${eJSON.$numberDouble})`; + } +} + +Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' }); diff --git a/node_modules/bson/src/ensure_buffer.ts b/node_modules/bson/src/ensure_buffer.ts new file mode 100644 index 0000000..8b82a08 --- /dev/null +++ b/node_modules/bson/src/ensure_buffer.ts @@ -0,0 +1,27 @@ +import { Buffer } from 'buffer'; +import { BSONTypeError } from './error'; +import { isAnyArrayBuffer } from './parser/utils'; + +/** + * Makes sure that, if a Uint8Array is passed in, it is wrapped in a Buffer. + * + * @param potentialBuffer - The potential buffer + * @returns Buffer the input if potentialBuffer is a buffer, or a buffer that + * wraps a passed in Uint8Array + * @throws BSONTypeError If anything other than a Buffer or Uint8Array is passed in + */ +export function ensureBuffer(potentialBuffer: Buffer | ArrayBufferView | ArrayBuffer): Buffer { + if (ArrayBuffer.isView(potentialBuffer)) { + return Buffer.from( + potentialBuffer.buffer, + potentialBuffer.byteOffset, + potentialBuffer.byteLength + ); + } + + if (isAnyArrayBuffer(potentialBuffer)) { + return Buffer.from(potentialBuffer); + } + + throw new BSONTypeError('Must use either Buffer or TypedArray'); +} diff --git a/node_modules/bson/src/error.ts b/node_modules/bson/src/error.ts new file mode 100644 index 0000000..8f1a417 --- /dev/null +++ b/node_modules/bson/src/error.ts @@ -0,0 +1,23 @@ +/** @public */ +export class BSONError extends Error { + constructor(message: string) { + super(message); + Object.setPrototypeOf(this, BSONError.prototype); + } + + get name(): string { + return 'BSONError'; + } +} + +/** @public */ +export class BSONTypeError extends TypeError { + constructor(message: string) { + super(message); + Object.setPrototypeOf(this, BSONTypeError.prototype); + } + + get name(): string { + return 'BSONTypeError'; + } +} diff --git a/node_modules/bson/src/extended_json.ts b/node_modules/bson/src/extended_json.ts new file mode 100644 index 0000000..9026962 --- /dev/null +++ b/node_modules/bson/src/extended_json.ts @@ -0,0 +1,462 @@ +import { Binary } from './binary'; +import type { Document } from './bson'; +import { Code } from './code'; +import { DBRef, isDBRefLike } from './db_ref'; +import { Decimal128 } from './decimal128'; +import { Double } from './double'; +import { BSONError, BSONTypeError } from './error'; +import { Int32 } from './int_32'; +import { Long } from './long'; +import { MaxKey } from './max_key'; +import { MinKey } from './min_key'; +import { ObjectId } from './objectid'; +import { isDate, isObjectLike, isRegExp } from './parser/utils'; +import { BSONRegExp } from './regexp'; +import { BSONSymbol } from './symbol'; +import { Timestamp } from './timestamp'; + +/** @public */ +export type EJSONOptions = EJSON.Options; + +/** @internal */ +type BSONType = + | Binary + | Code + | DBRef + | Decimal128 + | Double + | Int32 + | Long + | MaxKey + | MinKey + | ObjectId + | BSONRegExp + | BSONSymbol + | Timestamp; + +export function isBSONType(value: unknown): value is BSONType { + return ( + isObjectLike(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string' + ); +} + +// INT32 boundaries +const BSON_INT32_MAX = 0x7fffffff; +const BSON_INT32_MIN = -0x80000000; +// INT64 boundaries +// const BSON_INT64_MAX = 0x7fffffffffffffff; // TODO(NODE-4377): This number cannot be precisely represented in JS +const BSON_INT64_MAX = 0x8000000000000000; +const BSON_INT64_MIN = -0x8000000000000000; + +// all the types where we don't need to do any special processing and can just pass the EJSON +//straight to type.fromExtendedJSON +const keysToCodecs = { + $oid: ObjectId, + $binary: Binary, + $uuid: Binary, + $symbol: BSONSymbol, + $numberInt: Int32, + $numberDecimal: Decimal128, + $numberDouble: Double, + $numberLong: Long, + $minKey: MinKey, + $maxKey: MaxKey, + $regex: BSONRegExp, + $regularExpression: BSONRegExp, + $timestamp: Timestamp +} as const; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function deserializeValue(value: any, options: EJSON.Options = {}) { + if (typeof value === 'number') { + if (options.relaxed || options.legacy) { + return value; + } + + // if it's an integer, should interpret as smallest BSON integer + // that can represent it exactly. (if out of range, interpret as double.) + if (Math.floor(value) === value) { + if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) return new Int32(value); + if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) return Long.fromNumber(value); + } + + // If the number is a non-integer or out of integer range, should interpret as BSON Double. + return new Double(value); + } + + // from here on out we're looking for bson types, so bail if its not an object + if (value == null || typeof value !== 'object') return value; + + // upgrade deprecated undefined to null + if (value.$undefined) return null; + + const keys = Object.keys(value).filter( + k => k.startsWith('$') && value[k] != null + ) as (keyof typeof keysToCodecs)[]; + for (let i = 0; i < keys.length; i++) { + const c = keysToCodecs[keys[i]]; + if (c) return c.fromExtendedJSON(value, options); + } + + if (value.$date != null) { + const d = value.$date; + const date = new Date(); + + if (options.legacy) { + if (typeof d === 'number') date.setTime(d); + else if (typeof d === 'string') date.setTime(Date.parse(d)); + } else { + if (typeof d === 'string') date.setTime(Date.parse(d)); + else if (Long.isLong(d)) date.setTime(d.toNumber()); + else if (typeof d === 'number' && options.relaxed) date.setTime(d); + } + return date; + } + + if (value.$code != null) { + const copy = Object.assign({}, value); + if (value.$scope) { + copy.$scope = deserializeValue(value.$scope); + } + + return Code.fromExtendedJSON(value); + } + + if (isDBRefLike(value) || value.$dbPointer) { + const v = value.$ref ? value : value.$dbPointer; + + // we run into this in a "degenerate EJSON" case (with $id and $ref order flipped) + // because of the order JSON.parse goes through the document + if (v instanceof DBRef) return v; + + const dollarKeys = Object.keys(v).filter(k => k.startsWith('$')); + let valid = true; + dollarKeys.forEach(k => { + if (['$ref', '$id', '$db'].indexOf(k) === -1) valid = false; + }); + + // only make DBRef if $ keys are all valid + if (valid) return DBRef.fromExtendedJSON(v); + } + + return value; +} + +type EJSONSerializeOptions = EJSON.Options & { + seenObjects: { obj: unknown; propertyName: string }[]; +}; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeArray(array: any[], options: EJSONSerializeOptions): any[] { + return array.map((v: unknown, index: number) => { + options.seenObjects.push({ propertyName: `index ${index}`, obj: null }); + try { + return serializeValue(v, options); + } finally { + options.seenObjects.pop(); + } + }); +} + +function getISOString(date: Date) { + const isoStr = date.toISOString(); + // we should only show milliseconds in timestamp if they're non-zero + return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + 'Z'; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeValue(value: any, options: EJSONSerializeOptions): any { + if ((typeof value === 'object' || typeof value === 'function') && value !== null) { + const index = options.seenObjects.findIndex(entry => entry.obj === value); + if (index !== -1) { + const props = options.seenObjects.map(entry => entry.propertyName); + const leadingPart = props + .slice(0, index) + .map(prop => `${prop} -> `) + .join(''); + const alreadySeen = props[index]; + const circularPart = + ' -> ' + + props + .slice(index + 1, props.length - 1) + .map(prop => `${prop} -> `) + .join(''); + const current = props[props.length - 1]; + const leadingSpace = ' '.repeat(leadingPart.length + alreadySeen.length / 2); + const dashes = '-'.repeat( + circularPart.length + (alreadySeen.length + current.length) / 2 - 1 + ); + + throw new BSONTypeError( + 'Converting circular structure to EJSON:\n' + + ` ${leadingPart}${alreadySeen}${circularPart}${current}\n` + + ` ${leadingSpace}\\${dashes}/` + ); + } + options.seenObjects[options.seenObjects.length - 1].obj = value; + } + + if (Array.isArray(value)) return serializeArray(value, options); + + if (value === undefined) return null; + + if (value instanceof Date || isDate(value)) { + const dateNum = value.getTime(), + // is it in year range 1970-9999? + inRange = dateNum > -1 && dateNum < 253402318800000; + + if (options.legacy) { + return options.relaxed && inRange + ? { $date: value.getTime() } + : { $date: getISOString(value) }; + } + return options.relaxed && inRange + ? { $date: getISOString(value) } + : { $date: { $numberLong: value.getTime().toString() } }; + } + + if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) { + // it's an integer + if (Math.floor(value) === value) { + const int32Range = value >= BSON_INT32_MIN && value <= BSON_INT32_MAX, + int64Range = value >= BSON_INT64_MIN && value <= BSON_INT64_MAX; + + // interpret as being of the smallest BSON integer type that can represent the number exactly + if (int32Range) return { $numberInt: value.toString() }; + if (int64Range) return { $numberLong: value.toString() }; + } + return { $numberDouble: value.toString() }; + } + + if (value instanceof RegExp || isRegExp(value)) { + let flags = value.flags; + if (flags === undefined) { + const match = value.toString().match(/[gimuy]*$/); + if (match) { + flags = match[0]; + } + } + + const rx = new BSONRegExp(value.source, flags); + return rx.toExtendedJSON(options); + } + + if (value != null && typeof value === 'object') return serializeDocument(value, options); + return value; +} + +const BSON_TYPE_MAPPINGS = { + Binary: (o: Binary) => new Binary(o.value(), o.sub_type), + Code: (o: Code) => new Code(o.code, o.scope), + DBRef: (o: DBRef) => new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields), // "namespace" for 1.x library backwards compat + Decimal128: (o: Decimal128) => new Decimal128(o.bytes), + Double: (o: Double) => new Double(o.value), + Int32: (o: Int32) => new Int32(o.value), + Long: ( + o: Long & { + low_: number; + high_: number; + unsigned_: boolean | undefined; + } + ) => + Long.fromBits( + // underscore variants for 1.x backwards compatibility + o.low != null ? o.low : o.low_, + o.low != null ? o.high : o.high_, + o.low != null ? o.unsigned : o.unsigned_ + ), + MaxKey: () => new MaxKey(), + MinKey: () => new MinKey(), + ObjectID: (o: ObjectId) => new ObjectId(o), + ObjectId: (o: ObjectId) => new ObjectId(o), // support 4.0.0/4.0.1 before _bsontype was reverted back to ObjectID + BSONRegExp: (o: BSONRegExp) => new BSONRegExp(o.pattern, o.options), + Symbol: (o: BSONSymbol) => new BSONSymbol(o.value), + Timestamp: (o: Timestamp) => Timestamp.fromBits(o.low, o.high) +} as const; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function serializeDocument(doc: any, options: EJSONSerializeOptions) { + if (doc == null || typeof doc !== 'object') throw new BSONError('not an object instance'); + + const bsontype: BSONType['_bsontype'] = doc._bsontype; + if (typeof bsontype === 'undefined') { + // It's a regular object. Recursively serialize its property values. + const _doc: Document = {}; + for (const name in doc) { + options.seenObjects.push({ propertyName: name, obj: null }); + try { + const value = serializeValue(doc[name], options); + if (name === '__proto__') { + Object.defineProperty(_doc, name, { + value, + writable: true, + enumerable: true, + configurable: true + }); + } else { + _doc[name] = value; + } + } finally { + options.seenObjects.pop(); + } + } + return _doc; + } else if (isBSONType(doc)) { + // the "document" is really just a BSON type object + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let outDoc: any = doc; + if (typeof outDoc.toExtendedJSON !== 'function') { + // There's no EJSON serialization function on the object. It's probably an + // object created by a previous version of this library (or another library) + // that's duck-typing objects to look like they were generated by this library). + // Copy the object into this library's version of that type. + const mapper = BSON_TYPE_MAPPINGS[doc._bsontype]; + if (!mapper) { + throw new BSONTypeError('Unrecognized or invalid _bsontype: ' + doc._bsontype); + } + outDoc = mapper(outDoc); + } + + // Two BSON types may have nested objects that may need to be serialized too + if (bsontype === 'Code' && outDoc.scope) { + outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options)); + } else if (bsontype === 'DBRef' && outDoc.oid) { + outDoc = new DBRef( + serializeValue(outDoc.collection, options), + serializeValue(outDoc.oid, options), + serializeValue(outDoc.db, options), + serializeValue(outDoc.fields, options) + ); + } + + return outDoc.toExtendedJSON(options); + } else { + throw new BSONError('_bsontype must be a string, but was: ' + typeof bsontype); + } +} + +/** + * EJSON parse / stringify API + * @public + */ +// the namespace here is used to emulate `export * as EJSON from '...'` +// which as of now (sept 2020) api-extractor does not support +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace EJSON { + export interface Options { + /** Output using the Extended JSON v1 spec */ + legacy?: boolean; + /** Enable Extended JSON's `relaxed` mode, which attempts to return native JS types where possible, rather than BSON types */ + relaxed?: boolean; + /** + * Disable Extended JSON's `relaxed` mode, which attempts to return BSON types where possible, rather than native JS types + * @deprecated Please use the relaxed property instead + */ + strict?: boolean; + } + + /** + * Parse an Extended JSON string, constructing the JavaScript value or object described by that + * string. + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const text = '{ "int32": { "$numberInt": "10" } }'; + * + * // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } } + * console.log(EJSON.parse(text, { relaxed: false })); + * + * // prints { int32: 10 } + * console.log(EJSON.parse(text)); + * ``` + */ + export function parse(text: string, options?: EJSON.Options): SerializableTypes { + const finalOptions = Object.assign({}, { relaxed: true, legacy: false }, options); + + // relaxed implies not strict + if (typeof finalOptions.relaxed === 'boolean') finalOptions.strict = !finalOptions.relaxed; + if (typeof finalOptions.strict === 'boolean') finalOptions.relaxed = !finalOptions.strict; + + return JSON.parse(text, (key, value) => { + if (key.indexOf('\x00') !== -1) { + throw new BSONError( + `BSON Document field names cannot contain null bytes, found: ${JSON.stringify(key)}` + ); + } + return deserializeValue(value, finalOptions); + }); + } + + export type JSONPrimitive = string | number | boolean | null; + export type SerializableTypes = Document | Array | JSONPrimitive; + + /** + * Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer + * function is specified or optionally including only the specified properties if a replacer array + * is specified. + * + * @param value - The value to convert to extended JSON + * @param replacer - A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string + * @param space - A String or Number object that's used to insert white space into the output JSON string for readability purposes. + * @param options - Optional settings + * + * @example + * ```js + * const { EJSON } = require('bson'); + * const Int32 = require('mongodb').Int32; + * const doc = { int32: new Int32(10) }; + * + * // prints '{"int32":{"$numberInt":"10"}}' + * console.log(EJSON.stringify(doc, { relaxed: false })); + * + * // prints '{"int32":10}' + * console.log(EJSON.stringify(doc)); + * ``` + */ + export function stringify( + value: SerializableTypes, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + replacer?: (number | string)[] | ((this: any, key: string, value: any) => any) | EJSON.Options, + space?: string | number, + options?: EJSON.Options + ): string { + if (space != null && typeof space === 'object') { + options = space; + space = 0; + } + if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) { + options = replacer; + replacer = undefined; + space = 0; + } + const serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, { + seenObjects: [{ propertyName: '(root)', obj: null }] + }); + + const doc = serializeValue(value, serializeOptions); + return JSON.stringify(doc, replacer as Parameters[1], space); + } + + /** + * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object. + * + * @param value - The object to serialize + * @param options - Optional settings passed to the `stringify` function + */ + export function serialize(value: SerializableTypes, options?: EJSON.Options): Document { + options = options || {}; + return JSON.parse(stringify(value, options)); + } + + /** + * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types + * + * @param ejson - The Extended JSON object to deserialize + * @param options - Optional settings passed to the parse method + */ + export function deserialize(ejson: Document, options?: EJSON.Options): SerializableTypes { + options = options || {}; + return parse(JSON.stringify(ejson), options); + } +} diff --git a/node_modules/bson/src/int_32.ts b/node_modules/bson/src/int_32.ts new file mode 100644 index 0000000..b3b5760 --- /dev/null +++ b/node_modules/bson/src/int_32.ts @@ -0,0 +1,70 @@ +import type { EJSONOptions } from './extended_json'; + +/** @public */ +export interface Int32Extended { + $numberInt: string; +} + +/** + * A class representation of a BSON Int32 type. + * @public + * @category BSONType + */ +export class Int32 { + _bsontype!: 'Int32'; + + value!: number; + /** + * Create an Int32 type + * + * @param value - the number we want to represent as an int32. + */ + constructor(value: number | string) { + if (!(this instanceof Int32)) return new Int32(value); + + if ((value as unknown) instanceof Number) { + value = value.valueOf(); + } + + this.value = +value | 0; + } + + /** + * Access the number value. + * + * @returns returns the wrapped int32 number. + */ + valueOf(): number { + return this.value; + } + + toString(radix?: number): string { + return this.value.toString(radix); + } + + toJSON(): number { + return this.value; + } + + /** @internal */ + toExtendedJSON(options?: EJSONOptions): number | Int32Extended { + if (options && (options.relaxed || options.legacy)) return this.value; + return { $numberInt: this.value.toString() }; + } + + /** @internal */ + static fromExtendedJSON(doc: Int32Extended, options?: EJSONOptions): number | Int32 { + return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new Int32(doc.$numberInt); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + return `new Int32(${this.valueOf()})`; + } +} + +Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' }); diff --git a/node_modules/bson/src/long.ts b/node_modules/bson/src/long.ts new file mode 100644 index 0000000..ed3f6e1 --- /dev/null +++ b/node_modules/bson/src/long.ts @@ -0,0 +1,1040 @@ +import type { EJSONOptions } from './extended_json'; +import { isObjectLike } from './parser/utils'; +import type { Timestamp } from './timestamp'; + +interface LongWASMHelpers { + /** Gets the high bits of the last operation performed */ + get_high(this: void): number; + div_u( + this: void, + lowBits: number, + highBits: number, + lowBitsDivisor: number, + highBitsDivisor: number + ): number; + div_s( + this: void, + lowBits: number, + highBits: number, + lowBitsDivisor: number, + highBitsDivisor: number + ): number; + rem_u( + this: void, + lowBits: number, + highBits: number, + lowBitsDivisor: number, + highBitsDivisor: number + ): number; + rem_s( + this: void, + lowBits: number, + highBits: number, + lowBitsDivisor: number, + highBitsDivisor: number + ): number; + mul( + this: void, + lowBits: number, + highBits: number, + lowBitsMultiplier: number, + highBitsMultiplier: number + ): number; +} + +/** + * wasm optimizations, to do native i64 multiplication and divide + */ +let wasm: LongWASMHelpers | undefined = undefined; + +/* We do not want to have to include DOM types just for this check */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +declare const WebAssembly: any; + +try { + wasm = new WebAssembly.Instance( + new WebAssembly.Module( + // prettier-ignore + new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11]) + ), + {} + ).exports as unknown as LongWASMHelpers; +} catch { + // no wasm support +} + +const TWO_PWR_16_DBL = 1 << 16; +const TWO_PWR_24_DBL = 1 << 24; +const TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL; +const TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL; +const TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2; + +/** A cache of the Long representations of small integer values. */ +const INT_CACHE: { [key: number]: Long } = {}; + +/** A cache of the Long representations of small unsigned integer values. */ +const UINT_CACHE: { [key: number]: Long } = {}; + +/** @public */ +export interface LongExtended { + $numberLong: string; +} + +/** + * A class representing a 64-bit integer + * @public + * @category BSONType + * @remarks + * 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. + * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class. + */ +export class Long { + _bsontype!: 'Long'; + + /** An indicator used to reliably determine if an object is a Long or not. */ + __isLong__!: true; + + /** + * The high 32 bits as a signed value. + */ + high!: number; + + /** + * The low 32 bits as a signed value. + */ + low!: number; + + /** + * Whether unsigned or not. + */ + unsigned!: boolean; + + /** + * 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. + * + * Acceptable signatures are: + * - Long(low, high, unsigned?) + * - Long(bigint, unsigned?) + * - Long(string, unsigned?) + * + * @param low - The low (signed) 32 bits of the long + * @param high - The high (signed) 32 bits of the long + * @param unsigned - Whether unsigned or not, defaults to signed + */ + constructor(low: number | bigint | string = 0, high?: number | boolean, unsigned?: boolean) { + if (!(this instanceof Long)) return new Long(low, high, unsigned); + + if (typeof low === 'bigint') { + Object.assign(this, Long.fromBigInt(low, !!high)); + } else if (typeof low === 'string') { + Object.assign(this, Long.fromString(low, !!high)); + } else { + this.low = low | 0; + this.high = (high as number) | 0; + this.unsigned = !!unsigned; + } + + Object.defineProperty(this, '__isLong__', { + value: true, + configurable: false, + writable: false, + enumerable: false + }); + } + + static TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL); + + /** Maximum unsigned value. */ + static MAX_UNSIGNED_VALUE = Long.fromBits(0xffffffff | 0, 0xffffffff | 0, true); + /** Signed zero */ + static ZERO = Long.fromInt(0); + /** Unsigned zero. */ + static UZERO = Long.fromInt(0, true); + /** Signed one. */ + static ONE = Long.fromInt(1); + /** Unsigned one. */ + static UONE = Long.fromInt(1, true); + /** Signed negative one. */ + static NEG_ONE = Long.fromInt(-1); + /** Maximum signed value. */ + static MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0, false); + /** Minimum signed value. */ + static MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false); + + /** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. + * Each is assumed to use 32 bits. + * @param lowBits - The low 32 bits + * @param highBits - The high 32 bits + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long { + return new Long(lowBits, highBits, unsigned); + } + + /** + * Returns a Long representing the given 32 bit integer value. + * @param value - The 32 bit integer in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromInt(value: number, unsigned?: boolean): Long { + let obj, cachedObj, cache; + if (unsigned) { + value >>>= 0; + if ((cache = 0 <= value && value < 256)) { + cachedObj = UINT_CACHE[value]; + if (cachedObj) return cachedObj; + } + obj = Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true); + if (cache) UINT_CACHE[value] = obj; + return obj; + } else { + value |= 0; + if ((cache = -128 <= value && value < 128)) { + cachedObj = INT_CACHE[value]; + if (cachedObj) return cachedObj; + } + obj = Long.fromBits(value, value < 0 ? -1 : 0, false); + if (cache) INT_CACHE[value] = obj; + return obj; + } + } + + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromNumber(value: number, unsigned?: boolean): Long { + if (isNaN(value)) return unsigned ? Long.UZERO : Long.ZERO; + if (unsigned) { + if (value < 0) return Long.UZERO; + if (value >= TWO_PWR_64_DBL) return Long.MAX_UNSIGNED_VALUE; + } else { + if (value <= -TWO_PWR_63_DBL) return Long.MIN_VALUE; + if (value + 1 >= TWO_PWR_63_DBL) return Long.MAX_VALUE; + } + if (value < 0) return Long.fromNumber(-value, unsigned).neg(); + return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned); + } + + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * @param value - The number in question + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromBigInt(value: bigint, unsigned?: boolean): Long { + return Long.fromString(value.toString(), unsigned); + } + + /** + * Returns a Long representation of the given string, written using the specified radix. + * @param str - The textual representation of the Long + * @param unsigned - Whether unsigned or not, defaults to signed + * @param radix - The radix in which the text is written (2-36), defaults to 10 + * @returns The corresponding Long value + */ + static fromString(str: string, unsigned?: boolean, radix?: number): Long { + if (str.length === 0) throw Error('empty string'); + if (str === 'NaN' || str === 'Infinity' || str === '+Infinity' || str === '-Infinity') + return Long.ZERO; + if (typeof unsigned === 'number') { + // For goog.math.long compatibility + (radix = unsigned), (unsigned = false); + } else { + unsigned = !!unsigned; + } + radix = radix || 10; + if (radix < 2 || 36 < radix) throw RangeError('radix'); + + let p; + if ((p = str.indexOf('-')) > 0) throw Error('interior hyphen'); + else if (p === 0) { + return Long.fromString(str.substring(1), unsigned, radix).neg(); + } + + // Do several (8) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + const radixToPower = Long.fromNumber(Math.pow(radix, 8)); + + let result = Long.ZERO; + for (let i = 0; i < str.length; i += 8) { + const size = Math.min(8, str.length - i), + value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + const power = Long.fromNumber(Math.pow(radix, size)); + result = result.mul(power).add(Long.fromNumber(value)); + } else { + result = result.mul(radixToPower); + result = result.add(Long.fromNumber(value)); + } + } + result.unsigned = unsigned; + return result; + } + + /** + * Creates a Long from its byte representation. + * @param bytes - Byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @param le - Whether little or big endian, defaults to big endian + * @returns The corresponding Long value + */ + static fromBytes(bytes: number[], unsigned?: boolean, le?: boolean): Long { + return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned); + } + + /** + * Creates a Long from its little endian byte representation. + * @param bytes - Little endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromBytesLE(bytes: number[], unsigned?: boolean): Long { + return new Long( + bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24), + bytes[4] | (bytes[5] << 8) | (bytes[6] << 16) | (bytes[7] << 24), + unsigned + ); + } + + /** + * Creates a Long from its big endian byte representation. + * @param bytes - Big endian byte representation + * @param unsigned - Whether unsigned or not, defaults to signed + * @returns The corresponding Long value + */ + static fromBytesBE(bytes: number[], unsigned?: boolean): Long { + return new Long( + (bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7], + (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3], + unsigned + ); + } + + /** + * Tests if the specified object is a Long. + */ + static isLong(value: unknown): value is Long { + return isObjectLike(value) && value['__isLong__'] === true; + } + + /** + * Converts the specified value to a Long. + * @param unsigned - Whether unsigned or not, defaults to signed + */ + static fromValue( + val: number | string | { low: number; high: number; unsigned?: boolean }, + unsigned?: boolean + ): Long { + if (typeof val === 'number') return Long.fromNumber(val, unsigned); + if (typeof val === 'string') return Long.fromString(val, unsigned); + // Throws for non-objects, converts non-instanceof Long: + return Long.fromBits( + val.low, + val.high, + typeof unsigned === 'boolean' ? unsigned : val.unsigned + ); + } + + /** Returns the sum of this and the specified Long. */ + add(addend: string | number | Long | Timestamp): Long { + if (!Long.isLong(addend)) addend = Long.fromValue(addend); + + // Divide each number into 4 chunks of 16 bits, and then sum the chunks. + + const a48 = this.high >>> 16; + const a32 = this.high & 0xffff; + const a16 = this.low >>> 16; + const a00 = this.low & 0xffff; + + const b48 = addend.high >>> 16; + const b32 = addend.high & 0xffff; + const b16 = addend.low >>> 16; + const b00 = addend.low & 0xffff; + + let 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, this.unsigned); + } + + /** + * Returns the sum of this and the specified Long. + * @returns Sum + */ + and(other: string | number | Long | Timestamp): Long { + if (!Long.isLong(other)) other = Long.fromValue(other); + return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); + } + + /** + * Compares this Long's value with the specified's. + * @returns 0 if they are the same, 1 if the this is greater and -1 if the given one is greater + */ + compare(other: string | number | Long | Timestamp): 0 | 1 | -1 { + if (!Long.isLong(other)) other = Long.fromValue(other); + if (this.eq(other)) return 0; + const thisNeg = this.isNegative(), + otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) return -1; + if (!thisNeg && otherNeg) return 1; + // At this point the sign bits are the same + if (!this.unsigned) return this.sub(other).isNegative() ? -1 : 1; + // Both are positive if at least one is unsigned + return other.high >>> 0 > this.high >>> 0 || + (other.high === this.high && other.low >>> 0 > this.low >>> 0) + ? -1 + : 1; + } + + /** This is an alias of {@link Long.compare} */ + comp(other: string | number | Long | Timestamp): 0 | 1 | -1 { + return this.compare(other); + } + + /** + * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned. + * @returns Quotient + */ + divide(divisor: string | number | Long | Timestamp): Long { + if (!Long.isLong(divisor)) divisor = Long.fromValue(divisor); + if (divisor.isZero()) throw Error('division by zero'); + + // use wasm support if present + if (wasm) { + // guard against signed division overflow: the largest + // negative number / -1 would be 1 larger than the largest + // positive number, due to two's complement. + if ( + !this.unsigned && + this.high === -0x80000000 && + divisor.low === -1 && + divisor.high === -1 + ) { + // be consistent with non-wasm code path + return this; + } + const low = (this.unsigned ? wasm.div_u : wasm.div_s)( + this.low, + this.high, + divisor.low, + divisor.high + ); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + + if (this.isZero()) return this.unsigned ? Long.UZERO : Long.ZERO; + let approx, rem, res; + if (!this.unsigned) { + // This section is only relevant for signed longs and is derived from the + // closure library as a whole. + if (this.eq(Long.MIN_VALUE)) { + if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE)) return Long.MIN_VALUE; + // recall that -MIN_VALUE == MIN_VALUE + else if (divisor.eq(Long.MIN_VALUE)) return Long.ONE; + else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + const halfThis = this.shr(1); + approx = halfThis.div(divisor).shl(1); + if (approx.eq(Long.ZERO)) { + return divisor.isNegative() ? Long.ONE : Long.NEG_ONE; + } else { + rem = this.sub(divisor.mul(approx)); + res = approx.add(rem.div(divisor)); + return res; + } + } + } else if (divisor.eq(Long.MIN_VALUE)) return this.unsigned ? Long.UZERO : Long.ZERO; + if (this.isNegative()) { + if (divisor.isNegative()) return this.neg().div(divisor.neg()); + return this.neg().div(divisor).neg(); + } else if (divisor.isNegative()) return this.div(divisor.neg()).neg(); + res = Long.ZERO; + } else { + // The algorithm below has not been made for unsigned longs. It's therefore + // required to take special care of the MSB prior to running it. + if (!divisor.unsigned) divisor = divisor.toUnsigned(); + if (divisor.gt(this)) return Long.UZERO; + if (divisor.gt(this.shru(1))) + // 15 >>> 1 = 7 ; with divisor = 8 ; true + return Long.UONE; + res = Long.UZERO; + } + + // 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. + // eslint-disable-next-line @typescript-eslint/no-this-alias + rem = this; + while (rem.gte(divisor)) { + // 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() / divisor.toNumber())); + + // We will tweak the approximate result by changing it in the 48-th digit or + // the smallest non-fractional digit, whichever is larger. + const log2 = Math.ceil(Math.log(approx) / Math.LN2); + const 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. + let approxRes = Long.fromNumber(approx); + let approxRem = approxRes.mul(divisor); + while (approxRem.isNegative() || approxRem.gt(rem)) { + approx -= delta; + approxRes = Long.fromNumber(approx, this.unsigned); + approxRem = approxRes.mul(divisor); + } + + // 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.sub(approxRem); + } + return res; + } + + /**This is an alias of {@link Long.divide} */ + div(divisor: string | number | Long | Timestamp): Long { + return this.divide(divisor); + } + + /** + * Tests if this Long's value equals the specified's. + * @param other - Other value + */ + equals(other: string | number | Long | Timestamp): boolean { + if (!Long.isLong(other)) other = Long.fromValue(other); + if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1) + return false; + return this.high === other.high && this.low === other.low; + } + + /** This is an alias of {@link Long.equals} */ + eq(other: string | number | Long | Timestamp): boolean { + return this.equals(other); + } + + /** Gets the high 32 bits as a signed integer. */ + getHighBits(): number { + return this.high; + } + + /** Gets the high 32 bits as an unsigned integer. */ + getHighBitsUnsigned(): number { + return this.high >>> 0; + } + + /** Gets the low 32 bits as a signed integer. */ + getLowBits(): number { + return this.low; + } + + /** Gets the low 32 bits as an unsigned integer. */ + getLowBitsUnsigned(): number { + return this.low >>> 0; + } + + /** Gets the number of bits needed to represent the absolute value of this Long. */ + getNumBitsAbs(): number { + if (this.isNegative()) { + // Unsigned Longs are never negative + return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); + } + const val = this.high !== 0 ? this.high : this.low; + let bit: number; + for (bit = 31; bit > 0; bit--) if ((val & (1 << bit)) !== 0) break; + return this.high !== 0 ? bit + 33 : bit + 1; + } + + /** Tests if this Long's value is greater than the specified's. */ + greaterThan(other: string | number | Long | Timestamp): boolean { + return this.comp(other) > 0; + } + + /** This is an alias of {@link Long.greaterThan} */ + gt(other: string | number | Long | Timestamp): boolean { + return this.greaterThan(other); + } + + /** Tests if this Long's value is greater than or equal the specified's. */ + greaterThanOrEqual(other: string | number | Long | Timestamp): boolean { + return this.comp(other) >= 0; + } + + /** This is an alias of {@link Long.greaterThanOrEqual} */ + gte(other: string | number | Long | Timestamp): boolean { + return this.greaterThanOrEqual(other); + } + /** This is an alias of {@link Long.greaterThanOrEqual} */ + ge(other: string | number | Long | Timestamp): boolean { + return this.greaterThanOrEqual(other); + } + + /** Tests if this Long's value is even. */ + isEven(): boolean { + return (this.low & 1) === 0; + } + + /** Tests if this Long's value is negative. */ + isNegative(): boolean { + return !this.unsigned && this.high < 0; + } + + /** Tests if this Long's value is odd. */ + isOdd(): boolean { + return (this.low & 1) === 1; + } + + /** Tests if this Long's value is positive. */ + isPositive(): boolean { + return this.unsigned || this.high >= 0; + } + + /** Tests if this Long's value equals zero. */ + isZero(): boolean { + return this.high === 0 && this.low === 0; + } + + /** Tests if this Long's value is less than the specified's. */ + lessThan(other: string | number | Long | Timestamp): boolean { + return this.comp(other) < 0; + } + + /** This is an alias of {@link Long#lessThan}. */ + lt(other: string | number | Long | Timestamp): boolean { + return this.lessThan(other); + } + + /** Tests if this Long's value is less than or equal the specified's. */ + lessThanOrEqual(other: string | number | Long | Timestamp): boolean { + return this.comp(other) <= 0; + } + + /** This is an alias of {@link Long.lessThanOrEqual} */ + lte(other: string | number | Long | Timestamp): boolean { + return this.lessThanOrEqual(other); + } + + /** Returns this Long modulo the specified. */ + modulo(divisor: string | number | Long | Timestamp): Long { + if (!Long.isLong(divisor)) divisor = Long.fromValue(divisor); + + // use wasm support if present + if (wasm) { + const low = (this.unsigned ? wasm.rem_u : wasm.rem_s)( + this.low, + this.high, + divisor.low, + divisor.high + ); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + + return this.sub(this.div(divisor).mul(divisor)); + } + + /** This is an alias of {@link Long.modulo} */ + mod(divisor: string | number | Long | Timestamp): Long { + return this.modulo(divisor); + } + /** This is an alias of {@link Long.modulo} */ + rem(divisor: string | number | Long | Timestamp): Long { + return this.modulo(divisor); + } + + /** + * Returns the product of this and the specified Long. + * @param multiplier - Multiplier + * @returns Product + */ + multiply(multiplier: string | number | Long | Timestamp): Long { + if (this.isZero()) return Long.ZERO; + if (!Long.isLong(multiplier)) multiplier = Long.fromValue(multiplier); + + // use wasm support if present + if (wasm) { + const low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high); + return Long.fromBits(low, wasm.get_high(), this.unsigned); + } + + if (multiplier.isZero()) return Long.ZERO; + if (this.eq(Long.MIN_VALUE)) return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (multiplier.eq(Long.MIN_VALUE)) return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; + + if (this.isNegative()) { + if (multiplier.isNegative()) return this.neg().mul(multiplier.neg()); + else return this.neg().mul(multiplier).neg(); + } else if (multiplier.isNegative()) return this.mul(multiplier.neg()).neg(); + + // If both longs are small, use float multiplication + if (this.lt(Long.TWO_PWR_24) && multiplier.lt(Long.TWO_PWR_24)) + return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); + + // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products. + // We can skip products that would overflow. + + const a48 = this.high >>> 16; + const a32 = this.high & 0xffff; + const a16 = this.low >>> 16; + const a00 = this.low & 0xffff; + + const b48 = multiplier.high >>> 16; + const b32 = multiplier.high & 0xffff; + const b16 = multiplier.low >>> 16; + const b00 = multiplier.low & 0xffff; + + let 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, this.unsigned); + } + + /** This is an alias of {@link Long.multiply} */ + mul(multiplier: string | number | Long | Timestamp): Long { + return this.multiply(multiplier); + } + + /** Returns the Negation of this Long's value. */ + negate(): Long { + if (!this.unsigned && this.eq(Long.MIN_VALUE)) return Long.MIN_VALUE; + return this.not().add(Long.ONE); + } + + /** This is an alias of {@link Long.negate} */ + neg(): Long { + return this.negate(); + } + + /** Returns the bitwise NOT of this Long. */ + not(): Long { + return Long.fromBits(~this.low, ~this.high, this.unsigned); + } + + /** Tests if this Long's value differs from the specified's. */ + notEquals(other: string | number | Long | Timestamp): boolean { + return !this.equals(other); + } + + /** This is an alias of {@link Long.notEquals} */ + neq(other: string | number | Long | Timestamp): boolean { + return this.notEquals(other); + } + /** This is an alias of {@link Long.notEquals} */ + ne(other: string | number | Long | Timestamp): boolean { + return this.notEquals(other); + } + + /** + * Returns the bitwise OR of this Long and the specified. + */ + or(other: number | string | Long): Long { + if (!Long.isLong(other)) other = Long.fromValue(other); + return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); + } + + /** + * Returns this Long with bits shifted to the left by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + shiftLeft(numBits: number | Long): Long { + if (Long.isLong(numBits)) numBits = numBits.toInt(); + if ((numBits &= 63) === 0) return this; + else if (numBits < 32) + return Long.fromBits( + this.low << numBits, + (this.high << numBits) | (this.low >>> (32 - numBits)), + this.unsigned + ); + else return Long.fromBits(0, this.low << (numBits - 32), this.unsigned); + } + + /** This is an alias of {@link Long.shiftLeft} */ + shl(numBits: number | Long): Long { + return this.shiftLeft(numBits); + } + + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + shiftRight(numBits: number | Long): Long { + if (Long.isLong(numBits)) numBits = numBits.toInt(); + if ((numBits &= 63) === 0) return this; + else if (numBits < 32) + return Long.fromBits( + (this.low >>> numBits) | (this.high << (32 - numBits)), + this.high >> numBits, + this.unsigned + ); + else return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); + } + + /** This is an alias of {@link Long.shiftRight} */ + shr(numBits: number | Long): Long { + return this.shiftRight(numBits); + } + + /** + * Returns this Long with bits logically shifted to the right by the given amount. + * @param numBits - Number of bits + * @returns Shifted Long + */ + shiftRightUnsigned(numBits: Long | number): Long { + if (Long.isLong(numBits)) numBits = numBits.toInt(); + numBits &= 63; + if (numBits === 0) return this; + else { + const high = this.high; + if (numBits < 32) { + const low = this.low; + return Long.fromBits( + (low >>> numBits) | (high << (32 - numBits)), + high >>> numBits, + this.unsigned + ); + } else if (numBits === 32) return Long.fromBits(high, 0, this.unsigned); + else return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned); + } + } + + /** This is an alias of {@link Long.shiftRightUnsigned} */ + shr_u(numBits: number | Long): Long { + return this.shiftRightUnsigned(numBits); + } + /** This is an alias of {@link Long.shiftRightUnsigned} */ + shru(numBits: number | Long): Long { + return this.shiftRightUnsigned(numBits); + } + + /** + * Returns the difference of this and the specified Long. + * @param subtrahend - Subtrahend + * @returns Difference + */ + subtract(subtrahend: string | number | Long | Timestamp): Long { + if (!Long.isLong(subtrahend)) subtrahend = Long.fromValue(subtrahend); + return this.add(subtrahend.neg()); + } + + /** This is an alias of {@link Long.subtract} */ + sub(subtrahend: string | number | Long | Timestamp): Long { + return this.subtract(subtrahend); + } + + /** Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. */ + toInt(): number { + return this.unsigned ? this.low >>> 0 : this.low; + } + + /** Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). */ + toNumber(): number { + if (this.unsigned) return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0); + return this.high * TWO_PWR_32_DBL + (this.low >>> 0); + } + + /** Converts the Long to a BigInt (arbitrary precision). */ + toBigInt(): bigint { + return BigInt(this.toString()); + } + + /** + * Converts this Long to its byte representation. + * @param le - Whether little or big endian, defaults to big endian + * @returns Byte representation + */ + toBytes(le?: boolean): number[] { + return le ? this.toBytesLE() : this.toBytesBE(); + } + + /** + * Converts this Long to its little endian byte representation. + * @returns Little endian byte representation + */ + toBytesLE(): number[] { + const hi = this.high, + lo = this.low; + return [ + lo & 0xff, + (lo >>> 8) & 0xff, + (lo >>> 16) & 0xff, + lo >>> 24, + hi & 0xff, + (hi >>> 8) & 0xff, + (hi >>> 16) & 0xff, + hi >>> 24 + ]; + } + + /** + * Converts this Long to its big endian byte representation. + * @returns Big endian byte representation + */ + toBytesBE(): number[] { + const hi = this.high, + lo = this.low; + return [ + hi >>> 24, + (hi >>> 16) & 0xff, + (hi >>> 8) & 0xff, + hi & 0xff, + lo >>> 24, + (lo >>> 16) & 0xff, + (lo >>> 8) & 0xff, + lo & 0xff + ]; + } + + /** + * Converts this Long to signed. + */ + toSigned(): Long { + if (!this.unsigned) return this; + return Long.fromBits(this.low, this.high, false); + } + + /** + * Converts the Long to a string written in the specified radix. + * @param radix - Radix (2-36), defaults to 10 + * @throws RangeError If `radix` is out of range + */ + toString(radix?: number): string { + radix = radix || 10; + if (radix < 2 || 36 < radix) throw RangeError('radix'); + if (this.isZero()) return '0'; + if (this.isNegative()) { + // Unsigned Longs are never negative + if (this.eq(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. + const radixLong = Long.fromNumber(radix), + div = this.div(radixLong), + rem1 = div.mul(radixLong).sub(this); + return div.toString(radix) + rem1.toInt().toString(radix); + } else return '-' + this.neg().toString(radix); + } + + // Do several (6) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + const radixToPower = Long.fromNumber(Math.pow(radix, 6), this.unsigned); + // eslint-disable-next-line @typescript-eslint/no-this-alias + let rem: Long = this; + let result = ''; + // eslint-disable-next-line no-constant-condition + while (true) { + const remDiv = rem.div(radixToPower); + const intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0; + let digits = intval.toString(radix); + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } else { + while (digits.length < 6) digits = '0' + digits; + result = '' + digits + result; + } + } + } + + /** Converts this Long to unsigned. */ + toUnsigned(): Long { + if (this.unsigned) return this; + return Long.fromBits(this.low, this.high, true); + } + + /** Returns the bitwise XOR of this Long and the given one. */ + xor(other: Long | number | string): Long { + if (!Long.isLong(other)) other = Long.fromValue(other); + return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); + } + + /** This is an alias of {@link Long.isZero} */ + eqz(): boolean { + return this.isZero(); + } + + /** This is an alias of {@link Long.lessThanOrEqual} */ + le(other: string | number | Long | Timestamp): boolean { + return this.lessThanOrEqual(other); + } + + /* + **************************************************************** + * BSON SPECIFIC ADDITIONS * + **************************************************************** + */ + toExtendedJSON(options?: EJSONOptions): number | LongExtended { + if (options && options.relaxed) return this.toNumber(); + return { $numberLong: this.toString() }; + } + static fromExtendedJSON(doc: { $numberLong: string }, options?: EJSONOptions): number | Long { + const result = Long.fromString(doc.$numberLong); + return options && options.relaxed ? result.toNumber() : result; + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + return `new Long("${this.toString()}"${this.unsigned ? ', true' : ''})`; + } +} + +Object.defineProperty(Long.prototype, '__isLong__', { value: true }); +Object.defineProperty(Long.prototype, '_bsontype', { value: 'Long' }); diff --git a/node_modules/bson/src/map.ts b/node_modules/bson/src/map.ts new file mode 100644 index 0000000..ba00329 --- /dev/null +++ b/node_modules/bson/src/map.ts @@ -0,0 +1,119 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +// We have an ES6 Map available, return the native instance + +import { getGlobal } from './utils/global'; + +/** @public */ +let bsonMap: MapConstructor; + +const bsonGlobal = getGlobal<{ Map?: MapConstructor }>(); +if (bsonGlobal.Map) { + bsonMap = bsonGlobal.Map; +} else { + // We will return a polyfill + bsonMap = class Map { + private _keys: string[]; + private _values: Record; + constructor(array: [string, any][] = []) { + this._keys = []; + this._values = {}; + + for (let i = 0; i < array.length; i++) { + if (array[i] == null) continue; // skip null and undefined + const entry = array[i]; + const key = entry[0]; + const 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 }; + } + } + clear() { + this._keys = []; + this._values = {}; + } + delete(key: string) { + const 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; + } + entries() { + let index = 0; + + return { + next: () => { + const key = this._keys[index++]; + return { + value: key !== undefined ? [key, this._values[key].v] : undefined, + done: key !== undefined ? false : true + }; + } + }; + } + forEach(callback: (this: this, value: any, key: string, self: this) => void, self?: this) { + self = self || this; + + for (let i = 0; i < this._keys.length; i++) { + const key = this._keys[i]; + // Call the forEach callback + callback.call(self, this._values[key].v, key, self); + } + } + get(key: string) { + return this._values[key] ? this._values[key].v : undefined; + } + has(key: string) { + return this._values[key] != null; + } + keys() { + let index = 0; + + return { + next: () => { + const key = this._keys[index++]; + return { + value: key !== undefined ? key : undefined, + done: key !== undefined ? false : true + }; + } + }; + } + set(key: string, value: any) { + 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; + } + values() { + let index = 0; + + return { + next: () => { + const key = this._keys[index++]; + return { + value: key !== undefined ? this._values[key].v : undefined, + done: key !== undefined ? false : true + }; + } + }; + } + get size() { + return this._keys.length; + } + } as unknown as MapConstructor; +} + +export { bsonMap as Map }; diff --git a/node_modules/bson/src/max_key.ts b/node_modules/bson/src/max_key.ts new file mode 100644 index 0000000..0ff3d36 --- /dev/null +++ b/node_modules/bson/src/max_key.ts @@ -0,0 +1,38 @@ +/** @public */ +export interface MaxKeyExtended { + $maxKey: 1; +} + +/** + * A class representation of the BSON MaxKey type. + * @public + * @category BSONType + */ +export class MaxKey { + _bsontype!: 'MaxKey'; + + constructor() { + if (!(this instanceof MaxKey)) return new MaxKey(); + } + + /** @internal */ + toExtendedJSON(): MaxKeyExtended { + return { $maxKey: 1 }; + } + + /** @internal */ + static fromExtendedJSON(): MaxKey { + return new MaxKey(); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + return 'new MaxKey()'; + } +} + +Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' }); diff --git a/node_modules/bson/src/min_key.ts b/node_modules/bson/src/min_key.ts new file mode 100644 index 0000000..f872b1e --- /dev/null +++ b/node_modules/bson/src/min_key.ts @@ -0,0 +1,38 @@ +/** @public */ +export interface MinKeyExtended { + $minKey: 1; +} + +/** + * A class representation of the BSON MinKey type. + * @public + * @category BSONType + */ +export class MinKey { + _bsontype!: 'MinKey'; + + constructor() { + if (!(this instanceof MinKey)) return new MinKey(); + } + + /** @internal */ + toExtendedJSON(): MinKeyExtended { + return { $minKey: 1 }; + } + + /** @internal */ + static fromExtendedJSON(): MinKey { + return new MinKey(); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + return 'new MinKey()'; + } +} + +Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' }); diff --git a/node_modules/bson/src/objectid.ts b/node_modules/bson/src/objectid.ts new file mode 100644 index 0000000..7bf012d --- /dev/null +++ b/node_modules/bson/src/objectid.ts @@ -0,0 +1,354 @@ +import { Buffer } from 'buffer'; +import { ensureBuffer } from './ensure_buffer'; +import { BSONTypeError } from './error'; +import { deprecate, isUint8Array, randomBytes } from './parser/utils'; + +// Regular expression that checks for hex value +const checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$'); + +// Unique sequence for the current process (initialized on first use) +let PROCESS_UNIQUE: Uint8Array | null = null; + +/** @public */ +export interface ObjectIdLike { + id: string | Buffer; + __id?: string; + toHexString(): string; +} + +/** @public */ +export interface ObjectIdExtended { + $oid: string; +} + +const kId = Symbol('id'); + +/** + * A class representation of the BSON ObjectId type. + * @public + * @category BSONType + */ +export class ObjectId { + _bsontype!: 'ObjectID'; + + /** @internal */ + static index = Math.floor(Math.random() * 0xffffff); + + static cacheHexString: boolean; + + /** ObjectId Bytes @internal */ + private [kId]!: Buffer; + /** ObjectId hexString cache @internal */ + private __id?: string; + + /** + * Create an ObjectId type + * + * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number. + */ + constructor(inputId?: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array) { + if (!(this instanceof ObjectId)) return new ObjectId(inputId); + + // workingId is set based on type of input and whether valid id exists for the input + let workingId; + if (typeof inputId === 'object' && inputId && 'id' in inputId) { + if (typeof inputId.id !== 'string' && !ArrayBuffer.isView(inputId.id)) { + throw new BSONTypeError( + 'Argument passed in must have an id that is of type string or Buffer' + ); + } + if ('toHexString' in inputId && typeof inputId.toHexString === 'function') { + workingId = Buffer.from(inputId.toHexString(), 'hex'); + } else { + workingId = inputId.id; + } + } else { + workingId = inputId; + } + + // the following cases use workingId to construct an ObjectId + if (workingId == null || typeof workingId === 'number') { + // The most common use case (blank id, new objectId instance) + // Generate a new id + this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined); + } else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) { + // If intstanceof matches we can escape calling ensure buffer in Node.js environments + this[kId] = workingId instanceof Buffer ? workingId : ensureBuffer(workingId); + } else if (typeof workingId === 'string') { + if (workingId.length === 12) { + const bytes = Buffer.from(workingId); + if (bytes.byteLength === 12) { + this[kId] = bytes; + } else { + throw new BSONTypeError('Argument passed in must be a string of 12 bytes'); + } + } else if (workingId.length === 24 && checkForHexRegExp.test(workingId)) { + this[kId] = Buffer.from(workingId, 'hex'); + } else { + throw new BSONTypeError( + 'Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer' + ); + } + } else { + throw new BSONTypeError('Argument passed in does not match the accepted types'); + } + // If we are caching the hex string + if (ObjectId.cacheHexString) { + this.__id = this.id.toString('hex'); + } + } + + /** + * The ObjectId bytes + * @readonly + */ + get id(): Buffer { + return this[kId]; + } + + set id(value: Buffer) { + this[kId] = value; + if (ObjectId.cacheHexString) { + this.__id = value.toString('hex'); + } + } + + /** + * The generation time of this ObjectId instance + * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch + */ + get generationTime(): number { + return this.id.readInt32BE(0); + } + + set generationTime(value: number) { + // Encode time into first 4 bytes + this.id.writeUInt32BE(value, 0); + } + + /** Returns the ObjectId id as a 24 character hex string representation */ + toHexString(): string { + if (ObjectId.cacheHexString && this.__id) { + return this.__id; + } + + const hexString = this.id.toString('hex'); + + if (ObjectId.cacheHexString && !this.__id) { + this.__id = hexString; + } + + return hexString; + } + + /** + * Update the ObjectId index + * @privateRemarks + * Used in generating new ObjectId's on the driver + * @internal + */ + static getInc(): number { + return (ObjectId.index = (ObjectId.index + 1) % 0xffffff); + } + + /** + * Generate a 12 byte id buffer used in ObjectId's + * + * @param time - pass in a second based timestamp. + */ + static generate(time?: number): Buffer { + if ('number' !== typeof time) { + time = Math.floor(Date.now() / 1000); + } + + const inc = ObjectId.getInc(); + const buffer = Buffer.alloc(12); + + // 4-byte timestamp + buffer.writeUInt32BE(time, 0); + + // set PROCESS_UNIQUE if yet not initialized + if (PROCESS_UNIQUE === null) { + PROCESS_UNIQUE = randomBytes(5); + } + + // 5-byte process unique + buffer[4] = PROCESS_UNIQUE[0]; + buffer[5] = PROCESS_UNIQUE[1]; + buffer[6] = PROCESS_UNIQUE[2]; + buffer[7] = PROCESS_UNIQUE[3]; + buffer[8] = PROCESS_UNIQUE[4]; + + // 3-byte counter + buffer[11] = inc & 0xff; + buffer[10] = (inc >> 8) & 0xff; + buffer[9] = (inc >> 16) & 0xff; + + return buffer; + } + + /** + * Converts the id into a 24 character hex string for printing + * + * @param format - The Buffer toString format parameter. + */ + toString(format?: string): string { + // Is the id a buffer then use the buffer toString method to return the format + if (format) return this.id.toString(format); + return this.toHexString(); + } + + /** Converts to its JSON the 24 character hex string representation. */ + toJSON(): string { + return this.toHexString(); + } + + /** + * Compares the equality of this ObjectId with `otherID`. + * + * @param otherId - ObjectId instance to compare against. + */ + equals(otherId: string | ObjectId | ObjectIdLike): boolean { + if (otherId === undefined || otherId === null) { + return false; + } + + if (otherId instanceof ObjectId) { + return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]); + } + + if ( + typeof otherId === 'string' && + ObjectId.isValid(otherId) && + otherId.length === 12 && + isUint8Array(this.id) + ) { + return otherId === Buffer.prototype.toString.call(this.id, 'latin1'); + } + + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 24) { + return otherId.toLowerCase() === this.toHexString(); + } + + if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 12) { + return Buffer.from(otherId).equals(this.id); + } + + if ( + typeof otherId === 'object' && + 'toHexString' in otherId && + typeof otherId.toHexString === 'function' + ) { + const otherIdString = otherId.toHexString(); + const thisIdString = this.toHexString().toLowerCase(); + return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString; + } + + return false; + } + + /** Returns the generation date (accurate up to the second) that this ID was generated. */ + getTimestamp(): Date { + const timestamp = new Date(); + const time = this.id.readUInt32BE(0); + timestamp.setTime(Math.floor(time) * 1000); + return timestamp; + } + + /** @internal */ + static createPk(): ObjectId { + 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. + * + * @param time - an integer number representing a number of seconds. + */ + static createFromTime(time: number): ObjectId { + const buffer = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Encode time into first 4 bytes + buffer.writeUInt32BE(time, 0); + // Return the new objectId + return new ObjectId(buffer); + } + + /** + * Creates an ObjectId from a hex string representation of an ObjectId. + * + * @param hexString - create a ObjectId from a passed in 24 character hexstring. + */ + static createFromHexString(hexString: string): ObjectId { + // Throw an error if it's not a valid setup + if (typeof hexString === 'undefined' || (hexString != null && hexString.length !== 24)) { + throw new BSONTypeError( + 'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters' + ); + } + + return new ObjectId(Buffer.from(hexString, 'hex')); + } + + /** + * Checks if a value is a valid bson ObjectId + * + * @param id - ObjectId instance to validate. + */ + static isValid(id: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array): boolean { + if (id == null) return false; + + try { + new ObjectId(id); + return true; + } catch { + return false; + } + } + + /** @internal */ + toExtendedJSON(): ObjectIdExtended { + if (this.toHexString) return { $oid: this.toHexString() }; + return { $oid: this.toString('hex') }; + } + + /** @internal */ + static fromExtendedJSON(doc: ObjectIdExtended): ObjectId { + return new ObjectId(doc.$oid); + } + + /** + * Converts to a string representation of this Id. + * + * @returns return the 24 character hex string representation. + * @internal + */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + return `new ObjectId("${this.toHexString()}")`; + } +} + +// Deprecated methods +Object.defineProperty(ObjectId.prototype, 'generate', { + value: deprecate( + (time: number) => ObjectId.generate(time), + 'Please use the static `ObjectId.generate(time)` instead' + ) +}); + +Object.defineProperty(ObjectId.prototype, 'getInc', { + value: deprecate(() => ObjectId.getInc(), 'Please use the static `ObjectId.getInc()` instead') +}); + +Object.defineProperty(ObjectId.prototype, 'get_inc', { + value: deprecate(() => ObjectId.getInc(), 'Please use the static `ObjectId.getInc()` instead') +}); + +Object.defineProperty(ObjectId, 'get_inc', { + value: deprecate(() => ObjectId.getInc(), 'Please use the static `ObjectId.getInc()` instead') +}); + +Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' }); diff --git a/node_modules/bson/src/parser/calculate_size.ts b/node_modules/bson/src/parser/calculate_size.ts new file mode 100644 index 0000000..cc7f431 --- /dev/null +++ b/node_modules/bson/src/parser/calculate_size.ts @@ -0,0 +1,228 @@ +import { Buffer } from 'buffer'; +import { Binary } from '../binary'; +import type { Document } from '../bson'; +import * as constants from '../constants'; +import { isAnyArrayBuffer, isDate, isRegExp, normalizedFunctionString } from './utils'; + +export function calculateObjectSize( + object: Document, + serializeFunctions?: boolean, + ignoreUndefined?: boolean +): number { + let totalLength = 4 + 1; + + if (Array.isArray(object)) { + for (let 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 (typeof object?.toBSON === 'function') { + object = object.toBSON(); + } + + // Calculate size + for (const key in object) { + totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined); + } + } + + return totalLength; +} + +/** @internal */ +function calculateElement( + name: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + value: any, + serializeFunctions = false, + isArray = false, + ignoreUndefined = false +) { + // If we have toBSON defined, override the current object + if (typeof value?.toBSON === 'function') { + 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 >= constants.JS_INT_MIN && + value <= constants.JS_INT_MAX + ) { + if (value >= constants.BSON_INT32_MIN && value <= constants.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['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1; + } else if (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 ( + ArrayBuffer.isView(value) || + value instanceof ArrayBuffer || + isAnyArrayBuffer(value) + ) { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength + ); + } else if ( + value['_bsontype'] === 'Long' || + value['_bsontype'] === 'Double' || + value['_bsontype'] === 'Timestamp' + ) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } else if (value['_bsontype'] === 'Decimal128') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1); + } else if (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['_bsontype'] === 'Binary') { + const binary: Binary = value; + // Check what kind of subtype we have + if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + (binary.position + 1 + 4 + 1 + 4) + ); + } else { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (binary.position + 1 + 4 + 1) + ); + } + } else if (value['_bsontype'] === 'Symbol') { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + Buffer.byteLength(value.value, 'utf8') + + 4 + + 1 + + 1 + ); + } else if (value['_bsontype'] === 'DBRef') { + // Set up correct object for serialization + const ordered_values = Object.assign( + { + $ref: value.collection, + $id: value.oid + }, + value.fields + ); + + // Add db reference if it exists + if (value.db != null) { + 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 || isRegExp(value)) { + 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['_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 || isRegExp(value) || 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; +} diff --git a/node_modules/bson/src/parser/deserializer.ts b/node_modules/bson/src/parser/deserializer.ts new file mode 100644 index 0000000..faef442 --- /dev/null +++ b/node_modules/bson/src/parser/deserializer.ts @@ -0,0 +1,782 @@ +import { Buffer } from 'buffer'; +import { Binary } from '../binary'; +import type { Document } from '../bson'; +import { Code } from '../code'; +import * as constants from '../constants'; +import { DBRef, DBRefLike, isDBRefLike } from '../db_ref'; +import { Decimal128 } from '../decimal128'; +import { Double } from '../double'; +import { BSONError } from '../error'; +import { Int32 } from '../int_32'; +import { Long } from '../long'; +import { MaxKey } from '../max_key'; +import { MinKey } from '../min_key'; +import { ObjectId } from '../objectid'; +import { BSONRegExp } from '../regexp'; +import { BSONSymbol } from '../symbol'; +import { Timestamp } from '../timestamp'; +import { validateUtf8 } from '../validate_utf8'; + +/** @public */ +export interface DeserializeOptions { + /** evaluate functions in the BSON document scoped to the object deserialized. */ + evalFunctions?: boolean; + /** cache evaluated functions for reuse. */ + cacheFunctions?: boolean; + /** + * use a crc32 code for caching, otherwise use the string of the function. + * @deprecated this option to use the crc32 function never worked as intended + * due to the fact that the crc32 function itself was never implemented. + * */ + cacheFunctionsCrc32?: boolean; + /** when deserializing a Long will fit it into a Number if it's smaller than 53 bits */ + promoteLongs?: boolean; + /** when deserializing a Binary will return it as a node.js Buffer instance. */ + promoteBuffers?: boolean; + /** when deserializing will promote BSON values to their Node.js closest equivalent types. */ + promoteValues?: boolean; + /** allow to specify if there what fields we wish to return as unserialized raw buffer. */ + fieldsAsRaw?: Document; + /** return BSON regular expressions as BSONRegExp instances. */ + bsonRegExp?: boolean; + /** allows the buffer to be larger than the parsed BSON object */ + allowObjectSmallerThanBufferSize?: boolean; + /** Offset into buffer to begin reading document from */ + index?: number; + + raw?: boolean; + /** Allows for opt-out utf-8 validation for all keys or + * specified keys. Must be all true or all false. + * + * @example + * ```js + * // disables validation on all keys + * validation: { utf8: false } + * + * // enables validation only on specified keys a, b, and c + * validation: { utf8: { a: true, b: true, c: true } } + * + * // disables validation only on specified keys a, b + * validation: { utf8: { a: false, b: false } } + * ``` + */ + validation?: { utf8: boolean | Record | Record }; +} + +// Internal long versions +const JS_INT_MAX_LONG = Long.fromNumber(constants.JS_INT_MAX); +const JS_INT_MIN_LONG = Long.fromNumber(constants.JS_INT_MIN); + +const functionCache: { [hash: string]: Function } = {}; + +export function deserialize( + buffer: Buffer, + options: DeserializeOptions, + isArray?: boolean +): Document { + options = options == null ? {} : options; + const index = options && options.index ? options.index : 0; + // Read the document size + const size = + buffer[index] | + (buffer[index + 1] << 8) | + (buffer[index + 2] << 16) | + (buffer[index + 3] << 24); + + if (size < 5) { + throw new BSONError(`bson size must be >= 5, is ${size}`); + } + + if (options.allowObjectSmallerThanBufferSize && buffer.length < size) { + throw new BSONError(`buffer length ${buffer.length} must be >= bson size ${size}`); + } + + if (!options.allowObjectSmallerThanBufferSize && buffer.length !== size) { + throw new BSONError(`buffer length ${buffer.length} must === bson size ${size}`); + } + + if (size + index > buffer.byteLength) { + throw new BSONError( + `(bson size ${size} + options.index ${index} must be <= buffer length ${buffer.byteLength})` + ); + } + + // Illegal end value + if (buffer[index + size - 1] !== 0) { + throw new BSONError( + "One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00" + ); + } + + // Start deserializtion + return deserializeObject(buffer, index, options, isArray); +} + +const allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/; + +function deserializeObject( + buffer: Buffer, + index: number, + options: DeserializeOptions, + isArray = false +) { + const evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; + const cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions']; + + const fieldsAsRaw = options['fieldsAsRaw'] == null ? null : options['fieldsAsRaw']; + + // Return raw bson buffer instead of parsing it + const raw = options['raw'] == null ? false : options['raw']; + + // Return BSONRegExp objects instead of native regular expressions + const bsonRegExp = typeof options['bsonRegExp'] === 'boolean' ? options['bsonRegExp'] : false; + + // Controls the promotion of values vs wrapper classes + const promoteBuffers = options['promoteBuffers'] == null ? false : options['promoteBuffers']; + const promoteLongs = options['promoteLongs'] == null ? true : options['promoteLongs']; + const promoteValues = options['promoteValues'] == null ? true : options['promoteValues']; + + // Ensures default validation option if none given + const validation = options.validation == null ? { utf8: true } : options.validation; + + // Shows if global utf-8 validation is enabled or disabled + let globalUTFValidation = true; + // Reflects utf-8 validation setting regardless of global or specific key validation + let validationSetting: boolean; + // Set of keys either to enable or disable validation on + const utf8KeysSet = new Set(); + + // Check for boolean uniformity and empty validation option + const utf8ValidatedKeys = validation.utf8; + if (typeof utf8ValidatedKeys === 'boolean') { + validationSetting = utf8ValidatedKeys; + } else { + globalUTFValidation = false; + const utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function (key) { + return utf8ValidatedKeys[key]; + }); + if (utf8ValidationValues.length === 0) { + throw new BSONError('UTF-8 validation setting cannot be empty'); + } + if (typeof utf8ValidationValues[0] !== 'boolean') { + throw new BSONError('Invalid UTF-8 validation option, must specify boolean values'); + } + validationSetting = utf8ValidationValues[0]; + // Ensures boolean uniformity in utf-8 validation (all true or all false) + if (!utf8ValidationValues.every(item => item === validationSetting)) { + throw new BSONError('Invalid UTF-8 validation option - keys must be all true or all false'); + } + } + + // Add keys to set that will either be validated or not based on validationSetting + if (!globalUTFValidation) { + for (const key of Object.keys(utf8ValidatedKeys)) { + utf8KeysSet.add(key); + } + } + + // Set the start index + const startIndex = index; + + // Validate that we have at least 4 bytes of buffer + if (buffer.length < 5) throw new BSONError('corrupt bson message < 5 bytes long'); + + // Read the document size + const 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 BSONError('corrupt bson message'); + + // Create holding object + const object: Document = isArray ? [] : {}; + // Used for arrays to skip having to perform utf8 decoding + let arrayIndex = 0; + const done = false; + + let isPossibleDBRef = isArray ? false : null; + + // While we have more left data left keep parsing + const dataview = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength); + while (!done) { + // Read the type + const elementType = buffer[index++]; + + // If we get a zero it's the last byte, exit + if (elementType === 0) break; + + // Get the start search index + let 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.byteLength) throw new BSONError('Bad BSON Document: illegal CString'); + + // Represents the key + const name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i); + + // shouldValidateKey is true if the key should be validated, false otherwise + let shouldValidateKey = true; + if (globalUTFValidation || utf8KeysSet.has(name)) { + shouldValidateKey = validationSetting; + } else { + shouldValidateKey = !validationSetting; + } + + if (isPossibleDBRef !== false && (name as string)[0] === '$') { + isPossibleDBRef = allowedDBRefKeys.test(name as string); + } + let value; + + index = i + 1; + + if (elementType === constants.BSON_DATA_STRING) { + const 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 BSONError('bad string length in bson'); + } + value = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + index = index + stringSize; + } else if (elementType === constants.BSON_DATA_OID) { + const oid = Buffer.alloc(12); + buffer.copy(oid, 0, index, index + 12); + value = new ObjectId(oid); + index = index + 12; + } else if (elementType === constants.BSON_DATA_INT && promoteValues === false) { + value = new Int32( + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24) + ); + } else if (elementType === constants.BSON_DATA_INT) { + value = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + } else if (elementType === constants.BSON_DATA_NUMBER && promoteValues === false) { + value = new Double(dataview.getFloat64(index, true)); + index = index + 8; + } else if (elementType === constants.BSON_DATA_NUMBER) { + value = dataview.getFloat64(index, true); + index = index + 8; + } else if (elementType === constants.BSON_DATA_DATE) { + const lowBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + const highBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + value = new Date(new Long(lowBits, highBits).toNumber()); + } else if (elementType === constants.BSON_DATA_BOOLEAN) { + if (buffer[index] !== 0 && buffer[index] !== 1) + throw new BSONError('illegal boolean type value'); + value = buffer[index++] === 1; + } else if (elementType === constants.BSON_DATA_OBJECT) { + const _index = index; + const objectSize = + buffer[index] | + (buffer[index + 1] << 8) | + (buffer[index + 2] << 16) | + (buffer[index + 3] << 24); + if (objectSize <= 0 || objectSize > buffer.length - index) + throw new BSONError('bad embedded document length in bson'); + + // We have a raw value + if (raw) { + value = buffer.slice(index, index + objectSize); + } else { + let objectOptions = options; + if (!globalUTFValidation) { + objectOptions = { ...options, validation: { utf8: shouldValidateKey } }; + } + value = deserializeObject(buffer, _index, objectOptions, false); + } + + index = index + objectSize; + } else if (elementType === constants.BSON_DATA_ARRAY) { + const _index = index; + const objectSize = + buffer[index] | + (buffer[index + 1] << 8) | + (buffer[index + 2] << 16) | + (buffer[index + 3] << 24); + let arrayOptions = options; + + // Stop index + const stopIndex = index + objectSize; + + // All elements of array to be returned as raw bson + if (fieldsAsRaw && fieldsAsRaw[name]) { + arrayOptions = {}; + for (const n in options) { + ( + arrayOptions as { + [key: string]: DeserializeOptions[keyof DeserializeOptions]; + } + )[n] = options[n as keyof DeserializeOptions]; + } + arrayOptions['raw'] = true; + } + if (!globalUTFValidation) { + arrayOptions = { ...arrayOptions, validation: { utf8: shouldValidateKey } }; + } + value = deserializeObject(buffer, _index, arrayOptions, true); + index = index + objectSize; + + if (buffer[index - 1] !== 0) throw new BSONError('invalid array terminator byte'); + if (index !== stopIndex) throw new BSONError('corrupted array bson'); + } else if (elementType === constants.BSON_DATA_UNDEFINED) { + value = undefined; + } else if (elementType === constants.BSON_DATA_NULL) { + value = null; + } else if (elementType === constants.BSON_DATA_LONG) { + // Unpack the low and high bits + const lowBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + const highBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + const long = new Long(lowBits, highBits); + // Promote the long if possible + if (promoteLongs && promoteValues === true) { + value = + long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) + ? long.toNumber() + : long; + } else { + value = long; + } + } else if (elementType === constants.BSON_DATA_DECIMAL128) { + // Buffer to contain the decimal bytes + const bytes = Buffer.alloc(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 + const decimal128 = new Decimal128(bytes) as Decimal128 | { toObject(): unknown }; + // If we have an alternative mapper use that + if ('toObject' in decimal128 && typeof decimal128.toObject === 'function') { + value = decimal128.toObject(); + } else { + value = decimal128; + } + } else if (elementType === constants.BSON_DATA_BINARY) { + let binarySize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + const totalBinarySize = binarySize; + const subType = buffer[index++]; + + // Did we have a negative binary size, throw + if (binarySize < 0) throw new BSONError('Negative binary type element size found'); + + // Is the length longer than the document + if (binarySize > buffer.byteLength) + throw new BSONError('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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + + if (promoteBuffers && promoteValues) { + value = buffer.slice(index, index + binarySize); + } else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + if (subType === constants.BSON_BINARY_SUBTYPE_UUID_NEW) { + value = value.toUUID(); + } + } + } else { + const _buffer = Buffer.alloc(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 BSONError('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too long binary size'); + if (binarySize < totalBinarySize - 4) + throw new BSONError('Binary type with subtype 0x02 contains too short binary size'); + } + + // Copy the data + for (i = 0; i < binarySize; i++) { + _buffer[i] = buffer[index + i]; + } + + if (promoteBuffers && promoteValues) { + value = _buffer; + } else if (subType === constants.BSON_BINARY_SUBTYPE_UUID_NEW) { + value = new Binary(buffer.slice(index, index + binarySize), subType).toUUID(); + } else { + value = new Binary(buffer.slice(index, index + binarySize), subType); + } + } + + // Update the index + index = index + binarySize; + } else if (elementType === constants.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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + const 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + const regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + + // For each option add the corresponding one for javascript + const 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; + } + } + + value = new RegExp(source, optionsArray.join('')); + } else if (elementType === constants.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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + const 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 BSONError('Bad BSON Document: illegal CString'); + // Return the C string + const regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + + // Set the object + value = new BSONRegExp(source, regExpOptions); + } else if (elementType === constants.BSON_DATA_SYMBOL) { + const 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 BSONError('bad string length in bson'); + } + const symbol = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey); + value = promoteValues ? symbol : new BSONSymbol(symbol); + index = index + stringSize; + } else if (elementType === constants.BSON_DATA_TIMESTAMP) { + const lowBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + const highBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + + value = new Timestamp(lowBits, highBits); + } else if (elementType === constants.BSON_DATA_MIN_KEY) { + value = new MinKey(); + } else if (elementType === constants.BSON_DATA_MAX_KEY) { + value = new MaxKey(); + } else if (elementType === constants.BSON_DATA_CODE) { + const 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 BSONError('bad string length in bson'); + } + const functionString = getValidatedString( + buffer, + index, + index + stringSize - 1, + shouldValidateKey + ); + + // 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } else { + value = isolateEval(functionString); + } + } else { + value = new Code(functionString); + } + + // Update parse index position + index = index + stringSize; + } else if (elementType === constants.BSON_DATA_CODE_W_SCOPE) { + const 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 BSONError('code_w_scope total size shorter minimum expected length'); + } + + // Get the code string size + const 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 BSONError('bad string length in bson'); + } + + // Javascript function + const functionString = getValidatedString( + buffer, + index, + index + stringSize - 1, + shouldValidateKey + ); + // Update parse index position + index = index + stringSize; + // Parse the element + const _index = index; + // Decode the size of the object document + const objectSize = + buffer[index] | + (buffer[index + 1] << 8) | + (buffer[index + 2] << 16) | + (buffer[index + 3] << 24); + // Decode the scope object + const scopeObject = deserializeObject(buffer, _index, options, false); + // Adjust the index + index = index + objectSize; + + // Check if field length is too short + if (totalSize < 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too short, truncating scope'); + } + + // Check if totalSize field is too long + if (totalSize > 4 + 4 + objectSize + stringSize) { + throw new BSONError('code_w_scope total size is too 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) { + // Got to do this to avoid V8 deoptimizing the call due to finding eval + value = isolateEval(functionString, functionCache, object); + } else { + value = isolateEval(functionString); + } + + value.scope = scopeObject; + } else { + value = new Code(functionString, scopeObject); + } + } else if (elementType === constants.BSON_DATA_DBPOINTER) { + // Get the code string size + const 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 BSONError('bad string length in bson'); + // Namespace + if (validation != null && validation.utf8) { + if (!validateUtf8(buffer, index, index + stringSize - 1)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + } + const namespace = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + + // Read the oid + const oidBuffer = Buffer.alloc(12); + buffer.copy(oidBuffer, 0, index, index + 12); + const oid = new ObjectId(oidBuffer); + + // Update the index + index = index + 12; + + // Upgrade to DBRef type + value = new DBRef(namespace, oid); + } else { + throw new BSONError( + `Detected unknown BSON type ${elementType.toString(16)} for fieldname "${name}"` + ); + } + if (name === '__proto__') { + Object.defineProperty(object, name, { + value, + writable: true, + enumerable: true, + configurable: true + }); + } else { + object[name] = value; + } + } + + // Check if the deserialization was against a valid array/object + if (size !== index - startIndex) { + if (isArray) throw new BSONError('corrupt array bson'); + throw new BSONError('corrupt object bson'); + } + + // if we did not find "$ref", "$id", "$db", or found an extraneous $key, don't make a DBRef + if (!isPossibleDBRef) return object; + + if (isDBRefLike(object)) { + const copy = Object.assign({}, object) as Partial; + delete copy.$ref; + delete copy.$id; + delete copy.$db; + return new DBRef(object.$ref, object.$id, object.$db, copy); + } + + return object; +} + +/** + * Ensure eval is isolated, store the result in functionCache. + * + * @internal + */ +function isolateEval( + functionString: string, + functionCache?: { [hash: string]: Function }, + object?: Document +) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + if (!functionCache) return new Function(functionString); + // Check for cache hit, eval if missing and return cached function + if (functionCache[functionString] == null) { + // eslint-disable-next-line @typescript-eslint/no-implied-eval + functionCache[functionString] = new Function(functionString); + } + + // Set the object + return functionCache[functionString].bind(object); +} + +function getValidatedString( + buffer: Buffer, + start: number, + end: number, + shouldValidateUtf8: boolean +) { + const value = buffer.toString('utf8', start, end); + // if utf8 validation is on, do the check + if (shouldValidateUtf8) { + for (let i = 0; i < value.length; i++) { + if (value.charCodeAt(i) === 0xfffd) { + if (!validateUtf8(buffer, start, end)) { + throw new BSONError('Invalid UTF-8 string in BSON document'); + } + break; + } + } + } + return value; +} diff --git a/node_modules/bson/src/parser/serializer.ts b/node_modules/bson/src/parser/serializer.ts new file mode 100644 index 0000000..e76402a --- /dev/null +++ b/node_modules/bson/src/parser/serializer.ts @@ -0,0 +1,1076 @@ +import type { Buffer } from 'buffer'; +import { Binary } from '../binary'; +import type { BSONSymbol, DBRef, Document, MaxKey } from '../bson'; +import type { Code } from '../code'; +import * as constants from '../constants'; +import type { DBRefLike } from '../db_ref'; +import type { Decimal128 } from '../decimal128'; +import type { Double } from '../double'; +import { ensureBuffer } from '../ensure_buffer'; +import { BSONError, BSONTypeError } from '../error'; +import { isBSONType } from '../extended_json'; +import type { Int32 } from '../int_32'; +import { Long } from '../long'; +import { Map } from '../map'; +import type { MinKey } from '../min_key'; +import type { ObjectId } from '../objectid'; +import type { BSONRegExp } from '../regexp'; +import { + isBigInt64Array, + isBigUInt64Array, + isDate, + isMap, + isRegExp, + isUint8Array, + normalizedFunctionString +} from './utils'; + +/** @public */ +export interface SerializeOptions { + /** the serializer will check if keys are valid. */ + checkKeys?: boolean; + /** serialize the javascript functions **(default:false)**. */ + serializeFunctions?: boolean; + /** serialize will not emit undefined fields **(default:true)** */ + ignoreUndefined?: boolean; + /** @internal Resize internal buffer */ + minInternalBufferSize?: number; + /** the index in the buffer where we wish to start serializing into */ + index?: number; +} + +const regexp = /\x00/; // eslint-disable-line no-control-regex +const ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']); + +/* + * isArray indicates if we are writing to a BSON array (type 0x04) + * which forces the "key" which really an array index as a string to be written as ascii + * This will catch any errors in index as a string generation + */ + +function serializeString( + buffer: Buffer, + key: string, + value: string, + index: number, + isArray?: boolean +) { + // Encode String type + buffer[index++] = constants.BSON_DATA_STRING; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes + 1; + buffer[index - 1] = 0; + // Write the string + const size = buffer.write(value, index + 4, undefined, 'utf8'); + // Write the size of the string to buffer + buffer[index + 3] = ((size + 1) >> 24) & 0xff; + buffer[index + 2] = ((size + 1) >> 16) & 0xff; + buffer[index + 1] = ((size + 1) >> 8) & 0xff; + buffer[index] = (size + 1) & 0xff; + // Update index + index = index + 4 + size; + // Write zero + buffer[index++] = 0; + return index; +} + +const SPACE_FOR_FLOAT64 = new Uint8Array(8); +const DV_FOR_FLOAT64 = new DataView( + SPACE_FOR_FLOAT64.buffer, + SPACE_FOR_FLOAT64.byteOffset, + SPACE_FOR_FLOAT64.byteLength +); +function serializeNumber( + buffer: Buffer, + key: string, + value: number, + index: number, + isArray?: boolean +) { + // We have an integer value + // TODO(NODE-2529): Add support for big int + if ( + Number.isInteger(value) && + value >= constants.BSON_INT32_MIN && + value <= constants.BSON_INT32_MAX + ) { + // If the value fits in 32 bits encode as int32 + // Set int type 32 bits or less + buffer[index++] = constants.BSON_DATA_INT; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + } else { + // Encode as double + buffer[index++] = constants.BSON_DATA_NUMBER; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + DV_FOR_FLOAT64.setFloat64(0, value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + // Adjust index + index = index + 8; + } + + return index; +} + +function serializeNull(buffer: Buffer, key: string, _: unknown, index: number, isArray?: boolean) { + // Set long type + buffer[index++] = constants.BSON_DATA_NULL; + + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +} + +function serializeBoolean( + buffer: Buffer, + key: string, + value: boolean, + index: number, + isArray?: boolean +) { + // Write the type + buffer[index++] = constants.BSON_DATA_BOOLEAN; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Encode the boolean value + buffer[index++] = value ? 1 : 0; + return index; +} + +function serializeDate(buffer: Buffer, key: string, value: Date, index: number, isArray?: boolean) { + // Write the type + buffer[index++] = constants.BSON_DATA_DATE; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Write the date + const dateInMilis = Long.fromNumber(value.getTime()); + const lowBits = dateInMilis.getLowBits(); + const highBits = dateInMilis.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +} + +function serializeRegExp( + buffer: Buffer, + key: string, + value: RegExp, + index: number, + isArray?: boolean +) { + // Write the type + buffer[index++] = constants.BSON_DATA_REGEXP; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + if (value.source && value.source.match(regexp) != null) { + throw Error('value ' + value.source + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.source, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the parameters + if (value.ignoreCase) buffer[index++] = 0x69; // i + if (value.global) buffer[index++] = 0x73; // s + if (value.multiline) buffer[index++] = 0x6d; // m + + // Add ending zero + buffer[index++] = 0x00; + return index; +} + +function serializeBSONRegExp( + buffer: Buffer, + key: string, + value: BSONRegExp, + index: number, + isArray?: boolean +) { + // Write the type + buffer[index++] = constants.BSON_DATA_REGEXP; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Check the pattern for 0 bytes + if (value.pattern.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('pattern ' + value.pattern + ' must not contain null bytes'); + } + + // Adjust the index + index = index + buffer.write(value.pattern, index, undefined, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the options + index = index + buffer.write(value.options.split('').sort().join(''), index, undefined, 'utf8'); + // Add ending zero + buffer[index++] = 0x00; + return index; +} + +function serializeMinMax( + buffer: Buffer, + key: string, + value: MinKey | MaxKey, + index: number, + isArray?: boolean +) { + // Write the type of either min or max key + if (value === null) { + buffer[index++] = constants.BSON_DATA_NULL; + } else if (value._bsontype === 'MinKey') { + buffer[index++] = constants.BSON_DATA_MIN_KEY; + } else { + buffer[index++] = constants.BSON_DATA_MAX_KEY; + } + + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +} + +function serializeObjectId( + buffer: Buffer, + key: string, + value: ObjectId, + index: number, + isArray?: boolean +) { + // Write the type + buffer[index++] = constants.BSON_DATA_OID; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Write the objectId into the shared buffer + if (typeof value.id === 'string') { + buffer.write(value.id, index, undefined, 'binary'); + } else if (isUint8Array(value.id)) { + // Use the standard JS methods here because buffer.copy() is buggy with the + // browser polyfill + buffer.set(value.id.subarray(0, 12), index); + } else { + throw new BSONTypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId'); + } + + // Adjust index + return index + 12; +} + +function serializeBuffer( + buffer: Buffer, + key: string, + value: Buffer | Uint8Array, + index: number, + isArray?: boolean +) { + // Write the type + buffer[index++] = constants.BSON_DATA_BINARY; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Get size of the buffer (current write point) + const size = value.length; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the default subtype + buffer[index++] = constants.BSON_BINARY_SUBTYPE_DEFAULT; + // Copy the content form the binary field to the buffer + buffer.set(ensureBuffer(value), index); + // Adjust the index + index = index + size; + return index; +} + +function serializeObject( + buffer: Buffer, + key: string, + value: Document, + index: number, + checkKeys = false, + depth = 0, + serializeFunctions = false, + ignoreUndefined = true, + isArray = false, + path: Document[] = [] +) { + for (let i = 0; i < path.length; i++) { + if (path[i] === value) throw new BSONError('cyclic dependency detected'); + } + + // Push value to stack + path.push(value); + // Write the type + buffer[index++] = Array.isArray(value) ? constants.BSON_DATA_ARRAY : constants.BSON_DATA_OBJECT; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + const endIndex = serializeInto( + buffer, + value, + checkKeys, + index, + depth + 1, + serializeFunctions, + ignoreUndefined, + path + ); + // Pop stack + path.pop(); + return endIndex; +} + +function serializeDecimal128( + buffer: Buffer, + key: string, + value: Decimal128, + index: number, + isArray?: boolean +) { + buffer[index++] = constants.BSON_DATA_DECIMAL128; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the data from the value + // Prefer the standard JS methods because their typechecking is not buggy, + // unlike the `buffer` polyfill's. + buffer.set(value.bytes.subarray(0, 16), index); + return index + 16; +} + +function serializeLong(buffer: Buffer, key: string, value: Long, index: number, isArray?: boolean) { + // Write the type + buffer[index++] = + value._bsontype === 'Long' ? constants.BSON_DATA_LONG : constants.BSON_DATA_TIMESTAMP; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + const lowBits = value.getLowBits(); + const highBits = value.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +} + +function serializeInt32( + buffer: Buffer, + key: string, + value: Int32 | number, + index: number, + isArray?: boolean +) { + value = value.valueOf(); + // Set int type 32 bits or less + buffer[index++] = constants.BSON_DATA_INT; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + return index; +} + +function serializeDouble( + buffer: Buffer, + key: string, + value: Double, + index: number, + isArray?: boolean +) { + // Encode as double + buffer[index++] = constants.BSON_DATA_NUMBER; + + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Write float + DV_FOR_FLOAT64.setFloat64(0, value.value, true); + buffer.set(SPACE_FOR_FLOAT64, index); + + // Adjust index + index = index + 8; + return index; +} + +function serializeFunction( + buffer: Buffer, + key: string, + value: Function, + index: number, + _checkKeys = false, + _depth = 0, + isArray?: boolean +) { + buffer[index++] = constants.BSON_DATA_CODE; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + const functionString = normalizedFunctionString(value); + + // Write the string + const size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + return index; +} + +function serializeCode( + buffer: Buffer, + key: string, + value: Code, + index: number, + checkKeys = false, + depth = 0, + serializeFunctions = false, + ignoreUndefined = true, + isArray = false +) { + if (value.scope && typeof value.scope === 'object') { + // Write the type + buffer[index++] = constants.BSON_DATA_CODE_W_SCOPE; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Starting index + let startIndex = index; + + // Serialize the function + // Get the function string + const functionString = typeof value.code === 'string' ? value.code : value.code.toString(); + // Index adjustment + index = index + 4; + // Write string into buffer + const codeSize = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = codeSize & 0xff; + buffer[index + 1] = (codeSize >> 8) & 0xff; + buffer[index + 2] = (codeSize >> 16) & 0xff; + buffer[index + 3] = (codeSize >> 24) & 0xff; + // Write end 0 + buffer[index + 4 + codeSize - 1] = 0; + // Write the + index = index + codeSize + 4; + + // + // Serialize the scope value + const endIndex = serializeInto( + buffer, + value.scope, + checkKeys, + index, + depth + 1, + serializeFunctions, + ignoreUndefined + ); + index = endIndex - 1; + + // Writ the total + const totalSize = endIndex - startIndex; + + // Write the total size of the object + buffer[startIndex++] = totalSize & 0xff; + buffer[startIndex++] = (totalSize >> 8) & 0xff; + buffer[startIndex++] = (totalSize >> 16) & 0xff; + buffer[startIndex++] = (totalSize >> 24) & 0xff; + // Write trailing zero + buffer[index++] = 0; + } else { + buffer[index++] = constants.BSON_DATA_CODE; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + const functionString = value.code.toString(); + // Write the string + const size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + } + + return index; +} + +function serializeBinary( + buffer: Buffer, + key: string, + value: Binary, + index: number, + isArray?: boolean +) { + // Write the type + buffer[index++] = constants.BSON_DATA_BINARY; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Extract the buffer + const data = value.value(true) as Buffer | Uint8Array; + // Calculate size + let size = value.position; + // Add the deprecated 02 type 4 bytes of size to total + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) size = size + 4; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the subtype to the buffer + buffer[index++] = value.sub_type; + + // If we have binary type 2 the 4 first bytes are the size + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + size = size - 4; + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + } + + // Write the data to the object + buffer.set(data, index); + // Adjust the index + index = index + value.position; + return index; +} + +function serializeSymbol( + buffer: Buffer, + key: string, + value: BSONSymbol, + index: number, + isArray?: boolean +) { + // Write the type + buffer[index++] = constants.BSON_DATA_SYMBOL; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the string + const size = buffer.write(value.value, index + 4, undefined, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0x00; + return index; +} + +function serializeDBRef( + buffer: Buffer, + key: string, + value: DBRef, + index: number, + depth: number, + serializeFunctions: boolean, + isArray?: boolean +) { + // Write the type + buffer[index++] = constants.BSON_DATA_OBJECT; + // Number of written bytes + const numberOfWrittenBytes = !isArray + ? buffer.write(key, index, undefined, 'utf8') + : buffer.write(key, index, undefined, 'ascii'); + + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + let startIndex = index; + let output: DBRefLike = { + $ref: value.collection || value.namespace, // "namespace" was what library 1.x called "collection" + $id: value.oid + }; + + if (value.db != null) { + output.$db = value.db; + } + + output = Object.assign(output, value.fields); + const endIndex = serializeInto(buffer, output, false, index, depth + 1, serializeFunctions); + + // Calculate object size + const size = endIndex - startIndex; + // Write the size + buffer[startIndex++] = size & 0xff; + buffer[startIndex++] = (size >> 8) & 0xff; + buffer[startIndex++] = (size >> 16) & 0xff; + buffer[startIndex++] = (size >> 24) & 0xff; + // Set index + return endIndex; +} + +export function serializeInto( + buffer: Buffer, + object: Document, + checkKeys = false, + startingIndex = 0, + depth = 0, + serializeFunctions = false, + ignoreUndefined = true, + path: Document[] = [] +): number { + startingIndex = startingIndex || 0; + path = path || []; + + // Push the object to the path + path.push(object); + + // Start place to serialize into + let index = startingIndex + 4; + + // Special case isArray + if (Array.isArray(object)) { + // Get object keys + for (let i = 0; i < object.length; i++) { + const key = `${i}`; + let value = object[i]; + + // Is there an override value + if (typeof value?.toBSON === 'function') { + value = value.toBSON(); + } + + if (typeof value === 'string') { + index = serializeString(buffer, key, value, index, true); + } else if (typeof value === 'number') { + index = serializeNumber(buffer, key, value, index, true); + } else if (typeof value === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } else if (typeof value === 'boolean') { + index = serializeBoolean(buffer, key, value, index, true); + } else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index, true); + } else if (value === undefined) { + index = serializeNull(buffer, key, value, index, true); + } else if (value === null) { + index = serializeNull(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index, true); + } else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index, true); + } else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index, true); + } else if (typeof value === 'object' && value['_bsontype'] == null) { + index = serializeObject( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + true, + path + ); + } else if ( + typeof value === 'object' && + isBSONType(value) && + value._bsontype === 'Decimal128' + ) { + index = serializeDecimal128(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index, true); + } else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, true); + } else if (value['_bsontype'] === 'Code') { + index = serializeCode( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + true + ); + } else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, true); + } else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index, true); + } else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError(`Unrecognized or invalid _bsontype: ${String(value['_bsontype'])}`); + } + } + } else if (object instanceof Map || isMap(object)) { + const iterator = object.entries(); + let done = false; + + while (!done) { + // Unpack the next entry + const entry = iterator.next(); + done = !!entry.done; + // Are we done, then skip and terminate + if (done) continue; + + // Get the entry values + const key = entry.value[0]; + const value = entry.value[1]; + + // Check the type of the value + const type = typeof value; + + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } else if (type === 'bigint' || isBigInt64Array(value) || isBigUInt64Array(value)) { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } else if (value === null || (value === undefined && ignoreUndefined === false)) { + index = serializeNull(buffer, key, value, index); + } else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + false, + path + ); + } else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } else if (value['_bsontype'] === 'Code') { + index = serializeCode( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined + ); + } else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError(`Unrecognized or invalid _bsontype: ${String(value['_bsontype'])}`); + } + } + } else { + if (typeof object?.toBSON === 'function') { + // Provided a custom serialization method + object = object.toBSON(); + if (object != null && typeof object !== 'object') { + throw new BSONTypeError('toBSON function did not return an object'); + } + } + + // Iterate over all the keys + for (const key in object) { + let value = object[key]; + // Is there an override value + if (typeof value?.toBSON === 'function') { + value = value.toBSON(); + } + + // Check the type of the value + const type = typeof value; + + // Check the key and throw error if it's illegal + if (typeof key === 'string' && !ignoreKeys.has(key)) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } else if (type === 'bigint') { + throw new BSONTypeError('Unsupported type BigInt, please use Decimal128'); + } else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } else if (value === undefined) { + if (ignoreUndefined === false) index = serializeNull(buffer, key, value, index); + } else if (value === null) { + index = serializeNull(buffer, key, value, index); + } else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } else if (isUint8Array(value)) { + index = serializeBuffer(buffer, key, value, index); + } else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + false, + path + ); + } else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } else if (value['_bsontype'] === 'Code') { + index = serializeCode( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined + ); + } else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } else if (typeof value['_bsontype'] !== 'undefined') { + throw new BSONTypeError(`Unrecognized or invalid _bsontype: ${String(value['_bsontype'])}`); + } + } + } + + // Remove the path + path.pop(); + + // Final padding byte for object + buffer[index++] = 0x00; + + // Final size + const size = index - startingIndex; + // Write the size of the object + buffer[startingIndex++] = size & 0xff; + buffer[startingIndex++] = (size >> 8) & 0xff; + buffer[startingIndex++] = (size >> 16) & 0xff; + buffer[startingIndex++] = (size >> 24) & 0xff; + return index; +} diff --git a/node_modules/bson/src/parser/utils.ts b/node_modules/bson/src/parser/utils.ts new file mode 100644 index 0000000..abf935d --- /dev/null +++ b/node_modules/bson/src/parser/utils.ts @@ -0,0 +1,127 @@ +import { Buffer } from 'buffer'; +import { getGlobal } from '../utils/global'; + +type RandomBytesFunction = (size: number) => Uint8Array; + +/** + * Normalizes our expected stringified form of a function across versions of node + * @param fn - The function to stringify + */ +export function normalizedFunctionString(fn: Function): string { + return fn.toString().replace('function(', 'function ('); +} + +function isReactNative() { + const g = getGlobal<{ navigator?: { product?: string } }>(); + return typeof g.navigator === 'object' && g.navigator.product === 'ReactNative'; +} + +const insecureRandomBytes: RandomBytesFunction = function insecureRandomBytes(size: number) { + const insecureWarning = isReactNative() + ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.' + : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.'; + console.warn(insecureWarning); + + const result = Buffer.alloc(size); + for (let i = 0; i < size; ++i) result[i] = Math.floor(Math.random() * 256); + return result; +}; + +/* We do not want to have to include DOM types just for this check */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +declare let window: any; +declare let require: Function; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +declare let global: any; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +declare let process: any; // Used by @rollup/plugin-replace + +const detectRandomBytes = (): RandomBytesFunction => { + if (process.browser) { + if (typeof window !== 'undefined') { + // browser crypto implementation(s) + const target = window.crypto || window.msCrypto; // allow for IE11 + if (target && target.getRandomValues) { + return size => target.getRandomValues(Buffer.alloc(size)); + } + } + + if (typeof global !== 'undefined' && global.crypto && global.crypto.getRandomValues) { + // allow for RN packages such as https://www.npmjs.com/package/react-native-get-random-values to populate global + return size => global.crypto.getRandomValues(Buffer.alloc(size)); + } + + return insecureRandomBytes; + } else { + let requiredRandomBytes: RandomBytesFunction | null | undefined; + try { + requiredRandomBytes = require('crypto').randomBytes; + } catch (e) { + // keep the fallback + } + + // NOTE: in transpiled cases the above require might return null/undefined + + return requiredRandomBytes || insecureRandomBytes; + } +}; + +export const randomBytes = detectRandomBytes(); + +export function isAnyArrayBuffer(value: unknown): value is ArrayBuffer { + return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes( + Object.prototype.toString.call(value) + ); +} + +export function isUint8Array(value: unknown): value is Uint8Array { + return Object.prototype.toString.call(value) === '[object Uint8Array]'; +} + +export function isBigInt64Array(value: unknown): value is BigInt64Array { + return Object.prototype.toString.call(value) === '[object BigInt64Array]'; +} + +export function isBigUInt64Array(value: unknown): value is BigUint64Array { + return Object.prototype.toString.call(value) === '[object BigUint64Array]'; +} + +export function isRegExp(d: unknown): d is RegExp { + return Object.prototype.toString.call(d) === '[object RegExp]'; +} + +export function isMap(d: unknown): d is Map { + return Object.prototype.toString.call(d) === '[object Map]'; +} + +/** Call to check if your environment has `Buffer` */ +export function haveBuffer(): boolean { + return typeof global !== 'undefined' && typeof global.Buffer !== 'undefined'; +} + +// To ensure that 0.4 of node works correctly +export function isDate(d: unknown): d is Date { + return isObjectLike(d) && Object.prototype.toString.call(d) === '[object Date]'; +} + +/** + * @internal + * this is to solve the `'someKey' in x` problem where x is unknown. + * https://github.com/typescript-eslint/typescript-eslint/issues/1071#issuecomment-541955753 + */ +export function isObjectLike(candidate: unknown): candidate is Record { + return typeof candidate === 'object' && candidate !== null; +} + +declare let console: { warn(...message: unknown[]): void }; +export function deprecate(fn: T, message: string): T { + let warned = false; + function deprecated(this: unknown, ...args: unknown[]) { + if (!warned) { + console.warn(message); + warned = true; + } + return fn.apply(this, args); + } + return deprecated as unknown as T; +} diff --git a/node_modules/bson/src/regexp.ts b/node_modules/bson/src/regexp.ts new file mode 100644 index 0000000..efd5628 --- /dev/null +++ b/node_modules/bson/src/regexp.ts @@ -0,0 +1,105 @@ +import { BSONError, BSONTypeError } from './error'; +import type { EJSONOptions } from './extended_json'; + +function alphabetize(str: string): string { + return str.split('').sort().join(''); +} + +/** @public */ +export interface BSONRegExpExtendedLegacy { + $regex: string | BSONRegExp; + $options: string; +} + +/** @public */ +export interface BSONRegExpExtended { + $regularExpression: { + pattern: string; + options: string; + }; +} + +/** + * A class representation of the BSON RegExp type. + * @public + * @category BSONType + */ +export class BSONRegExp { + _bsontype!: 'BSONRegExp'; + + pattern!: string; + options!: string; + /** + * @param pattern - The regular expression pattern to match + * @param options - The regular expression options + */ + constructor(pattern: string, options?: string) { + if (!(this instanceof BSONRegExp)) return new BSONRegExp(pattern, options); + + this.pattern = pattern; + this.options = alphabetize(options ?? ''); + + if (this.pattern.indexOf('\x00') !== -1) { + throw new BSONError( + `BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}` + ); + } + if (this.options.indexOf('\x00') !== -1) { + throw new BSONError( + `BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}` + ); + } + + // Validate options + for (let 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 BSONError(`The regular expression option [${this.options[i]}] is not supported`); + } + } + } + + static parseOptions(options?: string): string { + return options ? options.split('').sort().join('') : ''; + } + + /** @internal */ + toExtendedJSON(options?: EJSONOptions): BSONRegExpExtendedLegacy | BSONRegExpExtended { + options = options || {}; + if (options.legacy) { + return { $regex: this.pattern, $options: this.options }; + } + return { $regularExpression: { pattern: this.pattern, options: this.options } }; + } + + /** @internal */ + static fromExtendedJSON(doc: BSONRegExpExtendedLegacy | BSONRegExpExtended): BSONRegExp { + if ('$regex' in doc) { + if (typeof doc.$regex !== 'string') { + // This is for $regex query operators that have extended json values. + if (doc.$regex._bsontype === 'BSONRegExp') { + return doc as unknown as BSONRegExp; + } + } else { + return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options)); + } + } + if ('$regularExpression' in doc) { + return new BSONRegExp( + doc.$regularExpression.pattern, + BSONRegExp.parseOptions(doc.$regularExpression.options) + ); + } + throw new BSONTypeError(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(doc)}`); + } +} + +Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' }); diff --git a/node_modules/bson/src/symbol.ts b/node_modules/bson/src/symbol.ts new file mode 100644 index 0000000..1e82fc1 --- /dev/null +++ b/node_modules/bson/src/symbol.ts @@ -0,0 +1,58 @@ +/** @public */ +export interface BSONSymbolExtended { + $symbol: string; +} + +/** + * A class representation of the BSON Symbol type. + * @public + * @category BSONType + */ +export class BSONSymbol { + _bsontype!: 'Symbol'; + + value!: string; + /** + * @param value - the string representing the symbol. + */ + constructor(value: string) { + if (!(this instanceof BSONSymbol)) return new BSONSymbol(value); + + this.value = value; + } + + /** Access the wrapped string value. */ + valueOf(): string { + return this.value; + } + + toString(): string { + return this.value; + } + + /** @internal */ + inspect(): string { + return `new BSONSymbol("${this.value}")`; + } + + toJSON(): string { + return this.value; + } + + /** @internal */ + toExtendedJSON(): BSONSymbolExtended { + return { $symbol: this.value }; + } + + /** @internal */ + static fromExtendedJSON(doc: BSONSymbolExtended): BSONSymbol { + return new BSONSymbol(doc.$symbol); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } +} + +Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' }); diff --git a/node_modules/bson/src/timestamp.ts b/node_modules/bson/src/timestamp.ts new file mode 100644 index 0000000..4c4b7e7 --- /dev/null +++ b/node_modules/bson/src/timestamp.ts @@ -0,0 +1,119 @@ +import { Long } from './long'; +import { isObjectLike } from './parser/utils'; + +/** @public */ +export type TimestampOverrides = '_bsontype' | 'toExtendedJSON' | 'fromExtendedJSON' | 'inspect'; +/** @public */ +export type LongWithoutOverrides = new (low: unknown, high?: number, unsigned?: boolean) => { + [P in Exclude]: Long[P]; +}; +/** @public */ +export const LongWithoutOverridesClass: LongWithoutOverrides = + Long as unknown as LongWithoutOverrides; + +/** @public */ +export interface TimestampExtended { + $timestamp: { + t: number; + i: number; + }; +} + +/** + * @public + * @category BSONType + * */ +export class Timestamp extends LongWithoutOverridesClass { + _bsontype!: 'Timestamp'; + + static readonly MAX_VALUE = Long.MAX_UNSIGNED_VALUE; + + /** + * @param low - A 64-bit Long representing the Timestamp. + */ + constructor(long: Long); + /** + * @param value - A pair of two values indicating timestamp and increment. + */ + constructor(value: { t: number; i: number }); + /** + * @param low - the low (signed) 32 bits of the Timestamp. + * @param high - the high (signed) 32 bits of the Timestamp. + * @deprecated Please use `Timestamp({ t: high, i: low })` or `Timestamp(Long(low, high))` instead. + */ + constructor(low: number, high: number); + constructor(low: number | Long | { t: number; i: number }, high?: number) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + if (!(this instanceof Timestamp)) return new Timestamp(low, high); + + if (Long.isLong(low)) { + super(low.low, low.high, true); + } else if (isObjectLike(low) && typeof low.t !== 'undefined' && typeof low.i !== 'undefined') { + super(low.i, low.t, true); + } else { + super(low, high, true); + } + Object.defineProperty(this, '_bsontype', { + value: 'Timestamp', + writable: false, + configurable: false, + enumerable: false + }); + } + + toJSON(): { $timestamp: string } { + return { + $timestamp: this.toString() + }; + } + + /** Returns a Timestamp represented by the given (32-bit) integer value. */ + static fromInt(value: number): Timestamp { + return new Timestamp(Long.fromInt(value, true)); + } + + /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */ + static fromNumber(value: number): Timestamp { + return new Timestamp(Long.fromNumber(value, true)); + } + + /** + * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits. + * + * @param lowBits - the low 32-bits. + * @param highBits - the high 32-bits. + */ + static fromBits(lowBits: number, highBits: number): Timestamp { + return new Timestamp(lowBits, highBits); + } + + /** + * Returns a Timestamp from the given string, optionally using the given radix. + * + * @param str - the textual representation of the Timestamp. + * @param optRadix - the radix in which the text is written. + */ + static fromString(str: string, optRadix: number): Timestamp { + return new Timestamp(Long.fromString(str, true, optRadix)); + } + + /** @internal */ + toExtendedJSON(): TimestampExtended { + return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } }; + } + + /** @internal */ + static fromExtendedJSON(doc: TimestampExtended): Timestamp { + return new Timestamp(doc.$timestamp); + } + + /** @internal */ + [Symbol.for('nodejs.util.inspect.custom')](): string { + return this.inspect(); + } + + inspect(): string { + return `new Timestamp({ t: ${this.getHighBits()}, i: ${this.getLowBits()} })`; + } +} diff --git a/node_modules/bson/src/utils/global.ts b/node_modules/bson/src/utils/global.ts new file mode 100644 index 0000000..3e45ffb --- /dev/null +++ b/node_modules/bson/src/utils/global.ts @@ -0,0 +1,22 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* We do not want to have to include DOM types just for this check */ +declare const window: unknown; +declare const self: unknown; +declare const global: unknown; + +function checkForMath(potentialGlobal: any) { + // eslint-disable-next-line eqeqeq + return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal; +} + +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +export function getGlobal>(): T { + return ( + checkForMath(typeof globalThis === 'object' && globalThis) || + checkForMath(typeof window === 'object' && window) || + checkForMath(typeof self === 'object' && self) || + checkForMath(typeof global === 'object' && global) || + // eslint-disable-next-line @typescript-eslint/no-implied-eval + Function('return this')() + ); +} diff --git a/node_modules/bson/src/uuid_utils.ts b/node_modules/bson/src/uuid_utils.ts new file mode 100644 index 0000000..f37b065 --- /dev/null +++ b/node_modules/bson/src/uuid_utils.ts @@ -0,0 +1,33 @@ +import { Buffer } from 'buffer'; +import { BSONTypeError } from './error'; + +// Validation regex for v4 uuid (validates with or without dashes) +const VALIDATION_REGEX = + /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i; + +export const uuidValidateString = (str: string): boolean => + typeof str === 'string' && VALIDATION_REGEX.test(str); + +export const uuidHexStringToBuffer = (hexString: string): Buffer => { + if (!uuidValidateString(hexString)) { + throw new BSONTypeError( + 'UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".' + ); + } + + const sanitizedHexString = hexString.replace(/-/g, ''); + return Buffer.from(sanitizedHexString, 'hex'); +}; + +export const bufferToUuidHexString = (buffer: Buffer, includeDashes = true): string => + includeDashes + ? buffer.toString('hex', 0, 4) + + '-' + + buffer.toString('hex', 4, 6) + + '-' + + buffer.toString('hex', 6, 8) + + '-' + + buffer.toString('hex', 8, 10) + + '-' + + buffer.toString('hex', 10, 16) + : buffer.toString('hex'); diff --git a/node_modules/bson/src/validate_utf8.ts b/node_modules/bson/src/validate_utf8.ts new file mode 100644 index 0000000..e1da934 --- /dev/null +++ b/node_modules/bson/src/validate_utf8.ts @@ -0,0 +1,47 @@ +const FIRST_BIT = 0x80; +const FIRST_TWO_BITS = 0xc0; +const FIRST_THREE_BITS = 0xe0; +const FIRST_FOUR_BITS = 0xf0; +const FIRST_FIVE_BITS = 0xf8; + +const TWO_BIT_CHAR = 0xc0; +const THREE_BIT_CHAR = 0xe0; +const FOUR_BIT_CHAR = 0xf0; +const CONTINUING_CHAR = 0x80; + +/** + * Determines if the passed in bytes are valid utf8 + * @param bytes - An array of 8-bit bytes. Must be indexable and have length property + * @param start - The index to start validating + * @param end - The index to end validating + */ +export function validateUtf8( + bytes: { [index: number]: number }, + start: number, + end: number +): boolean { + let continuation = 0; + + for (let i = start; i < end; i += 1) { + const byte = bytes[i]; + + if (continuation) { + if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) { + return false; + } + continuation -= 1; + } else if (byte & FIRST_BIT) { + if ((byte & FIRST_THREE_BITS) === TWO_BIT_CHAR) { + continuation = 1; + } else if ((byte & FIRST_FOUR_BITS) === THREE_BIT_CHAR) { + continuation = 2; + } else if ((byte & FIRST_FIVE_BITS) === FOUR_BIT_CHAR) { + continuation = 3; + } else { + return false; + } + } + } + + return !continuation; +} diff --git a/node_modules/buffer/AUTHORS.md b/node_modules/buffer/AUTHORS.md new file mode 100644 index 0000000..22eb171 --- /dev/null +++ b/node_modules/buffer/AUTHORS.md @@ -0,0 +1,70 @@ +# Authors + +#### Ordered by first contribution. + +- Romain Beauxis (toots@rastageeks.org) +- Tobias Koppers (tobias.koppers@googlemail.com) +- Janus (ysangkok@gmail.com) +- Rainer Dreyer (rdrey1@gmail.com) +- Tõnis Tiigi (tonistiigi@gmail.com) +- James Halliday (mail@substack.net) +- Michael Williamson (mike@zwobble.org) +- elliottcable (github@elliottcable.name) +- rafael (rvalle@livelens.net) +- Andrew Kelley (superjoe30@gmail.com) +- Andreas Madsen (amwebdk@gmail.com) +- Mike Brevoort (mike.brevoort@pearson.com) +- Brian White (mscdex@mscdex.net) +- Feross Aboukhadijeh (feross@feross.org) +- Ruben Verborgh (ruben@verborgh.org) +- eliang (eliang.cs@gmail.com) +- Jesse Tane (jesse.tane@gmail.com) +- Alfonso Boza (alfonso@cloud.com) +- Mathias Buus (mathiasbuus@gmail.com) +- Devon Govett (devongovett@gmail.com) +- Daniel Cousens (github@dcousens.com) +- Joseph Dykstra (josephdykstra@gmail.com) +- Parsha Pourkhomami (parshap+git@gmail.com) +- Damjan Košir (damjan.kosir@gmail.com) +- daverayment (dave.rayment@gmail.com) +- kawanet (u-suke@kawa.net) +- Linus Unnebäck (linus@folkdatorn.se) +- Nolan Lawson (nolan.lawson@gmail.com) +- Calvin Metcalf (calvin.metcalf@gmail.com) +- Koki Takahashi (hakatasiloving@gmail.com) +- Guy Bedford (guybedford@gmail.com) +- Jan Schär (jscissr@gmail.com) +- RaulTsc (tomescu.raul@gmail.com) +- Matthieu Monsch (monsch@alum.mit.edu) +- Dan Ehrenberg (littledan@chromium.org) +- Kirill Fomichev (fanatid@ya.ru) +- Yusuke Kawasaki (u-suke@kawa.net) +- DC (dcposch@dcpos.ch) +- John-David Dalton (john.david.dalton@gmail.com) +- adventure-yunfei (adventure030@gmail.com) +- Emil Bay (github@tixz.dk) +- Sam Sudar (sudar.sam@gmail.com) +- Volker Mische (volker.mische@gmail.com) +- David Walton (support@geekstocks.com) +- Сковорода Никита Андреевич (chalkerx@gmail.com) +- greenkeeper[bot] (greenkeeper[bot]@users.noreply.github.com) +- ukstv (sergey.ukustov@machinomy.com) +- Renée Kooi (renee@kooi.me) +- ranbochen (ranbochen@qq.com) +- Vladimir Borovik (bobahbdb@gmail.com) +- greenkeeper[bot] (23040076+greenkeeper[bot]@users.noreply.github.com) +- kumavis (aaron@kumavis.me) +- Sergey Ukustov (sergey.ukustov@machinomy.com) +- Fei Liu (liu.feiwood@gmail.com) +- Blaine Bublitz (blaine.bublitz@gmail.com) +- clement (clement@seald.io) +- Koushik Dutta (koushd@gmail.com) +- Jordan Harband (ljharb@gmail.com) +- Niklas Mischkulnig (mischnic@users.noreply.github.com) +- Nikolai Vavilov (vvnicholas@gmail.com) +- Fedor Nezhivoi (gyzerok@users.noreply.github.com) +- Peter Newman (peternewman@users.noreply.github.com) +- mathmakgakpak (44949126+mathmakgakpak@users.noreply.github.com) +- jkkang (jkkang@smartauth.kr) + +#### Generated by bin/update-authors.sh. diff --git a/node_modules/buffer/LICENSE b/node_modules/buffer/LICENSE new file mode 100644 index 0000000..d6bf75d --- /dev/null +++ b/node_modules/buffer/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Feross Aboukhadijeh, and other 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. diff --git a/node_modules/buffer/README.md b/node_modules/buffer/README.md new file mode 100644 index 0000000..9a23d7c --- /dev/null +++ b/node_modules/buffer/README.md @@ -0,0 +1,410 @@ +# buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] + +[travis-image]: https://img.shields.io/travis/feross/buffer/master.svg +[travis-url]: https://travis-ci.org/feross/buffer +[npm-image]: https://img.shields.io/npm/v/buffer.svg +[npm-url]: https://npmjs.org/package/buffer +[downloads-image]: https://img.shields.io/npm/dm/buffer.svg +[downloads-url]: https://npmjs.org/package/buffer +[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg +[standard-url]: https://standardjs.com + +#### The buffer module from [node.js](https://nodejs.org/), for the browser. + +[![saucelabs][saucelabs-image]][saucelabs-url] + +[saucelabs-image]: https://saucelabs.com/browser-matrix/buffer.svg +[saucelabs-url]: https://saucelabs.com/u/buffer + +With [browserify](http://browserify.org), simply `require('buffer')` or use the `Buffer` global and you will get this module. + +The goal is to provide an API that is 100% identical to +[node's Buffer API](https://nodejs.org/api/buffer.html). Read the +[official docs](https://nodejs.org/api/buffer.html) for the full list of properties, +instance methods, and class methods that are supported. + +## features + +- Manipulate binary data like a boss, in all browsers! +- Super fast. Backed by Typed Arrays (`Uint8Array`/`ArrayBuffer`, not `Object`) +- Extremely small bundle size (**6.75KB minified + gzipped**, 51.9KB with comments) +- Excellent browser support (Chrome, Firefox, Edge, Safari 9+, IE 11, iOS 9+, Android, etc.) +- Preserves Node API exactly, with one minor difference (see below) +- Square-bracket `buf[4]` notation works! +- Does not modify any browser prototypes or put anything on `window` +- Comprehensive test suite (including all buffer tests from node.js core) + +## install + +To use this module directly (without browserify), install it: + +```bash +npm install buffer +``` + +This module was previously called **native-buffer-browserify**, but please use **buffer** +from now on. + +If you do not use a bundler, you can use the [standalone script](https://bundle.run/buffer). + +## usage + +The module's API is identical to node's `Buffer` API. Read the +[official docs](https://nodejs.org/api/buffer.html) for the full list of properties, +instance methods, and class methods that are supported. + +As mentioned above, `require('buffer')` or use the `Buffer` global with +[browserify](http://browserify.org) and this module will automatically be included +in your bundle. Almost any npm module will work in the browser, even if it assumes that +the node `Buffer` API will be available. + +To depend on this module explicitly (without browserify), require it like this: + +```js +var Buffer = require('buffer/').Buffer // note: the trailing slash is important! +``` + +To require this module explicitly, use `require('buffer/')` which tells the node.js module +lookup algorithm (also used by browserify) to use the **npm module** named `buffer` +instead of the **node.js core** module named `buffer`! + + +## how does it work? + +The Buffer constructor returns instances of `Uint8Array` that have their prototype +changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of `Uint8Array`, +so the returned instances will have all the node `Buffer` methods and the +`Uint8Array` methods. Square bracket notation works as expected -- it returns a +single octet. + +The `Uint8Array` prototype remains unmodified. + + +## tracking the latest node api + +This module tracks the Buffer API in the latest (unstable) version of node.js. The Buffer +API is considered **stable** in the +[node stability index](https://nodejs.org/docs/latest/api/documentation.html#documentation_stability_index), +so it is unlikely that there will ever be breaking changes. +Nonetheless, when/if the Buffer API changes in node, this module's API will change +accordingly. + +## related packages + +- [`buffer-reverse`](https://www.npmjs.com/package/buffer-reverse) - Reverse a buffer +- [`buffer-xor`](https://www.npmjs.com/package/buffer-xor) - Bitwise xor a buffer +- [`is-buffer`](https://www.npmjs.com/package/is-buffer) - Determine if an object is a Buffer without including the whole `Buffer` package + +## conversion packages + +### convert typed array to buffer + +Use [`typedarray-to-buffer`](https://www.npmjs.com/package/typedarray-to-buffer) to convert any kind of typed array to a `Buffer`. Does not perform a copy, so it's super fast. + +### convert buffer to typed array + +`Buffer` is a subclass of `Uint8Array` (which is a typed array). So there is no need to explicitly convert to typed array. Just use the buffer as a `Uint8Array`. + +### convert blob to buffer + +Use [`blob-to-buffer`](https://www.npmjs.com/package/blob-to-buffer) to convert a `Blob` to a `Buffer`. + +### convert buffer to blob + +To convert a `Buffer` to a `Blob`, use the `Blob` constructor: + +```js +var blob = new Blob([ buffer ]) +``` + +Optionally, specify a mimetype: + +```js +var blob = new Blob([ buffer ], { type: 'text/html' }) +``` + +### convert arraybuffer to buffer + +To convert an `ArrayBuffer` to a `Buffer`, use the `Buffer.from` function. Does not perform a copy, so it's super fast. + +```js +var buffer = Buffer.from(arrayBuffer) +``` + +### convert buffer to arraybuffer + +To convert a `Buffer` to an `ArrayBuffer`, use the `.buffer` property (which is present on all `Uint8Array` objects): + +```js +var arrayBuffer = buffer.buffer.slice( + buffer.byteOffset, buffer.byteOffset + buffer.byteLength +) +``` + +Alternatively, use the [`to-arraybuffer`](https://www.npmjs.com/package/to-arraybuffer) module. + +## performance + +See perf tests in `/perf`. + +`BrowserBuffer` is the browser `buffer` module (this repo). `Uint8Array` is included as a +sanity check (since `BrowserBuffer` uses `Uint8Array` under the hood, `Uint8Array` will +always be at least a bit faster). Finally, `NodeBuffer` is the node.js buffer module, +which is included to compare against. + +NOTE: Performance has improved since these benchmarks were taken. PR welcome to update the README. + +### Chrome 38 + +| Method | Operations | Accuracy | Sampled | Fastest | +|:-------|:-----------|:---------|:--------|:-------:| +| BrowserBuffer#bracket-notation | 11,457,464 ops/sec | ±0.86% | 66 | ✓ | +| Uint8Array#bracket-notation | 10,824,332 ops/sec | ±0.74% | 65 | | +| | | | | +| BrowserBuffer#concat | 450,532 ops/sec | ±0.76% | 68 | | +| Uint8Array#concat | 1,368,911 ops/sec | ±1.50% | 62 | ✓ | +| | | | | +| BrowserBuffer#copy(16000) | 903,001 ops/sec | ±0.96% | 67 | | +| Uint8Array#copy(16000) | 1,422,441 ops/sec | ±1.04% | 66 | ✓ | +| | | | | +| BrowserBuffer#copy(16) | 11,431,358 ops/sec | ±0.46% | 69 | | +| Uint8Array#copy(16) | 13,944,163 ops/sec | ±1.12% | 68 | ✓ | +| | | | | +| BrowserBuffer#new(16000) | 106,329 ops/sec | ±6.70% | 44 | | +| Uint8Array#new(16000) | 131,001 ops/sec | ±2.85% | 31 | ✓ | +| | | | | +| BrowserBuffer#new(16) | 1,554,491 ops/sec | ±1.60% | 65 | | +| Uint8Array#new(16) | 6,623,930 ops/sec | ±1.66% | 65 | ✓ | +| | | | | +| BrowserBuffer#readDoubleBE | 112,830 ops/sec | ±0.51% | 69 | ✓ | +| DataView#getFloat64 | 93,500 ops/sec | ±0.57% | 68 | | +| | | | | +| BrowserBuffer#readFloatBE | 146,678 ops/sec | ±0.95% | 68 | ✓ | +| DataView#getFloat32 | 99,311 ops/sec | ±0.41% | 67 | | +| | | | | +| BrowserBuffer#readUInt32LE | 843,214 ops/sec | ±0.70% | 69 | ✓ | +| DataView#getUint32 | 103,024 ops/sec | ±0.64% | 67 | | +| | | | | +| BrowserBuffer#slice | 1,013,941 ops/sec | ±0.75% | 67 | | +| Uint8Array#subarray | 1,903,928 ops/sec | ±0.53% | 67 | ✓ | +| | | | | +| BrowserBuffer#writeFloatBE | 61,387 ops/sec | ±0.90% | 67 | | +| DataView#setFloat32 | 141,249 ops/sec | ±0.40% | 66 | ✓ | + + +### Firefox 33 + +| Method | Operations | Accuracy | Sampled | Fastest | +|:-------|:-----------|:---------|:--------|:-------:| +| BrowserBuffer#bracket-notation | 20,800,421 ops/sec | ±1.84% | 60 | | +| Uint8Array#bracket-notation | 20,826,235 ops/sec | ±2.02% | 61 | ✓ | +| | | | | +| BrowserBuffer#concat | 153,076 ops/sec | ±2.32% | 61 | | +| Uint8Array#concat | 1,255,674 ops/sec | ±8.65% | 52 | ✓ | +| | | | | +| BrowserBuffer#copy(16000) | 1,105,312 ops/sec | ±1.16% | 63 | | +| Uint8Array#copy(16000) | 1,615,911 ops/sec | ±0.55% | 66 | ✓ | +| | | | | +| BrowserBuffer#copy(16) | 16,357,599 ops/sec | ±0.73% | 68 | | +| Uint8Array#copy(16) | 31,436,281 ops/sec | ±1.05% | 68 | ✓ | +| | | | | +| BrowserBuffer#new(16000) | 52,995 ops/sec | ±6.01% | 35 | | +| Uint8Array#new(16000) | 87,686 ops/sec | ±5.68% | 45 | ✓ | +| | | | | +| BrowserBuffer#new(16) | 252,031 ops/sec | ±1.61% | 66 | | +| Uint8Array#new(16) | 8,477,026 ops/sec | ±0.49% | 68 | ✓ | +| | | | | +| BrowserBuffer#readDoubleBE | 99,871 ops/sec | ±0.41% | 69 | | +| DataView#getFloat64 | 285,663 ops/sec | ±0.70% | 68 | ✓ | +| | | | | +| BrowserBuffer#readFloatBE | 115,540 ops/sec | ±0.42% | 69 | | +| DataView#getFloat32 | 288,722 ops/sec | ±0.82% | 68 | ✓ | +| | | | | +| BrowserBuffer#readUInt32LE | 633,926 ops/sec | ±1.08% | 67 | ✓ | +| DataView#getUint32 | 294,808 ops/sec | ±0.79% | 64 | | +| | | | | +| BrowserBuffer#slice | 349,425 ops/sec | ±0.46% | 69 | | +| Uint8Array#subarray | 5,965,819 ops/sec | ±0.60% | 65 | ✓ | +| | | | | +| BrowserBuffer#writeFloatBE | 59,980 ops/sec | ±0.41% | 67 | | +| DataView#setFloat32 | 317,634 ops/sec | ±0.63% | 68 | ✓ | + +### Safari 8 + +| Method | Operations | Accuracy | Sampled | Fastest | +|:-------|:-----------|:---------|:--------|:-------:| +| BrowserBuffer#bracket-notation | 10,279,729 ops/sec | ±2.25% | 56 | ✓ | +| Uint8Array#bracket-notation | 10,030,767 ops/sec | ±2.23% | 59 | | +| | | | | +| BrowserBuffer#concat | 144,138 ops/sec | ±1.38% | 65 | | +| Uint8Array#concat | 4,950,764 ops/sec | ±1.70% | 63 | ✓ | +| | | | | +| BrowserBuffer#copy(16000) | 1,058,548 ops/sec | ±1.51% | 64 | | +| Uint8Array#copy(16000) | 1,409,666 ops/sec | ±1.17% | 65 | ✓ | +| | | | | +| BrowserBuffer#copy(16) | 6,282,529 ops/sec | ±1.88% | 58 | | +| Uint8Array#copy(16) | 11,907,128 ops/sec | ±2.87% | 58 | ✓ | +| | | | | +| BrowserBuffer#new(16000) | 101,663 ops/sec | ±3.89% | 57 | | +| Uint8Array#new(16000) | 22,050,818 ops/sec | ±6.51% | 46 | ✓ | +| | | | | +| BrowserBuffer#new(16) | 176,072 ops/sec | ±2.13% | 64 | | +| Uint8Array#new(16) | 24,385,731 ops/sec | ±5.01% | 51 | ✓ | +| | | | | +| BrowserBuffer#readDoubleBE | 41,341 ops/sec | ±1.06% | 67 | | +| DataView#getFloat64 | 322,280 ops/sec | ±0.84% | 68 | ✓ | +| | | | | +| BrowserBuffer#readFloatBE | 46,141 ops/sec | ±1.06% | 65 | | +| DataView#getFloat32 | 337,025 ops/sec | ±0.43% | 69 | ✓ | +| | | | | +| BrowserBuffer#readUInt32LE | 151,551 ops/sec | ±1.02% | 66 | | +| DataView#getUint32 | 308,278 ops/sec | ±0.94% | 67 | ✓ | +| | | | | +| BrowserBuffer#slice | 197,365 ops/sec | ±0.95% | 66 | | +| Uint8Array#subarray | 9,558,024 ops/sec | ±3.08% | 58 | ✓ | +| | | | | +| BrowserBuffer#writeFloatBE | 17,518 ops/sec | ±1.03% | 63 | | +| DataView#setFloat32 | 319,751 ops/sec | ±0.48% | 68 | ✓ | + + +### Node 0.11.14 + +| Method | Operations | Accuracy | Sampled | Fastest | +|:-------|:-----------|:---------|:--------|:-------:| +| BrowserBuffer#bracket-notation | 10,489,828 ops/sec | ±3.25% | 90 | | +| Uint8Array#bracket-notation | 10,534,884 ops/sec | ±0.81% | 92 | ✓ | +| NodeBuffer#bracket-notation | 10,389,910 ops/sec | ±0.97% | 87 | | +| | | | | +| BrowserBuffer#concat | 487,830 ops/sec | ±2.58% | 88 | | +| Uint8Array#concat | 1,814,327 ops/sec | ±1.28% | 88 | ✓ | +| NodeBuffer#concat | 1,636,523 ops/sec | ±1.88% | 73 | | +| | | | | +| BrowserBuffer#copy(16000) | 1,073,665 ops/sec | ±0.77% | 90 | | +| Uint8Array#copy(16000) | 1,348,517 ops/sec | ±0.84% | 89 | ✓ | +| NodeBuffer#copy(16000) | 1,289,533 ops/sec | ±0.82% | 93 | | +| | | | | +| BrowserBuffer#copy(16) | 12,782,706 ops/sec | ±0.74% | 85 | | +| Uint8Array#copy(16) | 14,180,427 ops/sec | ±0.93% | 92 | ✓ | +| NodeBuffer#copy(16) | 11,083,134 ops/sec | ±1.06% | 89 | | +| | | | | +| BrowserBuffer#new(16000) | 141,678 ops/sec | ±3.30% | 67 | | +| Uint8Array#new(16000) | 161,491 ops/sec | ±2.96% | 60 | | +| NodeBuffer#new(16000) | 292,699 ops/sec | ±3.20% | 55 | ✓ | +| | | | | +| BrowserBuffer#new(16) | 1,655,466 ops/sec | ±2.41% | 82 | | +| Uint8Array#new(16) | 14,399,926 ops/sec | ±0.91% | 94 | ✓ | +| NodeBuffer#new(16) | 3,894,696 ops/sec | ±0.88% | 92 | | +| | | | | +| BrowserBuffer#readDoubleBE | 109,582 ops/sec | ±0.75% | 93 | ✓ | +| DataView#getFloat64 | 91,235 ops/sec | ±0.81% | 90 | | +| NodeBuffer#readDoubleBE | 88,593 ops/sec | ±0.96% | 81 | | +| | | | | +| BrowserBuffer#readFloatBE | 139,854 ops/sec | ±1.03% | 85 | ✓ | +| DataView#getFloat32 | 98,744 ops/sec | ±0.80% | 89 | | +| NodeBuffer#readFloatBE | 92,769 ops/sec | ±0.94% | 93 | | +| | | | | +| BrowserBuffer#readUInt32LE | 710,861 ops/sec | ±0.82% | 92 | | +| DataView#getUint32 | 117,893 ops/sec | ±0.84% | 91 | | +| NodeBuffer#readUInt32LE | 851,412 ops/sec | ±0.72% | 93 | ✓ | +| | | | | +| BrowserBuffer#slice | 1,673,877 ops/sec | ±0.73% | 94 | | +| Uint8Array#subarray | 6,919,243 ops/sec | ±0.67% | 90 | ✓ | +| NodeBuffer#slice | 4,617,604 ops/sec | ±0.79% | 93 | | +| | | | | +| BrowserBuffer#writeFloatBE | 66,011 ops/sec | ±0.75% | 93 | | +| DataView#setFloat32 | 127,760 ops/sec | ±0.72% | 93 | ✓ | +| NodeBuffer#writeFloatBE | 103,352 ops/sec | ±0.83% | 93 | | + +### iojs 1.8.1 + +| Method | Operations | Accuracy | Sampled | Fastest | +|:-------|:-----------|:---------|:--------|:-------:| +| BrowserBuffer#bracket-notation | 10,990,488 ops/sec | ±1.11% | 91 | | +| Uint8Array#bracket-notation | 11,268,757 ops/sec | ±0.65% | 97 | | +| NodeBuffer#bracket-notation | 11,353,260 ops/sec | ±0.83% | 94 | ✓ | +| | | | | +| BrowserBuffer#concat | 378,954 ops/sec | ±0.74% | 94 | | +| Uint8Array#concat | 1,358,288 ops/sec | ±0.97% | 87 | | +| NodeBuffer#concat | 1,934,050 ops/sec | ±1.11% | 78 | ✓ | +| | | | | +| BrowserBuffer#copy(16000) | 894,538 ops/sec | ±0.56% | 84 | | +| Uint8Array#copy(16000) | 1,442,656 ops/sec | ±0.71% | 96 | | +| NodeBuffer#copy(16000) | 1,457,898 ops/sec | ±0.53% | 92 | ✓ | +| | | | | +| BrowserBuffer#copy(16) | 12,870,457 ops/sec | ±0.67% | 95 | | +| Uint8Array#copy(16) | 16,643,989 ops/sec | ±0.61% | 93 | ✓ | +| NodeBuffer#copy(16) | 14,885,848 ops/sec | ±0.74% | 94 | | +| | | | | +| BrowserBuffer#new(16000) | 109,264 ops/sec | ±4.21% | 63 | | +| Uint8Array#new(16000) | 138,916 ops/sec | ±1.87% | 61 | | +| NodeBuffer#new(16000) | 281,449 ops/sec | ±3.58% | 51 | ✓ | +| | | | | +| BrowserBuffer#new(16) | 1,362,935 ops/sec | ±0.56% | 99 | | +| Uint8Array#new(16) | 6,193,090 ops/sec | ±0.64% | 95 | ✓ | +| NodeBuffer#new(16) | 4,745,425 ops/sec | ±1.56% | 90 | | +| | | | | +| BrowserBuffer#readDoubleBE | 118,127 ops/sec | ±0.59% | 93 | ✓ | +| DataView#getFloat64 | 107,332 ops/sec | ±0.65% | 91 | | +| NodeBuffer#readDoubleBE | 116,274 ops/sec | ±0.94% | 95 | | +| | | | | +| BrowserBuffer#readFloatBE | 150,326 ops/sec | ±0.58% | 95 | ✓ | +| DataView#getFloat32 | 110,541 ops/sec | ±0.57% | 98 | | +| NodeBuffer#readFloatBE | 121,599 ops/sec | ±0.60% | 87 | | +| | | | | +| BrowserBuffer#readUInt32LE | 814,147 ops/sec | ±0.62% | 93 | | +| DataView#getUint32 | 137,592 ops/sec | ±0.64% | 90 | | +| NodeBuffer#readUInt32LE | 931,650 ops/sec | ±0.71% | 96 | ✓ | +| | | | | +| BrowserBuffer#slice | 878,590 ops/sec | ±0.68% | 93 | | +| Uint8Array#subarray | 2,843,308 ops/sec | ±1.02% | 90 | | +| NodeBuffer#slice | 4,998,316 ops/sec | ±0.68% | 90 | ✓ | +| | | | | +| BrowserBuffer#writeFloatBE | 65,927 ops/sec | ±0.74% | 93 | | +| DataView#setFloat32 | 139,823 ops/sec | ±0.97% | 89 | ✓ | +| NodeBuffer#writeFloatBE | 135,763 ops/sec | ±0.65% | 96 | | +| | | | | + +## Testing the project + +First, install the project: + + npm install + +Then, to run tests in Node.js, run: + + npm run test-node + +To test locally in a browser, you can run: + + npm run test-browser-es5-local # For ES5 browsers that don't support ES6 + npm run test-browser-es6-local # For ES6 compliant browsers + +This will print out a URL that you can then open in a browser to run the tests, using [airtap](https://www.npmjs.com/package/airtap). + +To run automated browser tests using Saucelabs, ensure that your `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variables are set, then run: + + npm test + +This is what's run in Travis, to check against various browsers. The list of browsers is kept in the `bin/airtap-es5.yml` and `bin/airtap-es6.yml` files. + +## JavaScript Standard Style + +This module uses [JavaScript Standard Style](https://github.com/feross/standard). + +[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) + +To test that the code conforms to the style, `npm install` and run: + + ./node_modules/.bin/standard + +## credit + +This was originally forked from [buffer-browserify](https://github.com/toots/buffer-browserify). + +## Security Policies and Procedures + +The `buffer` team and community take all security bugs in `buffer` seriously. Please see our [security policies and procedures](https://github.com/feross/security) document to learn how to report issues. + +## license + +MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org), and other contributors. Originally forked from an MIT-licensed module by Romain Beauxis. diff --git a/node_modules/buffer/index.d.ts b/node_modules/buffer/index.d.ts new file mode 100644 index 0000000..5d1a804 --- /dev/null +++ b/node_modules/buffer/index.d.ts @@ -0,0 +1,186 @@ +export class Buffer extends Uint8Array { + length: number + write(string: string, offset?: number, length?: number, encoding?: string): number; + toString(encoding?: string, start?: number, end?: number): string; + toJSON(): { type: 'Buffer', data: any[] }; + equals(otherBuffer: Buffer): boolean; + compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; + writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readUInt8(offset: number, noAssert?: boolean): number; + readUInt16LE(offset: number, noAssert?: boolean): number; + readUInt16BE(offset: number, noAssert?: boolean): number; + readUInt32LE(offset: number, noAssert?: boolean): number; + readUInt32BE(offset: number, noAssert?: boolean): number; + readInt8(offset: number, noAssert?: boolean): number; + readInt16LE(offset: number, noAssert?: boolean): number; + readInt16BE(offset: number, noAssert?: boolean): number; + readInt32LE(offset: number, noAssert?: boolean): number; + readInt32BE(offset: number, noAssert?: boolean): number; + readFloatLE(offset: number, noAssert?: boolean): number; + readFloatBE(offset: number, noAssert?: boolean): number; + readDoubleLE(offset: number, noAssert?: boolean): number; + readDoubleBE(offset: number, noAssert?: boolean): number; + reverse(): this; + swap16(): Buffer; + swap32(): Buffer; + swap64(): Buffer; + writeUInt8(value: number, offset: number, noAssert?: boolean): number; + writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeInt8(value: number, offset: number, noAssert?: boolean): number; + writeInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeFloatLE(value: number, offset: number, noAssert?: boolean): number; + writeFloatBE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; + fill(value: any, offset?: number, end?: number): this; + indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; + + /** + * Allocates a new buffer containing the given {str}. + * + * @param str String to store in buffer. + * @param encoding encoding to use, optional. Default is 'utf8' + */ + constructor (str: string, encoding?: string); + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + */ + constructor (size: number); + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + constructor (array: Uint8Array); + /** + * Produces a Buffer backed by the same allocated memory as + * the given {ArrayBuffer}. + * + * + * @param arrayBuffer The ArrayBuffer with which to share memory. + */ + constructor (arrayBuffer: ArrayBuffer); + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + constructor (array: any[]); + /** + * Copies the passed {buffer} data onto a new {Buffer} instance. + * + * @param buffer The buffer to copy. + */ + constructor (buffer: Buffer); + prototype: Buffer; + /** + * Allocates a new Buffer using an {array} of octets. + * + * @param array + */ + static from(array: any[]): Buffer; + /** + * When passed a reference to the .buffer property of a TypedArray instance, + * the newly created Buffer will share the same allocated memory as the TypedArray. + * The optional {byteOffset} and {length} arguments specify a memory range + * within the {arrayBuffer} that will be shared by the Buffer. + * + * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() + * @param byteOffset + * @param length + */ + static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; + /** + * Copies the passed {buffer} data onto a new Buffer instance. + * + * @param buffer + */ + static from(buffer: Buffer | Uint8Array): Buffer; + /** + * Creates a new Buffer containing the given JavaScript string {str}. + * If provided, the {encoding} parameter identifies the character encoding. + * If not provided, {encoding} defaults to 'utf8'. + * + * @param str + */ + static from(str: string, encoding?: string): Buffer; + /** + * Returns true if {obj} is a Buffer + * + * @param obj object to test. + */ + static isBuffer(obj: any): obj is Buffer; + /** + * Returns true if {encoding} is a valid encoding argument. + * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' + * + * @param encoding string to test. + */ + static isEncoding(encoding: string): boolean; + /** + * Gives the actual byte length of a string. encoding defaults to 'utf8'. + * This is not the same as String.prototype.length since that returns the number of characters in a string. + * + * @param string string to test. + * @param encoding encoding used to evaluate (defaults to 'utf8') + */ + static byteLength(string: string, encoding?: string): number; + /** + * Returns a buffer which is the result of concatenating all the buffers in the list together. + * + * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. + * If the list has exactly one item, then the first item of the list is returned. + * If the list has more than one item, then a new Buffer is created. + * + * @param list An array of Buffer objects to concatenate + * @param totalLength Total length of the buffers when concatenated. + * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. + */ + static concat(list: Buffer[], totalLength?: number): Buffer; + /** + * The same as buf1.compare(buf2). + */ + static compare(buf1: Buffer, buf2: Buffer): number; + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + * @param fill if specified, buffer will be initialized by calling buf.fill(fill). + * If parameter is omitted, buffer will be filled with zeros. + * @param encoding encoding used for call to buf.fill while initializing + */ + static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; + /** + * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents + * of the newly created Buffer are unknown and may contain sensitive data. + * + * @param size count of octets to allocate + */ + static allocUnsafe(size: number): Buffer; + /** + * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents + * of the newly created Buffer are unknown and may contain sensitive data. + * + * @param size count of octets to allocate + */ + static allocUnsafeSlow(size: number): Buffer; +} diff --git a/node_modules/buffer/index.js b/node_modules/buffer/index.js new file mode 100644 index 0000000..609cf31 --- /dev/null +++ b/node_modules/buffer/index.js @@ -0,0 +1,1817 @@ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + +'use strict' + +var base64 = require('base64-js') +var ieee754 = require('ieee754') +var customInspectSymbol = + (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation + ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation + : null + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} + +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + var proto = { foo: function () { return 42 } } + Object.setPrototypeOf(proto, Uint8Array.prototype) + Object.setPrototypeOf(arr, proto) + return arr.foo() === 42 + } catch (e) { + return false + } +} + +Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.buffer + } +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.byteOffset + } +}) + +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + Object.setPrototypeOf(buf, Buffer.prototype) + return buf +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError( + 'The "string" argument must be of type string. Received type number' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + if (ArrayBuffer.isView(value)) { + return fromArrayView(value) + } + + if (value == null) { + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) + } + + if (isInstance(value, ArrayBuffer) || + (value && isInstance(value.buffer, ArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof SharedArrayBuffer !== 'undefined' && + (isInstance(value, SharedArrayBuffer) || + (value && isInstance(value.buffer, SharedArrayBuffer)))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'number') { + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) + } + + var valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) + } + + var b = fromObject(value) + if (b) return b + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && + typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from( + value[Symbol.toPrimitive]('string'), encodingOrOffset, length + ) + } + + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype) +Object.setPrototypeOf(Buffer, Uint8Array) + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } +} + +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpreted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf +} + +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} + +function fromArrayView (arrayView) { + if (isInstance(arrayView, Uint8Array)) { + var copy = new Uint8Array(arrayView) + return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength) + } + return fromArrayLike(arrayView) +} + +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + Object.setPrototypeOf(buf, Buffer.prototype) + + return buf +} + +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } +} + +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true && + b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false +} + +Buffer.compare = function compare (a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (isInstance(buf, Uint8Array)) { + if (pos + buf.length > buffer.length) { + Buffer.from(buf).copy(buffer, pos) + } else { + Uint8Array.prototype.set.call( + buffer, + buf, + pos + ) + } + } else if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } else { + buf.copy(buffer, pos) + } + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) + } + + var len = string.length + var mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coercion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.toLocaleString = Buffer.prototype.toString + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' + return '' +} +if (customInspectSymbol) { + Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength) + } + if (!Buffer.isBuffer(target)) { + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [val], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + case 'latin1': + case 'binary': + return asciiWrite(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) + ? 4 + : (firstByte > 0xDF) + ? 3 + : (firstByte > 0xBF) + ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += hexSliceLookupTable[buf[i]] + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + // If bytes.length is odd, the last 8 bits must be ignored (same as node.js) + for (var i = 0; i < bytes.length - 1; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + Object.setPrototypeOf(newBuf, Buffer.prototype) + + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUintLE = +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUintBE = +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUint8 = +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUint16LE = +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUint16BE = +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUint32LE = +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUint32BE = +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUintLE = +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUintBE = +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUint8 = +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeUint16LE = +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeUint16BE = +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeUint32LE = +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeUint32BE = +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } else if (typeof val === 'boolean') { + val = Number(val) + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : Buffer.from(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass +// the `instanceof` check but they should be treated as of that type. +// See: https://github.com/feross/buffer/issues/166 +function isInstance (obj, type) { + return obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && + obj.constructor.name === type.name) +} +function numberIsNaN (obj) { + // For IE11 support + return obj !== obj // eslint-disable-line no-self-compare +} + +// Create lookup table for `toString('hex')` +// See: https://github.com/feross/buffer/issues/219 +var hexSliceLookupTable = (function () { + var alphabet = '0123456789abcdef' + var table = new Array(256) + for (var i = 0; i < 16; ++i) { + var i16 = i * 16 + for (var j = 0; j < 16; ++j) { + table[i16 + j] = alphabet[i] + alphabet[j] + } + } + return table +})() diff --git a/node_modules/buffer/package.json b/node_modules/buffer/package.json new file mode 100644 index 0000000..3b1b498 --- /dev/null +++ b/node_modules/buffer/package.json @@ -0,0 +1,96 @@ +{ + "name": "buffer", + "description": "Node.js Buffer API, for the browser", + "version": "5.7.1", + "author": { + "name": "Feross Aboukhadijeh", + "email": "feross@feross.org", + "url": "https://feross.org" + }, + "bugs": { + "url": "https://github.com/feross/buffer/issues" + }, + "contributors": [ + "Romain Beauxis ", + "James Halliday " + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + }, + "devDependencies": { + "airtap": "^3.0.0", + "benchmark": "^2.1.4", + "browserify": "^17.0.0", + "concat-stream": "^2.0.0", + "hyperquest": "^2.1.3", + "is-buffer": "^2.0.4", + "is-nan": "^1.3.0", + "split": "^1.0.1", + "standard": "*", + "tape": "^5.0.1", + "through2": "^4.0.2", + "uglify-js": "^3.11.3" + }, + "homepage": "https://github.com/feross/buffer", + "jspm": { + "map": { + "./index.js": { + "node": "@node/buffer" + } + } + }, + "keywords": [ + "arraybuffer", + "browser", + "browserify", + "buffer", + "compatible", + "dataview", + "uint8array" + ], + "license": "MIT", + "main": "index.js", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "git://github.com/feross/buffer.git" + }, + "scripts": { + "perf": "browserify --debug perf/bracket-notation.js > perf/bundle.js && open perf/index.html", + "perf-node": "node perf/bracket-notation.js && node perf/concat.js && node perf/copy-big.js && node perf/copy.js && node perf/new-big.js && node perf/new.js && node perf/readDoubleBE.js && node perf/readFloatBE.js && node perf/readUInt32LE.js && node perf/slice.js && node perf/writeFloatBE.js", + "size": "browserify -r ./ | uglifyjs -c -m | gzip | wc -c", + "test": "standard && node ./bin/test.js", + "test-browser-es5": "airtap -- test/*.js", + "test-browser-es5-local": "airtap --local -- test/*.js", + "test-browser-es6": "airtap -- test/*.js test/node/*.js", + "test-browser-es6-local": "airtap --local -- test/*.js test/node/*.js", + "test-node": "tape test/*.js test/node/*.js", + "update-authors": "./bin/update-authors.sh" + }, + "standard": { + "ignore": [ + "test/node/**/*.js", + "test/common.js", + "test/_polyfill.js", + "perf/**/*.js" + ], + "globals": [ + "SharedArrayBuffer" + ] + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] +} diff --git a/node_modules/cors/CONTRIBUTING.md b/node_modules/cors/CONTRIBUTING.md new file mode 100644 index 0000000..591b09a --- /dev/null +++ b/node_modules/cors/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# contributing to `cors` + +CORS is a node.js package for providing a [connect](http://www.senchalabs.org/connect/)/[express](http://expressjs.com/) middleware that can be used to enable [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) with various options. Learn more about the project in [the README](README.md). + +## The CORS Spec + +[http://www.w3.org/TR/cors/](http://www.w3.org/TR/cors/) + +## Pull Requests Welcome + +* Include `'use strict';` in every javascript file. +* 2 space indentation. +* Please run the testing steps below before submitting. + +## Testing + +```bash +$ npm install +$ npm test +``` + +## Interactive Testing Harness + +[http://node-cors-client.herokuapp.com](http://node-cors-client.herokuapp.com) + +Related git repositories: + +* [https://github.com/TroyGoode/node-cors-server](https://github.com/TroyGoode/node-cors-server) +* [https://github.com/TroyGoode/node-cors-client](https://github.com/TroyGoode/node-cors-client) + +## License + +[MIT License](http://www.opensource.org/licenses/mit-license.php) diff --git a/node_modules/cors/HISTORY.md b/node_modules/cors/HISTORY.md new file mode 100644 index 0000000..5762bce --- /dev/null +++ b/node_modules/cors/HISTORY.md @@ -0,0 +1,58 @@ +2.8.5 / 2018-11-04 +================== + + * Fix setting `maxAge` option to `0` + +2.8.4 / 2017-07-12 +================== + + * Work-around Safari bug in default pre-flight response + +2.8.3 / 2017-03-29 +================== + + * Fix error when options delegate missing `methods` option + +2.8.2 / 2017-03-28 +================== + + * Fix error when frozen options are passed + * Send "Vary: Origin" when using regular expressions + * Send "Vary: Access-Control-Request-Headers" when dynamic `allowedHeaders` + +2.8.1 / 2016-09-08 +================== + +This release only changed documentation. + +2.8.0 / 2016-08-23 +================== + + * Add `optionsSuccessStatus` option + +2.7.2 / 2016-08-23 +================== + + * Fix error when Node.js running in strict mode + +2.7.1 / 2015-05-28 +================== + + * Move module into expressjs organization + +2.7.0 / 2015-05-28 +================== + + * Allow array of matching condition as `origin` option + * Allow regular expression as `origin` option + +2.6.1 / 2015-05-28 +================== + + * Update `license` in package.json + +2.6.0 / 2015-04-27 +================== + + * Add `preflightContinue` option + * Fix "Vary: Origin" header added for "*" diff --git a/node_modules/cors/LICENSE b/node_modules/cors/LICENSE new file mode 100644 index 0000000..fd10c84 --- /dev/null +++ b/node_modules/cors/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2013 Troy Goode + +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. diff --git a/node_modules/cors/README.md b/node_modules/cors/README.md new file mode 100644 index 0000000..732b847 --- /dev/null +++ b/node_modules/cors/README.md @@ -0,0 +1,243 @@ +# cors + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +CORS is a node.js package for providing a [Connect](http://www.senchalabs.org/connect/)/[Express](http://expressjs.com/) middleware that can be used to enable [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) with various options. + +**[Follow me (@troygoode) on Twitter!](https://twitter.com/intent/user?screen_name=troygoode)** + +* [Installation](#installation) +* [Usage](#usage) + * [Simple Usage](#simple-usage-enable-all-cors-requests) + * [Enable CORS for a Single Route](#enable-cors-for-a-single-route) + * [Configuring CORS](#configuring-cors) + * [Configuring CORS Asynchronously](#configuring-cors-asynchronously) + * [Enabling CORS Pre-Flight](#enabling-cors-pre-flight) +* [Configuration Options](#configuration-options) +* [Demo](#demo) +* [License](#license) +* [Author](#author) + +## 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 cors +``` + +## Usage + +### Simple Usage (Enable *All* CORS Requests) + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +app.use(cors()) + +app.get('/products/:id', function (req, res, next) { + res.json({msg: 'This is CORS-enabled for all origins!'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +### Enable CORS for a Single Route + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +app.get('/products/:id', cors(), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for a Single Route'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +### Configuring CORS + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +var corsOptions = { + origin: 'http://example.com', + optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204 +} + +app.get('/products/:id', cors(corsOptions), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for only example.com.'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +### Configuring CORS w/ Dynamic Origin + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +var whitelist = ['http://example1.com', 'http://example2.com'] +var corsOptions = { + origin: function (origin, callback) { + if (whitelist.indexOf(origin) !== -1) { + callback(null, true) + } else { + callback(new Error('Not allowed by CORS')) + } + } +} + +app.get('/products/:id', cors(corsOptions), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for a whitelisted domain.'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +If you do not want to block REST tools or server-to-server requests, +add a `!origin` check in the origin function like so: + +```javascript +var corsOptions = { + origin: function (origin, callback) { + if (whitelist.indexOf(origin) !== -1 || !origin) { + callback(null, true) + } else { + callback(new Error('Not allowed by CORS')) + } + } +} +``` + +### Enabling CORS Pre-Flight + +Certain CORS requests are considered 'complex' and require an initial +`OPTIONS` request (called the "pre-flight request"). An example of a +'complex' CORS request is one that uses an HTTP verb other than +GET/HEAD/POST (such as DELETE) or that uses custom headers. To enable +pre-flighting, you must add a new OPTIONS handler for the route you want +to support: + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +app.options('/products/:id', cors()) // enable pre-flight request for DELETE request +app.del('/products/:id', cors(), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for all origins!'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +You can also enable pre-flight across-the-board like so: + +```javascript +app.options('*', cors()) // include before other routes +``` + +### Configuring CORS Asynchronously + +```javascript +var express = require('express') +var cors = require('cors') +var app = express() + +var whitelist = ['http://example1.com', 'http://example2.com'] +var corsOptionsDelegate = function (req, callback) { + var corsOptions; + if (whitelist.indexOf(req.header('Origin')) !== -1) { + corsOptions = { origin: true } // reflect (enable) the requested origin in the CORS response + } else { + corsOptions = { origin: false } // disable CORS for this request + } + callback(null, corsOptions) // callback expects two parameters: error and options +} + +app.get('/products/:id', cors(corsOptionsDelegate), function (req, res, next) { + res.json({msg: 'This is CORS-enabled for a whitelisted domain.'}) +}) + +app.listen(80, function () { + console.log('CORS-enabled web server listening on port 80') +}) +``` + +## Configuration Options + +* `origin`: Configures the **Access-Control-Allow-Origin** CORS header. Possible values: + - `Boolean` - set `origin` to `true` to reflect the [request origin](http://tools.ietf.org/html/draft-abarth-origin-09), as defined by `req.header('Origin')`, or set it to `false` to disable CORS. + - `String` - set `origin` to a specific origin. For example if you set it to `"http://example.com"` only requests from "http://example.com" will be allowed. + - `RegExp` - set `origin` to a regular expression pattern which will be used to test the request origin. If it's a match, the request origin will be reflected. For example the pattern `/example\.com$/` will reflect any request that is coming from an origin ending with "example.com". + - `Array` - set `origin` to an array of valid origins. Each origin can be a `String` or a `RegExp`. For example `["http://example1.com", /\.example2\.com$/]` will accept any request from "http://example1.com" or from a subdomain of "example2.com". + - `Function` - set `origin` to a function implementing some custom logic. The function takes the request origin as the first parameter and a callback (which expects the signature `err [object], allow [bool]`) as the second. +* `methods`: Configures the **Access-Control-Allow-Methods** CORS header. Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: `['GET', 'PUT', 'POST']`). +* `allowedHeaders`: Configures the **Access-Control-Allow-Headers** CORS header. Expects a comma-delimited string (ex: 'Content-Type,Authorization') or an array (ex: `['Content-Type', 'Authorization']`). If not specified, defaults to reflecting the headers specified in the request's **Access-Control-Request-Headers** header. +* `exposedHeaders`: Configures the **Access-Control-Expose-Headers** CORS header. Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range') or an array (ex: `['Content-Range', 'X-Content-Range']`). If not specified, no custom headers are exposed. +* `credentials`: Configures the **Access-Control-Allow-Credentials** CORS header. Set to `true` to pass the header, otherwise it is omitted. +* `maxAge`: Configures the **Access-Control-Max-Age** CORS header. Set to an integer to pass the header, otherwise it is omitted. +* `preflightContinue`: Pass the CORS preflight response to the next handler. +* `optionsSuccessStatus`: Provides a status code to use for successful `OPTIONS` requests, since some legacy browsers (IE11, various SmartTVs) choke on `204`. + +The default configuration is the equivalent of: + +```json +{ + "origin": "*", + "methods": "GET,HEAD,PUT,PATCH,POST,DELETE", + "preflightContinue": false, + "optionsSuccessStatus": 204 +} +``` + +For details on the effect of each CORS header, read [this](http://www.html5rocks.com/en/tutorials/cors/) article on HTML5 Rocks. + +## Demo + +A demo that illustrates CORS working (and not working) using jQuery is available here: [http://node-cors-client.herokuapp.com/](http://node-cors-client.herokuapp.com/) + +Code for that demo can be found here: + +* Client: [https://github.com/TroyGoode/node-cors-client](https://github.com/TroyGoode/node-cors-client) +* Server: [https://github.com/TroyGoode/node-cors-server](https://github.com/TroyGoode/node-cors-server) + +## License + +[MIT License](http://www.opensource.org/licenses/mit-license.php) + +## Author + +[Troy Goode](https://github.com/TroyGoode) ([troygoode@gmail.com](mailto:troygoode@gmail.com)) + +[coveralls-image]: https://img.shields.io/coveralls/expressjs/cors/master.svg +[coveralls-url]: https://coveralls.io/r/expressjs/cors?branch=master +[downloads-image]: https://img.shields.io/npm/dm/cors.svg +[downloads-url]: https://npmjs.org/package/cors +[npm-image]: https://img.shields.io/npm/v/cors.svg +[npm-url]: https://npmjs.org/package/cors +[travis-image]: https://img.shields.io/travis/expressjs/cors/master.svg +[travis-url]: https://travis-ci.org/expressjs/cors diff --git a/node_modules/cors/lib/index.js b/node_modules/cors/lib/index.js new file mode 100644 index 0000000..5475aec --- /dev/null +++ b/node_modules/cors/lib/index.js @@ -0,0 +1,238 @@ +(function () { + + 'use strict'; + + var assign = require('object-assign'); + var vary = require('vary'); + + var defaults = { + origin: '*', + methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', + preflightContinue: false, + optionsSuccessStatus: 204 + }; + + function isString(s) { + return typeof s === 'string' || s instanceof String; + } + + function isOriginAllowed(origin, allowedOrigin) { + if (Array.isArray(allowedOrigin)) { + for (var i = 0; i < allowedOrigin.length; ++i) { + if (isOriginAllowed(origin, allowedOrigin[i])) { + return true; + } + } + return false; + } else if (isString(allowedOrigin)) { + return origin === allowedOrigin; + } else if (allowedOrigin instanceof RegExp) { + return allowedOrigin.test(origin); + } else { + return !!allowedOrigin; + } + } + + function configureOrigin(options, req) { + var requestOrigin = req.headers.origin, + headers = [], + isAllowed; + + if (!options.origin || options.origin === '*') { + // allow any origin + headers.push([{ + key: 'Access-Control-Allow-Origin', + value: '*' + }]); + } else if (isString(options.origin)) { + // fixed origin + headers.push([{ + key: 'Access-Control-Allow-Origin', + value: options.origin + }]); + headers.push([{ + key: 'Vary', + value: 'Origin' + }]); + } else { + isAllowed = isOriginAllowed(requestOrigin, options.origin); + // reflect origin + headers.push([{ + key: 'Access-Control-Allow-Origin', + value: isAllowed ? requestOrigin : false + }]); + headers.push([{ + key: 'Vary', + value: 'Origin' + }]); + } + + return headers; + } + + function configureMethods(options) { + var methods = options.methods; + if (methods.join) { + methods = options.methods.join(','); // .methods is an array, so turn it into a string + } + return { + key: 'Access-Control-Allow-Methods', + value: methods + }; + } + + function configureCredentials(options) { + if (options.credentials === true) { + return { + key: 'Access-Control-Allow-Credentials', + value: 'true' + }; + } + return null; + } + + function configureAllowedHeaders(options, req) { + var allowedHeaders = options.allowedHeaders || options.headers; + var headers = []; + + if (!allowedHeaders) { + allowedHeaders = req.headers['access-control-request-headers']; // .headers wasn't specified, so reflect the request headers + headers.push([{ + key: 'Vary', + value: 'Access-Control-Request-Headers' + }]); + } else if (allowedHeaders.join) { + allowedHeaders = allowedHeaders.join(','); // .headers is an array, so turn it into a string + } + if (allowedHeaders && allowedHeaders.length) { + headers.push([{ + key: 'Access-Control-Allow-Headers', + value: allowedHeaders + }]); + } + + return headers; + } + + function configureExposedHeaders(options) { + var headers = options.exposedHeaders; + if (!headers) { + return null; + } else if (headers.join) { + headers = headers.join(','); // .headers is an array, so turn it into a string + } + if (headers && headers.length) { + return { + key: 'Access-Control-Expose-Headers', + value: headers + }; + } + return null; + } + + function configureMaxAge(options) { + var maxAge = (typeof options.maxAge === 'number' || options.maxAge) && options.maxAge.toString() + if (maxAge && maxAge.length) { + return { + key: 'Access-Control-Max-Age', + value: maxAge + }; + } + return null; + } + + function applyHeaders(headers, res) { + for (var i = 0, n = headers.length; i < n; i++) { + var header = headers[i]; + if (header) { + if (Array.isArray(header)) { + applyHeaders(header, res); + } else if (header.key === 'Vary' && header.value) { + vary(res, header.value); + } else if (header.value) { + res.setHeader(header.key, header.value); + } + } + } + } + + function cors(options, req, res, next) { + var headers = [], + method = req.method && req.method.toUpperCase && req.method.toUpperCase(); + + if (method === 'OPTIONS') { + // preflight + headers.push(configureOrigin(options, req)); + headers.push(configureCredentials(options, req)); + headers.push(configureMethods(options, req)); + headers.push(configureAllowedHeaders(options, req)); + headers.push(configureMaxAge(options, req)); + headers.push(configureExposedHeaders(options, req)); + applyHeaders(headers, res); + + if (options.preflightContinue) { + next(); + } else { + // Safari (and potentially other browsers) need content-length 0, + // for 204 or they just hang waiting for a body + res.statusCode = options.optionsSuccessStatus; + res.setHeader('Content-Length', '0'); + res.end(); + } + } else { + // actual response + headers.push(configureOrigin(options, req)); + headers.push(configureCredentials(options, req)); + headers.push(configureExposedHeaders(options, req)); + applyHeaders(headers, res); + next(); + } + } + + function middlewareWrapper(o) { + // if options are static (either via defaults or custom options passed in), wrap in a function + var optionsCallback = null; + if (typeof o === 'function') { + optionsCallback = o; + } else { + optionsCallback = function (req, cb) { + cb(null, o); + }; + } + + return function corsMiddleware(req, res, next) { + optionsCallback(req, function (err, options) { + if (err) { + next(err); + } else { + var corsOptions = assign({}, defaults, options); + var originCallback = null; + if (corsOptions.origin && typeof corsOptions.origin === 'function') { + originCallback = corsOptions.origin; + } else if (corsOptions.origin) { + originCallback = function (origin, cb) { + cb(null, corsOptions.origin); + }; + } + + if (originCallback) { + originCallback(req.headers.origin, function (err2, origin) { + if (err2 || !origin) { + next(err2); + } else { + corsOptions.origin = origin; + cors(corsOptions, req, res, next); + } + }); + } else { + next(); + } + } + }); + }; + } + + // can pass either an options hash, an options delegate, or nothing + module.exports = middlewareWrapper; + +}()); diff --git a/node_modules/cors/package.json b/node_modules/cors/package.json new file mode 100644 index 0000000..ff37d98 --- /dev/null +++ b/node_modules/cors/package.json @@ -0,0 +1,41 @@ +{ + "name": "cors", + "description": "Node.js CORS middleware", + "version": "2.8.5", + "author": "Troy Goode (https://github.com/troygoode/)", + "license": "MIT", + "keywords": [ + "cors", + "express", + "connect", + "middleware" + ], + "repository": "expressjs/cors", + "main": "./lib/index.js", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "devDependencies": { + "after": "0.8.2", + "eslint": "2.13.1", + "express": "4.16.3", + "mocha": "5.2.0", + "nyc": "13.1.0", + "supertest": "3.3.0" + }, + "files": [ + "lib/index.js", + "CONTRIBUTING.md", + "HISTORY.md", + "LICENSE", + "README.md" + ], + "engines": { + "node": ">= 0.10" + }, + "scripts": { + "test": "npm run lint && nyc --reporter=html --reporter=text mocha --require test/support/env", + "lint": "eslint lib test" + } +} diff --git a/node_modules/denque/CHANGELOG.md b/node_modules/denque/CHANGELOG.md new file mode 100644 index 0000000..391a1f5 --- /dev/null +++ b/node_modules/denque/CHANGELOG.md @@ -0,0 +1,29 @@ +## 2.1.0 + + - fix: issue where `clear()` is still keeping references to the elements (#47) + - refactor: performance optimizations for growth and array copy (#43) + - refactor: performance optimizations for toArray and fromArray (#46) + - test: add additional benchmarks for queue growth and `toArray` (#45) + +## 2.0.1 + + - fix(types): incorrect return type on `size()` + +## 2.0.0 + + - fix!: `push` & `unshift` now accept `undefined` values to match behaviour of `Array` (fixes #25) (#35) + - This is only a **BREAKING** change if you are currently expecting `push(undefined)` and `unshift(undefined)` to do + nothing - the new behaviour now correctly adds undefined values to the queue. + - **Note**: behaviour of `push()` & `unshift()` (no arguments) remains unchanged (nothing gets added to the queue). + - **Note**: If you need to differentiate between `undefined` values in the queue and the return value of `pop()` then + check the queue `.length` before popping. + - fix: incorrect methods in types definition file + +## 1.5.1 + + - perf: minor performance tweak when growing queue size (#29) + +## 1.5.0 + + - feat: adds capacity option for circular buffers (#27) + diff --git a/node_modules/denque/LICENSE b/node_modules/denque/LICENSE new file mode 100644 index 0000000..c9cde92 --- /dev/null +++ b/node_modules/denque/LICENSE @@ -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 2018-present Invertase Limited + + 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. diff --git a/node_modules/denque/README.md b/node_modules/denque/README.md new file mode 100644 index 0000000..3c645d3 --- /dev/null +++ b/node_modules/denque/README.md @@ -0,0 +1,77 @@ +

+

Denque

+

+ +

+ NPM downloads + NPM version + Tests status + Coverage + License + Follow on Twitter +

+ +Denque is a well tested, extremely fast and lightweight [double-ended queue](http://en.wikipedia.org/wiki/Double-ended_queue) +implementation with zero dependencies and includes TypeScript types. + +Double-ended queues can also be used as a: + +- [Stack](http://en.wikipedia.org/wiki/Stack_\(abstract_data_type\)) +- [Queue](http://en.wikipedia.org/wiki/Queue_\(data_structure\)) + +This implementation is currently the fastest available, even faster than `double-ended-queue`, see the [benchmarks](https://docs.page/invertase/denque/benchmarks). + +Every queue operation is done at a constant `O(1)` - including random access from `.peekAt(index)`. + +**Works on all node versions >= v0.10** + +## Quick Start + +Install the package: + +```bash +npm install denque +``` + +Create and consume a queue: + +```js +const Denque = require("denque"); + +const denque = new Denque([1,2,3,4]); +denque.shift(); // 1 +denque.pop(); // 4 +``` + + +See the [API reference documentation](https://docs.page/invertase/denque/api) for more examples. + +--- + +## Who's using it? + +- [Kafka Node.js client](https://www.npmjs.com/package/kafka-node) +- [MariaDB Node.js client](https://www.npmjs.com/package/mariadb) +- [MongoDB Node.js client](https://www.npmjs.com/package/mongodb) +- [MySQL Node.js client](https://www.npmjs.com/package/mysql2) +- [Redis Node.js clients](https://www.npmjs.com/package/redis) + +... and [many more](https://www.npmjs.com/browse/depended/denque). + + +--- + +## License + +- See [LICENSE](/LICENSE) + +--- + +

+ + + +

+ Built and maintained by Invertase. +

+

diff --git a/node_modules/denque/index.d.ts b/node_modules/denque/index.d.ts new file mode 100644 index 0000000..e125dd4 --- /dev/null +++ b/node_modules/denque/index.d.ts @@ -0,0 +1,47 @@ +declare class Denque { + length: number; + + constructor(); + + constructor(array: T[]); + + constructor(array: T[], options: IDenqueOptions); + + push(item: T): number; + + unshift(item: T): number; + + pop(): T | undefined; + + shift(): T | undefined; + + peekBack(): T | undefined; + + peekFront(): T | undefined; + + peekAt(index: number): T | undefined; + + get(index: number): T | undefined; + + remove(index: number, count: number): T[]; + + removeOne(index: number): T | undefined; + + splice(index: number, count: number, ...item: T[]): T[] | undefined; + + isEmpty(): boolean; + + clear(): void; + + size(): number; + + toString(): string; + + toArray(): T[]; +} + +interface IDenqueOptions { + capacity?: number +} + +export = Denque; diff --git a/node_modules/denque/index.js b/node_modules/denque/index.js new file mode 100644 index 0000000..6b2e9d8 --- /dev/null +++ b/node_modules/denque/index.js @@ -0,0 +1,481 @@ +'use strict'; + +/** + * Custom implementation of a double ended queue. + */ +function Denque(array, options) { + var options = options || {}; + this._capacity = options.capacity; + + this._head = 0; + this._tail = 0; + + if (Array.isArray(array)) { + this._fromArray(array); + } else { + this._capacityMask = 0x3; + this._list = new Array(4); + } +} + +/** + * -------------- + * PUBLIC API + * ------------- + */ + +/** + * Returns the item at the specified index from the list. + * 0 is the first element, 1 is the second, and so on... + * Elements at negative values are that many from the end: -1 is one before the end + * (the last element), -2 is two before the end (one before last), etc. + * @param index + * @returns {*} + */ +Denque.prototype.peekAt = function peekAt(index) { + var i = index; + // expect a number or return undefined + if ((i !== (i | 0))) { + return void 0; + } + var len = this.size(); + if (i >= len || i < -len) return undefined; + if (i < 0) i += len; + i = (this._head + i) & this._capacityMask; + return this._list[i]; +}; + +/** + * Alias for peekAt() + * @param i + * @returns {*} + */ +Denque.prototype.get = function get(i) { + return this.peekAt(i); +}; + +/** + * Returns the first item in the list without removing it. + * @returns {*} + */ +Denque.prototype.peek = function peek() { + if (this._head === this._tail) return undefined; + return this._list[this._head]; +}; + +/** + * Alias for peek() + * @returns {*} + */ +Denque.prototype.peekFront = function peekFront() { + return this.peek(); +}; + +/** + * Returns the item that is at the back of the queue without removing it. + * Uses peekAt(-1) + */ +Denque.prototype.peekBack = function peekBack() { + return this.peekAt(-1); +}; + +/** + * Returns the current length of the queue + * @return {Number} + */ +Object.defineProperty(Denque.prototype, 'length', { + get: function length() { + return this.size(); + } +}); + +/** + * Return the number of items on the list, or 0 if empty. + * @returns {number} + */ +Denque.prototype.size = function size() { + if (this._head === this._tail) return 0; + if (this._head < this._tail) return this._tail - this._head; + else return this._capacityMask + 1 - (this._head - this._tail); +}; + +/** + * Add an item at the beginning of the list. + * @param item + */ +Denque.prototype.unshift = function unshift(item) { + if (arguments.length === 0) return this.size(); + var len = this._list.length; + this._head = (this._head - 1 + len) & this._capacityMask; + this._list[this._head] = item; + if (this._tail === this._head) this._growArray(); + if (this._capacity && this.size() > this._capacity) this.pop(); + if (this._head < this._tail) return this._tail - this._head; + else return this._capacityMask + 1 - (this._head - this._tail); +}; + +/** + * Remove and return the first item on the list, + * Returns undefined if the list is empty. + * @returns {*} + */ +Denque.prototype.shift = function shift() { + var head = this._head; + if (head === this._tail) return undefined; + var item = this._list[head]; + this._list[head] = undefined; + this._head = (head + 1) & this._capacityMask; + if (head < 2 && this._tail > 10000 && this._tail <= this._list.length >>> 2) this._shrinkArray(); + return item; +}; + +/** + * Add an item to the bottom of the list. + * @param item + */ +Denque.prototype.push = function push(item) { + if (arguments.length === 0) return this.size(); + var tail = this._tail; + this._list[tail] = item; + this._tail = (tail + 1) & this._capacityMask; + if (this._tail === this._head) { + this._growArray(); + } + if (this._capacity && this.size() > this._capacity) { + this.shift(); + } + if (this._head < this._tail) return this._tail - this._head; + else return this._capacityMask + 1 - (this._head - this._tail); +}; + +/** + * Remove and return the last item on the list. + * Returns undefined if the list is empty. + * @returns {*} + */ +Denque.prototype.pop = function pop() { + var tail = this._tail; + if (tail === this._head) return undefined; + var len = this._list.length; + this._tail = (tail - 1 + len) & this._capacityMask; + var item = this._list[this._tail]; + this._list[this._tail] = undefined; + if (this._head < 2 && tail > 10000 && tail <= len >>> 2) this._shrinkArray(); + return item; +}; + +/** + * Remove and return the item at the specified index from the list. + * Returns undefined if the list is empty. + * @param index + * @returns {*} + */ +Denque.prototype.removeOne = function removeOne(index) { + var i = index; + // expect a number or return undefined + if ((i !== (i | 0))) { + return void 0; + } + if (this._head === this._tail) return void 0; + var size = this.size(); + var len = this._list.length; + if (i >= size || i < -size) return void 0; + if (i < 0) i += size; + i = (this._head + i) & this._capacityMask; + var item = this._list[i]; + var k; + if (index < size / 2) { + for (k = index; k > 0; k--) { + this._list[i] = this._list[i = (i - 1 + len) & this._capacityMask]; + } + this._list[i] = void 0; + this._head = (this._head + 1 + len) & this._capacityMask; + } else { + for (k = size - 1 - index; k > 0; k--) { + this._list[i] = this._list[i = (i + 1 + len) & this._capacityMask]; + } + this._list[i] = void 0; + this._tail = (this._tail - 1 + len) & this._capacityMask; + } + return item; +}; + +/** + * Remove number of items from the specified index from the list. + * Returns array of removed items. + * Returns undefined if the list is empty. + * @param index + * @param count + * @returns {array} + */ +Denque.prototype.remove = function remove(index, count) { + var i = index; + var removed; + var del_count = count; + // expect a number or return undefined + if ((i !== (i | 0))) { + return void 0; + } + if (this._head === this._tail) return void 0; + var size = this.size(); + var len = this._list.length; + if (i >= size || i < -size || count < 1) return void 0; + if (i < 0) i += size; + if (count === 1 || !count) { + removed = new Array(1); + removed[0] = this.removeOne(i); + return removed; + } + if (i === 0 && i + count >= size) { + removed = this.toArray(); + this.clear(); + return removed; + } + if (i + count > size) count = size - i; + var k; + removed = new Array(count); + for (k = 0; k < count; k++) { + removed[k] = this._list[(this._head + i + k) & this._capacityMask]; + } + i = (this._head + i) & this._capacityMask; + if (index + count === size) { + this._tail = (this._tail - count + len) & this._capacityMask; + for (k = count; k > 0; k--) { + this._list[i = (i + 1 + len) & this._capacityMask] = void 0; + } + return removed; + } + if (index === 0) { + this._head = (this._head + count + len) & this._capacityMask; + for (k = count - 1; k > 0; k--) { + this._list[i = (i + 1 + len) & this._capacityMask] = void 0; + } + return removed; + } + if (i < size / 2) { + this._head = (this._head + index + count + len) & this._capacityMask; + for (k = index; k > 0; k--) { + this.unshift(this._list[i = (i - 1 + len) & this._capacityMask]); + } + i = (this._head - 1 + len) & this._capacityMask; + while (del_count > 0) { + this._list[i = (i - 1 + len) & this._capacityMask] = void 0; + del_count--; + } + if (index < 0) this._tail = i; + } else { + this._tail = i; + i = (i + count + len) & this._capacityMask; + for (k = size - (count + index); k > 0; k--) { + this.push(this._list[i++]); + } + i = this._tail; + while (del_count > 0) { + this._list[i = (i + 1 + len) & this._capacityMask] = void 0; + del_count--; + } + } + if (this._head < 2 && this._tail > 10000 && this._tail <= len >>> 2) this._shrinkArray(); + return removed; +}; + +/** + * Native splice implementation. + * Remove number of items from the specified index from the list and/or add new elements. + * Returns array of removed items or empty array if count == 0. + * Returns undefined if the list is empty. + * + * @param index + * @param count + * @param {...*} [elements] + * @returns {array} + */ +Denque.prototype.splice = function splice(index, count) { + var i = index; + // expect a number or return undefined + if ((i !== (i | 0))) { + return void 0; + } + var size = this.size(); + if (i < 0) i += size; + if (i > size) return void 0; + if (arguments.length > 2) { + var k; + var temp; + var removed; + var arg_len = arguments.length; + var len = this._list.length; + var arguments_index = 2; + if (!size || i < size / 2) { + temp = new Array(i); + for (k = 0; k < i; k++) { + temp[k] = this._list[(this._head + k) & this._capacityMask]; + } + if (count === 0) { + removed = []; + if (i > 0) { + this._head = (this._head + i + len) & this._capacityMask; + } + } else { + removed = this.remove(i, count); + this._head = (this._head + i + len) & this._capacityMask; + } + while (arg_len > arguments_index) { + this.unshift(arguments[--arg_len]); + } + for (k = i; k > 0; k--) { + this.unshift(temp[k - 1]); + } + } else { + temp = new Array(size - (i + count)); + var leng = temp.length; + for (k = 0; k < leng; k++) { + temp[k] = this._list[(this._head + i + count + k) & this._capacityMask]; + } + if (count === 0) { + removed = []; + if (i != size) { + this._tail = (this._head + i + len) & this._capacityMask; + } + } else { + removed = this.remove(i, count); + this._tail = (this._tail - leng + len) & this._capacityMask; + } + while (arguments_index < arg_len) { + this.push(arguments[arguments_index++]); + } + for (k = 0; k < leng; k++) { + this.push(temp[k]); + } + } + return removed; + } else { + return this.remove(i, count); + } +}; + +/** + * Soft clear - does not reset capacity. + */ +Denque.prototype.clear = function clear() { + this._list = new Array(this._list.length); + this._head = 0; + this._tail = 0; +}; + +/** + * Returns true or false whether the list is empty. + * @returns {boolean} + */ +Denque.prototype.isEmpty = function isEmpty() { + return this._head === this._tail; +}; + +/** + * Returns an array of all queue items. + * @returns {Array} + */ +Denque.prototype.toArray = function toArray() { + return this._copyArray(false); +}; + +/** + * ------------- + * INTERNALS + * ------------- + */ + +/** + * Fills the queue with items from an array + * For use in the constructor + * @param array + * @private + */ +Denque.prototype._fromArray = function _fromArray(array) { + var length = array.length; + var capacity = this._nextPowerOf2(length); + + this._list = new Array(capacity); + this._capacityMask = capacity - 1; + this._tail = length; + + for (var i = 0; i < length; i++) this._list[i] = array[i]; +}; + +/** + * + * @param fullCopy + * @param size Initialize the array with a specific size. Will default to the current list size + * @returns {Array} + * @private + */ +Denque.prototype._copyArray = function _copyArray(fullCopy, size) { + var src = this._list; + var capacity = src.length; + var length = this.length; + size = size | length; + + // No prealloc requested and the buffer is contiguous + if (size == length && this._head < this._tail) { + // Simply do a fast slice copy + return this._list.slice(this._head, this._tail); + } + + var dest = new Array(size); + + var k = 0; + var i; + if (fullCopy || this._head > this._tail) { + for (i = this._head; i < capacity; i++) dest[k++] = src[i]; + for (i = 0; i < this._tail; i++) dest[k++] = src[i]; + } else { + for (i = this._head; i < this._tail; i++) dest[k++] = src[i]; + } + + return dest; +} + +/** + * Grows the internal list array. + * @private + */ +Denque.prototype._growArray = function _growArray() { + if (this._head != 0) { + // double array size and copy existing data, head to end, then beginning to tail. + var newList = this._copyArray(true, this._list.length << 1); + + this._tail = this._list.length; + this._head = 0; + + this._list = newList; + } else { + this._tail = this._list.length; + this._list.length <<= 1; + } + + this._capacityMask = (this._capacityMask << 1) | 1; +}; + +/** + * Shrinks the internal list array. + * @private + */ +Denque.prototype._shrinkArray = function _shrinkArray() { + this._list.length >>>= 1; + this._capacityMask >>>= 1; +}; + +/** + * Find the next power of 2, at least 4 + * @private + * @param {number} num + * @returns {number} + */ +Denque.prototype._nextPowerOf2 = function _nextPowerOf2(num) { + var log2 = Math.log(num) / Math.log(2); + var nextPow2 = 1 << (log2 + 1); + + return Math.max(nextPow2, 4); +} + +module.exports = Denque; diff --git a/node_modules/denque/package.json b/node_modules/denque/package.json new file mode 100644 index 0000000..a635910 --- /dev/null +++ b/node_modules/denque/package.json @@ -0,0 +1,58 @@ +{ + "name": "denque", + "version": "2.1.0", + "description": "The fastest javascript implementation of a double-ended queue. Used by the official Redis, MongoDB, MariaDB & MySQL libraries for Node.js and many other libraries. Maintains compatability with deque.", + "main": "index.js", + "engines": { + "node": ">=0.10" + }, + "keywords": [ + "data-structure", + "data-structures", + "queue", + "double", + "end", + "ended", + "deque", + "denque", + "double-ended-queue" + ], + "scripts": { + "test": "istanbul cover --report lcov _mocha && npm run typescript", + "coveralls": "cat ./coverage/lcov.info | coveralls", + "typescript": "tsc --project ./test/type/tsconfig.json", + "benchmark_thousand": "node benchmark/thousand", + "benchmark_2mil": "node benchmark/two_million", + "benchmark_splice": "node benchmark/splice", + "benchmark_remove": "node benchmark/remove", + "benchmark_removeOne": "node benchmark/removeOne", + "benchmark_growth": "node benchmark/growth", + "benchmark_toArray": "node benchmark/toArray", + "benchmark_fromArray": "node benchmark/fromArray" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/invertase/denque.git" + }, + "license": "Apache-2.0", + "author": { + "name": "Invertase", + "email": "oss@invertase.io", + "url": "http://github.com/invertase/" + }, + "contributors": [ + "Mike Diarmid (Salakar) " + ], + "bugs": { + "url": "https://github.com/invertase/denque/issues" + }, + "homepage": "https://docs.page/invertase/denque", + "devDependencies": { + "benchmark": "^2.1.4", + "codecov": "^3.8.3", + "double-ended-queue": "^2.1.0-0", + "istanbul": "^0.4.5", + "mocha": "^3.5.3", + "typescript": "^3.4.1" + } +} diff --git a/node_modules/engine.io-parser/LICENSE b/node_modules/engine.io-parser/LICENSE new file mode 100644 index 0000000..d8fdaec --- /dev/null +++ b/node_modules/engine.io-parser/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2016 Guillermo Rauch (@rauchg) + +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. \ No newline at end of file diff --git a/node_modules/engine.io-parser/Readme.md b/node_modules/engine.io-parser/Readme.md new file mode 100644 index 0000000..b109650 --- /dev/null +++ b/node_modules/engine.io-parser/Readme.md @@ -0,0 +1,158 @@ + +# engine.io-parser + +[![Build Status](https://github.com/socketio/engine.io-parser/workflows/CI/badge.svg?branch=main)](https://github.com/socketio/engine.io-parser/actions) +[![NPM version](https://badge.fury.io/js/engine.io-parser.svg)](https://npmjs.com/package/engine.io-parser) + +This is the JavaScript parser for the engine.io protocol encoding, +shared by both +[engine.io-client](https://github.com/socketio/engine.io-client) and +[engine.io](https://github.com/socketio/engine.io). + +## How to use + +### Standalone + +The parser can encode/decode packets, payloads, and payloads as binary +with the following methods: `encodePacket`, `decodePacket`, `encodePayload`, +`decodePayload`. + +Example: + +```js +const parser = require("engine.io-parser"); +const data = Buffer.from([ 1, 2, 3, 4 ]); + +parser.encodePacket({ type: "message", data }, encoded => { + const decodedData = parser.decodePacket(encoded); // decodedData === data +}); +``` + +### With browserify + +Engine.IO Parser is a commonjs module, which means you can include it by using +`require` on the browser and package using [browserify](http://browserify.org/): + +1. install the parser package + + ```shell + npm install engine.io-parser + ``` + +1. write your app code + + ```js + const parser = require("engine.io-parser"); + + const testBuffer = new Int8Array(10); + for (let i = 0; i < testBuffer.length; i++) testBuffer[i] = i; + + const packets = [{ type: "message", data: testBuffer.buffer }, { type: "message", data: "hello" }]; + + parser.encodePayload(packets, encoded => { + parser.decodePayload(encoded, + (packet, index, total) => { + const isLast = index + 1 == total; + if (!isLast) { + const buffer = new Int8Array(packet.data); // testBuffer + } else { + const message = packet.data; // "hello" + } + }); + }); + ``` + +1. build your app bundle + + ```bash + $ browserify app.js > bundle.js + ``` + +1. include on your page + + ```html + + ``` + +## Features + +- Runs on browser and node.js seamlessly +- Runs inside HTML5 WebWorker +- Can encode and decode packets + - Encodes from/to ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer in Node + +## API + +Note: `cb(type)` means the type is a callback function that contains a parameter of type `type` when called. + +### Node + +- `encodePacket` + - Encodes a packet. + - **Parameters** + - `Object`: the packet to encode, has `type` and `data`. + - `data`: can be a `String`, `Number`, `Buffer`, `ArrayBuffer` + - `Boolean`: binary support + - `Function`: callback, returns the encoded packet (`cb(String)`) +- `decodePacket` + - Decodes a packet. Data also available as an ArrayBuffer if requested. + - Returns data as `String` or (`Blob` on browser, `ArrayBuffer` on Node) + - **Parameters** + - `String` | `ArrayBuffer`: the packet to decode, has `type` and `data` + - `String`: optional, the binary type + +- `encodePayload` + - Encodes multiple messages (payload). + - If any contents are binary, they will be encoded as base64 strings. Base64 + encoded strings are marked with a b before the length specifier + - **Parameters** + - `Array`: an array of packets + - `Function`: callback, returns the encoded payload (`cb(String)`) +- `decodePayload` + - Decodes data when a payload is maybe expected. Possible binary contents are + decoded from their base64 representation. + - **Parameters** + - `String`: the payload + - `Function`: callback, returns (cb(`Object`: packet, `Number`:packet index, `Number`:packet total)) + +## Tests + +Standalone tests can be run with `npm test` which will run the node.js tests. + +Browser tests are run using [zuul](https://github.com/defunctzombie/zuul). +(You must have zuul setup with a saucelabs account.) + +You can run the tests locally using the following command: + +``` +npm run test:browser +``` + +## Support + +The support channels for `engine.io-parser` are the same as `socket.io`: + - irc.freenode.net **#socket.io** + - [Github Discussions](https://github.com/socketio/socket.io/discussions) + - [Website](https://socket.io) + +## Development + +To contribute patches, run tests or benchmarks, make sure to clone the +repository: + +```bash +git clone git://github.com/socketio/engine.io-parser.git +``` + +Then: + +```bash +cd engine.io-parser +npm ci +``` + +See the `Tests` section above for how to run tests before submitting any patches. + +## License + +MIT diff --git a/node_modules/engine.io-parser/build/cjs/commons.js b/node_modules/engine.io-parser/build/cjs/commons.js new file mode 100644 index 0000000..4a0b629 --- /dev/null +++ b/node_modules/engine.io-parser/build/cjs/commons.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0; +const PACKET_TYPES = Object.create(null); // no Map = no polyfill +exports.PACKET_TYPES = PACKET_TYPES; +PACKET_TYPES["open"] = "0"; +PACKET_TYPES["close"] = "1"; +PACKET_TYPES["ping"] = "2"; +PACKET_TYPES["pong"] = "3"; +PACKET_TYPES["message"] = "4"; +PACKET_TYPES["upgrade"] = "5"; +PACKET_TYPES["noop"] = "6"; +const PACKET_TYPES_REVERSE = Object.create(null); +exports.PACKET_TYPES_REVERSE = PACKET_TYPES_REVERSE; +Object.keys(PACKET_TYPES).forEach(key => { + PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key; +}); +const ERROR_PACKET = { type: "error", data: "parser error" }; +exports.ERROR_PACKET = ERROR_PACKET; diff --git a/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js b/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js new file mode 100644 index 0000000..d5801d2 --- /dev/null +++ b/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.decode = exports.encode = void 0; +const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; +// Use a lookup table to find the index. +const lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256); +for (let i = 0; i < chars.length; i++) { + lookup[chars.charCodeAt(i)] = i; +} +const encode = (arraybuffer) => { + let bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = ''; + for (i = 0; i < len; i += 3) { + base64 += chars[bytes[i] >> 2]; + base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)]; + base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)]; + base64 += chars[bytes[i + 2] & 63]; + } + if (len % 3 === 2) { + base64 = base64.substring(0, base64.length - 1) + '='; + } + else if (len % 3 === 1) { + base64 = base64.substring(0, base64.length - 2) + '=='; + } + return base64; +}; +exports.encode = encode; +const decode = (base64) => { + let bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4; + if (base64[base64.length - 1] === '=') { + bufferLength--; + if (base64[base64.length - 2] === '=') { + bufferLength--; + } + } + const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer); + for (i = 0; i < len; i += 4) { + encoded1 = lookup[base64.charCodeAt(i)]; + encoded2 = lookup[base64.charCodeAt(i + 1)]; + encoded3 = lookup[base64.charCodeAt(i + 2)]; + encoded4 = lookup[base64.charCodeAt(i + 3)]; + bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); + bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); + bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63); + } + return arraybuffer; +}; +exports.decode = decode; diff --git a/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js b/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js new file mode 100644 index 0000000..fb8b7ab --- /dev/null +++ b/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js @@ -0,0 +1,51 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const commons_js_1 = require("./commons.js"); +const base64_arraybuffer_js_1 = require("./contrib/base64-arraybuffer.js"); +const withNativeArrayBuffer = typeof ArrayBuffer === "function"; +const decodePacket = (encodedPacket, binaryType) => { + if (typeof encodedPacket !== "string") { + return { + type: "message", + data: mapBinary(encodedPacket, binaryType) + }; + } + const type = encodedPacket.charAt(0); + if (type === "b") { + return { + type: "message", + data: decodeBase64Packet(encodedPacket.substring(1), binaryType) + }; + } + const packetType = commons_js_1.PACKET_TYPES_REVERSE[type]; + if (!packetType) { + return commons_js_1.ERROR_PACKET; + } + return encodedPacket.length > 1 + ? { + type: commons_js_1.PACKET_TYPES_REVERSE[type], + data: encodedPacket.substring(1) + } + : { + type: commons_js_1.PACKET_TYPES_REVERSE[type] + }; +}; +const decodeBase64Packet = (data, binaryType) => { + if (withNativeArrayBuffer) { + const decoded = (0, base64_arraybuffer_js_1.decode)(data); + return mapBinary(decoded, binaryType); + } + else { + return { base64: true, data }; // fallback for old browsers + } +}; +const mapBinary = (data, binaryType) => { + switch (binaryType) { + case "blob": + return data instanceof ArrayBuffer ? new Blob([data]) : data; + case "arraybuffer": + default: + return data; // assuming the data is already an ArrayBuffer + } +}; +exports.default = decodePacket; diff --git a/node_modules/engine.io-parser/build/cjs/decodePacket.js b/node_modules/engine.io-parser/build/cjs/decodePacket.js new file mode 100644 index 0000000..2dbe0f8 --- /dev/null +++ b/node_modules/engine.io-parser/build/cjs/decodePacket.js @@ -0,0 +1,49 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const commons_js_1 = require("./commons.js"); +const decodePacket = (encodedPacket, binaryType) => { + if (typeof encodedPacket !== "string") { + return { + type: "message", + data: mapBinary(encodedPacket, binaryType) + }; + } + const type = encodedPacket.charAt(0); + if (type === "b") { + const buffer = Buffer.from(encodedPacket.substring(1), "base64"); + return { + type: "message", + data: mapBinary(buffer, binaryType) + }; + } + if (!commons_js_1.PACKET_TYPES_REVERSE[type]) { + return commons_js_1.ERROR_PACKET; + } + return encodedPacket.length > 1 + ? { + type: commons_js_1.PACKET_TYPES_REVERSE[type], + data: encodedPacket.substring(1) + } + : { + type: commons_js_1.PACKET_TYPES_REVERSE[type] + }; +}; +const mapBinary = (data, binaryType) => { + const isBuffer = Buffer.isBuffer(data); + switch (binaryType) { + case "arraybuffer": + return isBuffer ? toArrayBuffer(data) : data; + case "nodebuffer": + default: + return data; // assuming the data is already a Buffer + } +}; +const toArrayBuffer = (buffer) => { + const arrayBuffer = new ArrayBuffer(buffer.length); + const view = new Uint8Array(arrayBuffer); + for (let i = 0; i < buffer.length; i++) { + view[i] = buffer[i]; + } + return arrayBuffer; +}; +exports.default = decodePacket; diff --git a/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js b/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js new file mode 100644 index 0000000..b06ec9b --- /dev/null +++ b/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const commons_js_1 = require("./commons.js"); +const withNativeBlob = typeof Blob === "function" || + (typeof Blob !== "undefined" && + Object.prototype.toString.call(Blob) === "[object BlobConstructor]"); +const withNativeArrayBuffer = typeof ArrayBuffer === "function"; +// ArrayBuffer.isView method is not defined in IE10 +const isView = obj => { + return typeof ArrayBuffer.isView === "function" + ? ArrayBuffer.isView(obj) + : obj && obj.buffer instanceof ArrayBuffer; +}; +const encodePacket = ({ type, data }, supportsBinary, callback) => { + if (withNativeBlob && data instanceof Blob) { + if (supportsBinary) { + return callback(data); + } + else { + return encodeBlobAsBase64(data, callback); + } + } + else if (withNativeArrayBuffer && + (data instanceof ArrayBuffer || isView(data))) { + if (supportsBinary) { + return callback(data); + } + else { + return encodeBlobAsBase64(new Blob([data]), callback); + } + } + // plain string + return callback(commons_js_1.PACKET_TYPES[type] + (data || "")); +}; +const encodeBlobAsBase64 = (data, callback) => { + const fileReader = new FileReader(); + fileReader.onload = function () { + const content = fileReader.result.split(",")[1]; + callback("b" + content); + }; + return fileReader.readAsDataURL(data); +}; +exports.default = encodePacket; diff --git a/node_modules/engine.io-parser/build/cjs/encodePacket.js b/node_modules/engine.io-parser/build/cjs/encodePacket.js new file mode 100644 index 0000000..bd81d02 --- /dev/null +++ b/node_modules/engine.io-parser/build/cjs/encodePacket.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const commons_js_1 = require("./commons.js"); +const encodePacket = ({ type, data }, supportsBinary, callback) => { + if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) { + const buffer = toBuffer(data); + return callback(encodeBuffer(buffer, supportsBinary)); + } + // plain string + return callback(commons_js_1.PACKET_TYPES[type] + (data || "")); +}; +const toBuffer = data => { + if (Buffer.isBuffer(data)) { + return data; + } + else if (data instanceof ArrayBuffer) { + return Buffer.from(data); + } + else { + return Buffer.from(data.buffer, data.byteOffset, data.byteLength); + } +}; +// only 'message' packets can contain binary, so the type prefix is not needed +const encodeBuffer = (data, supportsBinary) => { + return supportsBinary ? data : "b" + data.toString("base64"); +}; +exports.default = encodePacket; diff --git a/node_modules/engine.io-parser/build/cjs/index.js b/node_modules/engine.io-parser/build/cjs/index.js new file mode 100644 index 0000000..858f247 --- /dev/null +++ b/node_modules/engine.io-parser/build/cjs/index.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0; +const encodePacket_js_1 = require("./encodePacket.js"); +exports.encodePacket = encodePacket_js_1.default; +const decodePacket_js_1 = require("./decodePacket.js"); +exports.decodePacket = decodePacket_js_1.default; +const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text +const encodePayload = (packets, callback) => { + // some packets may be added to the array while encoding, so the initial length must be saved + const length = packets.length; + const encodedPackets = new Array(length); + let count = 0; + packets.forEach((packet, i) => { + // force base64 encoding for binary packets + (0, encodePacket_js_1.default)(packet, false, encodedPacket => { + encodedPackets[i] = encodedPacket; + if (++count === length) { + callback(encodedPackets.join(SEPARATOR)); + } + }); + }); +}; +exports.encodePayload = encodePayload; +const decodePayload = (encodedPayload, binaryType) => { + const encodedPackets = encodedPayload.split(SEPARATOR); + const packets = []; + for (let i = 0; i < encodedPackets.length; i++) { + const decodedPacket = (0, decodePacket_js_1.default)(encodedPackets[i], binaryType); + packets.push(decodedPacket); + if (decodedPacket.type === "error") { + break; + } + } + return packets; +}; +exports.decodePayload = decodePayload; +exports.protocol = 4; diff --git a/node_modules/engine.io-parser/build/cjs/package.json b/node_modules/engine.io-parser/build/cjs/package.json new file mode 100644 index 0000000..bdc4dbd --- /dev/null +++ b/node_modules/engine.io-parser/build/cjs/package.json @@ -0,0 +1,8 @@ +{ + "name": "engine.io-parser", + "type": "commonjs", + "browser": { + "./encodePacket.js": "./encodePacket.browser.js", + "./decodePacket.js": "./decodePacket.browser.js" + } +} diff --git a/node_modules/engine.io-parser/build/esm/commons.d.ts b/node_modules/engine.io-parser/build/esm/commons.d.ts new file mode 100644 index 0000000..2eec1dd --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/commons.d.ts @@ -0,0 +1,14 @@ +declare const PACKET_TYPES: any; +declare const PACKET_TYPES_REVERSE: any; +declare const ERROR_PACKET: Packet; +export { PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET }; +export declare type PacketType = "open" | "close" | "ping" | "pong" | "message" | "upgrade" | "noop" | "error"; +export declare type RawData = any; +export interface Packet { + type: PacketType; + options?: { + compress: boolean; + }; + data?: RawData; +} +export declare type BinaryType = "nodebuffer" | "arraybuffer" | "blob"; diff --git a/node_modules/engine.io-parser/build/esm/commons.js b/node_modules/engine.io-parser/build/esm/commons.js new file mode 100644 index 0000000..c003b58 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/commons.js @@ -0,0 +1,14 @@ +const PACKET_TYPES = Object.create(null); // no Map = no polyfill +PACKET_TYPES["open"] = "0"; +PACKET_TYPES["close"] = "1"; +PACKET_TYPES["ping"] = "2"; +PACKET_TYPES["pong"] = "3"; +PACKET_TYPES["message"] = "4"; +PACKET_TYPES["upgrade"] = "5"; +PACKET_TYPES["noop"] = "6"; +const PACKET_TYPES_REVERSE = Object.create(null); +Object.keys(PACKET_TYPES).forEach(key => { + PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key; +}); +const ERROR_PACKET = { type: "error", data: "parser error" }; +export { PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET }; diff --git a/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts b/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts new file mode 100644 index 0000000..6e0fa6b --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts @@ -0,0 +1,2 @@ +export declare const encode: (arraybuffer: ArrayBuffer) => string; +export declare const decode: (base64: string) => ArrayBuffer; diff --git a/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js b/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js new file mode 100644 index 0000000..dd9ba62 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js @@ -0,0 +1,42 @@ +const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; +// Use a lookup table to find the index. +const lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256); +for (let i = 0; i < chars.length; i++) { + lookup[chars.charCodeAt(i)] = i; +} +export const encode = (arraybuffer) => { + let bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = ''; + for (i = 0; i < len; i += 3) { + base64 += chars[bytes[i] >> 2]; + base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)]; + base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)]; + base64 += chars[bytes[i + 2] & 63]; + } + if (len % 3 === 2) { + base64 = base64.substring(0, base64.length - 1) + '='; + } + else if (len % 3 === 1) { + base64 = base64.substring(0, base64.length - 2) + '=='; + } + return base64; +}; +export const decode = (base64) => { + let bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4; + if (base64[base64.length - 1] === '=') { + bufferLength--; + if (base64[base64.length - 2] === '=') { + bufferLength--; + } + } + const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer); + for (i = 0; i < len; i += 4) { + encoded1 = lookup[base64.charCodeAt(i)]; + encoded2 = lookup[base64.charCodeAt(i + 1)]; + encoded3 = lookup[base64.charCodeAt(i + 2)]; + encoded4 = lookup[base64.charCodeAt(i + 3)]; + bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); + bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); + bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63); + } + return arraybuffer; +}; diff --git a/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts b/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts new file mode 100644 index 0000000..e4045d6 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts @@ -0,0 +1,3 @@ +import { Packet, BinaryType, RawData } from "./commons.js"; +declare const decodePacket: (encodedPacket: RawData, binaryType?: BinaryType) => Packet; +export default decodePacket; diff --git a/node_modules/engine.io-parser/build/esm/decodePacket.browser.js b/node_modules/engine.io-parser/build/esm/decodePacket.browser.js new file mode 100644 index 0000000..1d8453d --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/decodePacket.browser.js @@ -0,0 +1,49 @@ +import { ERROR_PACKET, PACKET_TYPES_REVERSE } from "./commons.js"; +import { decode } from "./contrib/base64-arraybuffer.js"; +const withNativeArrayBuffer = typeof ArrayBuffer === "function"; +const decodePacket = (encodedPacket, binaryType) => { + if (typeof encodedPacket !== "string") { + return { + type: "message", + data: mapBinary(encodedPacket, binaryType) + }; + } + const type = encodedPacket.charAt(0); + if (type === "b") { + return { + type: "message", + data: decodeBase64Packet(encodedPacket.substring(1), binaryType) + }; + } + const packetType = PACKET_TYPES_REVERSE[type]; + if (!packetType) { + return ERROR_PACKET; + } + return encodedPacket.length > 1 + ? { + type: PACKET_TYPES_REVERSE[type], + data: encodedPacket.substring(1) + } + : { + type: PACKET_TYPES_REVERSE[type] + }; +}; +const decodeBase64Packet = (data, binaryType) => { + if (withNativeArrayBuffer) { + const decoded = decode(data); + return mapBinary(decoded, binaryType); + } + else { + return { base64: true, data }; // fallback for old browsers + } +}; +const mapBinary = (data, binaryType) => { + switch (binaryType) { + case "blob": + return data instanceof ArrayBuffer ? new Blob([data]) : data; + case "arraybuffer": + default: + return data; // assuming the data is already an ArrayBuffer + } +}; +export default decodePacket; diff --git a/node_modules/engine.io-parser/build/esm/decodePacket.d.ts b/node_modules/engine.io-parser/build/esm/decodePacket.d.ts new file mode 100644 index 0000000..e4045d6 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/decodePacket.d.ts @@ -0,0 +1,3 @@ +import { Packet, BinaryType, RawData } from "./commons.js"; +declare const decodePacket: (encodedPacket: RawData, binaryType?: BinaryType) => Packet; +export default decodePacket; diff --git a/node_modules/engine.io-parser/build/esm/decodePacket.js b/node_modules/engine.io-parser/build/esm/decodePacket.js new file mode 100644 index 0000000..58ca8eb --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/decodePacket.js @@ -0,0 +1,47 @@ +import { ERROR_PACKET, PACKET_TYPES_REVERSE } from "./commons.js"; +const decodePacket = (encodedPacket, binaryType) => { + if (typeof encodedPacket !== "string") { + return { + type: "message", + data: mapBinary(encodedPacket, binaryType) + }; + } + const type = encodedPacket.charAt(0); + if (type === "b") { + const buffer = Buffer.from(encodedPacket.substring(1), "base64"); + return { + type: "message", + data: mapBinary(buffer, binaryType) + }; + } + if (!PACKET_TYPES_REVERSE[type]) { + return ERROR_PACKET; + } + return encodedPacket.length > 1 + ? { + type: PACKET_TYPES_REVERSE[type], + data: encodedPacket.substring(1) + } + : { + type: PACKET_TYPES_REVERSE[type] + }; +}; +const mapBinary = (data, binaryType) => { + const isBuffer = Buffer.isBuffer(data); + switch (binaryType) { + case "arraybuffer": + return isBuffer ? toArrayBuffer(data) : data; + case "nodebuffer": + default: + return data; // assuming the data is already a Buffer + } +}; +const toArrayBuffer = (buffer) => { + const arrayBuffer = new ArrayBuffer(buffer.length); + const view = new Uint8Array(arrayBuffer); + for (let i = 0; i < buffer.length; i++) { + view[i] = buffer[i]; + } + return arrayBuffer; +}; +export default decodePacket; diff --git a/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts b/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts new file mode 100644 index 0000000..9ca28c8 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts @@ -0,0 +1,3 @@ +import { Packet, RawData } from "./commons.js"; +declare const encodePacket: ({ type, data }: Packet, supportsBinary: boolean, callback: (encodedPacket: RawData) => void) => void; +export default encodePacket; diff --git a/node_modules/engine.io-parser/build/esm/encodePacket.browser.js b/node_modules/engine.io-parser/build/esm/encodePacket.browser.js new file mode 100644 index 0000000..37d19e4 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/encodePacket.browser.js @@ -0,0 +1,41 @@ +import { PACKET_TYPES } from "./commons.js"; +const withNativeBlob = typeof Blob === "function" || + (typeof Blob !== "undefined" && + Object.prototype.toString.call(Blob) === "[object BlobConstructor]"); +const withNativeArrayBuffer = typeof ArrayBuffer === "function"; +// ArrayBuffer.isView method is not defined in IE10 +const isView = obj => { + return typeof ArrayBuffer.isView === "function" + ? ArrayBuffer.isView(obj) + : obj && obj.buffer instanceof ArrayBuffer; +}; +const encodePacket = ({ type, data }, supportsBinary, callback) => { + if (withNativeBlob && data instanceof Blob) { + if (supportsBinary) { + return callback(data); + } + else { + return encodeBlobAsBase64(data, callback); + } + } + else if (withNativeArrayBuffer && + (data instanceof ArrayBuffer || isView(data))) { + if (supportsBinary) { + return callback(data); + } + else { + return encodeBlobAsBase64(new Blob([data]), callback); + } + } + // plain string + return callback(PACKET_TYPES[type] + (data || "")); +}; +const encodeBlobAsBase64 = (data, callback) => { + const fileReader = new FileReader(); + fileReader.onload = function () { + const content = fileReader.result.split(",")[1]; + callback("b" + content); + }; + return fileReader.readAsDataURL(data); +}; +export default encodePacket; diff --git a/node_modules/engine.io-parser/build/esm/encodePacket.d.ts b/node_modules/engine.io-parser/build/esm/encodePacket.d.ts new file mode 100644 index 0000000..9ca28c8 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/encodePacket.d.ts @@ -0,0 +1,3 @@ +import { Packet, RawData } from "./commons.js"; +declare const encodePacket: ({ type, data }: Packet, supportsBinary: boolean, callback: (encodedPacket: RawData) => void) => void; +export default encodePacket; diff --git a/node_modules/engine.io-parser/build/esm/encodePacket.js b/node_modules/engine.io-parser/build/esm/encodePacket.js new file mode 100644 index 0000000..789eb74 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/encodePacket.js @@ -0,0 +1,25 @@ +import { PACKET_TYPES } from "./commons.js"; +const encodePacket = ({ type, data }, supportsBinary, callback) => { + if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) { + const buffer = toBuffer(data); + return callback(encodeBuffer(buffer, supportsBinary)); + } + // plain string + return callback(PACKET_TYPES[type] + (data || "")); +}; +const toBuffer = data => { + if (Buffer.isBuffer(data)) { + return data; + } + else if (data instanceof ArrayBuffer) { + return Buffer.from(data); + } + else { + return Buffer.from(data.buffer, data.byteOffset, data.byteLength); + } +}; +// only 'message' packets can contain binary, so the type prefix is not needed +const encodeBuffer = (data, supportsBinary) => { + return supportsBinary ? data : "b" + data.toString("base64"); +}; +export default encodePacket; diff --git a/node_modules/engine.io-parser/build/esm/index.d.ts b/node_modules/engine.io-parser/build/esm/index.d.ts new file mode 100644 index 0000000..e79de35 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/index.d.ts @@ -0,0 +1,7 @@ +import encodePacket from "./encodePacket.js"; +import decodePacket from "./decodePacket.js"; +import { Packet, PacketType, RawData, BinaryType } from "./commons.js"; +declare const encodePayload: (packets: Packet[], callback: (encodedPayload: string) => void) => void; +declare const decodePayload: (encodedPayload: string, binaryType?: BinaryType) => Packet[]; +export declare const protocol = 4; +export { encodePacket, encodePayload, decodePacket, decodePayload, Packet, PacketType, RawData, BinaryType }; diff --git a/node_modules/engine.io-parser/build/esm/index.js b/node_modules/engine.io-parser/build/esm/index.js new file mode 100644 index 0000000..237a472 --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/index.js @@ -0,0 +1,32 @@ +import encodePacket from "./encodePacket.js"; +import decodePacket from "./decodePacket.js"; +const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text +const encodePayload = (packets, callback) => { + // some packets may be added to the array while encoding, so the initial length must be saved + const length = packets.length; + const encodedPackets = new Array(length); + let count = 0; + packets.forEach((packet, i) => { + // force base64 encoding for binary packets + encodePacket(packet, false, encodedPacket => { + encodedPackets[i] = encodedPacket; + if (++count === length) { + callback(encodedPackets.join(SEPARATOR)); + } + }); + }); +}; +const decodePayload = (encodedPayload, binaryType) => { + const encodedPackets = encodedPayload.split(SEPARATOR); + const packets = []; + for (let i = 0; i < encodedPackets.length; i++) { + const decodedPacket = decodePacket(encodedPackets[i], binaryType); + packets.push(decodedPacket); + if (decodedPacket.type === "error") { + break; + } + } + return packets; +}; +export const protocol = 4; +export { encodePacket, encodePayload, decodePacket, decodePayload }; diff --git a/node_modules/engine.io-parser/build/esm/package.json b/node_modules/engine.io-parser/build/esm/package.json new file mode 100644 index 0000000..6f2c74a --- /dev/null +++ b/node_modules/engine.io-parser/build/esm/package.json @@ -0,0 +1,8 @@ +{ + "name": "engine.io-parser", + "type": "module", + "browser": { + "./encodePacket.js": "./encodePacket.browser.js", + "./decodePacket.js": "./decodePacket.browser.js" + } +} diff --git a/node_modules/engine.io-parser/package.json b/node_modules/engine.io-parser/package.json new file mode 100644 index 0000000..76f7db7 --- /dev/null +++ b/node_modules/engine.io-parser/package.json @@ -0,0 +1,58 @@ +{ + "name": "engine.io-parser", + "description": "Parser for the client for the realtime Engine", + "license": "MIT", + "version": "5.0.4", + "main": "./build/cjs/index.js", + "module": "./build/esm/index.js", + "exports": { + "import": "./build/esm/index.js", + "require": "./build/cjs/index.js" + }, + "types": "build/esm/index.d.ts", + "homepage": "https://github.com/socketio/engine.io-parser", + "devDependencies": { + "@babel/core": "~7.9.6", + "@babel/preset-env": "~7.9.6", + "@types/mocha": "^9.0.0", + "@types/node": "^16.9.6", + "babelify": "^10.0.0", + "benchmark": "^2.1.4", + "expect.js": "0.3.1", + "mocha": "^5.2.0", + "nyc": "~15.0.1", + "prettier": "^1.19.1", + "rimraf": "^3.0.2", + "socket.io-browsers": "^1.0.4", + "ts-node": "^10.2.1", + "tsify": "^5.0.4", + "typescript": "^4.4.3", + "zuul": "3.11.1", + "zuul-ngrok": "4.0.0" + }, + "scripts": { + "compile": "rimraf ./build && tsc && tsc -p tsconfig.esm.json && ./postcompile.sh", + "test": "npm run format:check && npm run compile && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi", + "test:node": "nyc mocha -r ts-node/register test/index.ts", + "test:browser": "zuul test/index.ts --no-coverage", + "format:check": "prettier --check 'lib/**/*.ts' 'test/**/*.ts'", + "format:fix": "prettier --write 'lib/**/*.ts' 'test/**/*.ts'" + }, + "repository": { + "type": "git", + "url": "git@github.com:socketio/engine.io-parser.git" + }, + "files": [ + "build/" + ], + "browser": { + "./test/node": "./test/browser", + "./build/esm/encodePacket.js": "./build/esm/encodePacket.browser.js", + "./build/esm/decodePacket.js": "./build/esm/decodePacket.browser.js", + "./build/cjs/encodePacket.js": "./build/cjs/encodePacket.browser.js", + "./build/cjs/decodePacket.js": "./build/cjs/decodePacket.browser.js" + }, + "engines": { + "node": ">=10.0.0" + } +} diff --git a/node_modules/engine.io/LICENSE b/node_modules/engine.io/LICENSE new file mode 100644 index 0000000..6494c3c --- /dev/null +++ b/node_modules/engine.io/LICENSE @@ -0,0 +1,19 @@ +(The MIT License) + +Copyright (c) 2014 Guillermo Rauch + +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. + diff --git a/node_modules/engine.io/README.md b/node_modules/engine.io/README.md new file mode 100644 index 0000000..163077f --- /dev/null +++ b/node_modules/engine.io/README.md @@ -0,0 +1,596 @@ + +# Engine.IO: the realtime engine + +[![Build Status](https://github.com/socketio/engine.io/workflows/CI/badge.svg?branch=master)](https://github.com/socketio/engine.io/actions) +[![NPM version](https://badge.fury.io/js/engine.io.svg)](http://badge.fury.io/js/engine.io) + +`Engine.IO` is the implementation of transport-based +cross-browser/cross-device bi-directional communication layer for +[Socket.IO](http://github.com/socketio/socket.io). + +## How to use + +### Server + +#### (A) Listening on a port + +```js +const engine = require('engine.io'); +const server = engine.listen(80); + +server.on('connection', socket => { + socket.send('utf 8 string'); + socket.send(Buffer.from([0, 1, 2, 3, 4, 5])); // binary data +}); +``` + +#### (B) Intercepting requests for a http.Server + +```js +const engine = require('engine.io'); +const http = require('http').createServer().listen(3000); +const server = engine.attach(http); + +server.on('connection', socket => { + socket.on('message', data => { }); + socket.on('close', () => { }); +}); +``` + +#### (C) Passing in requests + +```js +const engine = require('engine.io'); +const server = new engine.Server(); + +server.on('connection', socket => { + socket.send('hi'); +}); + +// … +httpServer.on('upgrade', (req, socket, head) => { + server.handleUpgrade(req, socket, head); +}); + +httpServer.on('request', (req, res) => { + server.handleRequest(req, res); +}); +``` + +### Client + +```html + + +``` + +For more information on the client refer to the +[engine-client](http://github.com/socketio/engine.io-client) repository. + +## What features does it have? + +- **Maximum reliability**. Connections are established even in the presence of: + - proxies and load balancers. + - personal firewall and antivirus software. + - for more information refer to **Goals** and **Architecture** sections +- **Minimal client size** aided by: + - lazy loading of flash transports. + - lack of redundant transports. +- **Scalable** + - load balancer friendly +- **Future proof** +- **100% Node.JS core style** + - No API sugar (left for higher level projects) + - Written in readable vanilla JavaScript + +## API + +### Server + +

+ +#### Top-level + +These are exposed by `require('engine.io')`: + +##### Events + +- `flush` + - Called when a socket buffer is being flushed. + - **Arguments** + - `Socket`: socket being flushed + - `Array`: write buffer +- `drain` + - Called when a socket buffer is drained + - **Arguments** + - `Socket`: socket being flushed + +##### Properties + +- `protocol` _(Number)_: protocol revision number +- `Server`: Server class constructor +- `Socket`: Socket class constructor +- `Transport` _(Function)_: transport constructor +- `transports` _(Object)_: map of available transports + +##### Methods + +- `()` + - Returns a new `Server` instance. If the first argument is an `http.Server` then the + new `Server` instance will be attached to it. Otherwise, the arguments are passed + directly to the `Server` constructor. + - **Parameters** + - `http.Server`: optional, server to attach to. + - `Object`: optional, options object (see `Server#constructor` api docs below) + + The following are identical ways to instantiate a server and then attach it. + +```js +const httpServer; // previously created with `http.createServer();` from node.js api. + +// create a server first, and then attach +const eioServer = require('engine.io').Server(); +eioServer.attach(httpServer); + +// or call the module as a function to get `Server` +const eioServer = require('engine.io')(); +eioServer.attach(httpServer); + +// immediately attach +const eioServer = require('engine.io')(httpServer); + +// with custom options +const eioServer = require('engine.io')(httpServer, { + maxHttpBufferSize: 1e3 +}); +``` + +- `listen` + - Creates an `http.Server` which listens on the given port and attaches WS + to it. It returns `501 Not Implemented` for regular http requests. + - **Parameters** + - `Number`: port to listen on. + - `Object`: optional, options object + - `Function`: callback for `listen`. + - **Options** + - All options from `Server.attach` method, documented below. + - **Additionally** See Server `constructor` below for options you can pass for creating the new Server + - **Returns** `Server` + +```js +const engine = require('engine.io'); +const server = engine.listen(3000, { + pingTimeout: 2000, + pingInterval: 10000 +}); + +server.on('connection', /* ... */); +``` + +- `attach` + - Captures `upgrade` requests for a `http.Server`. In other words, makes + a regular http.Server WebSocket-compatible. + - **Parameters** + - `http.Server`: server to attach to. + - `Object`: optional, options object + - **Options** + - All options from `Server.attach` method, documented below. + - **Additionally** See Server `constructor` below for options you can pass for creating the new Server + - **Returns** `Server` a new Server instance. + +```js +const engine = require('engine.io'); +const httpServer = require('http').createServer().listen(3000); +const server = engine.attach(httpServer, { + wsEngine: require('eiows').Server // requires having eiows as dependency +}); + +server.on('connection', /* ... */); +``` + +#### Server + +The main server/manager. _Inherits from EventEmitter_. + +##### Events + +- `connection` + - Fired when a new connection is established. + - **Arguments** + - `Socket`: a Socket object + +- `initial_headers` + - Fired on the first request of the connection, before writing the response headers + - **Arguments** + - `headers` (`Object`): a hash of headers + - `req` (`http.IncomingMessage`): the request + +- `headers` + - Fired on the all requests of the connection, before writing the response headers + - **Arguments** + - `headers` (`Object`): a hash of headers + - `req` (`http.IncomingMessage`): the request + +- `connection_error` + - Fired when an error occurs when establishing the connection. + - **Arguments** + - `error`: an object with following properties: + - `req` (`http.IncomingMessage`): the request that was dropped + - `code` (`Number`): one of `Server.errors` + - `message` (`string`): one of `Server.errorMessages` + - `context` (`Object`): extra info about the error + +| Code | Message | +| ---- | ------- | +| 0 | "Transport unknown" +| 1 | "Session ID unknown" +| 2 | "Bad handshake method" +| 3 | "Bad request" +| 4 | "Forbidden" +| 5 | "Unsupported protocol version" + + +##### Properties + +**Important**: if you plan to use Engine.IO in a scalable way, please +keep in mind the properties below will only reflect the clients connected +to a single process. + +- `clients` _(Object)_: hash of connected clients by id. +- `clientsCount` _(Number)_: number of connected clients. + +##### Methods + +- **constructor** + - Initializes the server + - **Parameters** + - `Object`: optional, options object + - **Options** + - `pingTimeout` (`Number`): how many ms without a pong packet to + consider the connection closed (`20000`) + - `pingInterval` (`Number`): how many ms before sending a new ping + packet (`25000`) + - `upgradeTimeout` (`Number`): how many ms before an uncompleted transport upgrade is cancelled (`10000`) + - `maxHttpBufferSize` (`Number`): how many bytes or characters a message + can be, before closing the session (to avoid DoS). Default + value is `1E6`. + - `allowRequest` (`Function`): A function that receives a given handshake + or upgrade request as its first parameter, and can decide whether to + continue or not. The second argument is a function that needs to be + called with the decided information: `fn(err, success)`, where + `success` is a boolean value where false means that the request is + rejected, and err is an error code. + - `transports` (` String`): transports to allow connections + to (`['polling', 'websocket']`) + - `allowUpgrades` (`Boolean`): whether to allow transport upgrades + (`true`) + - `perMessageDeflate` (`Object|Boolean`): parameters of the WebSocket permessage-deflate extension + (see [ws module](https://github.com/einaros/ws) api docs). Set to `true` to enable. (defaults to `false`) + - `threshold` (`Number`): data is compressed only if the byte size is above this value (`1024`) + - `httpCompression` (`Object|Boolean`): parameters of the http compression for the polling transports + (see [zlib](http://nodejs.org/api/zlib.html#zlib_options) api docs). Set to `false` to disable. (`true`) + - `threshold` (`Number`): data is compressed only if the byte size is above this value (`1024`) + - `cookie` (`Object|Boolean`): configuration of the cookie that + contains the client sid to send as part of handshake response + headers. This cookie might be used for sticky-session. Defaults to not sending any cookie (`false`). + See [here](https://github.com/jshttp/cookie#options-1) for all supported options. + - `wsEngine` (`Function`): what WebSocket server implementation to use. Specified module must conform to the `ws` interface (see [ws module api docs](https://github.com/websockets/ws/blob/master/doc/ws.md)). Default value is `ws`. An alternative c++ addon is also available by installing `eiows` module. + - `cors` (`Object`): the options that will be forwarded to the cors module. See [there](https://github.com/expressjs/cors#configuration-options) for all available options. Defaults to no CORS allowed. + - `initialPacket` (`Object`): an optional packet which will be concatenated to the handshake packet emitted by Engine.IO. + - `allowEIO3` (`Boolean`): whether to support v3 Engine.IO clients (defaults to `false`) +- `close` + - Closes all clients + - **Returns** `Server` for chaining +- `handleRequest` + - Called internally when a `Engine` request is intercepted. + - **Parameters** + - `http.IncomingMessage`: a node request object + - `http.ServerResponse`: a node response object + - **Returns** `Server` for chaining +- `handleUpgrade` + - Called internally when a `Engine` ws upgrade is intercepted. + - **Parameters** (same as `upgrade` event) + - `http.IncomingMessage`: a node request object + - `net.Stream`: TCP socket for the request + - `Buffer`: legacy tail bytes + - **Returns** `Server` for chaining +- `attach` + - Attach this Server instance to an `http.Server` + - Captures `upgrade` requests for a `http.Server`. In other words, makes + a regular http.Server WebSocket-compatible. + - **Parameters** + - `http.Server`: server to attach to. + - `Object`: optional, options object + - **Options** + - `path` (`String`): name of the path to capture (`/engine.io`). + - `destroyUpgrade` (`Boolean`): destroy unhandled upgrade requests (`true`) + - `destroyUpgradeTimeout` (`Number`): milliseconds after which unhandled requests are ended (`1000`) +- `generateId` + - Generate a socket id. + - Overwrite this method to generate your custom socket id. + - **Parameters** + - `http.IncomingMessage`: a node request object + - **Returns** A socket id for connected client. + +

+ +#### Socket + +A representation of a client. _Inherits from EventEmitter_. + +##### Events + +- `close` + - Fired when the client is disconnected. + - **Arguments** + - `String`: reason for closing + - `Object`: description object (optional) +- `message` + - Fired when the client sends a message. + - **Arguments** + - `String` or `Buffer`: Unicode string or Buffer with binary contents +- `error` + - Fired when an error occurs. + - **Arguments** + - `Error`: error object +- `flush` + - Called when the write buffer is being flushed. + - **Arguments** + - `Array`: write buffer +- `drain` + - Called when the write buffer is drained +- `packet` + - Called when a socket received a packet (`message`, `ping`) + - **Arguments** + - `type`: packet type + - `data`: packet data (if type is message) +- `packetCreate` + - Called before a socket sends a packet (`message`, `ping`) + - **Arguments** + - `type`: packet type + - `data`: packet data (if type is message) +- `heartbeat` + - Called when `ping` or `pong` packed is received (depends of client version) + +##### Properties + +- `id` _(String)_: unique identifier +- `server` _(Server)_: engine parent reference +- `request` _(http.IncomingMessage)_: request that originated the Socket +- `upgraded` _(Boolean)_: whether the transport has been upgraded +- `readyState` _(String)_: opening|open|closing|closed +- `transport` _(Transport)_: transport reference + +##### Methods + +- `send`: + - Sends a message, performing `message = toString(arguments[0])` unless + sending binary data, which is sent as is. + - **Parameters** + - `String` | `Buffer` | `ArrayBuffer` | `ArrayBufferView`: a string or any object implementing `toString()`, with outgoing data, or a Buffer or ArrayBuffer with binary data. Also any ArrayBufferView can be sent as is. + - `Object`: optional, options object + - `Function`: optional, a callback executed when the message gets flushed out by the transport + - **Options** + - `compress` (`Boolean`): whether to compress sending data. This option might be ignored and forced to be `true` when using polling. (`true`) + - **Returns** `Socket` for chaining +- `close` + - Disconnects the client + - **Returns** `Socket` for chaining + +### Client + +

+ +Exposed in the `eio` global namespace (in the browser), or by +`require('engine.io-client')` (in Node.JS). + +For the client API refer to the +[engine-client](http://github.com/learnboost/engine.io-client) repository. + +## Debug / logging + +Engine.IO is powered by [debug](http://github.com/visionmedia/debug). +In order to see all the debug output, run your app with the environment variable +`DEBUG` including the desired scope. + +To see the output from all of Engine.IO's debugging scopes you can use: + +``` +DEBUG=engine* node myapp +``` + +## Transports + +- `polling`: XHR / JSONP polling transport. +- `websocket`: WebSocket transport. + +## Plugins + +- [engine.io-conflation](https://github.com/EugenDueck/engine.io-conflation): Makes **conflation and aggregation** of messages straightforward. + +## Support + +The support channels for `engine.io` are the same as `socket.io`: + - irc.freenode.net **#socket.io** + - [Google Groups](http://groups.google.com/group/socket_io) + - [Website](http://socket.io) + +## Development + +To contribute patches, run tests or benchmarks, make sure to clone the +repository: + +``` +git clone git://github.com/LearnBoost/engine.io.git +``` + +Then: + +``` +cd engine.io +npm install +``` + +## Tests + +Tests run with `npm test`. It runs the server tests that are aided by +the usage of `engine.io-client`. + +Make sure `npm install` is run first. + +## Goals + +The main goal of `Engine` is ensuring the most reliable realtime communication. +Unlike the previous Socket.IO core, it always establishes a long-polling +connection first, then tries to upgrade to better transports that are "tested" on +the side. + +During the lifetime of the Socket.IO projects, we've found countless drawbacks +to relying on `HTML5 WebSocket` or `Flash Socket` as the first connection +mechanisms. + +Both are clearly the _right way_ of establishing a bidirectional communication, +with HTML5 WebSocket being the way of the future. However, to answer most business +needs, alternative traditional HTTP 1.1 mechanisms are just as good as delivering +the same solution. + +WebSocket based connections have two fundamental benefits: + +1. **Better server performance** + - _A: Load balancers_
+ Load balancing a long polling connection poses a serious architectural nightmare + since requests can come from any number of open sockets by the user agent, but + they all need to be routed to the process and computer that owns the `Engine` + connection. This negatively impacts RAM and CPU usage. + - _B: Network traffic_
+ WebSocket is designed around the premise that each message frame has to be + surrounded by the least amount of data. In HTTP 1.1 transports, each message + frame is surrounded by HTTP headers and chunked encoding frames. If you try to + send the message _"Hello world"_ with xhr-polling, the message ultimately + becomes larger than if you were to send it with WebSocket. + - _C: Lightweight parser_
+ As an effect of **B**, the server has to do a lot more work to parse the network + data and figure out the message when traditional HTTP requests are used + (as in long polling). This means that another advantage of WebSocket is + less server CPU usage. + +2. **Better user experience** + + Due to the reasons stated in point **1**, the most important effect of being able + to establish a WebSocket connection is raw data transfer speed, which translates + in _some_ cases in better user experience. + + Applications with heavy realtime interaction (such as games) will benefit greatly, + whereas applications like realtime chat (Gmail/Facebook), newsfeeds (Facebook) or + timelines (Twitter) will have negligible user experience improvements. + +Having said this, attempting to establish a WebSocket connection directly so far has +proven problematic: + +1. **Proxies**
+ Many corporate proxies block WebSocket traffic. + +2. **Personal firewall and antivirus software**
+ As a result of our research, we've found that at least 3 personal security + applications block WebSocket traffic. + +3. **Cloud application platforms**
+ Platforms like Heroku or No.de have had trouble keeping up with the fast-paced + nature of the evolution of the WebSocket protocol. Applications therefore end up + inevitably using long polling, but the seamless installation experience of + Socket.IO we strive for (_"require() it and it just works"_) disappears. + +Some of these problems have solutions. In the case of proxies and personal programs, +however, the solutions many times involve upgrading software. Experience has shown +that relying on client software upgrades to deliver a business solution is +fruitless: the very existence of this project has to do with a fragmented panorama +of user agent distribution, with clients connecting with latest versions of the most +modern user agents (Chrome, Firefox and Safari), but others with versions as low as +IE 5.5. + +From the user perspective, an unsuccessful WebSocket connection can translate in +up to at least 10 seconds of waiting for the realtime application to begin +exchanging data. This **perceptively** hurts user experience. + +To summarize, **Engine** focuses on reliability and user experience first, marginal +potential UX improvements and increased server performance second. `Engine` is the +result of all the lessons learned with WebSocket in the wild. + +## Architecture + +The main premise of `Engine`, and the core of its existence, is the ability to +swap transports on the fly. A connection starts as xhr-polling, but it can +switch to WebSocket. + +The central problem this poses is: how do we switch transports without losing +messages? + +`Engine` only switches from polling to another transport in between polling +cycles. Since the server closes the connection after a certain timeout when +there's no activity, and the polling transport implementation buffers messages +in between connections, this ensures no message loss and optimal performance. + +Another benefit of this design is that we workaround almost all the limitations +of **Flash Socket**, such as slow connection times, increased file size (we can +safely lazy load it without hurting user experience), etc. + +## FAQ + +### Can I use engine without Socket.IO ? + +Absolutely. Although the recommended framework for building realtime applications +is Socket.IO, since it provides fundamental features for real-world applications +such as multiplexing, reconnection support, etc. + +`Engine` is to Socket.IO what Connect is to Express. An essential piece for building +realtime frameworks, but something you _probably_ won't be using for building +actual applications. + +### Does the server serve the client? + +No. The main reason is that `Engine` is meant to be bundled with frameworks. +Socket.IO includes `Engine`, therefore serving two clients is not necessary. If +you use Socket.IO, including + +```html + + + + + \ No newline at end of file diff --git a/view/post.ejs b/view/post.ejs new file mode 100644 index 0000000..1d7eeb2 --- /dev/null +++ b/view/post.ejs @@ -0,0 +1,30 @@ + + + + + <%- include('../partials/head'); %> + Glas - <%= title %> + + + + + <%- include('../partials/menu'); %> +
+ Back to home +

<%= title %>

+

<%= content %>

+
+ + + replies +
+
+
+
+ <%- include('../partials/footer'); %> + + + + + + \ No newline at end of file diff --git a/view/search.ejs b/view/search.ejs new file mode 100644 index 0000000..5091d1e --- /dev/null +++ b/view/search.ejs @@ -0,0 +1,22 @@ + + + + + <%- include('../partials/head'); %> + + + + + <%- include('../partials/menu'); %> +
+ +
+ <%- include('../partials/footer'); %> + + + + + \ No newline at end of file diff --git a/views/index.ejs b/views/index.ejs deleted file mode 100644 index 00f2d9a..0000000 --- a/views/index.ejs +++ /dev/null @@ -1,19 +0,0 @@ - - - Index Page - - - - -

Welcome to my blog!

- -

Content:

- <% if (title.length != 0) { %> - <% for (x = 0; x <= title.length - 1; x++) {%> - <%= title[x] %> - <% } %> - <% } else { %> -

Nothing here

- <% } %> - - \ No newline at end of file diff --git a/views/post.ejs b/views/post.ejs deleted file mode 100644 index 4342f48..0000000 --- a/views/post.ejs +++ /dev/null @@ -1,12 +0,0 @@ - - - <%= title %> - - - - Back to home -

<%= title %>

- -

<%= content %>

- - \ No newline at end of file