@wabot-dev/framework 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/_virtual/XMLHttpRequest.js +7 -0
- package/dist/src/_virtual/_commonjsHelpers.js +32 -0
- package/dist/src/_virtual/base64id.js +3 -0
- package/dist/src/_virtual/binary.js +3 -0
- package/dist/src/_virtual/bom-handling.js +3 -0
- package/dist/src/_virtual/broadcast-operator.js +3 -0
- package/dist/src/_virtual/browser.js +3 -0
- package/dist/src/_virtual/browser2.js +3 -0
- package/dist/src/_virtual/browser3.js +3 -0
- package/dist/src/_virtual/browser4.js +3 -0
- package/dist/src/_virtual/browser5.js +3 -0
- package/dist/src/_virtual/buffer-util.js +3 -0
- package/dist/src/_virtual/buffer-util2.js +3 -0
- package/dist/src/_virtual/buffer-util3.js +3 -0
- package/dist/src/_virtual/charset.js +3 -0
- package/dist/src/_virtual/charset2.js +3 -0
- package/dist/src/_virtual/client.js +3 -0
- package/dist/src/_virtual/cluster-adapter.js +3 -0
- package/dist/src/_virtual/commons.js +3 -0
- package/dist/src/_virtual/dbcs-codec.js +3 -0
- package/dist/src/_virtual/decodePacket.js +3 -0
- package/dist/src/_virtual/encodePacket.js +3 -0
- package/dist/src/_virtual/encoding.js +3 -0
- package/dist/src/_virtual/encoding2.js +3 -0
- package/dist/src/_virtual/engine.io.js +3 -0
- package/dist/src/_virtual/in-memory-adapter.js +3 -0
- package/dist/src/_virtual/index.js +7 -0
- package/dist/src/_virtual/index10.js +3 -0
- package/dist/src/_virtual/index11.js +3 -0
- package/dist/src/_virtual/index12.js +3 -0
- package/dist/src/_virtual/index13.js +3 -0
- package/dist/src/_virtual/index14.js +3 -0
- package/dist/src/_virtual/index15.js +3 -0
- package/dist/src/_virtual/index16.js +3 -0
- package/dist/src/_virtual/index17.js +3 -0
- package/dist/src/_virtual/index18.js +3 -0
- package/dist/src/_virtual/index19.js +3 -0
- package/dist/src/_virtual/index2.js +7 -0
- package/dist/src/_virtual/index20.js +3 -0
- package/dist/src/_virtual/index21.js +3 -0
- package/dist/src/_virtual/index22.js +3 -0
- package/dist/src/_virtual/index23.js +3 -0
- package/dist/src/_virtual/index24.js +3 -0
- package/dist/src/_virtual/index25.js +3 -0
- package/dist/src/_virtual/index26.js +3 -0
- package/dist/src/_virtual/index27.js +3 -0
- package/dist/src/_virtual/index28.js +3 -0
- package/dist/src/_virtual/index29.js +3 -0
- package/dist/src/_virtual/index3.js +7 -0
- package/dist/src/_virtual/index30.js +3 -0
- package/dist/src/_virtual/index31.js +3 -0
- package/dist/src/_virtual/index32.js +3 -0
- package/dist/src/_virtual/index33.js +3 -0
- package/dist/src/_virtual/index4.js +3 -0
- package/dist/src/_virtual/index5.js +3 -0
- package/dist/src/_virtual/index6.js +3 -0
- package/dist/src/_virtual/index7.js +3 -0
- package/dist/src/_virtual/index8.js +6 -0
- package/dist/src/_virtual/index9.js +3 -0
- package/dist/src/_virtual/inherits.js +3 -0
- package/dist/src/_virtual/inherits_browser.js +3 -0
- package/dist/src/_virtual/is-binary.js +3 -0
- package/dist/src/_virtual/language.js +3 -0
- package/dist/src/_virtual/language2.js +3 -0
- package/dist/src/_virtual/mediaType.js +3 -0
- package/dist/src/_virtual/mediaType2.js +3 -0
- package/dist/src/_virtual/namespace.js +3 -0
- package/dist/src/_virtual/node.js +3 -0
- package/dist/src/_virtual/node2.js +3 -0
- package/dist/src/_virtual/node3.js +3 -0
- package/dist/src/_virtual/node4.js +3 -0
- package/dist/src/_virtual/node5.js +3 -0
- package/dist/src/_virtual/parent-namespace.js +3 -0
- package/dist/src/_virtual/polling-jsonp.js +3 -0
- package/dist/src/_virtual/polling.js +3 -0
- package/dist/src/_virtual/polling2.js +3 -0
- package/dist/src/_virtual/receiver.js +3 -0
- package/dist/src/_virtual/sbcs-codec.js +3 -0
- package/dist/src/_virtual/sender.js +3 -0
- package/dist/src/_virtual/server.js +3 -0
- package/dist/src/_virtual/socket-types.js +3 -0
- package/dist/src/_virtual/socket.js +3 -0
- package/dist/src/_virtual/socket2.js +3 -0
- package/dist/src/_virtual/stream.js +3 -0
- package/dist/src/_virtual/transport.js +3 -0
- package/dist/src/_virtual/typed-events.js +3 -0
- package/dist/src/_virtual/userver.js +3 -0
- package/dist/src/_virtual/utf16.js +3 -0
- package/dist/src/_virtual/utf32.js +3 -0
- package/dist/src/_virtual/utf7.js +3 -0
- package/dist/src/_virtual/uws.js +3 -0
- package/dist/src/_virtual/validation.js +3 -0
- package/dist/src/_virtual/validation2.js +3 -0
- package/dist/src/_virtual/validation3.js +3 -0
- package/dist/src/_virtual/websocket-server.js +3 -0
- package/dist/src/_virtual/websocket.js +7 -0
- package/dist/src/_virtual/websocket2.js +3 -0
- package/dist/src/_virtual/websocket3.js +3 -0
- package/dist/src/_virtual/webtransport.js +3 -0
- package/dist/src/_virtual/yeast.js +3 -0
- package/dist/src/channels/cmd/@cmd.js +2 -0
- package/dist/src/channels/cmd/CmdChannel.js +2 -0
- package/dist/src/channels/telegram/@telegram.js +2 -0
- package/dist/src/channels/telegram/TelegramChannel.js +2 -0
- package/dist/src/channels/whatsapp/@whatsapp.js +24 -0
- package/dist/src/channels/whatsapp/WhatsAppChannel.js +63 -0
- package/dist/src/channels/whatsapp/WhatsAppChannelConfig.js +8 -0
- package/dist/src/channels/whatsapp/WhatsAppConnection.js +61 -0
- package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +61 -0
- package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +36 -0
- package/dist/src/channels/whatsapp/whatsAppDevSocketContracts.js +9 -0
- package/dist/src/controller/express/Express.js +5 -0
- package/dist/src/controller/socket.io/SocketIO.js +5 -0
- package/dist/src/env/WabotEnv.js +21 -0
- package/dist/src/index.d.ts +168 -1
- package/dist/src/index.js +12 -0
- package/dist/src/logger/Logger.js +65 -0
- package/dist/src/node_modules/@socket.io/component-emitter/lib/esm/index.js +171 -0
- package/dist/src/node_modules/base64id/lib/base64id.js +117 -0
- package/dist/src/node_modules/body-parser/index.js +96 -0
- package/dist/src/node_modules/body-parser/lib/read.js +225 -0
- package/dist/src/node_modules/body-parser/lib/types/json.js +222 -0
- package/dist/src/node_modules/body-parser/lib/types/raw.js +90 -0
- package/dist/src/node_modules/body-parser/lib/types/text.js +95 -0
- package/dist/src/node_modules/body-parser/lib/types/urlencoded.js +194 -0
- package/dist/src/node_modules/body-parser/lib/utils.js +96 -0
- package/dist/src/node_modules/bytes/index.js +180 -0
- package/dist/src/node_modules/call-bind-apply-helpers/actualApply.js +24 -0
- package/dist/src/node_modules/call-bind-apply-helpers/functionApply.js +13 -0
- package/dist/src/node_modules/call-bind-apply-helpers/functionCall.js +13 -0
- package/dist/src/node_modules/call-bind-apply-helpers/index.js +29 -0
- package/dist/src/node_modules/call-bind-apply-helpers/reflectApply.js +13 -0
- package/dist/src/node_modules/call-bound/index.js +31 -0
- package/dist/src/node_modules/content-type/index.js +235 -0
- package/dist/src/node_modules/cookie/index.js +345 -0
- package/dist/src/node_modules/cors/lib/index.js +249 -0
- package/dist/src/node_modules/debug/src/browser.js +286 -0
- package/dist/src/node_modules/debug/src/common.js +303 -0
- package/dist/src/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/depd/index.js +550 -0
- package/dist/src/node_modules/dunder-proto/get.js +42 -0
- package/dist/src/node_modules/ee-first/index.js +104 -0
- package/dist/src/node_modules/engine.io/build/engine.io.js +73 -0
- package/dist/src/node_modules/engine.io/build/parser-v3/index.js +429 -0
- package/dist/src/node_modules/engine.io/build/parser-v3/utf8.js +198 -0
- package/dist/src/node_modules/engine.io/build/server.js +808 -0
- package/dist/src/node_modules/engine.io/build/socket.js +469 -0
- package/dist/src/node_modules/engine.io/build/transport.js +131 -0
- package/dist/src/node_modules/engine.io/build/transports/index.js +37 -0
- package/dist/src/node_modules/engine.io/build/transports/polling-jsonp.js +53 -0
- package/dist/src/node_modules/engine.io/build/transports/polling.js +346 -0
- package/dist/src/node_modules/engine.io/build/transports/websocket.js +106 -0
- package/dist/src/node_modules/engine.io/build/transports/webtransport.js +76 -0
- package/dist/src/node_modules/engine.io/build/transports-uws/index.js +20 -0
- package/dist/src/node_modules/engine.io/build/transports-uws/polling.js +378 -0
- package/dist/src/node_modules/engine.io/build/transports-uws/websocket.js +85 -0
- package/dist/src/node_modules/engine.io/build/userver.js +292 -0
- package/dist/src/node_modules/engine.io/node_modules/accepts/index.js +250 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/engine.io/node_modules/mime-db/db.json.js +10704 -0
- package/dist/src/node_modules/engine.io/node_modules/mime-db/index.js +24 -0
- package/dist/src/node_modules/engine.io/node_modules/mime-types/index.js +202 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/index.js +96 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/charset.js +179 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/encoding.js +193 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/language.js +188 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/mediaType.js +304 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/index.js +28 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/buffer-util.js +142 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/constants.js +21 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/event-target.js +303 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/extension.js +214 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/limiter.js +64 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/receiver.js +719 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/sender.js +513 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/stream.js +170 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/subprotocol.js +73 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/validation.js +141 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket-server.js +559 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket.js +1363 -0
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/has-cors.js +13 -0
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseqs.js +36 -0
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseuri.js +66 -0
- package/dist/src/node_modules/engine.io-client/build/esm/globals.node.js +92 -0
- package/dist/src/node_modules/engine.io-client/build/esm/index.js +17 -0
- package/dist/src/node_modules/engine.io-client/build/esm/socket.js +728 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transport.js +143 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/index.js +11 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +256 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +21 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling.js +146 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.js +107 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.node.js +48 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/webtransport.js +83 -0
- package/dist/src/node_modules/engine.io-client/build/esm/util.js +62 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/buffer-util.js +142 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/constants.js +21 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/event-target.js +303 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/extension.js +214 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/limiter.js +64 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/receiver.js +719 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/sender.js +513 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/stream.js +170 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/subprotocol.js +73 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/validation.js +141 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket-server.js +559 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket.js +1363 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/commons.js +29 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/decodePacket.js +70 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/encodePacket.js +51 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/index.js +179 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/commons.js +15 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/decodePacket.js +58 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/encodePacket.js +36 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/index.js +158 -0
- package/dist/src/node_modules/es-define-property/index.js +23 -0
- package/dist/src/node_modules/es-errors/eval.js +13 -0
- package/dist/src/node_modules/es-errors/index.js +13 -0
- package/dist/src/node_modules/es-errors/range.js +13 -0
- package/dist/src/node_modules/es-errors/ref.js +13 -0
- package/dist/src/node_modules/es-errors/syntax.js +13 -0
- package/dist/src/node_modules/es-errors/type.js +13 -0
- package/dist/src/node_modules/es-errors/uri.js +13 -0
- package/dist/src/node_modules/es-object-atoms/index.js +13 -0
- package/dist/src/node_modules/function-bind/implementation.js +93 -0
- package/dist/src/node_modules/function-bind/index.js +16 -0
- package/dist/src/node_modules/get-intrinsic/index.js +413 -0
- package/dist/src/node_modules/get-proto/Object.getPrototypeOf.js +17 -0
- package/dist/src/node_modules/get-proto/Reflect.getPrototypeOf.js +13 -0
- package/dist/src/node_modules/get-proto/index.js +40 -0
- package/dist/src/node_modules/gopd/gOPD.js +13 -0
- package/dist/src/node_modules/gopd/index.js +26 -0
- package/dist/src/node_modules/has-symbols/index.js +25 -0
- package/dist/src/node_modules/has-symbols/shams.js +54 -0
- package/dist/src/node_modules/hasown/index.js +19 -0
- package/dist/src/node_modules/http-errors/index.js +306 -0
- package/dist/src/node_modules/iconv-lite/encodings/dbcs-codec.js +598 -0
- package/dist/src/node_modules/iconv-lite/encodings/dbcs-data.js +206 -0
- package/dist/src/node_modules/iconv-lite/encodings/index.js +44 -0
- package/dist/src/node_modules/iconv-lite/encodings/internal.js +210 -0
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-codec.js +83 -0
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-data-generated.js +460 -0
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-data.js +187 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/big5-added.json.js +506 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp936.json.js +2621 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp949.json.js +2380 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp950.json.js +729 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/eucjp.json.js +822 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json.js +424 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/gbk-added.json.js +264 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/shiftjis.json.js +548 -0
- package/dist/src/node_modules/iconv-lite/encodings/utf16.js +206 -0
- package/dist/src/node_modules/iconv-lite/encodings/utf32.js +329 -0
- package/dist/src/node_modules/iconv-lite/encodings/utf7.js +297 -0
- package/dist/src/node_modules/iconv-lite/lib/bom-handling.js +61 -0
- package/dist/src/node_modules/iconv-lite/lib/index.js +192 -0
- package/dist/src/node_modules/iconv-lite/lib/streams.js +120 -0
- package/dist/src/node_modules/inherits/inherits.js +21 -0
- package/dist/src/node_modules/inherits/inherits_browser.js +38 -0
- package/dist/src/node_modules/math-intrinsics/abs.js +13 -0
- package/dist/src/node_modules/math-intrinsics/floor.js +13 -0
- package/dist/src/node_modules/math-intrinsics/isNaN.js +15 -0
- package/dist/src/node_modules/math-intrinsics/max.js +13 -0
- package/dist/src/node_modules/math-intrinsics/min.js +13 -0
- package/dist/src/node_modules/math-intrinsics/pow.js +13 -0
- package/dist/src/node_modules/math-intrinsics/round.js +13 -0
- package/dist/src/node_modules/math-intrinsics/sign.js +22 -0
- package/dist/src/node_modules/media-typer/index.js +153 -0
- package/dist/src/node_modules/mime-db/db.json.js +11656 -0
- package/dist/src/node_modules/mime-db/index.js +24 -0
- package/dist/src/node_modules/mime-types/index.js +226 -0
- package/dist/src/node_modules/mime-types/mimeScore.js +62 -0
- package/dist/src/node_modules/ms/index.js +172 -0
- package/dist/src/node_modules/object-assign/index.js +99 -0
- package/dist/src/node_modules/object-inspect/index.js +557 -0
- package/dist/src/node_modules/object-inspect/util.inspect.js +13 -0
- package/dist/src/node_modules/on-finished/index.js +245 -0
- package/dist/src/node_modules/qs/lib/formats.js +32 -0
- package/dist/src/node_modules/qs/lib/index.js +24 -0
- package/dist/src/node_modules/qs/lib/parse.js +339 -0
- package/dist/src/node_modules/qs/lib/stringify.js +369 -0
- package/dist/src/node_modules/qs/lib/utils.js +279 -0
- package/dist/src/node_modules/raw-body/index.js +351 -0
- package/dist/src/node_modules/safer-buffer/safer.js +88 -0
- package/dist/src/node_modules/setprototypeof/index.js +26 -0
- package/dist/src/node_modules/side-channel/index.js +58 -0
- package/dist/src/node_modules/side-channel-list/index.js +125 -0
- package/dist/src/node_modules/side-channel-map/index.js +82 -0
- package/dist/src/node_modules/side-channel-weakmap/index.js +99 -0
- package/dist/src/node_modules/socket.io/dist/broadcast-operator.js +448 -0
- package/dist/src/node_modules/socket.io/dist/client.js +281 -0
- package/dist/src/node_modules/socket.io/dist/index.js +837 -0
- package/dist/src/node_modules/socket.io/dist/namespace.js +597 -0
- package/dist/src/node_modules/socket.io/dist/parent-namespace.js +101 -0
- package/dist/src/node_modules/socket.io/dist/socket-types.js +21 -0
- package/dist/src/node_modules/socket.io/dist/socket.js +993 -0
- package/dist/src/node_modules/socket.io/dist/typed-events.js +92 -0
- package/dist/src/node_modules/socket.io/dist/uws.js +149 -0
- package/dist/src/node_modules/socket.io/node_modules/accepts/index.js +250 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/socket.io/node_modules/mime-db/db.json.js +10704 -0
- package/dist/src/node_modules/socket.io/node_modules/mime-db/index.js +24 -0
- package/dist/src/node_modules/socket.io/node_modules/mime-types/index.js +202 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/index.js +96 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/charset.js +179 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/encoding.js +193 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/language.js +188 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/mediaType.js +304 -0
- package/dist/src/node_modules/socket.io/package.json.js +5 -0
- package/dist/src/node_modules/socket.io/wrapper.js +5 -0
- package/dist/src/node_modules/socket.io-adapter/dist/cluster-adapter.js +689 -0
- package/dist/src/node_modules/socket.io-adapter/dist/contrib/yeast.js +64 -0
- package/dist/src/node_modules/socket.io-adapter/dist/in-memory-adapter.js +407 -0
- package/dist/src/node_modules/socket.io-adapter/dist/index.js +24 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/index.js +28 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/buffer-util.js +142 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/constants.js +21 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/event-target.js +303 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/extension.js +214 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/limiter.js +64 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/receiver.js +719 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/sender.js +513 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/stream.js +170 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/subprotocol.js +73 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/validation.js +141 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket-server.js +559 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket.js +1363 -0
- package/dist/src/node_modules/socket.io-client/build/esm/contrib/backo2.js +68 -0
- package/dist/src/node_modules/socket.io-client/build/esm/index.js +50 -0
- package/dist/src/node_modules/socket.io-client/build/esm/manager.js +373 -0
- package/dist/src/node_modules/socket.io-client/build/esm/on.js +8 -0
- package/dist/src/node_modules/socket.io-client/build/esm/socket.js +884 -0
- package/dist/src/node_modules/socket.io-client/build/esm/url.js +63 -0
- package/dist/src/node_modules/socket.io-parser/build/cjs/binary.js +99 -0
- package/dist/src/node_modules/socket.io-parser/build/cjs/index.js +337 -0
- package/dist/src/node_modules/socket.io-parser/build/cjs/is-binary.js +65 -0
- package/dist/src/node_modules/socket.io-parser/build/esm/binary.js +86 -0
- package/dist/src/node_modules/socket.io-parser/build/esm/index.js +314 -0
- package/dist/src/node_modules/socket.io-parser/build/esm/is-binary.js +52 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/statuses/codes.json.js +67 -0
- package/dist/src/node_modules/statuses/index.js +157 -0
- package/dist/src/node_modules/toidentifier/index.js +41 -0
- package/dist/src/node_modules/type-is/index.js +263 -0
- package/dist/src/node_modules/unpipe/index.js +78 -0
- package/dist/src/node_modules/vary/index.js +159 -0
- package/dist/src/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +702 -0
- package/dist/src/server/runChannel.js +8 -8
- package/dist/src/server/runServer.js +41 -2
- package/package.json +7 -3
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
import require$$0 from 'stream';
|
|
2
|
+
import { __require as requirePermessageDeflate } from './permessage-deflate.js';
|
|
3
|
+
import { __require as requireConstants } from './constants.js';
|
|
4
|
+
import { __require as requireBufferUtil } from './buffer-util.js';
|
|
5
|
+
import { __require as requireValidation } from './validation.js';
|
|
6
|
+
|
|
7
|
+
var receiver;
|
|
8
|
+
var hasRequiredReceiver;
|
|
9
|
+
|
|
10
|
+
function requireReceiver () {
|
|
11
|
+
if (hasRequiredReceiver) return receiver;
|
|
12
|
+
hasRequiredReceiver = 1;
|
|
13
|
+
|
|
14
|
+
const { Writable } = require$$0;
|
|
15
|
+
|
|
16
|
+
const PerMessageDeflate = requirePermessageDeflate();
|
|
17
|
+
const {
|
|
18
|
+
BINARY_TYPES,
|
|
19
|
+
EMPTY_BUFFER,
|
|
20
|
+
kStatusCode,
|
|
21
|
+
kWebSocket
|
|
22
|
+
} = requireConstants();
|
|
23
|
+
const { concat, toArrayBuffer, unmask } = requireBufferUtil();
|
|
24
|
+
const { isValidStatusCode, isValidUTF8 } = requireValidation();
|
|
25
|
+
|
|
26
|
+
const FastBuffer = Buffer[Symbol.species];
|
|
27
|
+
|
|
28
|
+
const GET_INFO = 0;
|
|
29
|
+
const GET_PAYLOAD_LENGTH_16 = 1;
|
|
30
|
+
const GET_PAYLOAD_LENGTH_64 = 2;
|
|
31
|
+
const GET_MASK = 3;
|
|
32
|
+
const GET_DATA = 4;
|
|
33
|
+
const INFLATING = 5;
|
|
34
|
+
const DEFER_EVENT = 6;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* HyBi Receiver implementation.
|
|
38
|
+
*
|
|
39
|
+
* @extends Writable
|
|
40
|
+
*/
|
|
41
|
+
class Receiver extends Writable {
|
|
42
|
+
/**
|
|
43
|
+
* Creates a Receiver instance.
|
|
44
|
+
*
|
|
45
|
+
* @param {Object} [options] Options object
|
|
46
|
+
* @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
|
|
47
|
+
* any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
|
|
48
|
+
* multiple times in the same tick
|
|
49
|
+
* @param {String} [options.binaryType=nodebuffer] The type for binary data
|
|
50
|
+
* @param {Object} [options.extensions] An object containing the negotiated
|
|
51
|
+
* extensions
|
|
52
|
+
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
|
|
53
|
+
* client or server mode
|
|
54
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
55
|
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
56
|
+
* not to skip UTF-8 validation for text and close messages
|
|
57
|
+
*/
|
|
58
|
+
constructor(options = {}) {
|
|
59
|
+
super();
|
|
60
|
+
|
|
61
|
+
this._allowSynchronousEvents =
|
|
62
|
+
options.allowSynchronousEvents !== undefined
|
|
63
|
+
? options.allowSynchronousEvents
|
|
64
|
+
: true;
|
|
65
|
+
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
66
|
+
this._extensions = options.extensions || {};
|
|
67
|
+
this._isServer = !!options.isServer;
|
|
68
|
+
this._maxPayload = options.maxPayload | 0;
|
|
69
|
+
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
70
|
+
this[kWebSocket] = undefined;
|
|
71
|
+
|
|
72
|
+
this._bufferedBytes = 0;
|
|
73
|
+
this._buffers = [];
|
|
74
|
+
|
|
75
|
+
this._compressed = false;
|
|
76
|
+
this._payloadLength = 0;
|
|
77
|
+
this._mask = undefined;
|
|
78
|
+
this._fragmented = 0;
|
|
79
|
+
this._masked = false;
|
|
80
|
+
this._fin = false;
|
|
81
|
+
this._opcode = 0;
|
|
82
|
+
|
|
83
|
+
this._totalPayloadLength = 0;
|
|
84
|
+
this._messageLength = 0;
|
|
85
|
+
this._fragments = [];
|
|
86
|
+
|
|
87
|
+
this._errored = false;
|
|
88
|
+
this._loop = false;
|
|
89
|
+
this._state = GET_INFO;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Implements `Writable.prototype._write()`.
|
|
94
|
+
*
|
|
95
|
+
* @param {Buffer} chunk The chunk of data to write
|
|
96
|
+
* @param {String} encoding The character encoding of `chunk`
|
|
97
|
+
* @param {Function} cb Callback
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
_write(chunk, encoding, cb) {
|
|
101
|
+
if (this._opcode === 0x08 && this._state == GET_INFO) return cb();
|
|
102
|
+
|
|
103
|
+
this._bufferedBytes += chunk.length;
|
|
104
|
+
this._buffers.push(chunk);
|
|
105
|
+
this.startLoop(cb);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Consumes `n` bytes from the buffered data.
|
|
110
|
+
*
|
|
111
|
+
* @param {Number} n The number of bytes to consume
|
|
112
|
+
* @return {Buffer} The consumed bytes
|
|
113
|
+
* @private
|
|
114
|
+
*/
|
|
115
|
+
consume(n) {
|
|
116
|
+
this._bufferedBytes -= n;
|
|
117
|
+
|
|
118
|
+
if (n === this._buffers[0].length) return this._buffers.shift();
|
|
119
|
+
|
|
120
|
+
if (n < this._buffers[0].length) {
|
|
121
|
+
const buf = this._buffers[0];
|
|
122
|
+
this._buffers[0] = new FastBuffer(
|
|
123
|
+
buf.buffer,
|
|
124
|
+
buf.byteOffset + n,
|
|
125
|
+
buf.length - n
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return new FastBuffer(buf.buffer, buf.byteOffset, n);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const dst = Buffer.allocUnsafe(n);
|
|
132
|
+
|
|
133
|
+
do {
|
|
134
|
+
const buf = this._buffers[0];
|
|
135
|
+
const offset = dst.length - n;
|
|
136
|
+
|
|
137
|
+
if (n >= buf.length) {
|
|
138
|
+
dst.set(this._buffers.shift(), offset);
|
|
139
|
+
} else {
|
|
140
|
+
dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
|
|
141
|
+
this._buffers[0] = new FastBuffer(
|
|
142
|
+
buf.buffer,
|
|
143
|
+
buf.byteOffset + n,
|
|
144
|
+
buf.length - n
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
n -= buf.length;
|
|
149
|
+
} while (n > 0);
|
|
150
|
+
|
|
151
|
+
return dst;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Starts the parsing loop.
|
|
156
|
+
*
|
|
157
|
+
* @param {Function} cb Callback
|
|
158
|
+
* @private
|
|
159
|
+
*/
|
|
160
|
+
startLoop(cb) {
|
|
161
|
+
this._loop = true;
|
|
162
|
+
|
|
163
|
+
do {
|
|
164
|
+
switch (this._state) {
|
|
165
|
+
case GET_INFO:
|
|
166
|
+
this.getInfo(cb);
|
|
167
|
+
break;
|
|
168
|
+
case GET_PAYLOAD_LENGTH_16:
|
|
169
|
+
this.getPayloadLength16(cb);
|
|
170
|
+
break;
|
|
171
|
+
case GET_PAYLOAD_LENGTH_64:
|
|
172
|
+
this.getPayloadLength64(cb);
|
|
173
|
+
break;
|
|
174
|
+
case GET_MASK:
|
|
175
|
+
this.getMask();
|
|
176
|
+
break;
|
|
177
|
+
case GET_DATA:
|
|
178
|
+
this.getData(cb);
|
|
179
|
+
break;
|
|
180
|
+
case INFLATING:
|
|
181
|
+
case DEFER_EVENT:
|
|
182
|
+
this._loop = false;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
} while (this._loop);
|
|
186
|
+
|
|
187
|
+
if (!this._errored) cb();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Reads the first two bytes of a frame.
|
|
192
|
+
*
|
|
193
|
+
* @param {Function} cb Callback
|
|
194
|
+
* @private
|
|
195
|
+
*/
|
|
196
|
+
getInfo(cb) {
|
|
197
|
+
if (this._bufferedBytes < 2) {
|
|
198
|
+
this._loop = false;
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const buf = this.consume(2);
|
|
203
|
+
|
|
204
|
+
if ((buf[0] & 0x30) !== 0x00) {
|
|
205
|
+
const error = this.createError(
|
|
206
|
+
RangeError,
|
|
207
|
+
'RSV2 and RSV3 must be clear',
|
|
208
|
+
true,
|
|
209
|
+
1002,
|
|
210
|
+
'WS_ERR_UNEXPECTED_RSV_2_3'
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
cb(error);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const compressed = (buf[0] & 0x40) === 0x40;
|
|
218
|
+
|
|
219
|
+
if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
|
|
220
|
+
const error = this.createError(
|
|
221
|
+
RangeError,
|
|
222
|
+
'RSV1 must be clear',
|
|
223
|
+
true,
|
|
224
|
+
1002,
|
|
225
|
+
'WS_ERR_UNEXPECTED_RSV_1'
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
cb(error);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
this._fin = (buf[0] & 0x80) === 0x80;
|
|
233
|
+
this._opcode = buf[0] & 0x0f;
|
|
234
|
+
this._payloadLength = buf[1] & 0x7f;
|
|
235
|
+
|
|
236
|
+
if (this._opcode === 0x00) {
|
|
237
|
+
if (compressed) {
|
|
238
|
+
const error = this.createError(
|
|
239
|
+
RangeError,
|
|
240
|
+
'RSV1 must be clear',
|
|
241
|
+
true,
|
|
242
|
+
1002,
|
|
243
|
+
'WS_ERR_UNEXPECTED_RSV_1'
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
cb(error);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (!this._fragmented) {
|
|
251
|
+
const error = this.createError(
|
|
252
|
+
RangeError,
|
|
253
|
+
'invalid opcode 0',
|
|
254
|
+
true,
|
|
255
|
+
1002,
|
|
256
|
+
'WS_ERR_INVALID_OPCODE'
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
cb(error);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
this._opcode = this._fragmented;
|
|
264
|
+
} else if (this._opcode === 0x01 || this._opcode === 0x02) {
|
|
265
|
+
if (this._fragmented) {
|
|
266
|
+
const error = this.createError(
|
|
267
|
+
RangeError,
|
|
268
|
+
`invalid opcode ${this._opcode}`,
|
|
269
|
+
true,
|
|
270
|
+
1002,
|
|
271
|
+
'WS_ERR_INVALID_OPCODE'
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
cb(error);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
this._compressed = compressed;
|
|
279
|
+
} else if (this._opcode > 0x07 && this._opcode < 0x0b) {
|
|
280
|
+
if (!this._fin) {
|
|
281
|
+
const error = this.createError(
|
|
282
|
+
RangeError,
|
|
283
|
+
'FIN must be set',
|
|
284
|
+
true,
|
|
285
|
+
1002,
|
|
286
|
+
'WS_ERR_EXPECTED_FIN'
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
cb(error);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (compressed) {
|
|
294
|
+
const error = this.createError(
|
|
295
|
+
RangeError,
|
|
296
|
+
'RSV1 must be clear',
|
|
297
|
+
true,
|
|
298
|
+
1002,
|
|
299
|
+
'WS_ERR_UNEXPECTED_RSV_1'
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
cb(error);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (
|
|
307
|
+
this._payloadLength > 0x7d ||
|
|
308
|
+
(this._opcode === 0x08 && this._payloadLength === 1)
|
|
309
|
+
) {
|
|
310
|
+
const error = this.createError(
|
|
311
|
+
RangeError,
|
|
312
|
+
`invalid payload length ${this._payloadLength}`,
|
|
313
|
+
true,
|
|
314
|
+
1002,
|
|
315
|
+
'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH'
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
cb(error);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
const error = this.createError(
|
|
323
|
+
RangeError,
|
|
324
|
+
`invalid opcode ${this._opcode}`,
|
|
325
|
+
true,
|
|
326
|
+
1002,
|
|
327
|
+
'WS_ERR_INVALID_OPCODE'
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
cb(error);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (!this._fin && !this._fragmented) this._fragmented = this._opcode;
|
|
335
|
+
this._masked = (buf[1] & 0x80) === 0x80;
|
|
336
|
+
|
|
337
|
+
if (this._isServer) {
|
|
338
|
+
if (!this._masked) {
|
|
339
|
+
const error = this.createError(
|
|
340
|
+
RangeError,
|
|
341
|
+
'MASK must be set',
|
|
342
|
+
true,
|
|
343
|
+
1002,
|
|
344
|
+
'WS_ERR_EXPECTED_MASK'
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
cb(error);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
} else if (this._masked) {
|
|
351
|
+
const error = this.createError(
|
|
352
|
+
RangeError,
|
|
353
|
+
'MASK must be clear',
|
|
354
|
+
true,
|
|
355
|
+
1002,
|
|
356
|
+
'WS_ERR_UNEXPECTED_MASK'
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
cb(error);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16;
|
|
364
|
+
else if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64;
|
|
365
|
+
else this.haveLength(cb);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Gets extended payload length (7+16).
|
|
370
|
+
*
|
|
371
|
+
* @param {Function} cb Callback
|
|
372
|
+
* @private
|
|
373
|
+
*/
|
|
374
|
+
getPayloadLength16(cb) {
|
|
375
|
+
if (this._bufferedBytes < 2) {
|
|
376
|
+
this._loop = false;
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
this._payloadLength = this.consume(2).readUInt16BE(0);
|
|
381
|
+
this.haveLength(cb);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Gets extended payload length (7+64).
|
|
386
|
+
*
|
|
387
|
+
* @param {Function} cb Callback
|
|
388
|
+
* @private
|
|
389
|
+
*/
|
|
390
|
+
getPayloadLength64(cb) {
|
|
391
|
+
if (this._bufferedBytes < 8) {
|
|
392
|
+
this._loop = false;
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const buf = this.consume(8);
|
|
397
|
+
const num = buf.readUInt32BE(0);
|
|
398
|
+
|
|
399
|
+
//
|
|
400
|
+
// The maximum safe integer in JavaScript is 2^53 - 1. An error is returned
|
|
401
|
+
// if payload length is greater than this number.
|
|
402
|
+
//
|
|
403
|
+
if (num > Math.pow(2, 53 - 32) - 1) {
|
|
404
|
+
const error = this.createError(
|
|
405
|
+
RangeError,
|
|
406
|
+
'Unsupported WebSocket frame: payload length > 2^53 - 1',
|
|
407
|
+
false,
|
|
408
|
+
1009,
|
|
409
|
+
'WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH'
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
cb(error);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
|
|
417
|
+
this.haveLength(cb);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Payload length has been read.
|
|
422
|
+
*
|
|
423
|
+
* @param {Function} cb Callback
|
|
424
|
+
* @private
|
|
425
|
+
*/
|
|
426
|
+
haveLength(cb) {
|
|
427
|
+
if (this._payloadLength && this._opcode < 0x08) {
|
|
428
|
+
this._totalPayloadLength += this._payloadLength;
|
|
429
|
+
if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
|
|
430
|
+
const error = this.createError(
|
|
431
|
+
RangeError,
|
|
432
|
+
'Max payload size exceeded',
|
|
433
|
+
false,
|
|
434
|
+
1009,
|
|
435
|
+
'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH'
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
cb(error);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (this._masked) this._state = GET_MASK;
|
|
444
|
+
else this._state = GET_DATA;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Reads mask bytes.
|
|
449
|
+
*
|
|
450
|
+
* @private
|
|
451
|
+
*/
|
|
452
|
+
getMask() {
|
|
453
|
+
if (this._bufferedBytes < 4) {
|
|
454
|
+
this._loop = false;
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
this._mask = this.consume(4);
|
|
459
|
+
this._state = GET_DATA;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Reads data bytes.
|
|
464
|
+
*
|
|
465
|
+
* @param {Function} cb Callback
|
|
466
|
+
* @private
|
|
467
|
+
*/
|
|
468
|
+
getData(cb) {
|
|
469
|
+
let data = EMPTY_BUFFER;
|
|
470
|
+
|
|
471
|
+
if (this._payloadLength) {
|
|
472
|
+
if (this._bufferedBytes < this._payloadLength) {
|
|
473
|
+
this._loop = false;
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
data = this.consume(this._payloadLength);
|
|
478
|
+
|
|
479
|
+
if (
|
|
480
|
+
this._masked &&
|
|
481
|
+
(this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0
|
|
482
|
+
) {
|
|
483
|
+
unmask(data, this._mask);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
if (this._opcode > 0x07) {
|
|
488
|
+
this.controlMessage(data, cb);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (this._compressed) {
|
|
493
|
+
this._state = INFLATING;
|
|
494
|
+
this.decompress(data, cb);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if (data.length) {
|
|
499
|
+
//
|
|
500
|
+
// This message is not compressed so its length is the sum of the payload
|
|
501
|
+
// length of all fragments.
|
|
502
|
+
//
|
|
503
|
+
this._messageLength = this._totalPayloadLength;
|
|
504
|
+
this._fragments.push(data);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
this.dataMessage(cb);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Decompresses data.
|
|
512
|
+
*
|
|
513
|
+
* @param {Buffer} data Compressed data
|
|
514
|
+
* @param {Function} cb Callback
|
|
515
|
+
* @private
|
|
516
|
+
*/
|
|
517
|
+
decompress(data, cb) {
|
|
518
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
519
|
+
|
|
520
|
+
perMessageDeflate.decompress(data, this._fin, (err, buf) => {
|
|
521
|
+
if (err) return cb(err);
|
|
522
|
+
|
|
523
|
+
if (buf.length) {
|
|
524
|
+
this._messageLength += buf.length;
|
|
525
|
+
if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
|
|
526
|
+
const error = this.createError(
|
|
527
|
+
RangeError,
|
|
528
|
+
'Max payload size exceeded',
|
|
529
|
+
false,
|
|
530
|
+
1009,
|
|
531
|
+
'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH'
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
cb(error);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
this._fragments.push(buf);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
this.dataMessage(cb);
|
|
542
|
+
if (this._state === GET_INFO) this.startLoop(cb);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Handles a data message.
|
|
548
|
+
*
|
|
549
|
+
* @param {Function} cb Callback
|
|
550
|
+
* @private
|
|
551
|
+
*/
|
|
552
|
+
dataMessage(cb) {
|
|
553
|
+
if (!this._fin) {
|
|
554
|
+
this._state = GET_INFO;
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
const messageLength = this._messageLength;
|
|
559
|
+
const fragments = this._fragments;
|
|
560
|
+
|
|
561
|
+
this._totalPayloadLength = 0;
|
|
562
|
+
this._messageLength = 0;
|
|
563
|
+
this._fragmented = 0;
|
|
564
|
+
this._fragments = [];
|
|
565
|
+
|
|
566
|
+
if (this._opcode === 2) {
|
|
567
|
+
let data;
|
|
568
|
+
|
|
569
|
+
if (this._binaryType === 'nodebuffer') {
|
|
570
|
+
data = concat(fragments, messageLength);
|
|
571
|
+
} else if (this._binaryType === 'arraybuffer') {
|
|
572
|
+
data = toArrayBuffer(concat(fragments, messageLength));
|
|
573
|
+
} else {
|
|
574
|
+
data = fragments;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (this._allowSynchronousEvents) {
|
|
578
|
+
this.emit('message', data, true);
|
|
579
|
+
this._state = GET_INFO;
|
|
580
|
+
} else {
|
|
581
|
+
this._state = DEFER_EVENT;
|
|
582
|
+
setImmediate(() => {
|
|
583
|
+
this.emit('message', data, true);
|
|
584
|
+
this._state = GET_INFO;
|
|
585
|
+
this.startLoop(cb);
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
} else {
|
|
589
|
+
const buf = concat(fragments, messageLength);
|
|
590
|
+
|
|
591
|
+
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
592
|
+
const error = this.createError(
|
|
593
|
+
Error,
|
|
594
|
+
'invalid UTF-8 sequence',
|
|
595
|
+
true,
|
|
596
|
+
1007,
|
|
597
|
+
'WS_ERR_INVALID_UTF8'
|
|
598
|
+
);
|
|
599
|
+
|
|
600
|
+
cb(error);
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
if (this._state === INFLATING || this._allowSynchronousEvents) {
|
|
605
|
+
this.emit('message', buf, false);
|
|
606
|
+
this._state = GET_INFO;
|
|
607
|
+
} else {
|
|
608
|
+
this._state = DEFER_EVENT;
|
|
609
|
+
setImmediate(() => {
|
|
610
|
+
this.emit('message', buf, false);
|
|
611
|
+
this._state = GET_INFO;
|
|
612
|
+
this.startLoop(cb);
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Handles a control message.
|
|
620
|
+
*
|
|
621
|
+
* @param {Buffer} data Data to handle
|
|
622
|
+
* @return {(Error|RangeError|undefined)} A possible error
|
|
623
|
+
* @private
|
|
624
|
+
*/
|
|
625
|
+
controlMessage(data, cb) {
|
|
626
|
+
if (this._opcode === 0x08) {
|
|
627
|
+
if (data.length === 0) {
|
|
628
|
+
this._loop = false;
|
|
629
|
+
this.emit('conclude', 1005, EMPTY_BUFFER);
|
|
630
|
+
this.end();
|
|
631
|
+
} else {
|
|
632
|
+
const code = data.readUInt16BE(0);
|
|
633
|
+
|
|
634
|
+
if (!isValidStatusCode(code)) {
|
|
635
|
+
const error = this.createError(
|
|
636
|
+
RangeError,
|
|
637
|
+
`invalid status code ${code}`,
|
|
638
|
+
true,
|
|
639
|
+
1002,
|
|
640
|
+
'WS_ERR_INVALID_CLOSE_CODE'
|
|
641
|
+
);
|
|
642
|
+
|
|
643
|
+
cb(error);
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const buf = new FastBuffer(
|
|
648
|
+
data.buffer,
|
|
649
|
+
data.byteOffset + 2,
|
|
650
|
+
data.length - 2
|
|
651
|
+
);
|
|
652
|
+
|
|
653
|
+
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
654
|
+
const error = this.createError(
|
|
655
|
+
Error,
|
|
656
|
+
'invalid UTF-8 sequence',
|
|
657
|
+
true,
|
|
658
|
+
1007,
|
|
659
|
+
'WS_ERR_INVALID_UTF8'
|
|
660
|
+
);
|
|
661
|
+
|
|
662
|
+
cb(error);
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
this._loop = false;
|
|
667
|
+
this.emit('conclude', code, buf);
|
|
668
|
+
this.end();
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
this._state = GET_INFO;
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (this._allowSynchronousEvents) {
|
|
676
|
+
this.emit(this._opcode === 0x09 ? 'ping' : 'pong', data);
|
|
677
|
+
this._state = GET_INFO;
|
|
678
|
+
} else {
|
|
679
|
+
this._state = DEFER_EVENT;
|
|
680
|
+
setImmediate(() => {
|
|
681
|
+
this.emit(this._opcode === 0x09 ? 'ping' : 'pong', data);
|
|
682
|
+
this._state = GET_INFO;
|
|
683
|
+
this.startLoop(cb);
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Builds an error object.
|
|
690
|
+
*
|
|
691
|
+
* @param {function(new:Error|RangeError)} ErrorCtor The error constructor
|
|
692
|
+
* @param {String} message The error message
|
|
693
|
+
* @param {Boolean} prefix Specifies whether or not to add a default prefix to
|
|
694
|
+
* `message`
|
|
695
|
+
* @param {Number} statusCode The status code
|
|
696
|
+
* @param {String} errorCode The exposed error code
|
|
697
|
+
* @return {(Error|RangeError)} The error
|
|
698
|
+
* @private
|
|
699
|
+
*/
|
|
700
|
+
createError(ErrorCtor, message, prefix, statusCode, errorCode) {
|
|
701
|
+
this._loop = false;
|
|
702
|
+
this._errored = true;
|
|
703
|
+
|
|
704
|
+
const err = new ErrorCtor(
|
|
705
|
+
prefix ? `Invalid WebSocket frame: ${message}` : message
|
|
706
|
+
);
|
|
707
|
+
|
|
708
|
+
Error.captureStackTrace(err, this.createError);
|
|
709
|
+
err.code = errorCode;
|
|
710
|
+
err[kStatusCode] = statusCode;
|
|
711
|
+
return err;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
receiver = Receiver;
|
|
716
|
+
return receiver;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
export { requireReceiver as __require };
|