@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,513 @@
|
|
|
1
|
+
import require$$0 from 'stream';
|
|
2
|
+
import require$$1 from 'crypto';
|
|
3
|
+
import { __require as requirePermessageDeflate } from './permessage-deflate.js';
|
|
4
|
+
import { __require as requireConstants } from './constants.js';
|
|
5
|
+
import { __require as requireValidation } from './validation.js';
|
|
6
|
+
import { __require as requireBufferUtil } from './buffer-util.js';
|
|
7
|
+
|
|
8
|
+
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex" }] */
|
|
9
|
+
|
|
10
|
+
var sender;
|
|
11
|
+
var hasRequiredSender;
|
|
12
|
+
|
|
13
|
+
function requireSender () {
|
|
14
|
+
if (hasRequiredSender) return sender;
|
|
15
|
+
hasRequiredSender = 1;
|
|
16
|
+
|
|
17
|
+
const { Duplex } = require$$0;
|
|
18
|
+
const { randomFillSync } = require$$1;
|
|
19
|
+
|
|
20
|
+
const PerMessageDeflate = requirePermessageDeflate();
|
|
21
|
+
const { EMPTY_BUFFER } = requireConstants();
|
|
22
|
+
const { isValidStatusCode } = requireValidation();
|
|
23
|
+
const { mask: applyMask, toBuffer } = requireBufferUtil();
|
|
24
|
+
|
|
25
|
+
const kByteLength = Symbol('kByteLength');
|
|
26
|
+
const maskBuffer = Buffer.alloc(4);
|
|
27
|
+
const RANDOM_POOL_SIZE = 8 * 1024;
|
|
28
|
+
let randomPool;
|
|
29
|
+
let randomPoolPointer = RANDOM_POOL_SIZE;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* HyBi Sender implementation.
|
|
33
|
+
*/
|
|
34
|
+
class Sender {
|
|
35
|
+
/**
|
|
36
|
+
* Creates a Sender instance.
|
|
37
|
+
*
|
|
38
|
+
* @param {Duplex} socket The connection socket
|
|
39
|
+
* @param {Object} [extensions] An object containing the negotiated extensions
|
|
40
|
+
* @param {Function} [generateMask] The function used to generate the masking
|
|
41
|
+
* key
|
|
42
|
+
*/
|
|
43
|
+
constructor(socket, extensions, generateMask) {
|
|
44
|
+
this._extensions = extensions || {};
|
|
45
|
+
|
|
46
|
+
if (generateMask) {
|
|
47
|
+
this._generateMask = generateMask;
|
|
48
|
+
this._maskBuffer = Buffer.alloc(4);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this._socket = socket;
|
|
52
|
+
|
|
53
|
+
this._firstFragment = true;
|
|
54
|
+
this._compress = false;
|
|
55
|
+
|
|
56
|
+
this._bufferedBytes = 0;
|
|
57
|
+
this._deflating = false;
|
|
58
|
+
this._queue = [];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Frames a piece of data according to the HyBi WebSocket protocol.
|
|
63
|
+
*
|
|
64
|
+
* @param {(Buffer|String)} data The data to frame
|
|
65
|
+
* @param {Object} options Options object
|
|
66
|
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
|
67
|
+
* FIN bit
|
|
68
|
+
* @param {Function} [options.generateMask] The function used to generate the
|
|
69
|
+
* masking key
|
|
70
|
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
|
71
|
+
* `data`
|
|
72
|
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
|
73
|
+
* key
|
|
74
|
+
* @param {Number} options.opcode The opcode
|
|
75
|
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
|
76
|
+
* modified
|
|
77
|
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
|
78
|
+
* RSV1 bit
|
|
79
|
+
* @return {(Buffer|String)[]} The framed data
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
static frame(data, options) {
|
|
83
|
+
let mask;
|
|
84
|
+
let merge = false;
|
|
85
|
+
let offset = 2;
|
|
86
|
+
let skipMasking = false;
|
|
87
|
+
|
|
88
|
+
if (options.mask) {
|
|
89
|
+
mask = options.maskBuffer || maskBuffer;
|
|
90
|
+
|
|
91
|
+
if (options.generateMask) {
|
|
92
|
+
options.generateMask(mask);
|
|
93
|
+
} else {
|
|
94
|
+
if (randomPoolPointer === RANDOM_POOL_SIZE) {
|
|
95
|
+
/* istanbul ignore else */
|
|
96
|
+
if (randomPool === undefined) {
|
|
97
|
+
//
|
|
98
|
+
// This is lazily initialized because server-sent frames must not
|
|
99
|
+
// be masked so it may never be used.
|
|
100
|
+
//
|
|
101
|
+
randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
randomFillSync(randomPool, 0, RANDOM_POOL_SIZE);
|
|
105
|
+
randomPoolPointer = 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
mask[0] = randomPool[randomPoolPointer++];
|
|
109
|
+
mask[1] = randomPool[randomPoolPointer++];
|
|
110
|
+
mask[2] = randomPool[randomPoolPointer++];
|
|
111
|
+
mask[3] = randomPool[randomPoolPointer++];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;
|
|
115
|
+
offset = 6;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
let dataLength;
|
|
119
|
+
|
|
120
|
+
if (typeof data === 'string') {
|
|
121
|
+
if (
|
|
122
|
+
(!options.mask || skipMasking) &&
|
|
123
|
+
options[kByteLength] !== undefined
|
|
124
|
+
) {
|
|
125
|
+
dataLength = options[kByteLength];
|
|
126
|
+
} else {
|
|
127
|
+
data = Buffer.from(data);
|
|
128
|
+
dataLength = data.length;
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
dataLength = data.length;
|
|
132
|
+
merge = options.mask && options.readOnly && !skipMasking;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let payloadLength = dataLength;
|
|
136
|
+
|
|
137
|
+
if (dataLength >= 65536) {
|
|
138
|
+
offset += 8;
|
|
139
|
+
payloadLength = 127;
|
|
140
|
+
} else if (dataLength > 125) {
|
|
141
|
+
offset += 2;
|
|
142
|
+
payloadLength = 126;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
|
|
146
|
+
|
|
147
|
+
target[0] = options.fin ? options.opcode | 0x80 : options.opcode;
|
|
148
|
+
if (options.rsv1) target[0] |= 0x40;
|
|
149
|
+
|
|
150
|
+
target[1] = payloadLength;
|
|
151
|
+
|
|
152
|
+
if (payloadLength === 126) {
|
|
153
|
+
target.writeUInt16BE(dataLength, 2);
|
|
154
|
+
} else if (payloadLength === 127) {
|
|
155
|
+
target[2] = target[3] = 0;
|
|
156
|
+
target.writeUIntBE(dataLength, 4, 6);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (!options.mask) return [target, data];
|
|
160
|
+
|
|
161
|
+
target[1] |= 0x80;
|
|
162
|
+
target[offset - 4] = mask[0];
|
|
163
|
+
target[offset - 3] = mask[1];
|
|
164
|
+
target[offset - 2] = mask[2];
|
|
165
|
+
target[offset - 1] = mask[3];
|
|
166
|
+
|
|
167
|
+
if (skipMasking) return [target, data];
|
|
168
|
+
|
|
169
|
+
if (merge) {
|
|
170
|
+
applyMask(data, mask, target, offset, dataLength);
|
|
171
|
+
return [target];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
applyMask(data, mask, data, 0, dataLength);
|
|
175
|
+
return [target, data];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Sends a close message to the other peer.
|
|
180
|
+
*
|
|
181
|
+
* @param {Number} [code] The status code component of the body
|
|
182
|
+
* @param {(String|Buffer)} [data] The message component of the body
|
|
183
|
+
* @param {Boolean} [mask=false] Specifies whether or not to mask the message
|
|
184
|
+
* @param {Function} [cb] Callback
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
close(code, data, mask, cb) {
|
|
188
|
+
let buf;
|
|
189
|
+
|
|
190
|
+
if (code === undefined) {
|
|
191
|
+
buf = EMPTY_BUFFER;
|
|
192
|
+
} else if (typeof code !== 'number' || !isValidStatusCode(code)) {
|
|
193
|
+
throw new TypeError('First argument must be a valid error code number');
|
|
194
|
+
} else if (data === undefined || !data.length) {
|
|
195
|
+
buf = Buffer.allocUnsafe(2);
|
|
196
|
+
buf.writeUInt16BE(code, 0);
|
|
197
|
+
} else {
|
|
198
|
+
const length = Buffer.byteLength(data);
|
|
199
|
+
|
|
200
|
+
if (length > 123) {
|
|
201
|
+
throw new RangeError('The message must not be greater than 123 bytes');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
buf = Buffer.allocUnsafe(2 + length);
|
|
205
|
+
buf.writeUInt16BE(code, 0);
|
|
206
|
+
|
|
207
|
+
if (typeof data === 'string') {
|
|
208
|
+
buf.write(data, 2);
|
|
209
|
+
} else {
|
|
210
|
+
buf.set(data, 2);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const options = {
|
|
215
|
+
[kByteLength]: buf.length,
|
|
216
|
+
fin: true,
|
|
217
|
+
generateMask: this._generateMask,
|
|
218
|
+
mask,
|
|
219
|
+
maskBuffer: this._maskBuffer,
|
|
220
|
+
opcode: 0x08,
|
|
221
|
+
readOnly: false,
|
|
222
|
+
rsv1: false
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
if (this._deflating) {
|
|
226
|
+
this.enqueue([this.dispatch, buf, false, options, cb]);
|
|
227
|
+
} else {
|
|
228
|
+
this.sendFrame(Sender.frame(buf, options), cb);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Sends a ping message to the other peer.
|
|
234
|
+
*
|
|
235
|
+
* @param {*} data The message to send
|
|
236
|
+
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
|
237
|
+
* @param {Function} [cb] Callback
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
ping(data, mask, cb) {
|
|
241
|
+
let byteLength;
|
|
242
|
+
let readOnly;
|
|
243
|
+
|
|
244
|
+
if (typeof data === 'string') {
|
|
245
|
+
byteLength = Buffer.byteLength(data);
|
|
246
|
+
readOnly = false;
|
|
247
|
+
} else {
|
|
248
|
+
data = toBuffer(data);
|
|
249
|
+
byteLength = data.length;
|
|
250
|
+
readOnly = toBuffer.readOnly;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (byteLength > 125) {
|
|
254
|
+
throw new RangeError('The data size must not be greater than 125 bytes');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const options = {
|
|
258
|
+
[kByteLength]: byteLength,
|
|
259
|
+
fin: true,
|
|
260
|
+
generateMask: this._generateMask,
|
|
261
|
+
mask,
|
|
262
|
+
maskBuffer: this._maskBuffer,
|
|
263
|
+
opcode: 0x09,
|
|
264
|
+
readOnly,
|
|
265
|
+
rsv1: false
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
if (this._deflating) {
|
|
269
|
+
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
270
|
+
} else {
|
|
271
|
+
this.sendFrame(Sender.frame(data, options), cb);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Sends a pong message to the other peer.
|
|
277
|
+
*
|
|
278
|
+
* @param {*} data The message to send
|
|
279
|
+
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
|
280
|
+
* @param {Function} [cb] Callback
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
pong(data, mask, cb) {
|
|
284
|
+
let byteLength;
|
|
285
|
+
let readOnly;
|
|
286
|
+
|
|
287
|
+
if (typeof data === 'string') {
|
|
288
|
+
byteLength = Buffer.byteLength(data);
|
|
289
|
+
readOnly = false;
|
|
290
|
+
} else {
|
|
291
|
+
data = toBuffer(data);
|
|
292
|
+
byteLength = data.length;
|
|
293
|
+
readOnly = toBuffer.readOnly;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (byteLength > 125) {
|
|
297
|
+
throw new RangeError('The data size must not be greater than 125 bytes');
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const options = {
|
|
301
|
+
[kByteLength]: byteLength,
|
|
302
|
+
fin: true,
|
|
303
|
+
generateMask: this._generateMask,
|
|
304
|
+
mask,
|
|
305
|
+
maskBuffer: this._maskBuffer,
|
|
306
|
+
opcode: 0x0a,
|
|
307
|
+
readOnly,
|
|
308
|
+
rsv1: false
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
if (this._deflating) {
|
|
312
|
+
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
313
|
+
} else {
|
|
314
|
+
this.sendFrame(Sender.frame(data, options), cb);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Sends a data message to the other peer.
|
|
320
|
+
*
|
|
321
|
+
* @param {*} data The message to send
|
|
322
|
+
* @param {Object} options Options object
|
|
323
|
+
* @param {Boolean} [options.binary=false] Specifies whether `data` is binary
|
|
324
|
+
* or text
|
|
325
|
+
* @param {Boolean} [options.compress=false] Specifies whether or not to
|
|
326
|
+
* compress `data`
|
|
327
|
+
* @param {Boolean} [options.fin=false] Specifies whether the fragment is the
|
|
328
|
+
* last one
|
|
329
|
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
|
330
|
+
* `data`
|
|
331
|
+
* @param {Function} [cb] Callback
|
|
332
|
+
* @public
|
|
333
|
+
*/
|
|
334
|
+
send(data, options, cb) {
|
|
335
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
336
|
+
let opcode = options.binary ? 2 : 1;
|
|
337
|
+
let rsv1 = options.compress;
|
|
338
|
+
|
|
339
|
+
let byteLength;
|
|
340
|
+
let readOnly;
|
|
341
|
+
|
|
342
|
+
if (typeof data === 'string') {
|
|
343
|
+
byteLength = Buffer.byteLength(data);
|
|
344
|
+
readOnly = false;
|
|
345
|
+
} else {
|
|
346
|
+
data = toBuffer(data);
|
|
347
|
+
byteLength = data.length;
|
|
348
|
+
readOnly = toBuffer.readOnly;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (this._firstFragment) {
|
|
352
|
+
this._firstFragment = false;
|
|
353
|
+
if (
|
|
354
|
+
rsv1 &&
|
|
355
|
+
perMessageDeflate &&
|
|
356
|
+
perMessageDeflate.params[
|
|
357
|
+
perMessageDeflate._isServer
|
|
358
|
+
? 'server_no_context_takeover'
|
|
359
|
+
: 'client_no_context_takeover'
|
|
360
|
+
]
|
|
361
|
+
) {
|
|
362
|
+
rsv1 = byteLength >= perMessageDeflate._threshold;
|
|
363
|
+
}
|
|
364
|
+
this._compress = rsv1;
|
|
365
|
+
} else {
|
|
366
|
+
rsv1 = false;
|
|
367
|
+
opcode = 0;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (options.fin) this._firstFragment = true;
|
|
371
|
+
|
|
372
|
+
if (perMessageDeflate) {
|
|
373
|
+
const opts = {
|
|
374
|
+
[kByteLength]: byteLength,
|
|
375
|
+
fin: options.fin,
|
|
376
|
+
generateMask: this._generateMask,
|
|
377
|
+
mask: options.mask,
|
|
378
|
+
maskBuffer: this._maskBuffer,
|
|
379
|
+
opcode,
|
|
380
|
+
readOnly,
|
|
381
|
+
rsv1
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
if (this._deflating) {
|
|
385
|
+
this.enqueue([this.dispatch, data, this._compress, opts, cb]);
|
|
386
|
+
} else {
|
|
387
|
+
this.dispatch(data, this._compress, opts, cb);
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
this.sendFrame(
|
|
391
|
+
Sender.frame(data, {
|
|
392
|
+
[kByteLength]: byteLength,
|
|
393
|
+
fin: options.fin,
|
|
394
|
+
generateMask: this._generateMask,
|
|
395
|
+
mask: options.mask,
|
|
396
|
+
maskBuffer: this._maskBuffer,
|
|
397
|
+
opcode,
|
|
398
|
+
readOnly,
|
|
399
|
+
rsv1: false
|
|
400
|
+
}),
|
|
401
|
+
cb
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Dispatches a message.
|
|
408
|
+
*
|
|
409
|
+
* @param {(Buffer|String)} data The message to send
|
|
410
|
+
* @param {Boolean} [compress=false] Specifies whether or not to compress
|
|
411
|
+
* `data`
|
|
412
|
+
* @param {Object} options Options object
|
|
413
|
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
|
414
|
+
* FIN bit
|
|
415
|
+
* @param {Function} [options.generateMask] The function used to generate the
|
|
416
|
+
* masking key
|
|
417
|
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
|
418
|
+
* `data`
|
|
419
|
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
|
420
|
+
* key
|
|
421
|
+
* @param {Number} options.opcode The opcode
|
|
422
|
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
|
423
|
+
* modified
|
|
424
|
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
|
425
|
+
* RSV1 bit
|
|
426
|
+
* @param {Function} [cb] Callback
|
|
427
|
+
* @private
|
|
428
|
+
*/
|
|
429
|
+
dispatch(data, compress, options, cb) {
|
|
430
|
+
if (!compress) {
|
|
431
|
+
this.sendFrame(Sender.frame(data, options), cb);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
436
|
+
|
|
437
|
+
this._bufferedBytes += options[kByteLength];
|
|
438
|
+
this._deflating = true;
|
|
439
|
+
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
440
|
+
if (this._socket.destroyed) {
|
|
441
|
+
const err = new Error(
|
|
442
|
+
'The socket was closed while data was being compressed'
|
|
443
|
+
);
|
|
444
|
+
|
|
445
|
+
if (typeof cb === 'function') cb(err);
|
|
446
|
+
|
|
447
|
+
for (let i = 0; i < this._queue.length; i++) {
|
|
448
|
+
const params = this._queue[i];
|
|
449
|
+
const callback = params[params.length - 1];
|
|
450
|
+
|
|
451
|
+
if (typeof callback === 'function') callback(err);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
this._bufferedBytes -= options[kByteLength];
|
|
458
|
+
this._deflating = false;
|
|
459
|
+
options.readOnly = false;
|
|
460
|
+
this.sendFrame(Sender.frame(buf, options), cb);
|
|
461
|
+
this.dequeue();
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Executes queued send operations.
|
|
467
|
+
*
|
|
468
|
+
* @private
|
|
469
|
+
*/
|
|
470
|
+
dequeue() {
|
|
471
|
+
while (!this._deflating && this._queue.length) {
|
|
472
|
+
const params = this._queue.shift();
|
|
473
|
+
|
|
474
|
+
this._bufferedBytes -= params[3][kByteLength];
|
|
475
|
+
Reflect.apply(params[0], this, params.slice(1));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Enqueues a send operation.
|
|
481
|
+
*
|
|
482
|
+
* @param {Array} params Send operation parameters.
|
|
483
|
+
* @private
|
|
484
|
+
*/
|
|
485
|
+
enqueue(params) {
|
|
486
|
+
this._bufferedBytes += params[3][kByteLength];
|
|
487
|
+
this._queue.push(params);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Sends a frame.
|
|
492
|
+
*
|
|
493
|
+
* @param {Buffer[]} list The frame to send
|
|
494
|
+
* @param {Function} [cb] Callback
|
|
495
|
+
* @private
|
|
496
|
+
*/
|
|
497
|
+
sendFrame(list, cb) {
|
|
498
|
+
if (list.length === 2) {
|
|
499
|
+
this._socket.cork();
|
|
500
|
+
this._socket.write(list[0]);
|
|
501
|
+
this._socket.write(list[1], cb);
|
|
502
|
+
this._socket.uncork();
|
|
503
|
+
} else {
|
|
504
|
+
this._socket.write(list[0], cb);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
sender = Sender;
|
|
510
|
+
return sender;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export { requireSender as __require };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import require$$0 from 'stream';
|
|
2
|
+
|
|
3
|
+
var stream;
|
|
4
|
+
var hasRequiredStream;
|
|
5
|
+
|
|
6
|
+
function requireStream () {
|
|
7
|
+
if (hasRequiredStream) return stream;
|
|
8
|
+
hasRequiredStream = 1;
|
|
9
|
+
|
|
10
|
+
const { Duplex } = require$$0;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Emits the `'close'` event on a stream.
|
|
14
|
+
*
|
|
15
|
+
* @param {Duplex} stream The stream.
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
function emitClose(stream) {
|
|
19
|
+
stream.emit('close');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The listener of the `'end'` event.
|
|
24
|
+
*
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
function duplexOnEnd() {
|
|
28
|
+
if (!this.destroyed && this._writableState.finished) {
|
|
29
|
+
this.destroy();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The listener of the `'error'` event.
|
|
35
|
+
*
|
|
36
|
+
* @param {Error} err The error
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
function duplexOnError(err) {
|
|
40
|
+
this.removeListener('error', duplexOnError);
|
|
41
|
+
this.destroy();
|
|
42
|
+
if (this.listenerCount('error') === 0) {
|
|
43
|
+
// Do not suppress the throwing behavior.
|
|
44
|
+
this.emit('error', err);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Wraps a `WebSocket` in a duplex stream.
|
|
50
|
+
*
|
|
51
|
+
* @param {WebSocket} ws The `WebSocket` to wrap
|
|
52
|
+
* @param {Object} [options] The options for the `Duplex` constructor
|
|
53
|
+
* @return {Duplex} The duplex stream
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
function createWebSocketStream(ws, options) {
|
|
57
|
+
let terminateOnDestroy = true;
|
|
58
|
+
|
|
59
|
+
const duplex = new Duplex({
|
|
60
|
+
...options,
|
|
61
|
+
autoDestroy: false,
|
|
62
|
+
emitClose: false,
|
|
63
|
+
objectMode: false,
|
|
64
|
+
writableObjectMode: false
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
ws.on('message', function message(msg, isBinary) {
|
|
68
|
+
const data =
|
|
69
|
+
!isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
|
|
70
|
+
|
|
71
|
+
if (!duplex.push(data)) ws.pause();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
ws.once('error', function error(err) {
|
|
75
|
+
if (duplex.destroyed) return;
|
|
76
|
+
|
|
77
|
+
// Prevent `ws.terminate()` from being called by `duplex._destroy()`.
|
|
78
|
+
//
|
|
79
|
+
// - If the `'error'` event is emitted before the `'open'` event, then
|
|
80
|
+
// `ws.terminate()` is a noop as no socket is assigned.
|
|
81
|
+
// - Otherwise, the error is re-emitted by the listener of the `'error'`
|
|
82
|
+
// event of the `Receiver` object. The listener already closes the
|
|
83
|
+
// connection by calling `ws.close()`. This allows a close frame to be
|
|
84
|
+
// sent to the other peer. If `ws.terminate()` is called right after this,
|
|
85
|
+
// then the close frame might not be sent.
|
|
86
|
+
terminateOnDestroy = false;
|
|
87
|
+
duplex.destroy(err);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
ws.once('close', function close() {
|
|
91
|
+
if (duplex.destroyed) return;
|
|
92
|
+
|
|
93
|
+
duplex.push(null);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
duplex._destroy = function (err, callback) {
|
|
97
|
+
if (ws.readyState === ws.CLOSED) {
|
|
98
|
+
callback(err);
|
|
99
|
+
process.nextTick(emitClose, duplex);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let called = false;
|
|
104
|
+
|
|
105
|
+
ws.once('error', function error(err) {
|
|
106
|
+
called = true;
|
|
107
|
+
callback(err);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
ws.once('close', function close() {
|
|
111
|
+
if (!called) callback(err);
|
|
112
|
+
process.nextTick(emitClose, duplex);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if (terminateOnDestroy) ws.terminate();
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
duplex._final = function (callback) {
|
|
119
|
+
if (ws.readyState === ws.CONNECTING) {
|
|
120
|
+
ws.once('open', function open() {
|
|
121
|
+
duplex._final(callback);
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// If the value of the `_socket` property is `null` it means that `ws` is a
|
|
127
|
+
// client websocket and the handshake failed. In fact, when this happens, a
|
|
128
|
+
// socket is never assigned to the websocket. Wait for the `'error'` event
|
|
129
|
+
// that will be emitted by the websocket.
|
|
130
|
+
if (ws._socket === null) return;
|
|
131
|
+
|
|
132
|
+
if (ws._socket._writableState.finished) {
|
|
133
|
+
callback();
|
|
134
|
+
if (duplex._readableState.endEmitted) duplex.destroy();
|
|
135
|
+
} else {
|
|
136
|
+
ws._socket.once('finish', function finish() {
|
|
137
|
+
// `duplex` is not destroyed here because the `'end'` event will be
|
|
138
|
+
// emitted on `duplex` after this `'finish'` event. The EOF signaling
|
|
139
|
+
// `null` chunk is, in fact, pushed when the websocket emits `'close'`.
|
|
140
|
+
callback();
|
|
141
|
+
});
|
|
142
|
+
ws.close();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
duplex._read = function () {
|
|
147
|
+
if (ws.isPaused) ws.resume();
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
duplex._write = function (chunk, encoding, callback) {
|
|
151
|
+
if (ws.readyState === ws.CONNECTING) {
|
|
152
|
+
ws.once('open', function open() {
|
|
153
|
+
duplex._write(chunk, encoding, callback);
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
ws.send(chunk, callback);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
duplex.on('end', duplexOnEnd);
|
|
162
|
+
duplex.on('error', duplexOnError);
|
|
163
|
+
return duplex;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
stream = createWebSocketStream;
|
|
167
|
+
return stream;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { requireStream as __require };
|