@wabot-dev/framework 0.0.14 → 0.0.16

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.
Files changed (361) hide show
  1. package/dist/src/channels/cmd/@cmd.js +1 -1
  2. package/dist/src/channels/cmd/CmdChannel.js +1 -1
  3. package/dist/src/channels/telegram/@telegram.js +1 -1
  4. package/dist/src/channels/telegram/TelegramChannel.js +1 -1
  5. package/dist/src/channels/whatsapp/@whatsapp.js +1 -1
  6. package/dist/src/channels/whatsapp/WhatsAppChannel.js +1 -1
  7. package/dist/src/channels/whatsapp/WhatsAppConnection.js +1 -1
  8. package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +2 -2
  9. package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +1 -1
  10. package/dist/src/controller/socket.io/SocketIO.js +1 -1
  11. package/dist/src/logger/Logger.js +1 -1
  12. package/dist/src/server/runChannel.js +1 -1
  13. package/dist/src/server/runServer.js +4 -4
  14. package/package.json +2 -1
  15. package/dist/src/_virtual/XMLHttpRequest.js +0 -7
  16. package/dist/src/_virtual/_commonjsHelpers.js +0 -32
  17. package/dist/src/_virtual/base64id.js +0 -3
  18. package/dist/src/_virtual/binary.js +0 -3
  19. package/dist/src/_virtual/bom-handling.js +0 -3
  20. package/dist/src/_virtual/broadcast-operator.js +0 -3
  21. package/dist/src/_virtual/browser.js +0 -3
  22. package/dist/src/_virtual/browser2.js +0 -3
  23. package/dist/src/_virtual/browser3.js +0 -3
  24. package/dist/src/_virtual/browser4.js +0 -3
  25. package/dist/src/_virtual/browser5.js +0 -3
  26. package/dist/src/_virtual/buffer-util.js +0 -3
  27. package/dist/src/_virtual/buffer-util2.js +0 -3
  28. package/dist/src/_virtual/buffer-util3.js +0 -3
  29. package/dist/src/_virtual/charset.js +0 -3
  30. package/dist/src/_virtual/charset2.js +0 -3
  31. package/dist/src/_virtual/client.js +0 -3
  32. package/dist/src/_virtual/cluster-adapter.js +0 -3
  33. package/dist/src/_virtual/commons.js +0 -3
  34. package/dist/src/_virtual/dbcs-codec.js +0 -3
  35. package/dist/src/_virtual/decodePacket.js +0 -3
  36. package/dist/src/_virtual/encodePacket.js +0 -3
  37. package/dist/src/_virtual/encoding.js +0 -3
  38. package/dist/src/_virtual/encoding2.js +0 -3
  39. package/dist/src/_virtual/engine.io.js +0 -3
  40. package/dist/src/_virtual/in-memory-adapter.js +0 -3
  41. package/dist/src/_virtual/index.js +0 -7
  42. package/dist/src/_virtual/index10.js +0 -3
  43. package/dist/src/_virtual/index11.js +0 -3
  44. package/dist/src/_virtual/index12.js +0 -3
  45. package/dist/src/_virtual/index13.js +0 -3
  46. package/dist/src/_virtual/index14.js +0 -3
  47. package/dist/src/_virtual/index15.js +0 -3
  48. package/dist/src/_virtual/index16.js +0 -3
  49. package/dist/src/_virtual/index17.js +0 -3
  50. package/dist/src/_virtual/index18.js +0 -3
  51. package/dist/src/_virtual/index19.js +0 -3
  52. package/dist/src/_virtual/index2.js +0 -7
  53. package/dist/src/_virtual/index20.js +0 -3
  54. package/dist/src/_virtual/index21.js +0 -3
  55. package/dist/src/_virtual/index22.js +0 -3
  56. package/dist/src/_virtual/index23.js +0 -3
  57. package/dist/src/_virtual/index24.js +0 -3
  58. package/dist/src/_virtual/index25.js +0 -3
  59. package/dist/src/_virtual/index26.js +0 -3
  60. package/dist/src/_virtual/index27.js +0 -3
  61. package/dist/src/_virtual/index28.js +0 -3
  62. package/dist/src/_virtual/index29.js +0 -3
  63. package/dist/src/_virtual/index3.js +0 -7
  64. package/dist/src/_virtual/index30.js +0 -3
  65. package/dist/src/_virtual/index31.js +0 -3
  66. package/dist/src/_virtual/index32.js +0 -3
  67. package/dist/src/_virtual/index33.js +0 -3
  68. package/dist/src/_virtual/index4.js +0 -3
  69. package/dist/src/_virtual/index5.js +0 -3
  70. package/dist/src/_virtual/index6.js +0 -3
  71. package/dist/src/_virtual/index7.js +0 -3
  72. package/dist/src/_virtual/index8.js +0 -6
  73. package/dist/src/_virtual/index9.js +0 -3
  74. package/dist/src/_virtual/inherits.js +0 -3
  75. package/dist/src/_virtual/inherits_browser.js +0 -3
  76. package/dist/src/_virtual/is-binary.js +0 -3
  77. package/dist/src/_virtual/language.js +0 -3
  78. package/dist/src/_virtual/language2.js +0 -3
  79. package/dist/src/_virtual/mediaType.js +0 -3
  80. package/dist/src/_virtual/mediaType2.js +0 -3
  81. package/dist/src/_virtual/namespace.js +0 -3
  82. package/dist/src/_virtual/node.js +0 -3
  83. package/dist/src/_virtual/node2.js +0 -3
  84. package/dist/src/_virtual/node3.js +0 -3
  85. package/dist/src/_virtual/node4.js +0 -3
  86. package/dist/src/_virtual/node5.js +0 -3
  87. package/dist/src/_virtual/parent-namespace.js +0 -3
  88. package/dist/src/_virtual/polling-jsonp.js +0 -3
  89. package/dist/src/_virtual/polling.js +0 -3
  90. package/dist/src/_virtual/polling2.js +0 -3
  91. package/dist/src/_virtual/receiver.js +0 -3
  92. package/dist/src/_virtual/sbcs-codec.js +0 -3
  93. package/dist/src/_virtual/sender.js +0 -3
  94. package/dist/src/_virtual/server.js +0 -3
  95. package/dist/src/_virtual/socket-types.js +0 -3
  96. package/dist/src/_virtual/socket.js +0 -3
  97. package/dist/src/_virtual/socket2.js +0 -3
  98. package/dist/src/_virtual/stream.js +0 -3
  99. package/dist/src/_virtual/transport.js +0 -3
  100. package/dist/src/_virtual/typed-events.js +0 -3
  101. package/dist/src/_virtual/userver.js +0 -3
  102. package/dist/src/_virtual/utf16.js +0 -3
  103. package/dist/src/_virtual/utf32.js +0 -3
  104. package/dist/src/_virtual/utf7.js +0 -3
  105. package/dist/src/_virtual/uws.js +0 -3
  106. package/dist/src/_virtual/validation.js +0 -3
  107. package/dist/src/_virtual/validation2.js +0 -3
  108. package/dist/src/_virtual/validation3.js +0 -3
  109. package/dist/src/_virtual/websocket-server.js +0 -3
  110. package/dist/src/_virtual/websocket.js +0 -7
  111. package/dist/src/_virtual/websocket2.js +0 -3
  112. package/dist/src/_virtual/websocket3.js +0 -3
  113. package/dist/src/_virtual/webtransport.js +0 -3
  114. package/dist/src/_virtual/yeast.js +0 -3
  115. package/dist/src/node_modules/@socket.io/component-emitter/lib/esm/index.js +0 -171
  116. package/dist/src/node_modules/base64id/lib/base64id.js +0 -117
  117. package/dist/src/node_modules/body-parser/index.js +0 -96
  118. package/dist/src/node_modules/body-parser/lib/read.js +0 -225
  119. package/dist/src/node_modules/body-parser/lib/types/json.js +0 -222
  120. package/dist/src/node_modules/body-parser/lib/types/raw.js +0 -90
  121. package/dist/src/node_modules/body-parser/lib/types/text.js +0 -95
  122. package/dist/src/node_modules/body-parser/lib/types/urlencoded.js +0 -194
  123. package/dist/src/node_modules/body-parser/lib/utils.js +0 -96
  124. package/dist/src/node_modules/bytes/index.js +0 -180
  125. package/dist/src/node_modules/call-bind-apply-helpers/actualApply.js +0 -24
  126. package/dist/src/node_modules/call-bind-apply-helpers/functionApply.js +0 -13
  127. package/dist/src/node_modules/call-bind-apply-helpers/functionCall.js +0 -13
  128. package/dist/src/node_modules/call-bind-apply-helpers/index.js +0 -29
  129. package/dist/src/node_modules/call-bind-apply-helpers/reflectApply.js +0 -13
  130. package/dist/src/node_modules/call-bound/index.js +0 -31
  131. package/dist/src/node_modules/content-type/index.js +0 -235
  132. package/dist/src/node_modules/cookie/index.js +0 -345
  133. package/dist/src/node_modules/cors/lib/index.js +0 -249
  134. package/dist/src/node_modules/debug/src/browser.js +0 -286
  135. package/dist/src/node_modules/debug/src/common.js +0 -303
  136. package/dist/src/node_modules/debug/src/index.js +0 -23
  137. package/dist/src/node_modules/debug/src/node.js +0 -279
  138. package/dist/src/node_modules/depd/index.js +0 -550
  139. package/dist/src/node_modules/dunder-proto/get.js +0 -42
  140. package/dist/src/node_modules/ee-first/index.js +0 -104
  141. package/dist/src/node_modules/engine.io/build/engine.io.js +0 -73
  142. package/dist/src/node_modules/engine.io/build/parser-v3/index.js +0 -429
  143. package/dist/src/node_modules/engine.io/build/parser-v3/utf8.js +0 -198
  144. package/dist/src/node_modules/engine.io/build/server.js +0 -808
  145. package/dist/src/node_modules/engine.io/build/socket.js +0 -469
  146. package/dist/src/node_modules/engine.io/build/transport.js +0 -131
  147. package/dist/src/node_modules/engine.io/build/transports/index.js +0 -37
  148. package/dist/src/node_modules/engine.io/build/transports/polling-jsonp.js +0 -53
  149. package/dist/src/node_modules/engine.io/build/transports/polling.js +0 -346
  150. package/dist/src/node_modules/engine.io/build/transports/websocket.js +0 -106
  151. package/dist/src/node_modules/engine.io/build/transports/webtransport.js +0 -76
  152. package/dist/src/node_modules/engine.io/build/transports-uws/index.js +0 -20
  153. package/dist/src/node_modules/engine.io/build/transports-uws/polling.js +0 -378
  154. package/dist/src/node_modules/engine.io/build/transports-uws/websocket.js +0 -85
  155. package/dist/src/node_modules/engine.io/build/userver.js +0 -292
  156. package/dist/src/node_modules/engine.io/node_modules/accepts/index.js +0 -250
  157. package/dist/src/node_modules/engine.io/node_modules/debug/src/browser.js +0 -285
  158. package/dist/src/node_modules/engine.io/node_modules/debug/src/common.js +0 -285
  159. package/dist/src/node_modules/engine.io/node_modules/debug/src/index.js +0 -23
  160. package/dist/src/node_modules/engine.io/node_modules/debug/src/node.js +0 -279
  161. package/dist/src/node_modules/engine.io/node_modules/mime-db/db.json.js +0 -10704
  162. package/dist/src/node_modules/engine.io/node_modules/mime-db/index.js +0 -24
  163. package/dist/src/node_modules/engine.io/node_modules/mime-types/index.js +0 -202
  164. package/dist/src/node_modules/engine.io/node_modules/negotiator/index.js +0 -96
  165. package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/charset.js +0 -179
  166. package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/encoding.js +0 -193
  167. package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/language.js +0 -188
  168. package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/mediaType.js +0 -304
  169. package/dist/src/node_modules/engine.io/node_modules/ws/index.js +0 -28
  170. package/dist/src/node_modules/engine.io/node_modules/ws/lib/buffer-util.js +0 -142
  171. package/dist/src/node_modules/engine.io/node_modules/ws/lib/constants.js +0 -21
  172. package/dist/src/node_modules/engine.io/node_modules/ws/lib/event-target.js +0 -303
  173. package/dist/src/node_modules/engine.io/node_modules/ws/lib/extension.js +0 -214
  174. package/dist/src/node_modules/engine.io/node_modules/ws/lib/limiter.js +0 -64
  175. package/dist/src/node_modules/engine.io/node_modules/ws/lib/permessage-deflate.js +0 -528
  176. package/dist/src/node_modules/engine.io/node_modules/ws/lib/receiver.js +0 -719
  177. package/dist/src/node_modules/engine.io/node_modules/ws/lib/sender.js +0 -513
  178. package/dist/src/node_modules/engine.io/node_modules/ws/lib/stream.js +0 -170
  179. package/dist/src/node_modules/engine.io/node_modules/ws/lib/subprotocol.js +0 -73
  180. package/dist/src/node_modules/engine.io/node_modules/ws/lib/validation.js +0 -141
  181. package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket-server.js +0 -559
  182. package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket.js +0 -1363
  183. package/dist/src/node_modules/engine.io-client/build/esm/contrib/has-cors.js +0 -13
  184. package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseqs.js +0 -36
  185. package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseuri.js +0 -66
  186. package/dist/src/node_modules/engine.io-client/build/esm/globals.node.js +0 -92
  187. package/dist/src/node_modules/engine.io-client/build/esm/index.js +0 -17
  188. package/dist/src/node_modules/engine.io-client/build/esm/socket.js +0 -728
  189. package/dist/src/node_modules/engine.io-client/build/esm/transport.js +0 -143
  190. package/dist/src/node_modules/engine.io-client/build/esm/transports/index.js +0 -11
  191. package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +0 -256
  192. package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +0 -21
  193. package/dist/src/node_modules/engine.io-client/build/esm/transports/polling.js +0 -146
  194. package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.js +0 -107
  195. package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.node.js +0 -48
  196. package/dist/src/node_modules/engine.io-client/build/esm/transports/webtransport.js +0 -83
  197. package/dist/src/node_modules/engine.io-client/build/esm/util.js +0 -62
  198. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/buffer-util.js +0 -142
  199. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/constants.js +0 -21
  200. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/event-target.js +0 -303
  201. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/extension.js +0 -214
  202. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/limiter.js +0 -64
  203. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/permessage-deflate.js +0 -528
  204. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/receiver.js +0 -719
  205. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/sender.js +0 -513
  206. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/stream.js +0 -170
  207. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/subprotocol.js +0 -73
  208. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/validation.js +0 -141
  209. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket-server.js +0 -559
  210. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket.js +0 -1363
  211. package/dist/src/node_modules/engine.io-parser/build/cjs/commons.js +0 -29
  212. package/dist/src/node_modules/engine.io-parser/build/cjs/decodePacket.js +0 -70
  213. package/dist/src/node_modules/engine.io-parser/build/cjs/encodePacket.js +0 -51
  214. package/dist/src/node_modules/engine.io-parser/build/cjs/index.js +0 -179
  215. package/dist/src/node_modules/engine.io-parser/build/esm/commons.js +0 -15
  216. package/dist/src/node_modules/engine.io-parser/build/esm/decodePacket.js +0 -58
  217. package/dist/src/node_modules/engine.io-parser/build/esm/encodePacket.js +0 -36
  218. package/dist/src/node_modules/engine.io-parser/build/esm/index.js +0 -158
  219. package/dist/src/node_modules/es-define-property/index.js +0 -23
  220. package/dist/src/node_modules/es-errors/eval.js +0 -13
  221. package/dist/src/node_modules/es-errors/index.js +0 -13
  222. package/dist/src/node_modules/es-errors/range.js +0 -13
  223. package/dist/src/node_modules/es-errors/ref.js +0 -13
  224. package/dist/src/node_modules/es-errors/syntax.js +0 -13
  225. package/dist/src/node_modules/es-errors/type.js +0 -13
  226. package/dist/src/node_modules/es-errors/uri.js +0 -13
  227. package/dist/src/node_modules/es-object-atoms/index.js +0 -13
  228. package/dist/src/node_modules/function-bind/implementation.js +0 -93
  229. package/dist/src/node_modules/function-bind/index.js +0 -16
  230. package/dist/src/node_modules/get-intrinsic/index.js +0 -413
  231. package/dist/src/node_modules/get-proto/Object.getPrototypeOf.js +0 -17
  232. package/dist/src/node_modules/get-proto/Reflect.getPrototypeOf.js +0 -13
  233. package/dist/src/node_modules/get-proto/index.js +0 -40
  234. package/dist/src/node_modules/gopd/gOPD.js +0 -13
  235. package/dist/src/node_modules/gopd/index.js +0 -26
  236. package/dist/src/node_modules/has-symbols/index.js +0 -25
  237. package/dist/src/node_modules/has-symbols/shams.js +0 -54
  238. package/dist/src/node_modules/hasown/index.js +0 -19
  239. package/dist/src/node_modules/http-errors/index.js +0 -306
  240. package/dist/src/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -598
  241. package/dist/src/node_modules/iconv-lite/encodings/dbcs-data.js +0 -206
  242. package/dist/src/node_modules/iconv-lite/encodings/index.js +0 -44
  243. package/dist/src/node_modules/iconv-lite/encodings/internal.js +0 -210
  244. package/dist/src/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -83
  245. package/dist/src/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -460
  246. package/dist/src/node_modules/iconv-lite/encodings/sbcs-data.js +0 -187
  247. package/dist/src/node_modules/iconv-lite/encodings/tables/big5-added.json.js +0 -506
  248. package/dist/src/node_modules/iconv-lite/encodings/tables/cp936.json.js +0 -2621
  249. package/dist/src/node_modules/iconv-lite/encodings/tables/cp949.json.js +0 -2380
  250. package/dist/src/node_modules/iconv-lite/encodings/tables/cp950.json.js +0 -729
  251. package/dist/src/node_modules/iconv-lite/encodings/tables/eucjp.json.js +0 -822
  252. package/dist/src/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json.js +0 -424
  253. package/dist/src/node_modules/iconv-lite/encodings/tables/gbk-added.json.js +0 -264
  254. package/dist/src/node_modules/iconv-lite/encodings/tables/shiftjis.json.js +0 -548
  255. package/dist/src/node_modules/iconv-lite/encodings/utf16.js +0 -206
  256. package/dist/src/node_modules/iconv-lite/encodings/utf32.js +0 -329
  257. package/dist/src/node_modules/iconv-lite/encodings/utf7.js +0 -297
  258. package/dist/src/node_modules/iconv-lite/lib/bom-handling.js +0 -61
  259. package/dist/src/node_modules/iconv-lite/lib/index.js +0 -192
  260. package/dist/src/node_modules/iconv-lite/lib/streams.js +0 -120
  261. package/dist/src/node_modules/inherits/inherits.js +0 -21
  262. package/dist/src/node_modules/inherits/inherits_browser.js +0 -38
  263. package/dist/src/node_modules/math-intrinsics/abs.js +0 -13
  264. package/dist/src/node_modules/math-intrinsics/floor.js +0 -13
  265. package/dist/src/node_modules/math-intrinsics/isNaN.js +0 -15
  266. package/dist/src/node_modules/math-intrinsics/max.js +0 -13
  267. package/dist/src/node_modules/math-intrinsics/min.js +0 -13
  268. package/dist/src/node_modules/math-intrinsics/pow.js +0 -13
  269. package/dist/src/node_modules/math-intrinsics/round.js +0 -13
  270. package/dist/src/node_modules/math-intrinsics/sign.js +0 -22
  271. package/dist/src/node_modules/media-typer/index.js +0 -153
  272. package/dist/src/node_modules/mime-db/db.json.js +0 -11656
  273. package/dist/src/node_modules/mime-db/index.js +0 -24
  274. package/dist/src/node_modules/mime-types/index.js +0 -226
  275. package/dist/src/node_modules/mime-types/mimeScore.js +0 -62
  276. package/dist/src/node_modules/ms/index.js +0 -172
  277. package/dist/src/node_modules/object-assign/index.js +0 -99
  278. package/dist/src/node_modules/object-inspect/index.js +0 -557
  279. package/dist/src/node_modules/object-inspect/util.inspect.js +0 -13
  280. package/dist/src/node_modules/on-finished/index.js +0 -245
  281. package/dist/src/node_modules/qs/lib/formats.js +0 -32
  282. package/dist/src/node_modules/qs/lib/index.js +0 -24
  283. package/dist/src/node_modules/qs/lib/parse.js +0 -339
  284. package/dist/src/node_modules/qs/lib/stringify.js +0 -369
  285. package/dist/src/node_modules/qs/lib/utils.js +0 -279
  286. package/dist/src/node_modules/raw-body/index.js +0 -351
  287. package/dist/src/node_modules/safer-buffer/safer.js +0 -88
  288. package/dist/src/node_modules/setprototypeof/index.js +0 -26
  289. package/dist/src/node_modules/side-channel/index.js +0 -58
  290. package/dist/src/node_modules/side-channel-list/index.js +0 -125
  291. package/dist/src/node_modules/side-channel-map/index.js +0 -82
  292. package/dist/src/node_modules/side-channel-weakmap/index.js +0 -99
  293. package/dist/src/node_modules/socket.io/dist/broadcast-operator.js +0 -448
  294. package/dist/src/node_modules/socket.io/dist/client.js +0 -281
  295. package/dist/src/node_modules/socket.io/dist/index.js +0 -837
  296. package/dist/src/node_modules/socket.io/dist/namespace.js +0 -597
  297. package/dist/src/node_modules/socket.io/dist/parent-namespace.js +0 -101
  298. package/dist/src/node_modules/socket.io/dist/socket-types.js +0 -21
  299. package/dist/src/node_modules/socket.io/dist/socket.js +0 -993
  300. package/dist/src/node_modules/socket.io/dist/typed-events.js +0 -92
  301. package/dist/src/node_modules/socket.io/dist/uws.js +0 -149
  302. package/dist/src/node_modules/socket.io/node_modules/accepts/index.js +0 -250
  303. package/dist/src/node_modules/socket.io/node_modules/debug/src/browser.js +0 -285
  304. package/dist/src/node_modules/socket.io/node_modules/debug/src/common.js +0 -285
  305. package/dist/src/node_modules/socket.io/node_modules/debug/src/index.js +0 -23
  306. package/dist/src/node_modules/socket.io/node_modules/debug/src/node.js +0 -279
  307. package/dist/src/node_modules/socket.io/node_modules/mime-db/db.json.js +0 -10704
  308. package/dist/src/node_modules/socket.io/node_modules/mime-db/index.js +0 -24
  309. package/dist/src/node_modules/socket.io/node_modules/mime-types/index.js +0 -202
  310. package/dist/src/node_modules/socket.io/node_modules/negotiator/index.js +0 -96
  311. package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/charset.js +0 -179
  312. package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/encoding.js +0 -193
  313. package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/language.js +0 -188
  314. package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/mediaType.js +0 -304
  315. package/dist/src/node_modules/socket.io/package.json.js +0 -5
  316. package/dist/src/node_modules/socket.io/wrapper.js +0 -5
  317. package/dist/src/node_modules/socket.io-adapter/dist/cluster-adapter.js +0 -689
  318. package/dist/src/node_modules/socket.io-adapter/dist/contrib/yeast.js +0 -64
  319. package/dist/src/node_modules/socket.io-adapter/dist/in-memory-adapter.js +0 -407
  320. package/dist/src/node_modules/socket.io-adapter/dist/index.js +0 -24
  321. package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/browser.js +0 -285
  322. package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/common.js +0 -285
  323. package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/index.js +0 -23
  324. package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/node.js +0 -279
  325. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/index.js +0 -28
  326. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/buffer-util.js +0 -142
  327. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/constants.js +0 -21
  328. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/event-target.js +0 -303
  329. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/extension.js +0 -214
  330. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/limiter.js +0 -64
  331. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/permessage-deflate.js +0 -528
  332. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/receiver.js +0 -719
  333. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/sender.js +0 -513
  334. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/stream.js +0 -170
  335. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/subprotocol.js +0 -73
  336. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/validation.js +0 -141
  337. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket-server.js +0 -559
  338. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket.js +0 -1363
  339. package/dist/src/node_modules/socket.io-client/build/esm/contrib/backo2.js +0 -68
  340. package/dist/src/node_modules/socket.io-client/build/esm/index.js +0 -50
  341. package/dist/src/node_modules/socket.io-client/build/esm/manager.js +0 -373
  342. package/dist/src/node_modules/socket.io-client/build/esm/on.js +0 -8
  343. package/dist/src/node_modules/socket.io-client/build/esm/socket.js +0 -884
  344. package/dist/src/node_modules/socket.io-client/build/esm/url.js +0 -63
  345. package/dist/src/node_modules/socket.io-parser/build/cjs/binary.js +0 -99
  346. package/dist/src/node_modules/socket.io-parser/build/cjs/index.js +0 -337
  347. package/dist/src/node_modules/socket.io-parser/build/cjs/is-binary.js +0 -65
  348. package/dist/src/node_modules/socket.io-parser/build/esm/binary.js +0 -86
  349. package/dist/src/node_modules/socket.io-parser/build/esm/index.js +0 -314
  350. package/dist/src/node_modules/socket.io-parser/build/esm/is-binary.js +0 -52
  351. package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/browser.js +0 -285
  352. package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/common.js +0 -285
  353. package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/index.js +0 -23
  354. package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/node.js +0 -279
  355. package/dist/src/node_modules/statuses/codes.json.js +0 -67
  356. package/dist/src/node_modules/statuses/index.js +0 -157
  357. package/dist/src/node_modules/toidentifier/index.js +0 -41
  358. package/dist/src/node_modules/type-is/index.js +0 -263
  359. package/dist/src/node_modules/unpipe/index.js +0 -78
  360. package/dist/src/node_modules/vary/index.js +0 -159
  361. package/dist/src/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +0 -702
@@ -1,808 +0,0 @@
1
- import { __exports as server } from '../../../_virtual/server.js';
2
- import require$$1 from 'querystring';
3
- import require$$7 from 'url';
4
- import { __require as requireBase64id } from '../../base64id/lib/base64id.js';
5
- import { __require as requireTransports } from './transports/index.js';
6
- import require$$0 from 'events';
7
- import { __require as requireSocket } from './socket.js';
8
- import { __require as requireSrc } from '../node_modules/debug/src/index.js';
9
- import { __require as requireCookie } from '../../cookie/index.js';
10
- import { __require as requireWs } from '../node_modules/ws/index.js';
11
- import { __require as requireWebtransport } from './transports/webtransport.js';
12
- import { __require as requireCjs } from '../../engine.io-parser/build/cjs/index.js';
13
- import { __require as requireLib } from '../../cors/lib/index.js';
14
-
15
- var hasRequiredServer;
16
-
17
- function requireServer () {
18
- if (hasRequiredServer) return server;
19
- hasRequiredServer = 1;
20
- Object.defineProperty(server, "__esModule", { value: true });
21
- server.Server = server.BaseServer = void 0;
22
- const qs = require$$1;
23
- const url_1 = require$$7;
24
- const base64id = requireBase64id();
25
- const transports_1 = requireTransports();
26
- const events_1 = require$$0;
27
- const socket_1 = requireSocket();
28
- const debug_1 = requireSrc();
29
- const cookie_1 = requireCookie();
30
- const ws_1 = requireWs();
31
- const webtransport_1 = requireWebtransport();
32
- const engine_io_parser_1 = requireCjs();
33
- const debug = (0, debug_1.default)("engine");
34
- const kResponseHeaders = Symbol("responseHeaders");
35
- function parseSessionId(data) {
36
- try {
37
- const parsed = JSON.parse(data);
38
- if (typeof parsed.sid === "string") {
39
- return parsed.sid;
40
- }
41
- }
42
- catch (e) { }
43
- }
44
- class BaseServer extends events_1.EventEmitter {
45
- /**
46
- * Server constructor.
47
- *
48
- * @param {Object} opts - options
49
- */
50
- constructor(opts = {}) {
51
- super();
52
- this.middlewares = [];
53
- this.clients = {};
54
- this.clientsCount = 0;
55
- this.opts = Object.assign({
56
- wsEngine: ws_1.Server,
57
- pingTimeout: 20000,
58
- pingInterval: 25000,
59
- upgradeTimeout: 10000,
60
- maxHttpBufferSize: 1e6,
61
- transports: ["polling", "websocket"], // WebTransport is disabled by default
62
- allowUpgrades: true,
63
- httpCompression: {
64
- threshold: 1024,
65
- },
66
- cors: false,
67
- allowEIO3: false,
68
- }, opts);
69
- if (opts.cookie) {
70
- this.opts.cookie = Object.assign({
71
- name: "io",
72
- path: "/",
73
- // @ts-ignore
74
- httpOnly: opts.cookie.path !== false,
75
- sameSite: "lax",
76
- }, opts.cookie);
77
- }
78
- if (this.opts.cors) {
79
- this.use(requireLib()(this.opts.cors));
80
- }
81
- if (opts.perMessageDeflate) {
82
- this.opts.perMessageDeflate = Object.assign({
83
- threshold: 1024,
84
- }, opts.perMessageDeflate);
85
- }
86
- this.init();
87
- }
88
- /**
89
- * Compute the pathname of the requests that are handled by the server
90
- * @param options
91
- * @protected
92
- */
93
- _computePath(options) {
94
- let path = (options.path || "/engine.io").replace(/\/$/, "");
95
- if (options.addTrailingSlash !== false) {
96
- // normalize path
97
- path += "/";
98
- }
99
- return path;
100
- }
101
- /**
102
- * Returns a list of available transports for upgrade given a certain transport.
103
- *
104
- * @return {Array}
105
- */
106
- upgrades(transport) {
107
- if (!this.opts.allowUpgrades)
108
- return [];
109
- return transports_1.default[transport].upgradesTo || [];
110
- }
111
- /**
112
- * Verifies a request.
113
- *
114
- * @param {EngineRequest} req
115
- * @param upgrade - whether it's an upgrade request
116
- * @param fn
117
- * @protected
118
- */
119
- verify(req, upgrade, fn) {
120
- // transport check
121
- const transport = req._query.transport;
122
- // WebTransport does not go through the verify() method, see the onWebTransportSession() method
123
- if (!~this.opts.transports.indexOf(transport) ||
124
- transport === "webtransport") {
125
- debug('unknown transport "%s"', transport);
126
- return fn(Server.errors.UNKNOWN_TRANSPORT, { transport });
127
- }
128
- // 'Origin' header check
129
- const isOriginInvalid = checkInvalidHeaderChar(req.headers.origin);
130
- if (isOriginInvalid) {
131
- const origin = req.headers.origin;
132
- req.headers.origin = null;
133
- debug("origin header invalid");
134
- return fn(Server.errors.BAD_REQUEST, {
135
- name: "INVALID_ORIGIN",
136
- origin,
137
- });
138
- }
139
- // sid check
140
- const sid = req._query.sid;
141
- if (sid) {
142
- if (!this.clients.hasOwnProperty(sid)) {
143
- debug('unknown sid "%s"', sid);
144
- return fn(Server.errors.UNKNOWN_SID, {
145
- sid,
146
- });
147
- }
148
- const previousTransport = this.clients[sid].transport.name;
149
- if (!upgrade && previousTransport !== transport) {
150
- debug("bad request: unexpected transport without upgrade");
151
- return fn(Server.errors.BAD_REQUEST, {
152
- name: "TRANSPORT_MISMATCH",
153
- transport,
154
- previousTransport,
155
- });
156
- }
157
- }
158
- else {
159
- // handshake is GET only
160
- if ("GET" !== req.method) {
161
- return fn(Server.errors.BAD_HANDSHAKE_METHOD, {
162
- method: req.method,
163
- });
164
- }
165
- if (transport === "websocket" && !upgrade) {
166
- debug("invalid transport upgrade");
167
- return fn(Server.errors.BAD_REQUEST, {
168
- name: "TRANSPORT_HANDSHAKE_ERROR",
169
- });
170
- }
171
- if (!this.opts.allowRequest)
172
- return fn();
173
- return this.opts.allowRequest(req, (message, success) => {
174
- if (!success) {
175
- return fn(Server.errors.FORBIDDEN, {
176
- message,
177
- });
178
- }
179
- fn();
180
- });
181
- }
182
- fn();
183
- }
184
- /**
185
- * Adds a new middleware.
186
- *
187
- * @example
188
- * import helmet from "helmet";
189
- *
190
- * engine.use(helmet());
191
- *
192
- * @param fn
193
- */
194
- use(fn) {
195
- this.middlewares.push(fn);
196
- }
197
- /**
198
- * Apply the middlewares to the request.
199
- *
200
- * @param req
201
- * @param res
202
- * @param callback
203
- * @protected
204
- */
205
- _applyMiddlewares(req, res, callback) {
206
- if (this.middlewares.length === 0) {
207
- debug("no middleware to apply, skipping");
208
- return callback();
209
- }
210
- const apply = (i) => {
211
- debug("applying middleware n°%d", i + 1);
212
- this.middlewares[i](req, res, (err) => {
213
- if (err) {
214
- return callback(err);
215
- }
216
- if (i + 1 < this.middlewares.length) {
217
- apply(i + 1);
218
- }
219
- else {
220
- callback();
221
- }
222
- });
223
- };
224
- apply(0);
225
- }
226
- /**
227
- * Closes all clients.
228
- */
229
- close() {
230
- debug("closing all open clients");
231
- for (let i in this.clients) {
232
- if (this.clients.hasOwnProperty(i)) {
233
- this.clients[i].close(true);
234
- }
235
- }
236
- this.cleanup();
237
- return this;
238
- }
239
- /**
240
- * generate a socket id.
241
- * Overwrite this method to generate your custom socket id
242
- *
243
- * @param {IncomingMessage} req - the request object
244
- */
245
- generateId(req) {
246
- return base64id.generateId();
247
- }
248
- /**
249
- * Handshakes a new client.
250
- *
251
- * @param {String} transportName
252
- * @param {Object} req - the request object
253
- * @param {Function} closeConnection
254
- *
255
- * @protected
256
- */
257
- async handshake(transportName, req, closeConnection) {
258
- const protocol = req._query.EIO === "4" ? 4 : 3; // 3rd revision by default
259
- if (protocol === 3 && !this.opts.allowEIO3) {
260
- debug("unsupported protocol version");
261
- this.emit("connection_error", {
262
- req,
263
- code: Server.errors.UNSUPPORTED_PROTOCOL_VERSION,
264
- message: Server.errorMessages[Server.errors.UNSUPPORTED_PROTOCOL_VERSION],
265
- context: {
266
- protocol,
267
- },
268
- });
269
- closeConnection(Server.errors.UNSUPPORTED_PROTOCOL_VERSION);
270
- return;
271
- }
272
- let id;
273
- try {
274
- id = await this.generateId(req);
275
- }
276
- catch (e) {
277
- debug("error while generating an id");
278
- this.emit("connection_error", {
279
- req,
280
- code: Server.errors.BAD_REQUEST,
281
- message: Server.errorMessages[Server.errors.BAD_REQUEST],
282
- context: {
283
- name: "ID_GENERATION_ERROR",
284
- error: e,
285
- },
286
- });
287
- closeConnection(Server.errors.BAD_REQUEST);
288
- return;
289
- }
290
- debug('handshaking client "%s"', id);
291
- try {
292
- var transport = this.createTransport(transportName, req);
293
- if ("polling" === transportName) {
294
- transport.maxHttpBufferSize = this.opts.maxHttpBufferSize;
295
- transport.httpCompression = this.opts.httpCompression;
296
- }
297
- else if ("websocket" === transportName) {
298
- transport.perMessageDeflate = this.opts.perMessageDeflate;
299
- }
300
- }
301
- catch (e) {
302
- debug('error handshaking to transport "%s"', transportName);
303
- this.emit("connection_error", {
304
- req,
305
- code: Server.errors.BAD_REQUEST,
306
- message: Server.errorMessages[Server.errors.BAD_REQUEST],
307
- context: {
308
- name: "TRANSPORT_HANDSHAKE_ERROR",
309
- error: e,
310
- },
311
- });
312
- closeConnection(Server.errors.BAD_REQUEST);
313
- return;
314
- }
315
- const socket = new socket_1.Socket(id, this, transport, req, protocol);
316
- transport.on("headers", (headers, req) => {
317
- const isInitialRequest = !req._query.sid;
318
- if (isInitialRequest) {
319
- if (this.opts.cookie) {
320
- headers["Set-Cookie"] = [
321
- // @ts-ignore
322
- (0, cookie_1.serialize)(this.opts.cookie.name, id, this.opts.cookie),
323
- ];
324
- }
325
- this.emit("initial_headers", headers, req);
326
- }
327
- this.emit("headers", headers, req);
328
- });
329
- transport.onRequest(req);
330
- this.clients[id] = socket;
331
- this.clientsCount++;
332
- socket.once("close", () => {
333
- delete this.clients[id];
334
- this.clientsCount--;
335
- });
336
- this.emit("connection", socket);
337
- return transport;
338
- }
339
- async onWebTransportSession(session) {
340
- const timeout = setTimeout(() => {
341
- debug("the client failed to establish a bidirectional stream in the given period");
342
- session.close();
343
- }, this.opts.upgradeTimeout);
344
- const streamReader = session.incomingBidirectionalStreams.getReader();
345
- const result = await streamReader.read();
346
- if (result.done) {
347
- debug("session is closed");
348
- return;
349
- }
350
- const stream = result.value;
351
- const transformStream = (0, engine_io_parser_1.createPacketDecoderStream)(this.opts.maxHttpBufferSize, "nodebuffer");
352
- const reader = stream.readable.pipeThrough(transformStream).getReader();
353
- // reading the first packet of the stream
354
- const { value, done } = await reader.read();
355
- if (done) {
356
- debug("stream is closed");
357
- return;
358
- }
359
- clearTimeout(timeout);
360
- if (value.type !== "open") {
361
- debug("invalid WebTransport handshake");
362
- return session.close();
363
- }
364
- if (value.data === undefined) {
365
- const transport = new webtransport_1.WebTransport(session, stream, reader);
366
- // note: we cannot use "this.generateId()", because there is no "req" argument
367
- const id = base64id.generateId();
368
- debug('handshaking client "%s" (WebTransport)', id);
369
- const socket = new socket_1.Socket(id, this, transport, null, 4);
370
- this.clients[id] = socket;
371
- this.clientsCount++;
372
- socket.once("close", () => {
373
- delete this.clients[id];
374
- this.clientsCount--;
375
- });
376
- this.emit("connection", socket);
377
- return;
378
- }
379
- const sid = parseSessionId(value.data);
380
- if (!sid) {
381
- debug("invalid WebTransport handshake");
382
- return session.close();
383
- }
384
- const client = this.clients[sid];
385
- if (!client) {
386
- debug("upgrade attempt for closed client");
387
- session.close();
388
- }
389
- else if (client.upgrading) {
390
- debug("transport has already been trying to upgrade");
391
- session.close();
392
- }
393
- else if (client.upgraded) {
394
- debug("transport had already been upgraded");
395
- session.close();
396
- }
397
- else {
398
- debug("upgrading existing transport");
399
- const transport = new webtransport_1.WebTransport(session, stream, reader);
400
- client._maybeUpgrade(transport);
401
- }
402
- }
403
- }
404
- server.BaseServer = BaseServer;
405
- /**
406
- * Protocol errors mappings.
407
- */
408
- BaseServer.errors = {
409
- UNKNOWN_TRANSPORT: 0,
410
- UNKNOWN_SID: 1,
411
- BAD_HANDSHAKE_METHOD: 2,
412
- BAD_REQUEST: 3,
413
- FORBIDDEN: 4,
414
- UNSUPPORTED_PROTOCOL_VERSION: 5,
415
- };
416
- BaseServer.errorMessages = {
417
- 0: "Transport unknown",
418
- 1: "Session ID unknown",
419
- 2: "Bad handshake method",
420
- 3: "Bad request",
421
- 4: "Forbidden",
422
- 5: "Unsupported protocol version",
423
- };
424
- /**
425
- * Exposes a subset of the http.ServerResponse interface, in order to be able to apply the middlewares to an upgrade
426
- * request.
427
- *
428
- * @see https://nodejs.org/api/http.html#class-httpserverresponse
429
- */
430
- class WebSocketResponse {
431
- constructor(req, socket) {
432
- this.req = req;
433
- this.socket = socket;
434
- // temporarily store the response headers on the req object (see the "headers" event)
435
- req[kResponseHeaders] = {};
436
- }
437
- setHeader(name, value) {
438
- this.req[kResponseHeaders][name] = value;
439
- }
440
- getHeader(name) {
441
- return this.req[kResponseHeaders][name];
442
- }
443
- removeHeader(name) {
444
- delete this.req[kResponseHeaders][name];
445
- }
446
- write() { }
447
- writeHead() { }
448
- end() {
449
- // we could return a proper error code, but the WebSocket client will emit an "error" event anyway.
450
- this.socket.destroy();
451
- }
452
- }
453
- /**
454
- * An Engine.IO server based on Node.js built-in HTTP server and the `ws` package for WebSocket connections.
455
- */
456
- class Server extends BaseServer {
457
- /**
458
- * Initialize websocket server
459
- *
460
- * @protected
461
- */
462
- init() {
463
- if (!~this.opts.transports.indexOf("websocket"))
464
- return;
465
- if (this.ws)
466
- this.ws.close();
467
- this.ws = new this.opts.wsEngine({
468
- noServer: true,
469
- clientTracking: false,
470
- perMessageDeflate: this.opts.perMessageDeflate,
471
- maxPayload: this.opts.maxHttpBufferSize,
472
- });
473
- if (typeof this.ws.on === "function") {
474
- this.ws.on("headers", (headersArray, req) => {
475
- // note: 'ws' uses an array of headers, while Engine.IO uses an object (response.writeHead() accepts both formats)
476
- // we could also try to parse the array and then sync the values, but that will be error-prone
477
- const additionalHeaders = req[kResponseHeaders] || {};
478
- delete req[kResponseHeaders];
479
- const isInitialRequest = !req._query.sid;
480
- if (isInitialRequest) {
481
- this.emit("initial_headers", additionalHeaders, req);
482
- }
483
- this.emit("headers", additionalHeaders, req);
484
- debug("writing headers: %j", additionalHeaders);
485
- Object.keys(additionalHeaders).forEach((key) => {
486
- headersArray.push(`${key}: ${additionalHeaders[key]}`);
487
- });
488
- });
489
- }
490
- }
491
- cleanup() {
492
- if (this.ws) {
493
- debug("closing webSocketServer");
494
- this.ws.close();
495
- // don't delete this.ws because it can be used again if the http server starts listening again
496
- }
497
- }
498
- /**
499
- * Prepares a request by processing the query string.
500
- *
501
- * @private
502
- */
503
- prepare(req) {
504
- // try to leverage pre-existing `req._query` (e.g: from connect)
505
- if (!req._query) {
506
- req._query = (~req.url.indexOf("?") ? qs.parse((0, url_1.parse)(req.url).query) : {});
507
- }
508
- }
509
- createTransport(transportName, req) {
510
- return new transports_1.default[transportName](req);
511
- }
512
- /**
513
- * Handles an Engine.IO HTTP request.
514
- *
515
- * @param {EngineRequest} req
516
- * @param {ServerResponse} res
517
- */
518
- handleRequest(req, res) {
519
- debug('handling "%s" http request "%s"', req.method, req.url);
520
- this.prepare(req);
521
- req.res = res;
522
- const callback = (errorCode, errorContext) => {
523
- if (errorCode !== undefined) {
524
- this.emit("connection_error", {
525
- req,
526
- code: errorCode,
527
- message: Server.errorMessages[errorCode],
528
- context: errorContext,
529
- });
530
- abortRequest(res, errorCode, errorContext);
531
- return;
532
- }
533
- if (req._query.sid) {
534
- debug("setting new request for existing client");
535
- this.clients[req._query.sid].transport.onRequest(req);
536
- }
537
- else {
538
- const closeConnection = (errorCode, errorContext) => abortRequest(res, errorCode, errorContext);
539
- this.handshake(req._query.transport, req, closeConnection);
540
- }
541
- };
542
- this._applyMiddlewares(req, res, (err) => {
543
- if (err) {
544
- callback(Server.errors.BAD_REQUEST, { name: "MIDDLEWARE_FAILURE" });
545
- }
546
- else {
547
- this.verify(req, false, callback);
548
- }
549
- });
550
- }
551
- /**
552
- * Handles an Engine.IO HTTP Upgrade.
553
- */
554
- handleUpgrade(req, socket, upgradeHead) {
555
- this.prepare(req);
556
- const res = new WebSocketResponse(req, socket);
557
- const callback = (errorCode, errorContext) => {
558
- if (errorCode !== undefined) {
559
- this.emit("connection_error", {
560
- req,
561
- code: errorCode,
562
- message: Server.errorMessages[errorCode],
563
- context: errorContext,
564
- });
565
- abortUpgrade(socket, errorCode, errorContext);
566
- return;
567
- }
568
- const head = Buffer.from(upgradeHead);
569
- upgradeHead = null;
570
- // some middlewares (like express-session) wait for the writeHead() call to flush their headers
571
- // see https://github.com/expressjs/session/blob/1010fadc2f071ddf2add94235d72224cf65159c6/index.js#L220-L244
572
- res.writeHead();
573
- // delegate to ws
574
- this.ws.handleUpgrade(req, socket, head, (websocket) => {
575
- this.onWebSocket(req, socket, websocket);
576
- });
577
- };
578
- this._applyMiddlewares(req, res, (err) => {
579
- if (err) {
580
- callback(Server.errors.BAD_REQUEST, { name: "MIDDLEWARE_FAILURE" });
581
- }
582
- else {
583
- this.verify(req, true, callback);
584
- }
585
- });
586
- }
587
- /**
588
- * Called upon a ws.io connection.
589
- *
590
- * @param {ws.Socket} websocket
591
- * @private
592
- */
593
- onWebSocket(req, socket, websocket) {
594
- websocket.on("error", onUpgradeError);
595
- if (transports_1.default[req._query.transport] !== undefined &&
596
- !transports_1.default[req._query.transport].prototype.handlesUpgrades) {
597
- debug("transport doesnt handle upgraded requests");
598
- websocket.close();
599
- return;
600
- }
601
- // get client id
602
- const id = req._query.sid;
603
- // keep a reference to the ws.Socket
604
- req.websocket = websocket;
605
- if (id) {
606
- const client = this.clients[id];
607
- if (!client) {
608
- debug("upgrade attempt for closed client");
609
- websocket.close();
610
- }
611
- else if (client.upgrading) {
612
- debug("transport has already been trying to upgrade");
613
- websocket.close();
614
- }
615
- else if (client.upgraded) {
616
- debug("transport had already been upgraded");
617
- websocket.close();
618
- }
619
- else {
620
- debug("upgrading existing transport");
621
- // transport error handling takes over
622
- websocket.removeListener("error", onUpgradeError);
623
- const transport = this.createTransport(req._query.transport, req);
624
- transport.perMessageDeflate = this.opts.perMessageDeflate;
625
- client._maybeUpgrade(transport);
626
- }
627
- }
628
- else {
629
- const closeConnection = (errorCode, errorContext) => abortUpgrade(socket, errorCode, errorContext);
630
- this.handshake(req._query.transport, req, closeConnection);
631
- }
632
- function onUpgradeError() {
633
- debug("websocket error before upgrade");
634
- // websocket.close() not needed
635
- }
636
- }
637
- /**
638
- * Captures upgrade requests for a http.Server.
639
- *
640
- * @param {http.Server} server
641
- * @param {Object} options
642
- */
643
- attach(server, options = {}) {
644
- const path = this._computePath(options);
645
- const destroyUpgradeTimeout = options.destroyUpgradeTimeout || 1000;
646
- function check(req) {
647
- // TODO use `path === new URL(...).pathname` in the next major release (ref: https://nodejs.org/api/url.html)
648
- return path === req.url.slice(0, path.length);
649
- }
650
- // cache and clean up listeners
651
- const listeners = server.listeners("request").slice(0);
652
- server.removeAllListeners("request");
653
- server.on("close", this.close.bind(this));
654
- server.on("listening", this.init.bind(this));
655
- // add request handler
656
- server.on("request", (req, res) => {
657
- if (check(req)) {
658
- debug('intercepting request for path "%s"', path);
659
- this.handleRequest(req, res);
660
- }
661
- else {
662
- let i = 0;
663
- const l = listeners.length;
664
- for (; i < l; i++) {
665
- listeners[i].call(server, req, res);
666
- }
667
- }
668
- });
669
- if (~this.opts.transports.indexOf("websocket")) {
670
- server.on("upgrade", (req, socket, head) => {
671
- if (check(req)) {
672
- this.handleUpgrade(req, socket, head);
673
- }
674
- else if (false !== options.destroyUpgrade) {
675
- // default node behavior is to disconnect when no handlers
676
- // but by adding a handler, we prevent that
677
- // and if no eio thing handles the upgrade
678
- // then the socket needs to die!
679
- setTimeout(function () {
680
- // @ts-ignore
681
- if (socket.writable && socket.bytesWritten <= 0) {
682
- socket.on("error", (e) => {
683
- debug("error while destroying upgrade: %s", e.message);
684
- });
685
- return socket.end();
686
- }
687
- }, destroyUpgradeTimeout);
688
- }
689
- });
690
- }
691
- }
692
- }
693
- server.Server = Server;
694
- /**
695
- * Close the HTTP long-polling request
696
- *
697
- * @param res - the response object
698
- * @param errorCode - the error code
699
- * @param errorContext - additional error context
700
- *
701
- * @private
702
- */
703
- function abortRequest(res, errorCode, errorContext) {
704
- const statusCode = errorCode === Server.errors.FORBIDDEN ? 403 : 400;
705
- const message = errorContext && errorContext.message
706
- ? errorContext.message
707
- : Server.errorMessages[errorCode];
708
- res.writeHead(statusCode, { "Content-Type": "application/json" });
709
- res.end(JSON.stringify({
710
- code: errorCode,
711
- message,
712
- }));
713
- }
714
- /**
715
- * Close the WebSocket connection
716
- *
717
- * @param {net.Socket} socket
718
- * @param {string} errorCode - the error code
719
- * @param {object} errorContext - additional error context
720
- */
721
- function abortUpgrade(socket, errorCode, errorContext = {}) {
722
- socket.on("error", () => {
723
- debug("ignoring error from closed connection");
724
- });
725
- if (socket.writable) {
726
- const message = errorContext.message || Server.errorMessages[errorCode];
727
- const length = Buffer.byteLength(message);
728
- socket.write("HTTP/1.1 400 Bad Request\r\n" +
729
- "Connection: close\r\n" +
730
- "Content-type: text/html\r\n" +
731
- "Content-Length: " +
732
- length +
733
- "\r\n" +
734
- "\r\n" +
735
- message);
736
- }
737
- socket.destroy();
738
- }
739
- /* eslint-disable */
740
- /**
741
- * From https://github.com/nodejs/node/blob/v8.4.0/lib/_http_common.js#L303-L354
742
- *
743
- * True if val contains an invalid field-vchar
744
- * field-value = *( field-content / obs-fold )
745
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
746
- * field-vchar = VCHAR / obs-text
747
- *
748
- * checkInvalidHeaderChar() is currently designed to be inlinable by v8,
749
- * so take care when making changes to the implementation so that the source
750
- * code size does not exceed v8's default max_inlined_source_size setting.
751
- **/
752
- // prettier-ignore
753
- const validHdrChars = [
754
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, // 0 - 15
755
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 - 31
756
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 32 - 47
757
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 48 - 63
758
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79
759
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80 - 95
760
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111
761
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, // 112 - 127
762
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 128 ...
763
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
764
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
765
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
766
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
767
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
768
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
769
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // ... 255
770
- ];
771
- function checkInvalidHeaderChar(val) {
772
- val += "";
773
- if (val.length < 1)
774
- return false;
775
- if (!validHdrChars[val.charCodeAt(0)]) {
776
- debug('invalid header, index 0, char "%s"', val.charCodeAt(0));
777
- return true;
778
- }
779
- if (val.length < 2)
780
- return false;
781
- if (!validHdrChars[val.charCodeAt(1)]) {
782
- debug('invalid header, index 1, char "%s"', val.charCodeAt(1));
783
- return true;
784
- }
785
- if (val.length < 3)
786
- return false;
787
- if (!validHdrChars[val.charCodeAt(2)]) {
788
- debug('invalid header, index 2, char "%s"', val.charCodeAt(2));
789
- return true;
790
- }
791
- if (val.length < 4)
792
- return false;
793
- if (!validHdrChars[val.charCodeAt(3)]) {
794
- debug('invalid header, index 3, char "%s"', val.charCodeAt(3));
795
- return true;
796
- }
797
- for (let i = 4; i < val.length; ++i) {
798
- if (!validHdrChars[val.charCodeAt(i)]) {
799
- debug('invalid header, index "%i", char "%s"', i, val.charCodeAt(i));
800
- return true;
801
- }
802
- }
803
- return false;
804
- }
805
- return server;
806
- }
807
-
808
- export { requireServer as __require };