@pllla/openclaw-plugin 0.1.0

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 (283) hide show
  1. package/dist/accounts.js +66 -0
  2. package/dist/bridges.js +110 -0
  3. package/dist/index.js +215 -0
  4. package/dist/lane.js +158 -0
  5. package/dist/pairing.js +36 -0
  6. package/dist/stateStore.js +88 -0
  7. package/node_modules/@socket.io/component-emitter/LICENSE +24 -0
  8. package/node_modules/@socket.io/component-emitter/Readme.md +79 -0
  9. package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +179 -0
  10. package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +176 -0
  11. package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +4 -0
  12. package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +179 -0
  13. package/node_modules/@socket.io/component-emitter/lib/esm/index.js +169 -0
  14. package/node_modules/@socket.io/component-emitter/lib/esm/package.json +4 -0
  15. package/node_modules/@socket.io/component-emitter/package.json +28 -0
  16. package/node_modules/debug/LICENSE +20 -0
  17. package/node_modules/debug/README.md +481 -0
  18. package/node_modules/debug/package.json +64 -0
  19. package/node_modules/debug/src/browser.js +272 -0
  20. package/node_modules/debug/src/common.js +292 -0
  21. package/node_modules/debug/src/index.js +10 -0
  22. package/node_modules/debug/src/node.js +263 -0
  23. package/node_modules/engine.io-client/LICENSE +22 -0
  24. package/node_modules/engine.io-client/README.md +331 -0
  25. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +3 -0
  26. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +4 -0
  27. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +1 -0
  28. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +14 -0
  29. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +15 -0
  30. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +38 -0
  31. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +1 -0
  32. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +67 -0
  33. package/node_modules/engine.io-client/build/cjs/globals.d.ts +4 -0
  34. package/node_modules/engine.io-client/build/cjs/globals.js +26 -0
  35. package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +21 -0
  36. package/node_modules/engine.io-client/build/cjs/globals.node.js +97 -0
  37. package/node_modules/engine.io-client/build/cjs/index.d.ts +15 -0
  38. package/node_modules/engine.io-client/build/cjs/index.js +32 -0
  39. package/node_modules/engine.io-client/build/cjs/package.json +10 -0
  40. package/node_modules/engine.io-client/build/cjs/socket.d.ts +482 -0
  41. package/node_modules/engine.io-client/build/cjs/socket.js +766 -0
  42. package/node_modules/engine.io-client/build/cjs/transport.d.ts +106 -0
  43. package/node_modules/engine.io-client/build/cjs/transport.js +153 -0
  44. package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +8 -0
  45. package/node_modules/engine.io-client/build/cjs/transports/index.js +11 -0
  46. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +15 -0
  47. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +60 -0
  48. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +108 -0
  49. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +285 -0
  50. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +11 -0
  51. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +44 -0
  52. package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +52 -0
  53. package/node_modules/engine.io-client/build/cjs/transports/polling.js +165 -0
  54. package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +36 -0
  55. package/node_modules/engine.io-client/build/cjs/transports/websocket.js +136 -0
  56. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +14 -0
  57. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +68 -0
  58. package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +18 -0
  59. package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +94 -0
  60. package/node_modules/engine.io-client/build/cjs/util.d.ts +7 -0
  61. package/node_modules/engine.io-client/build/cjs/util.js +65 -0
  62. package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +3 -0
  63. package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +2 -0
  64. package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +1 -0
  65. package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +11 -0
  66. package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +15 -0
  67. package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +34 -0
  68. package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +1 -0
  69. package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +64 -0
  70. package/node_modules/engine.io-client/build/esm/globals.d.ts +4 -0
  71. package/node_modules/engine.io-client/build/esm/globals.js +22 -0
  72. package/node_modules/engine.io-client/build/esm/globals.node.d.ts +21 -0
  73. package/node_modules/engine.io-client/build/esm/globals.node.js +91 -0
  74. package/node_modules/engine.io-client/build/esm/index.d.ts +15 -0
  75. package/node_modules/engine.io-client/build/esm/index.js +15 -0
  76. package/node_modules/engine.io-client/build/esm/package.json +10 -0
  77. package/node_modules/engine.io-client/build/esm/socket.d.ts +482 -0
  78. package/node_modules/engine.io-client/build/esm/socket.js +728 -0
  79. package/node_modules/engine.io-client/build/esm/transport.d.ts +106 -0
  80. package/node_modules/engine.io-client/build/esm/transport.js +142 -0
  81. package/node_modules/engine.io-client/build/esm/transports/index.d.ts +8 -0
  82. package/node_modules/engine.io-client/build/esm/transports/index.js +8 -0
  83. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +15 -0
  84. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +56 -0
  85. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +108 -0
  86. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +271 -0
  87. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +11 -0
  88. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +17 -0
  89. package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +52 -0
  90. package/node_modules/engine.io-client/build/esm/transports/polling.js +145 -0
  91. package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +36 -0
  92. package/node_modules/engine.io-client/build/esm/transports/websocket.js +125 -0
  93. package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +14 -0
  94. package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +41 -0
  95. package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +18 -0
  96. package/node_modules/engine.io-client/build/esm/transports/webtransport.js +80 -0
  97. package/node_modules/engine.io-client/build/esm/util.d.ts +7 -0
  98. package/node_modules/engine.io-client/build/esm/util.js +59 -0
  99. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +3 -0
  100. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +2 -0
  101. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +1 -0
  102. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +11 -0
  103. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +15 -0
  104. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +34 -0
  105. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +1 -0
  106. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +64 -0
  107. package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +4 -0
  108. package/node_modules/engine.io-client/build/esm-debug/globals.js +22 -0
  109. package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +21 -0
  110. package/node_modules/engine.io-client/build/esm-debug/globals.node.js +91 -0
  111. package/node_modules/engine.io-client/build/esm-debug/index.d.ts +15 -0
  112. package/node_modules/engine.io-client/build/esm-debug/index.js +15 -0
  113. package/node_modules/engine.io-client/build/esm-debug/package.json +10 -0
  114. package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +482 -0
  115. package/node_modules/engine.io-client/build/esm-debug/socket.js +757 -0
  116. package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +106 -0
  117. package/node_modules/engine.io-client/build/esm-debug/transport.js +145 -0
  118. package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +8 -0
  119. package/node_modules/engine.io-client/build/esm-debug/transports/index.js +8 -0
  120. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +15 -0
  121. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +56 -0
  122. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +108 -0
  123. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +276 -0
  124. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +11 -0
  125. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +17 -0
  126. package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +52 -0
  127. package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +158 -0
  128. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +36 -0
  129. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +128 -0
  130. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +14 -0
  131. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +41 -0
  132. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +18 -0
  133. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +87 -0
  134. package/node_modules/engine.io-client/build/esm-debug/util.d.ts +7 -0
  135. package/node_modules/engine.io-client/build/esm-debug/util.js +59 -0
  136. package/node_modules/engine.io-client/dist/engine.io.esm.min.js +7 -0
  137. package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -0
  138. package/node_modules/engine.io-client/dist/engine.io.js +3094 -0
  139. package/node_modules/engine.io-client/dist/engine.io.js.map +1 -0
  140. package/node_modules/engine.io-client/dist/engine.io.min.js +7 -0
  141. package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -0
  142. package/node_modules/engine.io-client/package.json +95 -0
  143. package/node_modules/engine.io-parser/LICENSE +22 -0
  144. package/node_modules/engine.io-parser/Readme.md +158 -0
  145. package/node_modules/engine.io-parser/build/cjs/commons.d.ts +14 -0
  146. package/node_modules/engine.io-parser/build/cjs/commons.js +19 -0
  147. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +2 -0
  148. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +48 -0
  149. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +2 -0
  150. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +66 -0
  151. package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +2 -0
  152. package/node_modules/engine.io-parser/build/cjs/decodePacket.js +59 -0
  153. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +4 -0
  154. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +72 -0
  155. package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +3 -0
  156. package/node_modules/engine.io-parser/build/cjs/encodePacket.js +38 -0
  157. package/node_modules/engine.io-parser/build/cjs/index.d.ts +9 -0
  158. package/node_modules/engine.io-parser/build/cjs/index.js +164 -0
  159. package/node_modules/engine.io-parser/build/cjs/package.json +8 -0
  160. package/node_modules/engine.io-parser/build/esm/commons.d.ts +14 -0
  161. package/node_modules/engine.io-parser/build/esm/commons.js +14 -0
  162. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +2 -0
  163. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +43 -0
  164. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +2 -0
  165. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +62 -0
  166. package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +2 -0
  167. package/node_modules/engine.io-parser/build/esm/decodePacket.js +55 -0
  168. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +4 -0
  169. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +68 -0
  170. package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +3 -0
  171. package/node_modules/engine.io-parser/build/esm/encodePacket.js +33 -0
  172. package/node_modules/engine.io-parser/build/esm/index.d.ts +9 -0
  173. package/node_modules/engine.io-parser/build/esm/index.js +156 -0
  174. package/node_modules/engine.io-parser/build/esm/package.json +8 -0
  175. package/node_modules/engine.io-parser/package.json +46 -0
  176. package/node_modules/ms/index.js +162 -0
  177. package/node_modules/ms/license.md +21 -0
  178. package/node_modules/ms/package.json +38 -0
  179. package/node_modules/ms/readme.md +59 -0
  180. package/node_modules/socket.io-client/LICENSE +21 -0
  181. package/node_modules/socket.io-client/README.md +29 -0
  182. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +2 -0
  183. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +4 -0
  184. package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +12 -0
  185. package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +69 -0
  186. package/node_modules/socket.io-client/build/cjs/index.d.ts +29 -0
  187. package/node_modules/socket.io-client/build/cjs/index.js +76 -0
  188. package/node_modules/socket.io-client/build/cjs/manager.d.ts +295 -0
  189. package/node_modules/socket.io-client/build/cjs/manager.js +416 -0
  190. package/node_modules/socket.io-client/build/cjs/on.d.ts +2 -0
  191. package/node_modules/socket.io-client/build/cjs/on.js +9 -0
  192. package/node_modules/socket.io-client/build/cjs/socket.d.ts +593 -0
  193. package/node_modules/socket.io-client/build/cjs/socket.js +909 -0
  194. package/node_modules/socket.io-client/build/cjs/url.d.ts +33 -0
  195. package/node_modules/socket.io-client/build/cjs/url.js +69 -0
  196. package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +2 -0
  197. package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +2 -0
  198. package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +12 -0
  199. package/node_modules/socket.io-client/build/esm/contrib/backo2.js +66 -0
  200. package/node_modules/socket.io-client/build/esm/index.d.ts +29 -0
  201. package/node_modules/socket.io-client/build/esm/index.js +58 -0
  202. package/node_modules/socket.io-client/build/esm/manager.d.ts +295 -0
  203. package/node_modules/socket.io-client/build/esm/manager.js +367 -0
  204. package/node_modules/socket.io-client/build/esm/on.d.ts +2 -0
  205. package/node_modules/socket.io-client/build/esm/on.js +6 -0
  206. package/node_modules/socket.io-client/build/esm/package.json +5 -0
  207. package/node_modules/socket.io-client/build/esm/socket.d.ts +593 -0
  208. package/node_modules/socket.io-client/build/esm/socket.js +880 -0
  209. package/node_modules/socket.io-client/build/esm/url.d.ts +33 -0
  210. package/node_modules/socket.io-client/build/esm/url.js +59 -0
  211. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +2 -0
  212. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +2 -0
  213. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +12 -0
  214. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +66 -0
  215. package/node_modules/socket.io-client/build/esm-debug/index.d.ts +29 -0
  216. package/node_modules/socket.io-client/build/esm-debug/index.js +62 -0
  217. package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +295 -0
  218. package/node_modules/socket.io-client/build/esm-debug/manager.js +386 -0
  219. package/node_modules/socket.io-client/build/esm-debug/on.d.ts +2 -0
  220. package/node_modules/socket.io-client/build/esm-debug/on.js +6 -0
  221. package/node_modules/socket.io-client/build/esm-debug/package.json +5 -0
  222. package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +593 -0
  223. package/node_modules/socket.io-client/build/esm-debug/socket.js +902 -0
  224. package/node_modules/socket.io-client/build/esm-debug/url.d.ts +33 -0
  225. package/node_modules/socket.io-client/build/esm-debug/url.js +63 -0
  226. package/node_modules/socket.io-client/dist/socket.io.esm.min.js +7 -0
  227. package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -0
  228. package/node_modules/socket.io-client/dist/socket.io.js +4955 -0
  229. package/node_modules/socket.io-client/dist/socket.io.js.map +1 -0
  230. package/node_modules/socket.io-client/dist/socket.io.min.js +7 -0
  231. package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -0
  232. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +7 -0
  233. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -0
  234. package/node_modules/socket.io-client/package.json +101 -0
  235. package/node_modules/socket.io-parser/LICENSE +20 -0
  236. package/node_modules/socket.io-parser/Readme.md +81 -0
  237. package/node_modules/socket.io-parser/build/cjs/binary.d.ts +20 -0
  238. package/node_modules/socket.io-parser/build/cjs/binary.js +90 -0
  239. package/node_modules/socket.io-parser/build/cjs/index.d.ts +101 -0
  240. package/node_modules/socket.io-parser/build/cjs/index.js +366 -0
  241. package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +7 -0
  242. package/node_modules/socket.io-parser/build/cjs/is-binary.js +54 -0
  243. package/node_modules/socket.io-parser/build/cjs/package.json +3 -0
  244. package/node_modules/socket.io-parser/build/esm/binary.d.ts +20 -0
  245. package/node_modules/socket.io-parser/build/esm/binary.js +86 -0
  246. package/node_modules/socket.io-parser/build/esm/index.d.ts +101 -0
  247. package/node_modules/socket.io-parser/build/esm/index.js +352 -0
  248. package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +7 -0
  249. package/node_modules/socket.io-parser/build/esm/is-binary.js +50 -0
  250. package/node_modules/socket.io-parser/build/esm/package.json +3 -0
  251. package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +20 -0
  252. package/node_modules/socket.io-parser/build/esm-debug/binary.js +86 -0
  253. package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +101 -0
  254. package/node_modules/socket.io-parser/build/esm-debug/index.js +357 -0
  255. package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +7 -0
  256. package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +50 -0
  257. package/node_modules/socket.io-parser/build/esm-debug/package.json +3 -0
  258. package/node_modules/socket.io-parser/package.json +44 -0
  259. package/node_modules/ws/LICENSE +20 -0
  260. package/node_modules/ws/README.md +548 -0
  261. package/node_modules/ws/browser.js +8 -0
  262. package/node_modules/ws/index.js +22 -0
  263. package/node_modules/ws/lib/buffer-util.js +131 -0
  264. package/node_modules/ws/lib/constants.js +19 -0
  265. package/node_modules/ws/lib/event-target.js +292 -0
  266. package/node_modules/ws/lib/extension.js +203 -0
  267. package/node_modules/ws/lib/limiter.js +55 -0
  268. package/node_modules/ws/lib/permessage-deflate.js +530 -0
  269. package/node_modules/ws/lib/receiver.js +743 -0
  270. package/node_modules/ws/lib/sender.js +607 -0
  271. package/node_modules/ws/lib/stream.js +161 -0
  272. package/node_modules/ws/lib/subprotocol.js +62 -0
  273. package/node_modules/ws/lib/validation.js +152 -0
  274. package/node_modules/ws/lib/websocket-server.js +562 -0
  275. package/node_modules/ws/lib/websocket.js +1407 -0
  276. package/node_modules/ws/package.json +74 -0
  277. package/node_modules/ws/wrapper.mjs +21 -0
  278. package/node_modules/xmlhttprequest-ssl/LICENSE +22 -0
  279. package/node_modules/xmlhttprequest-ssl/README.md +67 -0
  280. package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +689 -0
  281. package/node_modules/xmlhttprequest-ssl/package.json +40 -0
  282. package/openclaw.plugin.json +60 -0
  283. package/package.json +48 -0
@@ -0,0 +1,357 @@
1
+ import { Emitter } from "@socket.io/component-emitter";
2
+ import { deconstructPacket, reconstructPacket } from "./binary.js";
3
+ import { isBinary, hasBinary } from "./is-binary.js";
4
+ import debugModule from "debug"; // debug()
5
+ const debug = debugModule("socket.io-parser"); // debug()
6
+ /**
7
+ * These strings must not be used as event names, as they have a special meaning.
8
+ */
9
+ const RESERVED_EVENTS = [
10
+ "connect", // used on the client side
11
+ "connect_error", // used on the client side
12
+ "disconnect", // used on both sides
13
+ "disconnecting", // used on the server side
14
+ "newListener", // used by the Node.js EventEmitter
15
+ "removeListener", // used by the Node.js EventEmitter
16
+ ];
17
+ /**
18
+ * Protocol version.
19
+ *
20
+ * @public
21
+ */
22
+ export const protocol = 5;
23
+ export var PacketType;
24
+ (function (PacketType) {
25
+ PacketType[PacketType["CONNECT"] = 0] = "CONNECT";
26
+ PacketType[PacketType["DISCONNECT"] = 1] = "DISCONNECT";
27
+ PacketType[PacketType["EVENT"] = 2] = "EVENT";
28
+ PacketType[PacketType["ACK"] = 3] = "ACK";
29
+ PacketType[PacketType["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
30
+ PacketType[PacketType["BINARY_EVENT"] = 5] = "BINARY_EVENT";
31
+ PacketType[PacketType["BINARY_ACK"] = 6] = "BINARY_ACK";
32
+ })(PacketType || (PacketType = {}));
33
+ /**
34
+ * A socket.io Encoder instance
35
+ */
36
+ export class Encoder {
37
+ /**
38
+ * Encoder constructor
39
+ *
40
+ * @param {function} replacer - custom replacer to pass down to JSON.parse
41
+ */
42
+ constructor(replacer) {
43
+ this.replacer = replacer;
44
+ }
45
+ /**
46
+ * Encode a packet as a single string if non-binary, or as a
47
+ * buffer sequence, depending on packet type.
48
+ *
49
+ * @param {Object} obj - packet object
50
+ */
51
+ encode(obj) {
52
+ debug("encoding packet %j", obj);
53
+ if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
54
+ if (hasBinary(obj)) {
55
+ return this.encodeAsBinary({
56
+ type: obj.type === PacketType.EVENT
57
+ ? PacketType.BINARY_EVENT
58
+ : PacketType.BINARY_ACK,
59
+ nsp: obj.nsp,
60
+ data: obj.data,
61
+ id: obj.id,
62
+ });
63
+ }
64
+ }
65
+ return [this.encodeAsString(obj)];
66
+ }
67
+ /**
68
+ * Encode packet as string.
69
+ */
70
+ encodeAsString(obj) {
71
+ // first is type
72
+ let str = "" + obj.type;
73
+ // attachments if we have them
74
+ if (obj.type === PacketType.BINARY_EVENT ||
75
+ obj.type === PacketType.BINARY_ACK) {
76
+ str += obj.attachments + "-";
77
+ }
78
+ // if we have a namespace other than `/`
79
+ // we append it followed by a comma `,`
80
+ if (obj.nsp && "/" !== obj.nsp) {
81
+ str += obj.nsp + ",";
82
+ }
83
+ // immediately followed by the id
84
+ if (null != obj.id) {
85
+ str += obj.id;
86
+ }
87
+ // json data
88
+ if (null != obj.data) {
89
+ str += JSON.stringify(obj.data, this.replacer);
90
+ }
91
+ debug("encoded %j as %s", obj, str);
92
+ return str;
93
+ }
94
+ /**
95
+ * Encode packet as 'buffer sequence' by removing blobs, and
96
+ * deconstructing packet into object with placeholders and
97
+ * a list of buffers.
98
+ */
99
+ encodeAsBinary(obj) {
100
+ const deconstruction = deconstructPacket(obj);
101
+ const pack = this.encodeAsString(deconstruction.packet);
102
+ const buffers = deconstruction.buffers;
103
+ buffers.unshift(pack); // add packet info to beginning of data list
104
+ return buffers; // write all the buffers
105
+ }
106
+ }
107
+ /**
108
+ * A socket.io Decoder instance
109
+ *
110
+ * @return {Object} decoder
111
+ */
112
+ export class Decoder extends Emitter {
113
+ /**
114
+ * Decoder constructor
115
+ */
116
+ constructor(opts) {
117
+ super();
118
+ this.opts = Object.assign({
119
+ reviver: undefined,
120
+ maxAttachments: 10,
121
+ }, typeof opts === "function" ? { reviver: opts } : opts);
122
+ }
123
+ /**
124
+ * Decodes an encoded packet string into packet JSON.
125
+ *
126
+ * @param {String} obj - encoded packet
127
+ */
128
+ add(obj) {
129
+ let packet;
130
+ if (typeof obj === "string") {
131
+ if (this.reconstructor) {
132
+ throw new Error("got plaintext data when reconstructing a packet");
133
+ }
134
+ packet = this.decodeString(obj);
135
+ const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;
136
+ if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {
137
+ packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
138
+ // binary packet's json
139
+ this.reconstructor = new BinaryReconstructor(packet);
140
+ }
141
+ else {
142
+ // non-binary full packet
143
+ super.emitReserved("decoded", packet);
144
+ }
145
+ }
146
+ else if (isBinary(obj) || obj.base64) {
147
+ // raw binary data
148
+ if (!this.reconstructor) {
149
+ throw new Error("got binary data when not reconstructing a packet");
150
+ }
151
+ else {
152
+ packet = this.reconstructor.takeBinaryData(obj);
153
+ if (packet) {
154
+ // received final buffer
155
+ this.reconstructor = null;
156
+ super.emitReserved("decoded", packet);
157
+ }
158
+ }
159
+ }
160
+ else {
161
+ throw new Error("Unknown type: " + obj);
162
+ }
163
+ }
164
+ /**
165
+ * Decode a packet String (JSON data)
166
+ *
167
+ * @param {String} str
168
+ * @return {Object} packet
169
+ */
170
+ decodeString(str) {
171
+ let i = 0;
172
+ // look up type
173
+ const p = {
174
+ type: Number(str.charAt(0)),
175
+ };
176
+ if (PacketType[p.type] === undefined) {
177
+ throw new Error("unknown packet type " + p.type);
178
+ }
179
+ // look up attachments if type binary
180
+ if (p.type === PacketType.BINARY_EVENT ||
181
+ p.type === PacketType.BINARY_ACK) {
182
+ const start = i + 1;
183
+ while (str.charAt(++i) !== "-" && i != str.length) { }
184
+ const buf = str.substring(start, i);
185
+ if (buf != Number(buf) || str.charAt(i) !== "-") {
186
+ throw new Error("Illegal attachments");
187
+ }
188
+ const n = Number(buf);
189
+ if (!isInteger(n) || n < 1) {
190
+ throw new Error("Illegal attachments");
191
+ }
192
+ else if (n > this.opts.maxAttachments) {
193
+ throw new Error("too many attachments");
194
+ }
195
+ p.attachments = n;
196
+ }
197
+ // look up namespace (if any)
198
+ if ("/" === str.charAt(i + 1)) {
199
+ const start = i + 1;
200
+ while (++i) {
201
+ const c = str.charAt(i);
202
+ if ("," === c)
203
+ break;
204
+ if (i === str.length)
205
+ break;
206
+ }
207
+ p.nsp = str.substring(start, i);
208
+ }
209
+ else {
210
+ p.nsp = "/";
211
+ }
212
+ // look up id
213
+ const next = str.charAt(i + 1);
214
+ if ("" !== next && Number(next) == next) {
215
+ const start = i + 1;
216
+ while (++i) {
217
+ const c = str.charAt(i);
218
+ if (null == c || Number(c) != c) {
219
+ --i;
220
+ break;
221
+ }
222
+ if (i === str.length)
223
+ break;
224
+ }
225
+ p.id = Number(str.substring(start, i + 1));
226
+ }
227
+ // look up json data
228
+ if (str.charAt(++i)) {
229
+ const payload = this.tryParse(str.substr(i));
230
+ if (Decoder.isPayloadValid(p.type, payload)) {
231
+ p.data = payload;
232
+ }
233
+ else {
234
+ throw new Error("invalid payload");
235
+ }
236
+ }
237
+ debug("decoded %s as %j", str, p);
238
+ return p;
239
+ }
240
+ tryParse(str) {
241
+ try {
242
+ return JSON.parse(str, this.opts.reviver);
243
+ }
244
+ catch (e) {
245
+ return false;
246
+ }
247
+ }
248
+ static isPayloadValid(type, payload) {
249
+ switch (type) {
250
+ case PacketType.CONNECT:
251
+ return isObject(payload);
252
+ case PacketType.DISCONNECT:
253
+ return payload === undefined;
254
+ case PacketType.CONNECT_ERROR:
255
+ return typeof payload === "string" || isObject(payload);
256
+ case PacketType.EVENT:
257
+ case PacketType.BINARY_EVENT:
258
+ return (Array.isArray(payload) &&
259
+ (typeof payload[0] === "number" ||
260
+ (typeof payload[0] === "string" &&
261
+ RESERVED_EVENTS.indexOf(payload[0]) === -1)));
262
+ case PacketType.ACK:
263
+ case PacketType.BINARY_ACK:
264
+ return Array.isArray(payload);
265
+ }
266
+ }
267
+ /**
268
+ * Deallocates a parser's resources
269
+ */
270
+ destroy() {
271
+ if (this.reconstructor) {
272
+ this.reconstructor.finishedReconstruction();
273
+ this.reconstructor = null;
274
+ }
275
+ }
276
+ }
277
+ /**
278
+ * A manager of a binary event's 'buffer sequence'. Should
279
+ * be constructed whenever a packet of type BINARY_EVENT is
280
+ * decoded.
281
+ *
282
+ * @param {Object} packet
283
+ * @return {BinaryReconstructor} initialized reconstructor
284
+ */
285
+ class BinaryReconstructor {
286
+ constructor(packet) {
287
+ this.packet = packet;
288
+ this.buffers = [];
289
+ this.reconPack = packet;
290
+ }
291
+ /**
292
+ * Method to be called when binary data received from connection
293
+ * after a BINARY_EVENT packet.
294
+ *
295
+ * @param {Buffer | ArrayBuffer} binData - the raw binary data received
296
+ * @return {null | Object} returns null if more binary data is expected or
297
+ * a reconstructed packet object if all buffers have been received.
298
+ */
299
+ takeBinaryData(binData) {
300
+ this.buffers.push(binData);
301
+ if (this.buffers.length === this.reconPack.attachments) {
302
+ // done with buffer list
303
+ const packet = reconstructPacket(this.reconPack, this.buffers);
304
+ this.finishedReconstruction();
305
+ return packet;
306
+ }
307
+ return null;
308
+ }
309
+ /**
310
+ * Cleans up binary packet reconstruction variables.
311
+ */
312
+ finishedReconstruction() {
313
+ this.reconPack = null;
314
+ this.buffers = [];
315
+ }
316
+ }
317
+ function isNamespaceValid(nsp) {
318
+ return typeof nsp === "string";
319
+ }
320
+ // see https://caniuse.com/mdn-javascript_builtins_number_isinteger
321
+ const isInteger = Number.isInteger ||
322
+ function (value) {
323
+ return (typeof value === "number" &&
324
+ isFinite(value) &&
325
+ Math.floor(value) === value);
326
+ };
327
+ function isAckIdValid(id) {
328
+ return id === undefined || isInteger(id);
329
+ }
330
+ // see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
331
+ function isObject(value) {
332
+ return Object.prototype.toString.call(value) === "[object Object]";
333
+ }
334
+ function isDataValid(type, payload) {
335
+ switch (type) {
336
+ case PacketType.CONNECT:
337
+ return payload === undefined || isObject(payload);
338
+ case PacketType.DISCONNECT:
339
+ return payload === undefined;
340
+ case PacketType.EVENT:
341
+ return (Array.isArray(payload) &&
342
+ (typeof payload[0] === "number" ||
343
+ (typeof payload[0] === "string" &&
344
+ RESERVED_EVENTS.indexOf(payload[0]) === -1)));
345
+ case PacketType.ACK:
346
+ return Array.isArray(payload);
347
+ case PacketType.CONNECT_ERROR:
348
+ return typeof payload === "string" || isObject(payload);
349
+ default:
350
+ return false;
351
+ }
352
+ }
353
+ export function isPacketValid(packet) {
354
+ return (isNamespaceValid(packet.nsp) &&
355
+ isAckIdValid(packet.id) &&
356
+ isDataValid(packet.type, packet.data));
357
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
3
+ *
4
+ * @private
5
+ */
6
+ export declare function isBinary(obj: any): boolean;
7
+ export declare function hasBinary(obj: any, toJSON?: boolean): boolean;
@@ -0,0 +1,50 @@
1
+ const withNativeArrayBuffer = typeof ArrayBuffer === "function";
2
+ const isView = (obj) => {
3
+ return typeof ArrayBuffer.isView === "function"
4
+ ? ArrayBuffer.isView(obj)
5
+ : obj.buffer instanceof ArrayBuffer;
6
+ };
7
+ const toString = Object.prototype.toString;
8
+ const withNativeBlob = typeof Blob === "function" ||
9
+ (typeof Blob !== "undefined" &&
10
+ toString.call(Blob) === "[object BlobConstructor]");
11
+ const withNativeFile = typeof File === "function" ||
12
+ (typeof File !== "undefined" &&
13
+ toString.call(File) === "[object FileConstructor]");
14
+ /**
15
+ * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
16
+ *
17
+ * @private
18
+ */
19
+ export function isBinary(obj) {
20
+ return ((withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) ||
21
+ (withNativeBlob && obj instanceof Blob) ||
22
+ (withNativeFile && obj instanceof File));
23
+ }
24
+ export function hasBinary(obj, toJSON) {
25
+ if (!obj || typeof obj !== "object") {
26
+ return false;
27
+ }
28
+ if (Array.isArray(obj)) {
29
+ for (let i = 0, l = obj.length; i < l; i++) {
30
+ if (hasBinary(obj[i])) {
31
+ return true;
32
+ }
33
+ }
34
+ return false;
35
+ }
36
+ if (isBinary(obj)) {
37
+ return true;
38
+ }
39
+ if (obj.toJSON &&
40
+ typeof obj.toJSON === "function" &&
41
+ arguments.length === 1) {
42
+ return hasBinary(obj.toJSON(), true);
43
+ }
44
+ for (const key in obj) {
45
+ if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
46
+ return true;
47
+ }
48
+ }
49
+ return false;
50
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "socket.io-parser",
3
+ "version": "4.2.7",
4
+ "description": "socket.io protocol parser",
5
+ "homepage": "https://github.com/socketio/socket.io/tree/main/packages/socket.io-client#readme",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/socketio/socket.io.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/socketio/socket.io/issues"
12
+ },
13
+ "files": [
14
+ "build/"
15
+ ],
16
+ "main": "./build/cjs/index.js",
17
+ "module": "./build/esm/index.js",
18
+ "types": "./build/esm/index.d.ts",
19
+ "exports": {
20
+ "import": {
21
+ "node": "./build/esm-debug/index.js",
22
+ "development": "./build/esm-debug/index.js",
23
+ "default": "./build/esm/index.js"
24
+ },
25
+ "require": "./build/cjs/index.js"
26
+ },
27
+ "dependencies": {
28
+ "@socket.io/component-emitter": "~3.1.0",
29
+ "debug": "~4.4.1"
30
+ },
31
+ "scripts": {
32
+ "compile": "rimraf ./build && tsc && tsc -p tsconfig.esm.json && ./postcompile.sh",
33
+ "test": "npm run format:check && npm run compile && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi",
34
+ "test:node": "mocha --reporter dot --bail test/index.js",
35
+ "test:browser": "wdio",
36
+ "format:fix": "prettier --write --parser typescript '*.js' 'lib/**/*.ts' 'test/**/*.js'",
37
+ "format:check": "prettier --check --parser typescript '*.js' 'lib/**/*.ts' 'test/**/*.js'",
38
+ "prepack": "npm run compile"
39
+ },
40
+ "license": "MIT",
41
+ "engines": {
42
+ "node": ">=10.0.0"
43
+ }
44
+ }
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
2
+ Copyright (c) 2013 Arnout Kazemier and contributors
3
+ Copyright (c) 2016 Luigi Pinca and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.