@wabot-dev/framework 0.0.14 → 0.0.17
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/ai/deepseek/DeepSeekChatBotAdapter.js +108 -0
- package/dist/src/channels/cmd/@cmd.js +1 -1
- package/dist/src/channels/cmd/CmdChannel.js +1 -1
- package/dist/src/channels/socket-io/@socket.js +24 -0
- package/dist/src/channels/socket-io/SocketChannel.js +78 -0
- package/dist/src/channels/socket-io/SocketChannelConfig.js +15 -0
- package/dist/src/channels/telegram/@telegram.js +1 -1
- package/dist/src/channels/telegram/TelegramChannel.js +1 -1
- package/dist/src/channels/whatsapp/@whatsapp.js +1 -1
- package/dist/src/channels/whatsapp/WhatsAppChannel.js +1 -1
- package/dist/src/channels/whatsapp/WhatsAppConnection.js +1 -1
- package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +11 -3
- package/dist/src/channels/whatsapp/{whatsAppDevSocketContracts.js → WhatsAppDevSocketContracts.js} +1 -0
- package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +4 -1
- package/dist/src/channels/whatsapp/WhatsAppSender.js +23 -0
- package/dist/src/controller/socket.io/SocketIO.js +1 -1
- package/dist/src/index.d.ts +82 -9
- package/dist/src/index.js +9 -1
- package/dist/src/logger/Logger.js +1 -1
- package/dist/src/mindset/MindsetOperator.js +1 -1
- package/dist/src/server/runChannel.js +1 -1
- package/dist/src/server/runServer.js +4 -4
- package/package.json +2 -1
- package/dist/src/_virtual/XMLHttpRequest.js +0 -7
- package/dist/src/_virtual/_commonjsHelpers.js +0 -32
- package/dist/src/_virtual/base64id.js +0 -3
- package/dist/src/_virtual/binary.js +0 -3
- package/dist/src/_virtual/bom-handling.js +0 -3
- package/dist/src/_virtual/broadcast-operator.js +0 -3
- package/dist/src/_virtual/browser.js +0 -3
- package/dist/src/_virtual/browser2.js +0 -3
- package/dist/src/_virtual/browser3.js +0 -3
- package/dist/src/_virtual/browser4.js +0 -3
- package/dist/src/_virtual/browser5.js +0 -3
- package/dist/src/_virtual/buffer-util.js +0 -3
- package/dist/src/_virtual/buffer-util2.js +0 -3
- package/dist/src/_virtual/buffer-util3.js +0 -3
- package/dist/src/_virtual/charset.js +0 -3
- package/dist/src/_virtual/charset2.js +0 -3
- package/dist/src/_virtual/client.js +0 -3
- package/dist/src/_virtual/cluster-adapter.js +0 -3
- package/dist/src/_virtual/commons.js +0 -3
- package/dist/src/_virtual/dbcs-codec.js +0 -3
- package/dist/src/_virtual/decodePacket.js +0 -3
- package/dist/src/_virtual/encodePacket.js +0 -3
- package/dist/src/_virtual/encoding.js +0 -3
- package/dist/src/_virtual/encoding2.js +0 -3
- package/dist/src/_virtual/engine.io.js +0 -3
- package/dist/src/_virtual/in-memory-adapter.js +0 -3
- package/dist/src/_virtual/index.js +0 -7
- package/dist/src/_virtual/index10.js +0 -3
- package/dist/src/_virtual/index11.js +0 -3
- package/dist/src/_virtual/index12.js +0 -3
- package/dist/src/_virtual/index13.js +0 -3
- package/dist/src/_virtual/index14.js +0 -3
- package/dist/src/_virtual/index15.js +0 -3
- package/dist/src/_virtual/index16.js +0 -3
- package/dist/src/_virtual/index17.js +0 -3
- package/dist/src/_virtual/index18.js +0 -3
- package/dist/src/_virtual/index19.js +0 -3
- package/dist/src/_virtual/index2.js +0 -7
- package/dist/src/_virtual/index20.js +0 -3
- package/dist/src/_virtual/index21.js +0 -3
- package/dist/src/_virtual/index22.js +0 -3
- package/dist/src/_virtual/index23.js +0 -3
- package/dist/src/_virtual/index24.js +0 -3
- package/dist/src/_virtual/index25.js +0 -3
- package/dist/src/_virtual/index26.js +0 -3
- package/dist/src/_virtual/index27.js +0 -3
- package/dist/src/_virtual/index28.js +0 -3
- package/dist/src/_virtual/index29.js +0 -3
- package/dist/src/_virtual/index3.js +0 -7
- package/dist/src/_virtual/index30.js +0 -3
- package/dist/src/_virtual/index31.js +0 -3
- package/dist/src/_virtual/index32.js +0 -3
- package/dist/src/_virtual/index33.js +0 -3
- package/dist/src/_virtual/index4.js +0 -3
- package/dist/src/_virtual/index5.js +0 -3
- package/dist/src/_virtual/index6.js +0 -3
- package/dist/src/_virtual/index7.js +0 -3
- package/dist/src/_virtual/index8.js +0 -6
- package/dist/src/_virtual/index9.js +0 -3
- package/dist/src/_virtual/inherits.js +0 -3
- package/dist/src/_virtual/inherits_browser.js +0 -3
- package/dist/src/_virtual/is-binary.js +0 -3
- package/dist/src/_virtual/language.js +0 -3
- package/dist/src/_virtual/language2.js +0 -3
- package/dist/src/_virtual/mediaType.js +0 -3
- package/dist/src/_virtual/mediaType2.js +0 -3
- package/dist/src/_virtual/namespace.js +0 -3
- package/dist/src/_virtual/node.js +0 -3
- package/dist/src/_virtual/node2.js +0 -3
- package/dist/src/_virtual/node3.js +0 -3
- package/dist/src/_virtual/node4.js +0 -3
- package/dist/src/_virtual/node5.js +0 -3
- package/dist/src/_virtual/parent-namespace.js +0 -3
- package/dist/src/_virtual/polling-jsonp.js +0 -3
- package/dist/src/_virtual/polling.js +0 -3
- package/dist/src/_virtual/polling2.js +0 -3
- package/dist/src/_virtual/receiver.js +0 -3
- package/dist/src/_virtual/sbcs-codec.js +0 -3
- package/dist/src/_virtual/sender.js +0 -3
- package/dist/src/_virtual/server.js +0 -3
- package/dist/src/_virtual/socket-types.js +0 -3
- package/dist/src/_virtual/socket.js +0 -3
- package/dist/src/_virtual/socket2.js +0 -3
- package/dist/src/_virtual/stream.js +0 -3
- package/dist/src/_virtual/transport.js +0 -3
- package/dist/src/_virtual/typed-events.js +0 -3
- package/dist/src/_virtual/userver.js +0 -3
- package/dist/src/_virtual/utf16.js +0 -3
- package/dist/src/_virtual/utf32.js +0 -3
- package/dist/src/_virtual/utf7.js +0 -3
- package/dist/src/_virtual/uws.js +0 -3
- package/dist/src/_virtual/validation.js +0 -3
- package/dist/src/_virtual/validation2.js +0 -3
- package/dist/src/_virtual/validation3.js +0 -3
- package/dist/src/_virtual/websocket-server.js +0 -3
- package/dist/src/_virtual/websocket.js +0 -7
- package/dist/src/_virtual/websocket2.js +0 -3
- package/dist/src/_virtual/websocket3.js +0 -3
- package/dist/src/_virtual/webtransport.js +0 -3
- package/dist/src/_virtual/yeast.js +0 -3
- package/dist/src/node_modules/@socket.io/component-emitter/lib/esm/index.js +0 -171
- package/dist/src/node_modules/base64id/lib/base64id.js +0 -117
- package/dist/src/node_modules/body-parser/index.js +0 -96
- package/dist/src/node_modules/body-parser/lib/read.js +0 -225
- package/dist/src/node_modules/body-parser/lib/types/json.js +0 -222
- package/dist/src/node_modules/body-parser/lib/types/raw.js +0 -90
- package/dist/src/node_modules/body-parser/lib/types/text.js +0 -95
- package/dist/src/node_modules/body-parser/lib/types/urlencoded.js +0 -194
- package/dist/src/node_modules/body-parser/lib/utils.js +0 -96
- package/dist/src/node_modules/bytes/index.js +0 -180
- package/dist/src/node_modules/call-bind-apply-helpers/actualApply.js +0 -24
- package/dist/src/node_modules/call-bind-apply-helpers/functionApply.js +0 -13
- package/dist/src/node_modules/call-bind-apply-helpers/functionCall.js +0 -13
- package/dist/src/node_modules/call-bind-apply-helpers/index.js +0 -29
- package/dist/src/node_modules/call-bind-apply-helpers/reflectApply.js +0 -13
- package/dist/src/node_modules/call-bound/index.js +0 -31
- package/dist/src/node_modules/content-type/index.js +0 -235
- package/dist/src/node_modules/cookie/index.js +0 -345
- package/dist/src/node_modules/cors/lib/index.js +0 -249
- package/dist/src/node_modules/debug/src/browser.js +0 -286
- package/dist/src/node_modules/debug/src/common.js +0 -303
- package/dist/src/node_modules/debug/src/index.js +0 -23
- package/dist/src/node_modules/debug/src/node.js +0 -279
- package/dist/src/node_modules/depd/index.js +0 -550
- package/dist/src/node_modules/dunder-proto/get.js +0 -42
- package/dist/src/node_modules/ee-first/index.js +0 -104
- package/dist/src/node_modules/engine.io/build/engine.io.js +0 -73
- package/dist/src/node_modules/engine.io/build/parser-v3/index.js +0 -429
- package/dist/src/node_modules/engine.io/build/parser-v3/utf8.js +0 -198
- package/dist/src/node_modules/engine.io/build/server.js +0 -808
- package/dist/src/node_modules/engine.io/build/socket.js +0 -469
- package/dist/src/node_modules/engine.io/build/transport.js +0 -131
- package/dist/src/node_modules/engine.io/build/transports/index.js +0 -37
- package/dist/src/node_modules/engine.io/build/transports/polling-jsonp.js +0 -53
- package/dist/src/node_modules/engine.io/build/transports/polling.js +0 -346
- package/dist/src/node_modules/engine.io/build/transports/websocket.js +0 -106
- package/dist/src/node_modules/engine.io/build/transports/webtransport.js +0 -76
- package/dist/src/node_modules/engine.io/build/transports-uws/index.js +0 -20
- package/dist/src/node_modules/engine.io/build/transports-uws/polling.js +0 -378
- package/dist/src/node_modules/engine.io/build/transports-uws/websocket.js +0 -85
- package/dist/src/node_modules/engine.io/build/userver.js +0 -292
- package/dist/src/node_modules/engine.io/node_modules/accepts/index.js +0 -250
- package/dist/src/node_modules/engine.io/node_modules/debug/src/browser.js +0 -285
- package/dist/src/node_modules/engine.io/node_modules/debug/src/common.js +0 -285
- package/dist/src/node_modules/engine.io/node_modules/debug/src/index.js +0 -23
- package/dist/src/node_modules/engine.io/node_modules/debug/src/node.js +0 -279
- package/dist/src/node_modules/engine.io/node_modules/mime-db/db.json.js +0 -10704
- package/dist/src/node_modules/engine.io/node_modules/mime-db/index.js +0 -24
- package/dist/src/node_modules/engine.io/node_modules/mime-types/index.js +0 -202
- package/dist/src/node_modules/engine.io/node_modules/negotiator/index.js +0 -96
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/charset.js +0 -179
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/encoding.js +0 -193
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/language.js +0 -188
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/mediaType.js +0 -304
- package/dist/src/node_modules/engine.io/node_modules/ws/index.js +0 -28
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/buffer-util.js +0 -142
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/constants.js +0 -21
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/event-target.js +0 -303
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/extension.js +0 -214
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/limiter.js +0 -64
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/permessage-deflate.js +0 -528
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/receiver.js +0 -719
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/sender.js +0 -513
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/stream.js +0 -170
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/subprotocol.js +0 -73
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/validation.js +0 -141
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket-server.js +0 -559
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket.js +0 -1363
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/has-cors.js +0 -13
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseqs.js +0 -36
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseuri.js +0 -66
- package/dist/src/node_modules/engine.io-client/build/esm/globals.node.js +0 -92
- package/dist/src/node_modules/engine.io-client/build/esm/index.js +0 -17
- package/dist/src/node_modules/engine.io-client/build/esm/socket.js +0 -728
- package/dist/src/node_modules/engine.io-client/build/esm/transport.js +0 -143
- package/dist/src/node_modules/engine.io-client/build/esm/transports/index.js +0 -11
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +0 -256
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +0 -21
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling.js +0 -146
- package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.js +0 -107
- package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.node.js +0 -48
- package/dist/src/node_modules/engine.io-client/build/esm/transports/webtransport.js +0 -83
- package/dist/src/node_modules/engine.io-client/build/esm/util.js +0 -62
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/buffer-util.js +0 -142
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/constants.js +0 -21
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/event-target.js +0 -303
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/extension.js +0 -214
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/limiter.js +0 -64
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/permessage-deflate.js +0 -528
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/receiver.js +0 -719
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/sender.js +0 -513
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/stream.js +0 -170
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/subprotocol.js +0 -73
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/validation.js +0 -141
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket-server.js +0 -559
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket.js +0 -1363
- package/dist/src/node_modules/engine.io-parser/build/cjs/commons.js +0 -29
- package/dist/src/node_modules/engine.io-parser/build/cjs/decodePacket.js +0 -70
- package/dist/src/node_modules/engine.io-parser/build/cjs/encodePacket.js +0 -51
- package/dist/src/node_modules/engine.io-parser/build/cjs/index.js +0 -179
- package/dist/src/node_modules/engine.io-parser/build/esm/commons.js +0 -15
- package/dist/src/node_modules/engine.io-parser/build/esm/decodePacket.js +0 -58
- package/dist/src/node_modules/engine.io-parser/build/esm/encodePacket.js +0 -36
- package/dist/src/node_modules/engine.io-parser/build/esm/index.js +0 -158
- package/dist/src/node_modules/es-define-property/index.js +0 -23
- package/dist/src/node_modules/es-errors/eval.js +0 -13
- package/dist/src/node_modules/es-errors/index.js +0 -13
- package/dist/src/node_modules/es-errors/range.js +0 -13
- package/dist/src/node_modules/es-errors/ref.js +0 -13
- package/dist/src/node_modules/es-errors/syntax.js +0 -13
- package/dist/src/node_modules/es-errors/type.js +0 -13
- package/dist/src/node_modules/es-errors/uri.js +0 -13
- package/dist/src/node_modules/es-object-atoms/index.js +0 -13
- package/dist/src/node_modules/function-bind/implementation.js +0 -93
- package/dist/src/node_modules/function-bind/index.js +0 -16
- package/dist/src/node_modules/get-intrinsic/index.js +0 -413
- package/dist/src/node_modules/get-proto/Object.getPrototypeOf.js +0 -17
- package/dist/src/node_modules/get-proto/Reflect.getPrototypeOf.js +0 -13
- package/dist/src/node_modules/get-proto/index.js +0 -40
- package/dist/src/node_modules/gopd/gOPD.js +0 -13
- package/dist/src/node_modules/gopd/index.js +0 -26
- package/dist/src/node_modules/has-symbols/index.js +0 -25
- package/dist/src/node_modules/has-symbols/shams.js +0 -54
- package/dist/src/node_modules/hasown/index.js +0 -19
- package/dist/src/node_modules/http-errors/index.js +0 -306
- package/dist/src/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -598
- package/dist/src/node_modules/iconv-lite/encodings/dbcs-data.js +0 -206
- package/dist/src/node_modules/iconv-lite/encodings/index.js +0 -44
- package/dist/src/node_modules/iconv-lite/encodings/internal.js +0 -210
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -83
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -460
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-data.js +0 -187
- package/dist/src/node_modules/iconv-lite/encodings/tables/big5-added.json.js +0 -506
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp936.json.js +0 -2621
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp949.json.js +0 -2380
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp950.json.js +0 -729
- package/dist/src/node_modules/iconv-lite/encodings/tables/eucjp.json.js +0 -822
- package/dist/src/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json.js +0 -424
- package/dist/src/node_modules/iconv-lite/encodings/tables/gbk-added.json.js +0 -264
- package/dist/src/node_modules/iconv-lite/encodings/tables/shiftjis.json.js +0 -548
- package/dist/src/node_modules/iconv-lite/encodings/utf16.js +0 -206
- package/dist/src/node_modules/iconv-lite/encodings/utf32.js +0 -329
- package/dist/src/node_modules/iconv-lite/encodings/utf7.js +0 -297
- package/dist/src/node_modules/iconv-lite/lib/bom-handling.js +0 -61
- package/dist/src/node_modules/iconv-lite/lib/index.js +0 -192
- package/dist/src/node_modules/iconv-lite/lib/streams.js +0 -120
- package/dist/src/node_modules/inherits/inherits.js +0 -21
- package/dist/src/node_modules/inherits/inherits_browser.js +0 -38
- package/dist/src/node_modules/math-intrinsics/abs.js +0 -13
- package/dist/src/node_modules/math-intrinsics/floor.js +0 -13
- package/dist/src/node_modules/math-intrinsics/isNaN.js +0 -15
- package/dist/src/node_modules/math-intrinsics/max.js +0 -13
- package/dist/src/node_modules/math-intrinsics/min.js +0 -13
- package/dist/src/node_modules/math-intrinsics/pow.js +0 -13
- package/dist/src/node_modules/math-intrinsics/round.js +0 -13
- package/dist/src/node_modules/math-intrinsics/sign.js +0 -22
- package/dist/src/node_modules/media-typer/index.js +0 -153
- package/dist/src/node_modules/mime-db/db.json.js +0 -11656
- package/dist/src/node_modules/mime-db/index.js +0 -24
- package/dist/src/node_modules/mime-types/index.js +0 -226
- package/dist/src/node_modules/mime-types/mimeScore.js +0 -62
- package/dist/src/node_modules/ms/index.js +0 -172
- package/dist/src/node_modules/object-assign/index.js +0 -99
- package/dist/src/node_modules/object-inspect/index.js +0 -557
- package/dist/src/node_modules/object-inspect/util.inspect.js +0 -13
- package/dist/src/node_modules/on-finished/index.js +0 -245
- package/dist/src/node_modules/qs/lib/formats.js +0 -32
- package/dist/src/node_modules/qs/lib/index.js +0 -24
- package/dist/src/node_modules/qs/lib/parse.js +0 -339
- package/dist/src/node_modules/qs/lib/stringify.js +0 -369
- package/dist/src/node_modules/qs/lib/utils.js +0 -279
- package/dist/src/node_modules/raw-body/index.js +0 -351
- package/dist/src/node_modules/safer-buffer/safer.js +0 -88
- package/dist/src/node_modules/setprototypeof/index.js +0 -26
- package/dist/src/node_modules/side-channel/index.js +0 -58
- package/dist/src/node_modules/side-channel-list/index.js +0 -125
- package/dist/src/node_modules/side-channel-map/index.js +0 -82
- package/dist/src/node_modules/side-channel-weakmap/index.js +0 -99
- package/dist/src/node_modules/socket.io/dist/broadcast-operator.js +0 -448
- package/dist/src/node_modules/socket.io/dist/client.js +0 -281
- package/dist/src/node_modules/socket.io/dist/index.js +0 -837
- package/dist/src/node_modules/socket.io/dist/namespace.js +0 -597
- package/dist/src/node_modules/socket.io/dist/parent-namespace.js +0 -101
- package/dist/src/node_modules/socket.io/dist/socket-types.js +0 -21
- package/dist/src/node_modules/socket.io/dist/socket.js +0 -993
- package/dist/src/node_modules/socket.io/dist/typed-events.js +0 -92
- package/dist/src/node_modules/socket.io/dist/uws.js +0 -149
- package/dist/src/node_modules/socket.io/node_modules/accepts/index.js +0 -250
- package/dist/src/node_modules/socket.io/node_modules/debug/src/browser.js +0 -285
- package/dist/src/node_modules/socket.io/node_modules/debug/src/common.js +0 -285
- package/dist/src/node_modules/socket.io/node_modules/debug/src/index.js +0 -23
- package/dist/src/node_modules/socket.io/node_modules/debug/src/node.js +0 -279
- package/dist/src/node_modules/socket.io/node_modules/mime-db/db.json.js +0 -10704
- package/dist/src/node_modules/socket.io/node_modules/mime-db/index.js +0 -24
- package/dist/src/node_modules/socket.io/node_modules/mime-types/index.js +0 -202
- package/dist/src/node_modules/socket.io/node_modules/negotiator/index.js +0 -96
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/charset.js +0 -179
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/encoding.js +0 -193
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/language.js +0 -188
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/mediaType.js +0 -304
- package/dist/src/node_modules/socket.io/package.json.js +0 -5
- package/dist/src/node_modules/socket.io/wrapper.js +0 -5
- package/dist/src/node_modules/socket.io-adapter/dist/cluster-adapter.js +0 -689
- package/dist/src/node_modules/socket.io-adapter/dist/contrib/yeast.js +0 -64
- package/dist/src/node_modules/socket.io-adapter/dist/in-memory-adapter.js +0 -407
- package/dist/src/node_modules/socket.io-adapter/dist/index.js +0 -24
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/browser.js +0 -285
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/common.js +0 -285
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/index.js +0 -23
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/node.js +0 -279
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/index.js +0 -28
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/buffer-util.js +0 -142
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/constants.js +0 -21
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/event-target.js +0 -303
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/extension.js +0 -214
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/limiter.js +0 -64
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/permessage-deflate.js +0 -528
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/receiver.js +0 -719
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/sender.js +0 -513
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/stream.js +0 -170
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/subprotocol.js +0 -73
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/validation.js +0 -141
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket-server.js +0 -559
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket.js +0 -1363
- package/dist/src/node_modules/socket.io-client/build/esm/contrib/backo2.js +0 -68
- package/dist/src/node_modules/socket.io-client/build/esm/index.js +0 -50
- package/dist/src/node_modules/socket.io-client/build/esm/manager.js +0 -373
- package/dist/src/node_modules/socket.io-client/build/esm/on.js +0 -8
- package/dist/src/node_modules/socket.io-client/build/esm/socket.js +0 -884
- package/dist/src/node_modules/socket.io-client/build/esm/url.js +0 -63
- package/dist/src/node_modules/socket.io-parser/build/cjs/binary.js +0 -99
- package/dist/src/node_modules/socket.io-parser/build/cjs/index.js +0 -337
- package/dist/src/node_modules/socket.io-parser/build/cjs/is-binary.js +0 -65
- package/dist/src/node_modules/socket.io-parser/build/esm/binary.js +0 -86
- package/dist/src/node_modules/socket.io-parser/build/esm/index.js +0 -314
- package/dist/src/node_modules/socket.io-parser/build/esm/is-binary.js +0 -52
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/browser.js +0 -285
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/common.js +0 -285
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/index.js +0 -23
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/node.js +0 -279
- package/dist/src/node_modules/statuses/codes.json.js +0 -67
- package/dist/src/node_modules/statuses/index.js +0 -157
- package/dist/src/node_modules/toidentifier/index.js +0 -41
- package/dist/src/node_modules/type-is/index.js +0 -263
- package/dist/src/node_modules/unpipe/index.js +0 -78
- package/dist/src/node_modules/vary/index.js +0 -159
- package/dist/src/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +0 -702
|
@@ -1,513 +0,0 @@
|
|
|
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 };
|
|
@@ -1,170 +0,0 @@
|
|
|
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 };
|